Skip to content

Commit d2979f3

Browse files
committed
updated docs
1 parent 1c6b760 commit d2979f3

File tree

5 files changed

+210
-99
lines changed

5 files changed

+210
-99
lines changed

client/hstest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ hstest_thread::test_10(int test_num)
960960
++op_success_count;
961961
arg.sh.increment_count();
962962
if (arg.sh.dump && arg.sh.pipe == 1) {
963-
fwrite(wbuf, wbuflen, 1, stderr);
963+
fwrite(wbuf.begin(), wbuf.size(), 1, stderr);
964964
}
965965
}
966966
}

docs-en/perl-client.en.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,15 @@ executing them separatedly.
116116
# ...
117117
}
118118

119+
-----------------------------------------------------------------
120+
If handlersocket is configured to authenticate client connections
121+
(ie., handlersocket_plain_secret or handlersocket_plain_secret_wr
122+
is set), a client must call 'auth' method before any other
123+
methods.
124+
125+
my $res = $hs->auth('password');
126+
die $hs->get_error() if $res->[0] != 0;
127+
119128
-----------------------------------------------------------------
120129
When an error is occured, the first element of the returned
121130
arrayref becomes a non-zero value. A negative value indicates

docs-en/protocol.en.txt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Request and Response
2929
lines) at one time, and receive responses for them at one time.
3030

3131
----------------------------------------------------------------------------
32-
'open_index' request
32+
Opening index
3333

3434
The 'open_index' request has the following syntax.
3535

@@ -74,23 +74,21 @@ FILETER is a sequence of the following parameters.
7474
HandlerSocket supports '=', '>', '>=', '<', and '<='.
7575
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
7676
must be smaller than or equal to the number of index columns specified by
77-
the <columns> parameter of the corresponding 'open_index' request.
77+
the <indexname> parameter of the corresponding 'open_index' request.
7878
- <v1> ... <vn> specify the index column values to fetch.
7979
- LIM is optional. <limit> and <offset> are numbers. When omitted, it works
8080
as if 1 and 0 are specified. These parameter works like LIMIT of SQL.
8181
These values don't include the number of records skipped by a filter.
8282
- 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
83+
smaller than the number of index columns specified by the <indexname>
84+
parameter of the corresponding 'open_index' request. If IN is specified in
85+
a find request, the <icol>-th parameter value of <v1> ... <vn> is ignored.
8886
- FILTERs are optional. A FILTER specifies a filter. <ftyp> is either 'F'
8987
(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
88+
<fcol> must be smaller than the number of columns specified by the
89+
<fcolumns> parameter of the corresponding 'open_index' request. Multiple
90+
filters can be specified, and work as the logical AND of them. The
91+
difference of 'F' and 'W' is that, when a record does not meet the
9492
specified condition, 'F' simply skips the record, and 'W' stops the loop.
9593

9694
----------------------------------------------------------------------------
@@ -112,8 +110,8 @@ MOD is a sequence of the following parameters.
112110
<mk> must be smaller than or equal to the length of <columns> specified by
113111
the corresponding 'open_index' request. If <mop> is 'D', these parameters
114112
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.
113+
'-' and it attempts to change a column value from negative to positive or
114+
positive to negative, the column value is not modified.
117115

118116
----------------------------------------------------------------------------
119117
Inserting data
@@ -187,6 +185,8 @@ syntax.
187185
0 1 <nummod>
188186

189187
- <nummod> is the number of modified rows.
188+
- As an exception, if the '?' suffix is specified in <mop>, a response has
189+
the syntax of a response for 'find' instead.
190190

191191
----------------------------------------------------------------------------
192192
Response for 'insert'
@@ -196,3 +196,10 @@ syntax.
196196

197197
0 1
198198

199+
----------------------------------------------------------------------------
200+
Response for 'auth'
201+
202+
If 'auth' is succeeded, HanderSocket returns a line of the following syntax.
203+
204+
0 1
205+

docs-ja/perl-client.ja.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ execute_multiメソッドを使えば、複数のリクエストを一つの呼
109109
# ...
110110
}
111111

112+
-----------------------------------------------------------------
113+
もしhandlersocketが接続を認証するように設定されている
114+
(handlersocket_plain_secret又はhandlersocket_plain_secret_wrがセッ
115+
トされている)ならば、クライアントは他のメソッド呼び出しの前にauth
116+
メソッドを呼び出す必要があります。
117+
118+
my $res = $hs->auth('password');
119+
die $hs->get_error() if $res->[0] != 0;
120+
112121
-----------------------------------------------------------------
113122
エラーが起こると返値の配列参照の最初の要素が0以外になります。負の
114123
数の場合はI/Oエラーが起こったことを示し、その場合はその

docs-ja/protocol.ja.txt

Lines changed: 171 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,180 @@
11

2-
-----------------------------------------------------------------
2+
----------------------------------------------------------------------------
33
handlersocketの通信プロトコル
44

5-
-----------------------------------------------------------------
6-
構文
5+
----------------------------------------------------------------------------
6+
基本的な構文
77

8-
コマンド行は改行(LF)で終わる。
9-
コマンド行は複数のトークンからなり、トークン間はTABで区切られる
8+
HandlerSocketのプロトコルは行ベース。各行は改行文字(0x0a)で終わる。
9+
各行は複数のトークンからなり、トークン間はTAB文字(0x09)で区切られる
1010
・トークンはNULLトークンか、文字列トークンのいずれか。
11-
NULLトークンは単一のNUL文字であらわされる
12-
・文字列トークンは、0バイト以上の文字列であらわされる。ただし0x10
13-
未満の文字については0x01を前置し、0x40を加えたコードであらわさ
14-
れる。それ以外の文字はその文字自身のコードであらわされる
11+
NULLトークンは単一のNUL文字(0x00)であらわされる
12+
・文字列トークンは、0バイト以上の文字列であらわされる。ただし0x10未満の文字
13+
については0x01を前置し、0x40を加えたコードであらわされる。それ以外の文字は
14+
その文字自身のコードであらわされる
1515

16-
-----------------------------------------------------------------
16+
----------------------------------------------------------------------------
1717
リクエストとレスポンス
1818

19-
・接続が確立した直後の状態では、まずクライアントがコマンド行を送
20-
る。(リクエスト)
21-
・サーバはクライアントが送ったリクエストと丁度同じ数のコマンド行
22-
を返す。(レスポンス)
23-
・リクエストはパイプライン化してよい。つまりクライアントは前に
24-
送ったリクエストに対する返事を待たずに次のリクエストを送っても
25-
よい。
26-
27-
-----------------------------------------------------------------
28-
リクエスト
29-
30-
・open_index命令は次のような構文を持つ。
31-
'P' indexid dbname tablename indexname fieldlist
32-
indexidは開いている索引に付けられる番号で、同一接続上で後に実行
33-
する命令の、対象索引を指定するために使われる。dbname、tablename、
34-
indexnameはそれぞれ開きたいDB、テーブル、索引の名前。索引の名前
35-
として"PRIMARY"を指定するとプライマリキーが開かれる。fieldlist
36-
はカンマ区切りの列名のリスト。
37-
・find命令は次のような構文を持つ。
38-
indexid op nflds v1 ... vn limit offset
39-
indexidは実行対象の索引を指定する。opは索引検索の演算子(後述)。
40-
v1からvnは可変長で、その個数はnflds。nfldsはindexidで指定された
41-
open_index命令のindexnameの索引のfieldlistのフィールド数に等し
42-
いか小さくなくてはならない。m2からmkは可変長で、その個数は
43-
indexidで指定されたopen_index命令が発行された際のfieldlistに一
44-
致しなければならない。コマンド行のlimit以降は省略できる。limit
45-
とoffsetは、検索条件に合致する列のうちレスポンスに返す列数の上
46-
限と、スキップする列数。limitとoffsetを省略した場合はそれぞれ1
47-
と0が指定されたときと同じ動作をする。find命令はレスポンスとして、
48-
条件に合致した列のリストを返す。opとして指定できる演算子は次の
49-
とおり。
50-
'=' - v1 ... vnと一致するものを取得
51-
'>' - v1 ... vnより大きいものを昇順に取得
52-
'>=' - v1 ... vnに一致するか大きいものを昇順に取得
53-
'<' - v1 ... vnより小さいものを降順に取得
54-
'<=' - v1 ... vnに一致するか等しいものを降順に取得
55-
nfldsが1より大きい(v1 ... vnが2個以上)ときは辞書式順序で比較さ
56-
れる。
57-
・find_modify命令は次のような構文を持つ。
58-
indexid op nflds v1 ... vn limit offset modop m1 ... mk
59-
modopより前の部分はfind命令と同等で、これによって操作対象の行を
60-
指定する。その操作対象の行に対しmodopで指定された変更処理を実行
61-
する。m1 ... mkは可変長で、省略できる。modopは次いずれか。
62-
'U' - indexidで指定されたopen_index命令のfieldlist列
63-
の内容を、m1 ... mkの値で更新する。
64-
'D' - 対象の行を削除する。m1 ... mkの値は無視される。
65-
・insert命令はのような構文を持つ。
66-
indexid '+' nflds v1 ... vn
67-
indexidで指定されたテーブルに、列を挿入する。v1 ... vnは可変長
68-
で、その個数はnflds。nfldsはindexidで指定されたopen_index命令の
69-
indexnameの索引のfieldlistのフィールド数に等しいか小さくなくて
70-
はならない。
71-
72-
-----------------------------------------------------------------
73-
レスポンス
74-
75-
・open_index命令が成功したとき、レスポンスは次の構文を持つ。
76-
'0' '1'
77-
・find命令が成功したとき、レスポンスは次の構文を持つ。
78-
'0' nflds v1 ... vn
79-
nfldsは結果セットの列の数をあらわす。v1 ... vnは可変長で、その
80-
長さはnfldsの整数倍。v1 ... vnは空のこともあり、それは条件に合
81-
致するレコードが存在しなかったことをあらわす。結果セットが複数
82-
行になったときはv1 ... vnの長さがnfldsの2倍以上となり、最初の
83-
行から順にv1 ... vnにセットされる。
84-
・modify命令が成功したとき、レスポンスは次の構文を持つ。
85-
'0' '1' nummod
86-
nummodは変更が施された行数。nummodが0のときは変更された行が無
87-
かったことをあらわす。
88-
・insert命令が成功したとき、レスポンスは次の構文を持つ。
89-
'0' '1'
90-
・命令が失敗したとき、レスポンスは命令に関わらず次の構文を持つ。
91-
err '1' message
92-
errは0以外の数値で、エラーコードをあらわす。messageは人間可読な
93-
エラーメッセージ。ただしmessageが無いこともある。
19+
・HandlerSocketのプロトコルは単純なリクエスト・レスポンスプロトコルになって
20+
いる。接続が確立した後は、まずクライアントがリクエストを送る。
21+
・サーバは、クライアントが送ったリクエストと丁度同じ数の行(レスポンス)を返
22+
す。
23+
・リクエストはパイプライン化してよい。つまりクライアントは前に送ったリクエス
24+
トに対する返事(レスポンス)を待たずに次のリクエストを送ってもよい。
25+
26+
----------------------------------------------------------------------------
27+
インデックスを開く
28+
29+
open_index命令は次のような構文を持つ。
30+
31+
P <indexid> <dbname> <tablename> <indexname> <columns> [<fcolumns>]
32+
33+
- <indexid>は数字で、同一接続上で後に実行する命令の、対象索引を指定するため
34+
に使われる。
35+
- <dbname>, <tablename>, <indexname>は文字列で、それぞれDB名、テーブル名、
36+
索引の名前を指定する。<indexname>として「PRIMARY」を指定するとプライマリ
37+
キーが開かれる。
38+
- <columns>はカンマ区切りの列名のリスト。
39+
- <fcolumns>はカンマ区切りの列名のリスト。これは省略することができる。
40+
41+
このopen_index命令が実行されると、HandlerSocketプラグインは指定されたDB、
42+
テーブル、索引を開く。開かれた索引は接続が閉じられるまで開かれたままになる。
43+
開かれた索引は<indexid>の数字で識別される。もし既に<indexid>に指定された番号
44+
の索引が既に開かれている場合は古いほうが閉じられる。この<indexid>はなるべく
45+
小さな数字を使ったほうが効率が良い。
46+
47+
----------------------------------------------------------------------------
48+
データ取得
49+
50+
find命令は次のような構文を持つ。
51+
52+
<indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...]
53+
54+
LIMは次のようなパラメータの並び
55+
56+
<limit> <offset>
57+
58+
INは次のようなパラメータの並び
59+
60+
@ <icol> <ivlen> <iv1> ... <ivn>
61+
62+
FILTERは次のようなパラメータの並び
63+
64+
<ftyp> <fop> <fcol> <fval>
65+
66+
- <indexid>は数字で、これは同じ接続上で過去に実行したopen_index命令に指定さ
67+
れた数字でなければならない。
68+
- <op>は比較演算子で、現在のバージョンでは '=', '>', '>=', '<', '<=' をサ
69+
ポートしている。
70+
- <vlen>は後に続くパラメータ<v1> ... <vn>の長さ。この値は対応するopen_index
71+
命令の<indexname>パラメータで指定された索引のキー列の数と同じか小さいもの
72+
でなければならない。
73+
- <v1> ... <vn>は取得するべきキーの値を指定するパラメータ。
74+
- LIMは省略できる。<limit>と<offset>は数字で、これはSQLのLIMITと同じように
75+
はたらく。省略した場合は1と0を指定した場合と同じ動作をする。FILTERによっ
76+
て読み飛ばされたレコードは<limit>と<offset>にカウントされない。
77+
- INは省略できる。指定されると、これはSQLの WHERE ... IN のように動作する。
78+
<icol>は対応するopen_index命令の<indexname>パラメータで指定された索引の
79+
キー列の数より小さいものでなければならない。INが指定されたときは、find命
80+
令の<v1> ... <vn>のうち<icol>番目の値は無視される。
81+
- FILTERは省略できる。これは行取得の際のフィルタを指定する。<ftyp>は
82+
'F'(filter)か'W'(while)のいずれかでなければならない。<fop>は比較演算子。
83+
<fcol>は数字で、これは対応するopen_index命令の<fcolumns>で指定された列の
84+
数より小さいものでなければならない。複数のフィルタを指定することもでき、
85+
その場合は各フィルタのANDと解釈される。'F'と'W'の違いは、条件にあてはま
86+
らない行があったときに'F'は単にそれをスキップするが、'W'はその時点でルー
87+
プを抜けるという点。
88+
89+
----------------------------------------------------------------------------
90+
更新と削除
91+
92+
find_modify命令は次のような構文を持つ。
93+
94+
<indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...] MOD
95+
96+
MODは次のようなパラメータの並び
97+
98+
<mop> <m1> ... <mk>
99+
100+
- <mop>は'U', '+', '-', 'D', 'U?', '+?', '-?', 'D?'のいずれか。'?'が付いた
101+
ものは付いていないものとほぼ同じ動作をするが、付いていないものがレスポン
102+
スとして更新された行の数を返すのに対し、付いているものは更新される前の行
103+
の内容を返す点のみが異なる。'U'は更新、'D'は削除、'+'はインクリメント、
104+
'-'はデクリメントを実行する。
105+
- <m1> ... <mk>はセットされる各列の値。<m1> ... <mk>の長さは対応する
106+
open_index命令の<columns>の長さと等しいか小さくなければならない。<mop>が
107+
'D'のときはこれらのパラメータは無視される。<mop>が'+'か'-'のときは、これら
108+
の値は数値でなければならない。<mop>が'-'で、それが負数から正数、または正数
109+
から負数へ列の値を変更するようなものであった場合は、値は変更されない。
110+
111+
----------------------------------------------------------------------------
112+
行の挿入
113+
114+
insert命令は次のような構文を持つ。
115+
116+
<indexid> + <vlen> <v1> ... <vn>
117+
118+
- <vlen>は後に続くパラメータ<v1> ... <vn>の長さ。これは対応するopen_indexの
119+
<columns>の長さに等しいか小さくなければならない。
120+
- <v1> ... <vn>はセットされる各列の値。指定されないかった列についてはその列
121+
のデフォルト値がセットされる。
122+
123+
----------------------------------------------------------------------------
124+
認証
125+
126+
auth命令は次のような構文を持つ。
127+
128+
A <atyp> <akey>
129+
130+
- <atyp>は現在のバージョンでは'1'のみが有効。
131+
- 指定された<akey>が、サーバの設定の'handlersocket_plain_secret'や
132+
'handlersocket_plain_secret_wr'に指定された文字列と一致した場合にのみ認証
133+
は成功する。
134+
- HandlerSocketの認証が有効になっているときは、この'auth'が成功しない限りそ
135+
れ以外の命令は全て失敗する。
136+
137+
----------------------------------------------------------------------------
138+
open_indexに対するレスポンス
139+
140+
open_index命令が成功したとき、レスポンスは次の構文を持つ。
141+
142+
0 1
143+
144+
----------------------------------------------------------------------------
145+
findに対するレスポンス
146+
147+
find命令が成功したとき、レスポンスは次の構文を持つ。
148+
149+
0 <numcolumns> <r1> ... <rn>
150+
151+
- <numcolumns>はfind命令の対応するopen_index命令に指定した<columns>の長さに
152+
一致する。
153+
- <r1> ... <rn>は結果セット。もしN行がfind命令で見つかったなら、<r1> ...
154+
<rn>の長さは ( <numcolumns> * N )になる。
155+
156+
----------------------------------------------------------------------------
157+
find_modifyに対するレスポンス
158+
159+
find_modify命令が成功したとき、レスポンスは次の構文を持つ。
160+
161+
0 1 <nummod>
162+
163+
- <nummod>は変更された行の数。
164+
- 例外として、<mop>が'?'の付いたものであった場合には、find命令に対するレスポ
165+
ンスと同じ構文のレスポンスを返す。
166+
167+
----------------------------------------------------------------------------
168+
insertに対するレスポンス
169+
170+
insert命令が成功したとき、レスポンスは次の構文を持つ。
171+
172+
0 1
173+
174+
----------------------------------------------------------------------------
175+
authに対するレスポンス
176+
177+
auth命令が成功したとき、レスポンスは次の構文を持つ。
178+
179+
0 1
94180

0 commit comments

Comments
 (0)