From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 8080427A69 for ; Mon, 11 Mar 2019 14:10:30 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id gGsMOi2TiGsA for ; Mon, 11 Mar 2019 14:10:30 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id B77EB27695 for ; Mon, 11 Mar 2019 14:10:29 -0400 (EDT) From: Nikita Pettik 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 Message-Id: <2bb818aa4a68f456c5460cdaa3a519bd1bb57e2f.1552327461.git.korablev@tarantool.org> In-Reply-To: References: In-Reply-To: References: Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: v.shpilevoy@tarantool.org, Nikita Pettik 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