Skip to content

Commit 0c8bf66

Browse files
committed
Fixes gh-2306 New field in binary iproto protocol, third commi
1 parent 2b5c7f6 commit 0c8bf66

File tree

1 file changed

+44
-46
lines changed

1 file changed

+44
-46
lines changed

doc/dev_guide/internals/box_protocol.rst

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -665,11 +665,11 @@ The body is a 3-item map:
665665
IPROTO_OPTIONS: :samp:`{{MP_ARRAY array}}`
666666
})
667667
668-
Use IPROTO_STMT_ID (0x43) + statement-id (MP_INT) if executing a prepared statement,
668+
Use IPROTO_STMT_ID (0x43) and statement-id (MP_INT) if executing a prepared statement,
669669
or use
670-
IPROTO_SQL_TEXT (0x40) + statement-text (MP_STR) if executing an SQL string, then
671-
IPROTO_SQL_BIND (0x41) + array of parameter values to match ? placeholders or
672-
:name placeholders, IPROTO_OPTIONS (0x2b) + array of options (usually empty).
670+
IPROTO_SQL_TEXT (0x40) and statement-text (MP_STR) if executing an SQL string, then
671+
IPROTO_SQL_BIND (0x41) and array of parameter values to match ? placeholders or
672+
:name placeholders, IPROTO_OPTIONS (0x2b) and array of options (usually empty).
673673

674674
For example, suppose we prepare a statement
675675
with two ? placeholders, and execute with two parameters, thus: |br|
@@ -731,9 +731,9 @@ The body is a 1-item map:
731731
IPROTO_STMT_ID: :samp:`{{MP_INT integer}}` or IPROTO_SQL_TEXT: :samp:`{{MP_STR string}}`
732732
})
733733
734-
IPROTO_STMT_ID (0x43) + statement-id (MP_INT) if executing a prepared statement
734+
IPROTO_STMT_ID (0x43) and statement-id (MP_INT) if executing a prepared statement
735735
or
736-
IPROTO_SQL_TEXT (0x40) + statement-text (string) if executing an SQL string.
736+
IPROTO_SQL_TEXT (0x40) and statement-text (string) if executing an SQL string.
737737
Thus the IPROTO_PREPARE map item is the same as the first item of the
738738
:ref:`IPROTO_EXECUTE <box_protocol-execute>` body.
739739

@@ -1052,7 +1052,7 @@ If the SQL statement is SELECT or VALUES or PRAGMA, the response contains:
10521052
})
10531053
10541054
* :samp:`IPROTO_METADATA: {array of column maps}` = array of column maps, with each column map containing
1055-
at least IPROTO_FIELD_NAME (0x00) + MP_STR, and IPROTO_FIELD_TYPE (0x01) + MP_STR.
1055+
at least IPROTO_FIELD_NAME (0x00) and MP_STR, and IPROTO_FIELD_TYPE (0x01) and MP_STR.
10561056
Additionally, if ``sql_full_metadata`` in the
10571057
:ref:`_session_settings <box_space-session_settings>` system space
10581058
is TRUE, then the array will have these additional column maps
@@ -1061,10 +1061,10 @@ If the SQL statement is SELECT or VALUES or PRAGMA, the response contains:
10611061

10621062
.. code-block:: none
10631063
1064-
IPROTO_FIELD_COLL (0x02) + MP_STR
1065-
IPROTO_FIELD_IS_NULLABLE (0x03) + MP_BOOL
1066-
IPROTO_FIELD_IS_AUTOINCREMENT (0x04) + MP_BOOL
1067-
IPROTO_FIELD_SPAN (0x05) + MP_STR or MP_NIL
1064+
IPROTO_FIELD_COLL (0x02) and MP_STR
1065+
IPROTO_FIELD_IS_NULLABLE (0x03) and MP_BOOL
1066+
IPROTO_FIELD_IS_AUTOINCREMENT (0x04) and MP_BOOL
1067+
IPROTO_FIELD_SPAN (0x05) and MP_STR or MP_NIL
10681068
10691069
* :samp:`IPROTO_DATA:{array of tuples}` = the result set "rows".
10701070

@@ -1085,7 +1085,6 @@ we could get this response, in the body:
10851085
IPROTO_FIELD_IS_NULLABLE: false,
10861086
IPROTO_FIELD_IS_AUTOINCREMENT: true,
10871087
IPROTO_FIELD_SPAN: nil,
1088-
,
10891088
IPROTO_FIELD_NAME: 'Д',
10901089
IPROTO_FIELD_TYPE: 'string',
10911090
IPROTO_FIELD_COLL: 'unicode',
@@ -1102,8 +1101,8 @@ If instead we said |br|
11021101
:code:`conn:prepare([[SELECT dd, дд AS д FROM t1;]])` |br|
11031102
then we could get almost the same response, but there would
11041103
be no IPROTO_DATA and there would be two additional items: |br|
1105-
``34 00 = IPROTO_BIND_COUNT + MP_UINT = 0`` (there are no parameters to bind), |br|
1106-
``33 90 = IPROTO_BIND_METADATA + MP_ARRAY, size 0`` (there are no parameters to bind).
1104+
``34 00 = IPROTO_BIND_COUNT and MP_UINT = 0`` (there are no parameters to bind), |br|
1105+
``33 90 = IPROTO_BIND_METADATA and MP_ARRAY, size 0`` (there are no parameters to bind).
11071106

11081107
.. cssclass:: highlight
11091108
.. parsed-literal::
@@ -1119,7 +1118,6 @@ be no IPROTO_DATA and there would be two additional items: |br|
11191118
IPROTO_FIELD_IS_NULLABLE: false
11201119
IPROTO_FIELD_IS_AUTOINCREMENT: true
11211120
IPROTO_FIELD_SPAN: nil,
1122-
,
11231121
IPROTO_FIELD_NAME: 'Д',
11241122
IPROTO_FIELD_TYPE: 'string',
11251123
IPROTO_FIELD_COLL: 'unicode',
@@ -1273,7 +1271,7 @@ IPROTO_BEGIN, the transaction data-change and query requests,
12731271
IPROTO_COMMIT or IPROTO_ROLLBACK.
12741272
Each request must contain the same IPROTO_STREAM_ID value.
12751273
With streaming there is no need to add
1276-
:ref:`IPROTO_FLAGS <box_protocol-flags>` + IPROTO_FLAG_COMMIT
1274+
:ref:`IPROTO_FLAGS <box_protocol-flags>` and IPROTO_FLAG_COMMIT
12771275
in the header of the last request of a transaction.
12781276
Rollback will be automatic if disconnect occurs before commit is possible.
12791277

@@ -1390,12 +1388,12 @@ The fields within IPROTO_BALLOT are map items:
13901388

13911389
.. code-block:: none
13921390
1393-
IPROTO_BALLOT_IS_RO_CFG (0x01) + MP_BOOL
1394-
IPROTO_BALLOT_VCLOCK (0x02) + vclock
1395-
IPROTO_BALLOT_GC_VCLOCK (0x03) + vclock
1396-
IPROTO_BALLOT_IS_RO (0x04) + MP_BOOL
1397-
IPROTO_BALLOT_IS_ANON = 0x05 + MP_BOOL
1398-
IPROTO_BALLOT_IS_BOOTED = 0x06 + MP_BOOL
1391+
IPROTO_BALLOT_IS_RO_CFG (0x01) and MP_BOOL
1392+
IPROTO_BALLOT_VCLOCK (0x02) and vclock
1393+
IPROTO_BALLOT_GC_VCLOCK (0x03) and vclock
1394+
IPROTO_BALLOT_IS_RO (0x04) and MP_BOOL
1395+
IPROTO_BALLOT_IS_ANON = 0x05 and MP_BOOL
1396+
IPROTO_BALLOT_IS_BOOTED = 0x06 and MP_BOOL
13991397
14001398
IPROTO_BALLOT_IS_RO_CFG and IPRO_BALLOT_VCLOCK and IPROTO_BALLOT_GC_VCLOCK and IPROTO_BALLOT_IS_RO
14011399
were added in version :doc:`2.6.1 </release/2.6.1>`.
@@ -1571,7 +1569,7 @@ example:
15711569

15721570
.. code-block:: none
15731571
1574-
ce 00 00 00 20 MP_UINT = HEADER + BODY SIZE
1572+
ce 00 00 00 20 MP_UINT = HEADER AND BODY SIZE
15751573
83 MP_MAP, size 3
15761574
00 Response-Code-Indicator
15771575
ce 00 00 00 00 MP_UINT = IPROTO_OK
@@ -1590,7 +1588,7 @@ example:
15901588

15911589
.. code-block:: none
15921590
1593-
ce 00 00 00 3b MP_UINT = HEADER + BODY SIZE
1591+
ce 00 00 00 3b MP_UINT = HEADER AND BODY SIZE
15941592
83 MP_MAP, size 3 (i.e. 3 items in header)
15951593
00 Response-Code-Indicator
15961594
ce 00 00 80 0a MP_UINT = hexadecimal 800a
@@ -1638,17 +1636,17 @@ then tcpdump will show this response, after the header:
16381636
32 IPROTO_METADATA
16391637
92 MP_ARRAY, size 2 (i.e. 2 columns)
16401638
85 MP_MAP, size 5 (i.e. 5 items for column#1)
1641-
00 a2 44 44 IPROTO_FIELD_NAME + 'DD'
1642-
01 a7 69 6e 74 65 67 65 72 IPROTO_FIELD_TYPE + 'integer'
1643-
03 c2 IPROTO_FIELD_IS_NULLABLE + false
1644-
04 c3 IPROTO_FIELD_IS_AUTOINCREMENT + true
1645-
05 c0 PROTO_FIELD_SPAN + nil
1639+
00 a2 44 44 IPROTO_FIELD_NAME and 'DD'
1640+
01 a7 69 6e 74 65 67 65 72 IPROTO_FIELD_TYPE and 'integer'
1641+
03 c2 IPROTO_FIELD_IS_NULLABLE and false
1642+
04 c3 IPROTO_FIELD_IS_AUTOINCREMENT and true
1643+
05 c0 PROTO_FIELD_SPAN and nil
16461644
85 MP_MAP, size 5 (i.e. 5 items for column#2)
1647-
00 a2 d0 94 IPROTO_FIELD_NAME + 'Д' upper case
1648-
01 a6 73 74 72 69 6e 67 IPROTO_FIELD_TYPE + 'string'
1649-
02 a7 75 6e 69 63 6f 64 65 IPROTO_FIELD_COLL + 'unicode'
1650-
03 c3 IPROTO_FIELD_IS_NULLABLE + true
1651-
05 a4 d0 b4 d0 b4 IPROTO_FIELD_SPAN + 'дд' lower case
1645+
00 a2 d0 94 IPROTO_FIELD_NAME and 'Д' upper case
1646+
01 a6 73 74 72 69 6e 67 IPROTO_FIELD_TYPE and 'string'
1647+
02 a7 75 6e 69 63 6f 64 65 IPROTO_FIELD_COLL and 'unicode'
1648+
03 c3 IPROTO_FIELD_IS_NULLABLE and true
1649+
05 a4 d0 b4 d0 b4 IPROTO_FIELD_SPAN and 'дд' lower case
16521650
30 IPROTO_DATA
16531651
92 MP_ARRAY, size 2
16541652
92 MP_ARRAY, size 2
@@ -1662,8 +1660,8 @@ Byte code for the SQL PREPARE example. If we said |br|
16621660
:code:`conn:prepare([[SELECT dd, дд AS д FROM t1;]])` |br|
16631661
then tcpdump would should show almost the same response, but there would
16641662
be no IPROTO_DATA and there would be two additional items: |br|
1665-
:code:`34 00 = IPROTO_BIND_COUNT + MP_UINT = 0` (there are no parameters to bind), |br|
1666-
:code:`33 90 = IPROTO_BIND_METADATA + MP_ARRAY`, size 0 (there are no parameters to bind).
1663+
:code:`34 00 = IPROTO_BIND_COUNT and MP_UINT = 0` (there are no parameters to bind), |br|
1664+
:code:`33 90 = IPROTO_BIND_METADATA and MP_ARRAY`, size 0 (there are no parameters to bind).
16671665

16681666
.. code-block:: none
16691667
@@ -1677,17 +1675,17 @@ be no IPROTO_DATA and there would be two additional items: |br|
16771675
32 IPROTO_METADATA
16781676
92 MP_ARRAY, size 2 (i.e. 2 columns)
16791677
85 MP_MAP, size 5 (i.e. 5 items for column#1)
1680-
00 a2 44 44 IPROTO_FIELD_NAME + 'DD'
1681-
01 a7 69 6e 74 65 67 65 72 IPROTO_FIELD_TYPE + 'integer'
1682-
03 c2 IPROTO_FIELD_IS_NULLABLE + false
1683-
04 c3 IPROTO_FIELD_IS_AUTOINCREMENT + true
1684-
05 c0 PROTO_FIELD_SPAN + nil
1678+
00 a2 44 44 IPROTO_FIELD_NAME and 'DD'
1679+
01 a7 69 6e 74 65 67 65 72 IPROTO_FIELD_TYPE and 'integer'
1680+
03 c2 IPROTO_FIELD_IS_NULLABLE and false
1681+
04 c3 IPROTO_FIELD_IS_AUTOINCREMENT and true
1682+
05 c0 PROTO_FIELD_SPAN and nil
16851683
85 MP_MAP, size 5 (i.e. 5 items for column#2)
1686-
00 a2 d0 94 IPROTO_FIELD_NAME + 'Д' upper case
1687-
01 a6 73 74 72 69 6e 67 IPROTO_FIELD_TYPE + 'string'
1688-
02 a7 75 6e 69 63 6f 64 65 IPROTO_FIELD_COLL + 'unicode'
1689-
03 c3 IPROTO_FIELD_IS_NULLABLE + true
1690-
05 a4 d0 b4 d0 b4 IPROTO_FIELD_SPAN + 'дд' lower case
1684+
00 a2 d0 94 IPROTO_FIELD_NAME and 'Д' upper case
1685+
01 a6 73 74 72 69 6e 67 IPROTO_FIELD_TYPE and 'string'
1686+
02 a7 75 6e 69 63 6f 64 65 IPROTO_FIELD_COLL and 'unicode'
1687+
03 c3 IPROTO_FIELD_IS_NULLABLE and true
1688+
05 a4 d0 b4 d0 b4 IPROTO_FIELD_SPAN and 'дд' lower case
16911689
16921690
Byte code for the heartbeat example. The master might send this body:
16931691

0 commit comments

Comments
 (0)