~percona-dev/percona-server/release-5.5.11-20.2-fix-bug-764138

« back to all changes in this revision

Viewing changes to HandlerSocket-Plugin-for-MySQL/docs-en/protocol.en.txt

  • Committer: Ignacio Nin
  • Date: 2011-03-13 17:18:23 UTC
  • mfrom: (33.3.17 release-5.5.8-20)
  • Revision ID: ignacio.nin@percona.com-20110313171823-m06xs104nekulywb
Merge changes from release-5.5.8-20 to 5.5.9

Merge changes from the release branch of 5.5.8 to 5.5.9. These include
the HandlerSocket and UDF directories and the building scripts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
----------------------------------------------------------------------------
 
3
The HandlerSocket protocol
 
4
 
 
5
----------------------------------------------------------------------------
 
6
Basic syntax
 
7
 
 
8
- The HandlerSocket protocol is line-based. Each line ends with LF(0x0a).
 
9
- Each line consists a concatenation of tokens separated by HT(0x09).
 
10
- A token is either NULL or an encoded string. Note that you need to
 
11
  distinguish NULL from an empty string, as most DBMs does so.
 
12
- NULL is expressed as a single NUL(0x00).
 
13
- An encoded string is a string with the following encoding rules.
 
14
        - Characters in the range [0x10 - 0xff] are not encoded.
 
15
        - A character in the range [0x00 - 0x0f] is prefixed by 0x01 and
 
16
          shifted by 0x40. For example, 0x03 is encoded as 0x01 0x43.
 
17
- Note that a string can be empty. A continuation of 0x09 0x09 means that
 
18
  there is an empty string between them. A continuation of 0x09 0x0a means
 
19
  that there is an empty string at the end of the line.
 
20
 
 
21
----------------------------------------------------------------------------
 
22
Request and Response
 
23
 
 
24
- The HandlerSocket protocol is a simple request/response protocol. After a
 
25
  connection is established, the client side sends a request, and then the
 
26
  server side sends a response.
 
27
- A request/response consists of a single line.
 
28
- Requests can be pipelined; That is, you can send multiple requests (ie.
 
29
  lines) at one time, and receive responses for them at one time.
 
30
 
 
31
----------------------------------------------------------------------------
 
32
'open_index' request
 
33
 
 
34
The 'open_index' request has the following syntax.
 
35
 
 
36
    P <indexid> <dbname> <tablename> <indexname> <columns>
 
37
 
 
38
- <indexid> is a number in decimal.
 
39
- <dbname>, <tablename>, and <indexname> are strings. To open the primary
 
40
  key, use PRIMARY as <indexname>.
 
41
- <columns> is a comma-separated list of column names.
 
42
 
 
43
Once an 'open_index' request is issued, the HandlerSocket plugin opens the
 
44
specified index and keep it open until the client connection is closed. Each
 
45
open index is identified by <indexid>. If <indexid> is already open, the old
 
46
open index is closed. You can open the same combination of <dbname>
 
47
<tablename> <indexname> multple times, possibly with different <columns>.
 
48
For efficiency, keep <indexid> small as far as possible.
 
49
 
 
50
----------------------------------------------------------------------------
 
51
Getting data
 
52
 
 
53
The 'find' request has the following syntax.
 
54
 
 
55
    <indexid> <op> <vlen> <v1> ... <vn> <limit> <offset>
 
56
 
 
57
- <indexid> is a number. This number must be an <indexid> specified by a
 
58
  'open_index' request executed previously on the same connection.
 
59
- <op> specifies the comparison operation to use. The current version of
 
60
  HandlerSocket supports '=', '>', '>=', '<', and '<='.
 
61
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
 
62
  must be smaller than or equal to the number of index columns specified by
 
63
  specified by the corresponding 'open_index' request.
 
64
- <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.
 
67
 
 
68
----------------------------------------------------------------------------
 
69
Updating/Deleting data
 
70
 
 
71
The 'find_modify' request has the following syntax.
 
72
 
 
73
    <indexid> <op> <vlen> <v1> ... <vn> <limit> <offset> <mop> <m1> ... <mk>
 
74
 
 
75
- <mop> is either 'U' (update) or 'D' (delete).
 
76
- <m1> ... <mk> specifies the column values to set. The length of <m1> ...
 
77
  <mk> must be smaller than or equal to the length of <columns> specified by
 
78
  the corresponding 'open_index' request. If <mop> is 'D', these parameters
 
79
  are ignored.
 
80
 
 
81
----------------------------------------------------------------------------
 
82
Inserting data
 
83
 
 
84
The 'insert' request has the following syntax.
 
85
 
 
86
    <indexid> '+' <vlen> <v1> ... <vn>
 
87
 
 
88
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
 
89
  must be smaller than or equal to the length of <columns> specified by the
 
90
  corresponding 'open_index' request.
 
91
- <v1> ... <vn> specify the column values to set. For columns not in
 
92
  <columns>, the default values for each column are set.
 
93
 
 
94
----------------------------------------------------------------------------
 
95
Response syntax
 
96
 
 
97
HandlerSocket returns a response of the following syntax for each request.
 
98
 
 
99
    <errorcode> <numcolumns> <r1> ... <rn>
 
100
 
 
101
- <errorcode> indicates whether the request has successfully executed or not.
 
102
  '0' means success. Non-zero means an error.
 
103
- <numcolumns> indicates the number of columns of the result set.
 
104
- <r1> ... <rn> is the result set. The length of <r1> ... <rn> is always a
 
105
  multiple of <numcolumns>. It is possible that <r1> ... <rn> is empty.
 
106
 
 
107
If <errorcode> is non-zero, <numcolumns> is always 1 and <r1> indicates a
 
108
human-readable error message, though sometimes <r1> is not provided.
 
109
 
 
110
----------------------------------------------------------------------------
 
111
Response for 'open_index'
 
112
 
 
113
If 'open_index' is succeeded, HandlerSocket returns a line of the following
 
114
syntax.
 
115
 
 
116
    0 1
 
117
 
 
118
----------------------------------------------------------------------------
 
119
Response for 'find'
 
120
 
 
121
If 'find' is succeeded, HandlerSocket returns a line of the following
 
122
syntax.
 
123
 
 
124
   0 <numcolumns> <r1> ... <rn>
 
125
 
 
126
- <numcolumns> always equals to the length of <columns> of the corresponding
 
127
  'open_index' request.
 
128
- <r1> ... <rn> is the result set. If N rows are found, the length of <r1>
 
129
  ... <rn> becomes ( <numcolumns> * N ).
 
130
 
 
131
----------------------------------------------------------------------------
 
132
Response for 'find_modify'
 
133
 
 
134
If 'find_modify' is succeeded, HandlerSocket returns a line of the following
 
135
syntax.
 
136
 
 
137
   0 1 <nummod>
 
138
 
 
139
- <nummod> is the number of modified rows.
 
140
 
 
141
----------------------------------------------------------------------------
 
142
Response for 'insert'
 
143
 
 
144
If 'insert' is succeeded, HanderSocket returns a line of the following
 
145
syntax.
 
146
 
 
147
   0 1
 
148