From: Nikita Pettik <korablev@tarantool.org> To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik <korablev@tarantool.org> Subject: [tarantool-patches] [PATCH 1/2] sql: make type in column-meta be consistent with NoSQL names Date: Mon, 11 Mar 2019 21:10:25 +0300 [thread overview] Message-ID: <2bb818aa4a68f456c5460cdaa3a519bd1bb57e2f.1552327461.git.korablev@tarantool.org> (raw) In-Reply-To: <cover.1552327461.git.korablev@tarantool.org> In-Reply-To: <cover.1552327461.git.korablev@tarantool.org> Column meta-information which is sent alongside execution result via IProto protocol, contains string representation of column type. In some cases, name of type is different from actual type of field. For instance, if column has type SCALAR, string representation in meta-information will be "BLOB"; for NUMBER NoSQL type - it will be "NUMERIC"; for STRING - "TEXT". Instead of this mess, let's always return exact name of underlying NoSQL type. --- src/box/sql/select.c | 31 ++----------- test/sql/errinj.result | 2 +- test/sql/gh-2362-select-access-rights.result | 4 +- test/sql/iproto.result | 68 ++++++++++++++-------------- 4 files changed, 41 insertions(+), 64 deletions(-) diff --git a/src/box/sql/select.c b/src/box/sql/select.c index 782da1f7c..8e8125195 100644 --- a/src/box/sql/select.c +++ b/src/box/sql/select.c @@ -1739,33 +1739,10 @@ generateColumnNames(Parse * pParse, /* Parser context */ p = pEList->a[i].pExpr; if (NEVER(p == 0)) continue; - switch (p->type) { - case FIELD_TYPE_INTEGER: - sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, "INTEGER", - SQL_TRANSIENT); - break; - case FIELD_TYPE_NUMBER: - sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, "NUMERIC", - SQL_TRANSIENT); - break; - case FIELD_TYPE_STRING: - sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, "TEXT", - SQL_TRANSIENT); - break; - case FIELD_TYPE_SCALAR: - sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, "BLOB", - SQL_TRANSIENT); - break; - case FIELD_TYPE_BOOLEAN: - if (p->op == TK_VARIABLE) - var_pos[var_count++] = i; - sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, "BOOLEAN", - SQL_TRANSIENT); - break; - default: - sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, "UNKNOWN", - SQL_TRANSIENT); - } + if (p->op == TK_VARIABLE) + var_pos[var_count++] = i; + sqlVdbeSetColName(v, i, COLNAME_DECLTYPE, + field_type_strs[p->type], SQL_TRANSIENT); if (pEList->a[i].zName) { char *zName = pEList->a[i].zName; sqlVdbeSetColName(v, i, COLNAME_NAME, zName, diff --git a/test/sql/errinj.result b/test/sql/errinj.result index 0f6075b13..6763faf63 100644 --- a/test/sql/errinj.result +++ b/test/sql/errinj.result @@ -115,7 +115,7 @@ select_res --- - metadata: - name: '1' - type: INTEGER + type: integer rows: - [1] ... diff --git a/test/sql/gh-2362-select-access-rights.result b/test/sql/gh-2362-select-access-rights.result index 0e5b9bf56..39b38bcf7 100644 --- a/test/sql/gh-2362-select-access-rights.result +++ b/test/sql/gh-2362-select-access-rights.result @@ -32,9 +32,9 @@ c:execute("SELECT * FROM t1;") --- - metadata: - name: S1 - type: INTEGER + type: integer - name: S2 - type: INTEGER + type: integer rows: - [1, 1] ... diff --git a/test/sql/iproto.result b/test/sql/iproto.result index da7b40f22..3a77c8e93 100644 --- a/test/sql/iproto.result +++ b/test/sql/iproto.result @@ -58,11 +58,11 @@ ret --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string rows: - [1, 2, '3'] - [4, 5, '6'] @@ -103,7 +103,7 @@ cn:execute('select id as identifier from test where a = 5;') --- - metadata: - name: IDENTIFIER - type: INTEGER + type: integer rows: [] ... -- netbox API errors. @@ -131,11 +131,11 @@ cn:execute('select * from test where id = ?', {1}) --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string rows: - [1, 2, '3'] ... @@ -143,11 +143,11 @@ cn:execute('select * from test limit ?', {2}) --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string rows: - [1, 2, '3'] - [7, 8.5, '9'] @@ -171,11 +171,11 @@ cn:execute('select * from test limit 1 offset ?', {2}) --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string rows: - [10, 11, null] ... @@ -210,11 +210,11 @@ cn:execute('select * from test where id = :value', parameters) --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string rows: - [1, 2, '3'] ... @@ -306,7 +306,7 @@ cn:execute('select :value3, ?, :value1, ?, ?, @value2, ?, :value3', parameters) - name: '@value2' type: INTEGER - name: '?' - type: BOOLEAN + type: boolean - name: :value3 type: INTEGER rows: @@ -436,13 +436,13 @@ cn:execute('select * from test2') --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: INTEGER + type: integer - name: B - type: INTEGER + type: integer - name: C - type: INTEGER + type: integer rows: - [1, 1, 1, 1] ... @@ -602,11 +602,11 @@ cn:execute('select * from test where id = :1', {1}) --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string rows: - [1, 2, '3'] ... @@ -620,11 +620,11 @@ res = cn:execute('select * from test') res.metadata --- - - name: ID - type: INTEGER + type: integer - name: A - type: NUMERIC + type: number - name: B - type: TEXT + type: string ... box.sql.execute('drop table test') --- @@ -672,11 +672,11 @@ future4:wait_result() --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: INTEGER + type: integer - name: B - type: INTEGER + type: integer rows: - [1, 1, 1] - [2, 2, 2] @@ -731,9 +731,9 @@ cn:execute('select * from test') --- - metadata: - name: ID - type: INTEGER + type: integer - name: A - type: INTEGER + type: integer rows: - [1, 11] - [2, 2] @@ -850,9 +850,9 @@ cn:execute('select * from "test"') --- - metadata: - name: id - type: INTEGER + type: integer - name: x - type: UNKNOWN + type: any rows: - [1, [1, 2, 3]] - [2, {'a': 3}] -- 2.15.1
next prev parent reply other threads:[~2019-03-11 18:10 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-11 18:10 [tarantool-patches] [PATCH 0/2] SQL types fixes Nikita Pettik 2019-03-11 18:10 ` Nikita Pettik [this message] 2019-03-21 9:03 ` [tarantool-patches] Re: [PATCH 1/2] sql: make type in column-meta be consistent with NoSQL names Vladislav Shpilevoy 2019-03-21 14:00 ` Konstantin Osipov 2019-03-11 18:10 ` [tarantool-patches] [PATCH 2/2] sql: don't change type of function's retval after codegen Nikita Pettik 2019-03-21 9:03 ` [tarantool-patches] " Vladislav Shpilevoy 2019-03-21 12:51 ` n.pettik 2019-03-21 14:46 ` Vladislav Shpilevoy 2019-04-03 7:58 ` [tarantool-patches] Re: [PATCH 0/2] SQL types fixes Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=2bb818aa4a68f456c5460cdaa3a519bd1bb57e2f.1552327461.git.korablev@tarantool.org \ --to=korablev@tarantool.org \ --cc=tarantool-patches@freelists.org \ --cc=v.shpilevoy@tarantool.org \ --subject='Re: [tarantool-patches] [PATCH 1/2] sql: make type in column-meta be consistent with NoSQL names' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox