From 1a6b2fcc809cff645f771dbf655154d3e7a6352f Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Fri, 26 May 2017 21:34:08 +0300 Subject: [PATCH] sql: add iproto sql constants Needed for #2285 --- src/box/iproto_constants.c | 24 ++++++++++++++++++++++-- src/box/iproto_constants.h | 31 ++++++++++++++++++++++++++++++- test/box/misc.result | 3 ++- 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/box/iproto_constants.c b/src/box/iproto_constants.c index 5d7b15626a..5977986f9b 100644 --- a/src/box/iproto_constants.c +++ b/src/box/iproto_constants.c @@ -86,6 +86,7 @@ const unsigned char iproto_key_type[IPROTO_KEY_MAX] = /* 0x26 */ MP_MAP, /* IPROTO_VCLOCK */ /* 0x27 */ MP_STR, /* IPROTO_EXPR */ /* 0x28 */ MP_ARRAY, /* IPROTO_OPS */ + /* 0x29 */ MP_STR, /* IPROTO_FIELD_NAME */ /* }}} */ }; @@ -101,7 +102,8 @@ const char *iproto_type_strs[] = "AUTH", "EVAL", "UPSERT", - "CALL" + "CALL", + "EXECUTE", }; #define bit(c) (1ULL<<IPROTO_##c) @@ -162,7 +164,7 @@ const char *iproto_key_strs[IPROTO_KEY_MAX] = { "vector clock", /* 0x26 */ "expression", /* 0x27 */ "operations", /* 0x28 */ - NULL, /* 0x29 */ + "field name", /* 0x29 */ NULL, /* 0x2a */ NULL, /* 0x2b */ NULL, /* 0x2c */ @@ -171,6 +173,24 @@ const char *iproto_key_strs[IPROTO_KEY_MAX] = { NULL, /* 0x2f */ "data", /* 0x30 */ "error" /* 0x31 */ + "description", /* 0x32 */ + NULL, /* 0x33 */ + NULL, /* 0x34 */ + NULL, /* 0x35 */ + NULL, /* 0x36 */ + NULL, /* 0x37 */ + NULL, /* 0x38 */ + NULL, /* 0x39 */ + NULL, /* 0x3a */ + NULL, /* 0x3b */ + NULL, /* 0x3c */ + NULL, /* 0x3d */ + NULL, /* 0x3e */ + NULL, /* 0x3f */ + "sql text", /* 0x40 */ + "sql bind", /* 0x41 */ + "sql options", /* 0x42 */ + NULL, /* MAX */ }; const char *vy_page_info_key_strs[VY_PAGE_INFO_KEY_MAX] = { diff --git a/src/box/iproto_constants.h b/src/box/iproto_constants.h index a79113f203..453d9e9f06 100644 --- a/src/box/iproto_constants.h +++ b/src/box/iproto_constants.h @@ -52,11 +52,13 @@ enum { enum iproto_key { IPROTO_REQUEST_TYPE = 0x00, IPROTO_SYNC = 0x01, + /* Replication keys (header) */ IPROTO_REPLICA_ID = 0x02, IPROTO_LSN = 0x03, IPROTO_TIMESTAMP = 0x04, IPROTO_SCHEMA_VERSION = 0x05, + /* Leave a gap for other keys in the header. */ IPROTO_SPACE_ID = 0x10, IPROTO_INDEX_ID = 0x11, @@ -64,20 +66,45 @@ enum iproto_key { IPROTO_OFFSET = 0x13, IPROTO_ITERATOR = 0x14, IPROTO_INDEX_BASE = 0x15, + /* Leave a gap between integer values and other keys */ IPROTO_KEY = 0x20, IPROTO_TUPLE = 0x21, IPROTO_FUNCTION_NAME = 0x22, IPROTO_USER_NAME = 0x23, - /* Replication keys (body) */ + + /* + * Replication keys (body). + * Unfortunately, there is no gap between request and + * replication keys (between USER_NAME and INSTANCE_UUID). + * So imagine, that OPS, EXPR and FIELD_NAME keys follows + * the USER_NAME key. + */ IPROTO_INSTANCE_UUID = 0x24, IPROTO_CLUSTER_UUID = 0x25, IPROTO_VCLOCK = 0x26, + + /* Also request keys. See the comment above. */ IPROTO_EXPR = 0x27, /* EVAL */ IPROTO_OPS = 0x28, /* UPSERT but not UPDATE ops, because of legacy */ + IPROTO_FIELD_NAME = 0x29, + /* Leave a gap between request keys and response keys */ IPROTO_DATA = 0x30, IPROTO_ERROR = 0x31, + /** + * IPROTO_DESCRIPTION: [ + * { IPROTO_FIELD_NAME: name }, + * { ... }, + * ... + * ] + */ + IPROTO_DESCRIPTION = 0x32, + + /* Leave a gap between response keys and SQL keys. */ + IPROTO_SQL_TEXT = 0x40, + IPROTO_SQL_BIND = 0x41, + IPROTO_SQL_OPTIONS = 0x42, IPROTO_KEY_MAX }; @@ -141,6 +168,8 @@ enum iproto_type { IPROTO_UPSERT = 9, /** CALL request - returns arbitrary MessagePack */ IPROTO_CALL = 10, + /** Execute an SQL statement. */ + IPROTO_EXECUTE = 11, /** The maximum typecode used for box.stat() */ IPROTO_TYPE_STAT_MAX, diff --git a/test/box/misc.result b/test/box/misc.result index 1bd7f48bc1..d76d14f636 100644 --- a/test/box/misc.result +++ b/test/box/misc.result @@ -203,10 +203,11 @@ t; - INSERT - EVAL - CALL + - ERROR - REPLACE - UPSERT - AUTH - - ERROR + - EXECUTE - UPDATE - total - rps -- GitLab