lwtarantool 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +84 -0
  3. data/ext/lwtarantool/conn.c +314 -0
  4. data/ext/lwtarantool/depend +23 -0
  5. data/ext/lwtarantool/errors.c +24 -0
  6. data/ext/lwtarantool/extconf.rb +8 -0
  7. data/ext/lwtarantool/lwtarantool.c +12 -0
  8. data/ext/lwtarantool/lwtarantool.h +38 -0
  9. data/ext/lwtarantool/request.c +124 -0
  10. data/ext/lwtarantool/vendor/msgpuck/CMakeLists.txt +73 -0
  11. data/ext/lwtarantool/vendor/msgpuck/hints.c +674 -0
  12. data/ext/lwtarantool/vendor/msgpuck/msgpuck.c +375 -0
  13. data/ext/lwtarantool/vendor/msgpuck/msgpuck.h +2195 -0
  14. data/ext/lwtarantool/vendor/msgpuck/test/CMakeLists.txt +25 -0
  15. data/ext/lwtarantool/vendor/msgpuck/test/msgpuck.c +1126 -0
  16. data/ext/lwtarantool/vendor/msgpuck/test/test.c +105 -0
  17. data/ext/lwtarantool/vendor/msgpuck/test/test.h +123 -0
  18. data/ext/lwtarantool/vendor/tarantool-c/CMakeLists.txt +89 -0
  19. data/ext/lwtarantool/vendor/tarantool-c/cmake/FindMsgPuck.cmake +18 -0
  20. data/ext/lwtarantool/vendor/tarantool-c/cmake/FindSphinx.cmake +10 -0
  21. data/ext/lwtarantool/vendor/tarantool-c/doc/CMakeLists.txt +15 -0
  22. data/ext/lwtarantool/vendor/tarantool-c/doc/source/example.c +340 -0
  23. data/ext/lwtarantool/vendor/tarantool-c/include/CMakeLists.txt +6 -0
  24. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tarantool.h +67 -0
  25. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_auth.h +72 -0
  26. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_buf.h +88 -0
  27. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_call.h +83 -0
  28. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_delete.h +52 -0
  29. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_execute.h +24 -0
  30. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_insert.h +62 -0
  31. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_io.h +67 -0
  32. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_iob.h +62 -0
  33. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_iter.h +301 -0
  34. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_mem.h +102 -0
  35. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_net.h +242 -0
  36. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_object.h +248 -0
  37. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_opt.h +138 -0
  38. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_ping.h +49 -0
  39. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_proto.h +295 -0
  40. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_reply.h +204 -0
  41. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_request.h +377 -0
  42. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_schema.h +165 -0
  43. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_select.h +59 -0
  44. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_stream.h +79 -0
  45. data/ext/lwtarantool/vendor/tarantool-c/include/tarantool/tnt_update.h +226 -0
  46. data/ext/lwtarantool/vendor/tarantool-c/include/tp.h +1998 -0
  47. data/ext/lwtarantool/vendor/tarantool-c/test/CMakeLists.txt +36 -0
  48. data/ext/lwtarantool/vendor/tarantool-c/test/common.c +233 -0
  49. data/ext/lwtarantool/vendor/tarantool-c/test/common.h +28 -0
  50. data/ext/lwtarantool/vendor/tarantool-c/test/plain_test.c +152 -0
  51. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_call.c +57 -0
  52. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_disconnect.c +31 -0
  53. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_tcp.c +840 -0
  54. data/ext/lwtarantool/vendor/tarantool-c/test/tarantool_unix.c +384 -0
  55. data/ext/lwtarantool/vendor/tarantool-c/test/test.c +72 -0
  56. data/ext/lwtarantool/vendor/tarantool-c/test/test.h +94 -0
  57. data/ext/lwtarantool/vendor/tarantool-c/test/tnt_assoc.c +6 -0
  58. data/ext/lwtarantool/vendor/tarantool-c/test/tnt_assoc.h +67 -0
  59. data/ext/lwtarantool/vendor/tarantool-c/third_party/PMurHash.c +317 -0
  60. data/ext/lwtarantool/vendor/tarantool-c/third_party/PMurHash.h +68 -0
  61. data/ext/lwtarantool/vendor/tarantool-c/third_party/base64.c +300 -0
  62. data/ext/lwtarantool/vendor/tarantool-c/third_party/base64.h +91 -0
  63. data/ext/lwtarantool/vendor/tarantool-c/third_party/mhash.h +589 -0
  64. data/ext/lwtarantool/vendor/tarantool-c/third_party/sha1.c +219 -0
  65. data/ext/lwtarantool/vendor/tarantool-c/third_party/sha1.h +24 -0
  66. data/ext/lwtarantool/vendor/tarantool-c/third_party/uri.c +6528 -0
  67. data/ext/lwtarantool/vendor/tarantool-c/third_party/uri.h +81 -0
  68. data/ext/lwtarantool/vendor/tarantool-c/tnt/CMakeLists.txt +83 -0
  69. data/ext/lwtarantool/vendor/tarantool-c/tnt/pmatomic.h +494 -0
  70. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_assoc.c +9 -0
  71. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_assoc.h +172 -0
  72. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_auth.c +118 -0
  73. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_buf.c +171 -0
  74. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_call.c +79 -0
  75. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_delete.c +52 -0
  76. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_execute.c +60 -0
  77. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_insert.c +60 -0
  78. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_io.c +520 -0
  79. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_iob.c +75 -0
  80. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_iter.c +293 -0
  81. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_mem.c +82 -0
  82. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_net.c +336 -0
  83. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_object.c +476 -0
  84. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_opt.c +117 -0
  85. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_ping.c +38 -0
  86. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_proto_internal.h +43 -0
  87. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_reply.c +300 -0
  88. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_request.c +336 -0
  89. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_schema.c +334 -0
  90. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_select.c +58 -0
  91. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_stream.c +71 -0
  92. data/ext/lwtarantool/vendor/tarantool-c/tnt/tnt_update.c +247 -0
  93. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/CMakeLists.txt +69 -0
  94. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_dir.c +173 -0
  95. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_dir.h +58 -0
  96. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_log.c +329 -0
  97. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_log.h +119 -0
  98. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_rpl.c +189 -0
  99. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_rpl.h +47 -0
  100. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_snapshot.c +163 -0
  101. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_snapshot.h +50 -0
  102. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_xlog.c +163 -0
  103. data/ext/lwtarantool/vendor/tarantool-c/tntrpl/tnt_xlog.h +50 -0
  104. data/lib/lwtarantool/connection.rb +84 -0
  105. data/lib/lwtarantool/request.rb +58 -0
  106. data/lib/lwtarantool.rb +23 -0
  107. metadata +164 -0
@@ -0,0 +1,295 @@
1
+ #ifndef TNT_PROTO_H_INCLUDED
2
+ #define TNT_PROTO_H_INCLUDED
3
+
4
+ /*
5
+ * Redistribution and use in source and binary forms, with or
6
+ * without modification, are permitted provided that the following
7
+ * conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above
10
+ * copyright notice, this list of conditions and the
11
+ * following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials
16
+ * provided with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ /**
34
+ * \file tnt_proto.h
35
+ * \brief IProto protocol constants
36
+ */
37
+
38
+ /**
39
+ * \brief Request/response header field types (keys)
40
+ */
41
+ enum tnt_header_key_t {
42
+ TNT_CODE = 0x00,
43
+ TNT_SYNC = 0x01,
44
+ TNT_SERVER_ID = 0x02,
45
+ TNT_LSN = 0x03,
46
+ TNT_TIMESTAMP = 0x04,
47
+ TNT_SCHEMA_ID = 0x05
48
+ };
49
+
50
+ /**
51
+ * \brief Request body field types (keys)
52
+ */
53
+ enum tnt_body_key_t {
54
+ TNT_SPACE = 0x10,
55
+ TNT_INDEX = 0x11,
56
+ TNT_LIMIT = 0x12,
57
+ TNT_OFFSET = 0x13,
58
+ TNT_ITERATOR = 0x14,
59
+ TNT_INDEX_BASE = 0x15,
60
+ TNT_KEY = 0x20,
61
+ TNT_TUPLE = 0x21,
62
+ TNT_FUNCTION = 0x22,
63
+ TNT_USERNAME = 0x23,
64
+ TNT_SERVER_UUID = 0x24,
65
+ TNT_CLUSTER_UUID = 0x25,
66
+ TNT_VCLOCK = 0x26,
67
+ TNT_EXPRESSION = 0x27,
68
+ TNT_OPS = 0x28,
69
+ TNT_SQL_TEXT = 0x40,
70
+ TNT_SQL_BIND = 0x41,
71
+ };
72
+
73
+ /**
74
+ * \brief Response body field types (keys)
75
+ */
76
+ enum tnt_response_key_t {
77
+ TNT_DATA = 0x30,
78
+ TNT_ERROR = 0x31,
79
+ TNT_METADATA = 0x32,
80
+ TNT_SQL_INFO = 0x43,
81
+ };
82
+
83
+ /**
84
+ * \brief Request types
85
+ */
86
+ enum tnt_request_t {
87
+ TNT_OP_SELECT = 1,
88
+ TNT_OP_INSERT = 2,
89
+ TNT_OP_REPLACE = 3,
90
+ TNT_OP_UPDATE = 4,
91
+ TNT_OP_DELETE = 5,
92
+ TNT_OP_CALL_16 = 6,
93
+ TNT_OP_AUTH = 7,
94
+ TNT_OP_EVAL = 8,
95
+ TNT_OP_UPSERT = 9,
96
+ TNT_OP_CALL = 10,
97
+ TNT_OP_EXECUTE = 11,
98
+ TNT_OP_PING = 64,
99
+ TNT_OP_JOIN = 65,
100
+ TNT_OP_SUBSCRIBE = 66
101
+ };
102
+
103
+ /**
104
+ * \brief Update operations
105
+ */
106
+ enum tnt_update_op_t {
107
+ TNT_UOP_ADDITION = '+',
108
+ TNT_UOP_SUBSTRACT = '-',
109
+ TNT_UOP_AND = '&',
110
+ TNT_UOP_XOR = '^',
111
+ TNT_UOP_OR = '|',
112
+ TNT_UOP_DELETE = '#',
113
+ TNT_UOP_INSERT = '!',
114
+ TNT_UOP_ASSIGN = '=',
115
+ TNT_UOP_SPLICE = ':',
116
+ };
117
+
118
+ /**
119
+ * \brief Iterator types
120
+ */
121
+ enum tnt_iterator_t {
122
+ TNT_ITER_EQ = 0,
123
+ TNT_ITER_REQ,
124
+ TNT_ITER_ALL,
125
+ TNT_ITER_LT,
126
+ TNT_ITER_LE,
127
+ TNT_ITER_GE,
128
+ TNT_ITER_GT,
129
+ TNT_ITER_BITS_ALL_SET,
130
+ TNT_ITER_BITS_ANY_SET,
131
+ TNT_ITER_BITS_ALL_NOT_SET,
132
+ TNT_ITER_OVERLAP,
133
+ TNT_ITER_NEIGHBOR,
134
+ };
135
+
136
+ /**
137
+ * \internal
138
+ */
139
+ #define TNT_SCRAMBLE_SIZE 20
140
+ /**
141
+ * \internal
142
+ */
143
+ #define TNT_GREETING_SIZE 128
144
+ /**
145
+ * \internal
146
+ */
147
+ #define TNT_VERSION_SIZE 64
148
+ /**
149
+ * \internal
150
+ */
151
+ #define TNT_SALT_SIZE 44
152
+
153
+ /**
154
+ * \brief System spaces
155
+ */
156
+ enum tnt_spaces_t {
157
+ tnt_sp_space = 280,
158
+ tnt_sp_index = 288,
159
+ tnt_sp_func = 296,
160
+ tnt_sp_user = 304,
161
+ tnt_sp_priv = 312,
162
+ tnt_vsp_space = 281,
163
+ tnt_vsp_index = 289,
164
+ tnt_vsp_func = 297,
165
+ tnt_vsp_user = 305,
166
+ tnt_vsp_priv = 313,
167
+ };
168
+
169
+ /**
170
+ * \brief System indexes
171
+ */
172
+ enum tnt_indexes_t {
173
+ tnt_vin_primary = 0,
174
+ tnt_vin_owner = 1,
175
+ tnt_vin_name = 2,
176
+ };
177
+
178
+ /**
179
+ * \brief Error code types
180
+ */
181
+ enum tnt_errcode_t {
182
+ TNT_ER_UNKNOWN = 0,
183
+ TNT_ER_ILLEGAL_PARAMS = 1,
184
+ TNT_ER_MEMORY_ISSUE = 2,
185
+ TNT_ER_TUPLE_FOUND = 3,
186
+ TNT_ER_TUPLE_NOT_FOUND = 4,
187
+ TNT_ER_UNSUPPORTED = 5,
188
+ TNT_ER_NONMASTER = 6,
189
+ TNT_ER_READONLY = 7,
190
+ TNT_ER_INJECTION = 8,
191
+ TNT_ER_CREATE_SPACE = 9,
192
+ TNT_ER_SPACE_EXISTS = 10,
193
+ TNT_ER_DROP_SPACE = 11,
194
+ TNT_ER_ALTER_SPACE = 12,
195
+ TNT_ER_INDEX_TYPE = 13,
196
+ TNT_ER_MODIFY_INDEX = 14,
197
+ TNT_ER_LAST_DROP = 15,
198
+ TNT_ER_TUPLE_FORMAT_LIMIT = 16,
199
+ TNT_ER_DROP_PRIMARY_KEY = 17,
200
+ TNT_ER_KEY_PART_TYPE = 18,
201
+ TNT_ER_EXACT_MATCH = 19,
202
+ TNT_ER_INVALID_MSGPACK = 20,
203
+ TNT_ER_PROC_RET = 21,
204
+ TNT_ER_TUPLE_NOT_ARRAY = 22,
205
+ TNT_ER_FIELD_TYPE = 23,
206
+ TNT_ER_FIELD_TYPE_MISMATCH = 24,
207
+ TNT_ER_SPLICE = 25,
208
+ TNT_ER_ARG_TYPE = 26,
209
+ TNT_ER_TUPLE_IS_TOO_LONG = 27,
210
+ TNT_ER_UNKNOWN_UPDATE_OP = 28,
211
+ TNT_ER_UPDATE_FIELD = 29,
212
+ TNT_ER_FIBER_STACK = 30,
213
+ TNT_ER_KEY_PART_COUNT = 31,
214
+ TNT_ER_PROC_LUA = 32,
215
+ TNT_ER_NO_SUCH_PROC = 33,
216
+ TNT_ER_NO_SUCH_TRIGGER = 34,
217
+ TNT_ER_NO_SUCH_INDEX = 35,
218
+ TNT_ER_NO_SUCH_SPACE = 36,
219
+ TNT_ER_NO_SUCH_FIELD = 37,
220
+ TNT_ER_SPACE_FIELD_COUNT = 38,
221
+ TNT_ER_INDEX_FIELD_COUNT = 39,
222
+ TNT_ER_WAL_IO = 40,
223
+ TNT_ER_MORE_THAN_ONE_TUPLE = 41,
224
+ TNT_ER_ACCESS_DENIED = 42,
225
+ TNT_ER_CREATE_USER = 43,
226
+ TNT_ER_DROP_USER = 44,
227
+ TNT_ER_NO_SUCH_USER = 45,
228
+ TNT_ER_USER_EXISTS = 46,
229
+ TNT_ER_PASSWORD_MISMATCH = 47,
230
+ TNT_ER_UNKNOWN_REQUEST_TYPE = 48,
231
+ TNT_ER_UNKNOWN_SCHEMA_OBJECT = 49,
232
+ TNT_ER_CREATE_FUNCTION = 50,
233
+ TNT_ER_NO_SUCH_FUNCTION = 51,
234
+ TNT_ER_FUNCTION_EXISTS = 52,
235
+ TNT_ER_FUNCTION_ACCESS_DENIED = 53,
236
+ TNT_ER_FUNCTION_MAX = 54,
237
+ TNT_ER_SPACE_ACCESS_DENIED = 55,
238
+ TNT_ER_USER_MAX = 56,
239
+ TNT_ER_NO_SUCH_ENGINE = 57,
240
+ TNT_ER_RELOAD_CFG = 58,
241
+ TNT_ER_CFG = 59,
242
+ TNT_ER_SOPHIA = 60,
243
+ TNT_ER_LOCAL_SERVER_IS_NOT_ACTIVE = 61,
244
+ TNT_ER_UNKNOWN_SERVER = 62,
245
+ TNT_ER_CLUSTER_ID_MISMATCH = 63,
246
+ TNT_ER_INVALID_UUID = 64,
247
+ TNT_ER_CLUSTER_ID_IS_RO = 65,
248
+ TNT_ER_RESERVED66 = 66,
249
+ TNT_ER_SERVER_ID_IS_RESERVED = 67,
250
+ TNT_ER_INVALID_ORDER = 68,
251
+ TNT_ER_MISSING_REQUEST_FIELD = 69,
252
+ TNT_ER_IDENTIFIER = 70,
253
+ TNT_ER_DROP_FUNCTION = 71,
254
+ TNT_ER_ITERATOR_TYPE = 72,
255
+ TNT_ER_REPLICA_MAX = 73,
256
+ TNT_ER_INVALID_XLOG = 74,
257
+ TNT_ER_INVALID_XLOG_NAME = 75,
258
+ TNT_ER_INVALID_XLOG_ORDER = 76,
259
+ TNT_ER_NO_CONNECTION = 77,
260
+ TNT_ER_TIMEOUT = 78,
261
+ TNT_ER_ACTIVE_TRANSACTION = 79,
262
+ TNT_ER_NO_ACTIVE_TRANSACTION = 80,
263
+ TNT_ER_CROSS_ENGINE_TRANSACTION = 81,
264
+ TNT_ER_NO_SUCH_ROLE = 82,
265
+ TNT_ER_ROLE_EXISTS = 83,
266
+ TNT_ER_CREATE_ROLE = 84,
267
+ TNT_ER_INDEX_EXISTS = 85,
268
+ TNT_ER_TUPLE_REF_OVERFLOW = 86,
269
+ TNT_ER_ROLE_LOOP = 87,
270
+ TNT_ER_GRANT = 88,
271
+ TNT_ER_PRIV_GRANTED = 89,
272
+ TNT_ER_ROLE_GRANTED = 90,
273
+ TNT_ER_PRIV_NOT_GRANTED = 91,
274
+ TNT_ER_ROLE_NOT_GRANTED = 92,
275
+ TNT_ER_MISSING_SNAPSHOT = 93,
276
+ TNT_ER_CANT_UPDATE_PRIMARY_KEY = 94,
277
+ TNT_ER_UPDATE_INTEGER_OVERFLOW = 95,
278
+ TNT_ER_GUEST_USER_PASSWORD = 96,
279
+ TNT_ER_TRANSACTION_CONFLICT = 97,
280
+ TNT_ER_UNSUPPORTED_ROLE_PRIV = 98,
281
+ TNT_ER_LOAD_FUNCTION = 99,
282
+ TNT_ER_FUNCTION_LANGUAGE = 100,
283
+ TNT_ER_RTREE_RECT = 101,
284
+ TNT_ER_PROC_C = 102,
285
+ TNT_ER_UNKNOWN_RTREE_INDEX_DISTANCE_TYPE = 103,
286
+ TNT_ER_PROTOCOL = 104,
287
+ TNT_ER_UPSERT_UNIQUE_SECONDARY_KEY = 105,
288
+ TNT_ER_WRONG_INDEX_RECORD = 106,
289
+ TNT_ER_WRONG_INDEX_PARTS = 107,
290
+ TNT_ER_WRONG_INDEX_OPTIONS = 108,
291
+ TNT_ER_WRONG_SCHEMA_VERSION = 109,
292
+ TNT_ER_SLAB_ALLOC_MAX = 110,
293
+ };
294
+
295
+ #endif /* TNT_PROTO_H_INCLUDED */
@@ -0,0 +1,204 @@
1
+ #ifndef TNT_REPLY_H_INCLUDED
2
+ #define TNT_REPLY_H_INCLUDED
3
+
4
+ /*
5
+ * Redistribution and use in source and binary forms, with or
6
+ * without modification, are permitted provided that the following
7
+ * conditions are met:
8
+ *
9
+ * 1. Redistributions of source code must retain the above
10
+ * copyright notice, this list of conditions and the
11
+ * following disclaimer.
12
+ *
13
+ * 2. Redistributions in binary form must reproduce the above
14
+ * copyright notice, this list of conditions and the following
15
+ * disclaimer in the documentation and/or other materials
16
+ * provided with the distribution.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND
19
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
26
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
29
+ * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ /**
34
+ * \file tnt_reply.h
35
+ * \brief Basic reply structure (parsing responses, e.t.c)
36
+ */
37
+
38
+ /**
39
+ * \brief Size of iproto header
40
+ */
41
+ #define TNT_REPLY_IPROTO_HDR_SIZE 5
42
+
43
+ /**
44
+ * \brief Callback for recv reply from buffer
45
+ *
46
+ * \param ptr pointer to buffer and offset
47
+ * \param dst copy reply to
48
+ * \param size size to recv to
49
+ *
50
+ * \returns size of bytes written
51
+ * \retval -1 error
52
+ */
53
+ typedef ssize_t (*tnt_reply_t)(void *ptr, char *dst, ssize_t size);
54
+
55
+ /*!
56
+ * \brief basic reply structure
57
+ */
58
+ struct tnt_reply {
59
+ int alloc; /*!< allocation mark */
60
+ uint64_t bitmap; /*!< bitmap of field IDs that was read */
61
+ const char *buf; /*!< points to beginning of buffer */
62
+ size_t buf_size; /*!< size of query buffer */
63
+ uint64_t code; /*!< response code (0 is success, error number if not) */
64
+ uint64_t sync; /*!< synchronization id */
65
+ uint64_t schema_id; /*!< unique schema id */
66
+ const char *error; /*!< error message (NULL if not present) */
67
+ const char *error_end; /*!< end of error message (NULL if not present) */
68
+ const char *data; /*!< tuple data (NULL if not present) */
69
+ const char *data_end; /*!< end if tuple data (NULL if not present) */
70
+ const char *metadata; /*!< tuple metadata (NULL if not present) */
71
+ const char *metadata_end; /*!< end if tuple metadata (NULL if not present) */
72
+ const char *sqlinfo; /*!< map sqlinfo (NULL if not present) */
73
+ const char *sqlinfo_end;/*!< end if map sqlinfo (NULL if not present) */
74
+ };
75
+
76
+ /*!
77
+ * \brief Get error number
78
+ */
79
+ #define TNT_REPLY_ERR(R) ((R)->code)
80
+
81
+ /*!
82
+ * \brief Allocate and init reply object
83
+ *
84
+ * if reply pointer is NULL, then new stream will be created
85
+ *
86
+ * \param r reply object pointer
87
+ *
88
+ * \returns reply object pointer
89
+ * \retval NULL memory allocation failure
90
+ */
91
+ struct tnt_reply *
92
+ tnt_reply_init(struct tnt_reply *r);
93
+
94
+ /*!
95
+ * \brief Free previously inited reply object
96
+ *
97
+ * \param r reply object pointer
98
+ */
99
+ void
100
+ tnt_reply_free(struct tnt_reply *r);
101
+
102
+ /*!
103
+ * \brief process buffer as iproto reply
104
+ *
105
+ * \param[in] r reply object pointer
106
+ * \param[in] buf buffer data pointer
107
+ * \param[in] size buffer data size
108
+ * \param[out] off returned offset, may be NULL
109
+ *
110
+ * if reply is fully read, then zero is returned and offset set to the
111
+ * end of reply data in buffer.
112
+ *
113
+ * if reply is not complete, then 1 is returned and offset set to the
114
+ * size needed to read.
115
+ *
116
+ * if there were error while parsing reply, -1 is returned.
117
+ *
118
+ * \returns status of processing reply
119
+ * \retval 0 read reply
120
+ * \retval 1 need 'offset' bytes more
121
+ * \retval -1 error while parsing request
122
+ */
123
+ int
124
+ tnt_reply(struct tnt_reply *r, char *buf, size_t size, size_t *off);
125
+
126
+ /*!
127
+ * \brief Process iproto reply with supplied recv function
128
+ *
129
+ * \param r reply object pointer
130
+ * \param rcv supplied recv function
131
+ * \param ptr recv function argument
132
+ *
133
+ * \returns status of parsing
134
+ * \retval 0 ok
135
+ * \retval -1 error, while parsing response
136
+ */
137
+ int
138
+ tnt_reply_from(struct tnt_reply *r, tnt_reply_t rcv, void *ptr);
139
+
140
+ /*!
141
+ * \brief Process buffer as reply header without copying processed bytes
142
+ *
143
+ * \param[in] r reply object pointer
144
+ * \param[in] buf buffer data pointer
145
+ * \param[in] size buffer data size
146
+ * \param[out] off returned offset, may be NULL
147
+ *
148
+ * if buffer contains valid reply header, then zero is returned and offset set to the
149
+ * end of reply header in buffer.
150
+ *
151
+ * if there were error while parsing buffer, -1 is returned.
152
+ *
153
+ * \returns status of processing reply
154
+ * \retval 0 process reply header
155
+ * \retval -1 error while parsing buffer
156
+ */
157
+ int
158
+ tnt_reply_hdr0(struct tnt_reply *r, const char *buf, size_t size, size_t *off);
159
+
160
+ /*!
161
+ * \brief Process buffer as reply body without copying processed bytes
162
+ *
163
+ * \param[in] r reply object pointer
164
+ * \param[in] buf buffer data pointer
165
+ * \param[in] size buffer data size
166
+ * \param[out] off returned offset, may be NULL
167
+ *
168
+ * if buffer contains valid reply body, then zero is returned and offset set to the
169
+ * end of reply body in buffer.
170
+ *
171
+ * if there were error while parsing buffer, -1 is returned.
172
+ *
173
+ * \returns status of processing reply
174
+ * \retval 0 process reply body
175
+ * \retval -1 error while parsing buffer
176
+ */
177
+ int
178
+ tnt_reply_body0(struct tnt_reply *r, const char *buf, size_t size, size_t *off);
179
+
180
+ /*!
181
+ * \brief Process buffer as reply without copying processed bytes
182
+ *
183
+ * \param[in] r reply object pointer
184
+ * \param[in] buf buffer data pointer
185
+ * \param[in] size buffer data size
186
+ * \param[out] off returned offset, may be NULL
187
+ *
188
+ * if buffer contains full and valid reply, then zero is returned and offset set to the
189
+ * end of reply in buffer.
190
+ *
191
+ * if buffer doesn't contain full reply, then 1 is returned and offset set to the
192
+ * size needed to read.
193
+ *
194
+ * if there were error while parsing buffer, -1 is returned.
195
+ *
196
+ * \returns status of processing reply
197
+ * \retval 0 process reply
198
+ * \retval 1 need 'offset' bytes more
199
+ * \retval -1 error while parsing buffer
200
+ */
201
+ int
202
+ tnt_reply0(struct tnt_reply *r, const char *buf, size_t size, size_t *off);
203
+
204
+ #endif /* TNT_REPLY_H_INCLUDED */