@@ -33,12 +33,14 @@ Request and Response
3333
3434The 'open_index' request has the following syntax.
3535
36- P <indexid> <dbname> <tablename> <indexname> <columns>
36+ P <indexid> <dbname> <tablename> <indexname> <columns> [<fcolumns>]
3737
3838- <indexid> is a number in decimal.
3939- <dbname>, <tablename>, and <indexname> are strings. To open the primary
4040 key, use PRIMARY as <indexname>.
4141- <columns> is a comma-separated list of column names.
42+ - <fcolumns> is a comma-separated list of column names. This parameter is
43+ optional.
4244
4345Once an 'open_index' request is issued, the HandlerSocket plugin opens the
4446specified index and keep it open until the client connection is closed. Each
@@ -51,46 +53,94 @@ For efficiency, keep <indexid> small as far as possible.
5153Getting data
5254
5355The 'find' request has the following syntax.
56+
57+ <indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...]
5458
55- <indexid> <op> <vlen> <v1> ... <vn> <limit> <offset>
59+ LIM is a sequence of the following parameters.
60+
61+ <limit> <offset>
62+
63+ IN is a sequence of the following parameters.
64+
65+ @ <icol> <ivlen> <iv1> ... <ivn>
66+
67+ FILETER is a sequence of the following parameters.
68+
69+ <ftyp> <fop> <fcol> <fval>
5670
5771- <indexid> is a number. This number must be an <indexid> specified by a
5872 'open_index' request executed previously on the same connection.
5973- <op> specifies the comparison operation to use. The current version of
6074 HandlerSocket supports '=', '>', '>=', '<', and '<='.
6175- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
6276 must be smaller than or equal to the number of index columns specified by
63- specified by the corresponding 'open_index' request.
77+ the <columns> parameter of the corresponding 'open_index' request.
6478- <v1> ... <vn> specify the index column values to fetch.
65- - <limit> and <offset> are numbers. These parameters can be omitted. When
66- omitted, it works as if 1 and 0 are specified.
79+ - LIM is optional. <limit> and <offset> are numbers. When omitted, it works
80+ as if 1 and 0 are specified. These parameter works like LIMIT of SQL.
81+ These values don't include the number of records skipped by a filter.
82+ - IN is optional. It works like WHERE ... IN syntax of SQL. <icol> must be
83+ smaller than or equal to the number of index columns specified by the
84+ <columns> parameter of the corresponding 'open_index' request. If IN is
85+ specified in a find request, the <icol>-th parameter value of <v1> ...
86+ <vn> is ignored.
87+ smaller than or equal to the number of index columns specified by the
88+ - FILTERs are optional. A FILTER specifies a filter. <ftyp> is either 'F'
89+ (filter) or 'W' (while). <fop> specifies the comparison operation to use.
90+ <fcol> must be smaller than or equal to the number of columns specified by
91+ the <fcolumns> parameter of the corresponding 'open_index' request.
92+ Multiple filters can be specified, and work as the logical AND of them.
93+ The difference of 'F' and 'W' is that, when a record does not meet the
94+ specified condition, 'F' simply skips the record, and 'W' stops the loop.
6795
6896----------------------------------------------------------------------------
6997Updating/Deleting data
7098
7199The 'find_modify' request has the following syntax.
72100
73- <indexid> <op> <vlen> <v1> ... <vn> <limit> <offset> <mop> <m1> ... <mk>
101+ <indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...] MOD
102+
103+ MOD is a sequence of the following parameters.
104+
105+ <mop> <m1> ... <mk>
74106
75- - <mop> is either 'U' (update) or 'D' (delete).
107+ - <mop> is 'U' (update), '+' (increment), '-' (decrement), 'D' (delete),
108+ 'U?', '+?', '-?', or 'D?'. If the '?' suffix is specified, it returns
109+ the contents of the records before modification (as if it's a 'find'
110+ request), instead of the number of modified records.
76111- <m1> ... <mk> specifies the column values to set. The length of <m1> ...
77112 <mk> must be smaller than or equal to the length of <columns> specified by
78113 the corresponding 'open_index' request. If <mop> is 'D', these parameters
79- are ignored.
114+ are ignored. If <mop> is '+' or '-', values must be numeric. If <mop> is
115+ '-' and it attempts to change column values from negative to positive or
116+ positive to negative, it is not modified.
80117
81118----------------------------------------------------------------------------
82119Inserting data
83120
84121The 'insert' request has the following syntax.
85122
86- <indexid> '+' <vlen> <v1> ... <vn>
123+ <indexid> + <vlen> <v1> ... <vn>
87124
88125- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
89126 must be smaller than or equal to the length of <columns> specified by the
90127 corresponding 'open_index' request.
91128- <v1> ... <vn> specify the column values to set. For columns not in
92129 <columns>, the default values for each column are set.
93130
131+ ----------------------------------------------------------------------------
132+ Authentication
133+
134+ The 'auth' request has the following syntax.
135+
136+ A <atyp> <akey>
137+
138+ - <atyp> must be '1'
139+ - An 'auth' request succeeds iff <akey> is the correct secret specified by
140+ the 'handlersocket_plain_secret' or 'handlersocket_plain_secret_rw'.
141+ - If an authentication is enabled for a listener, any other requests on a
142+ connection fail before an 'auth' request succeeded on the connection.
143+
94144----------------------------------------------------------------------------
95145Response syntax
96146
0 commit comments