From 50de0ad44c24221f6569c3517109f44a45dcde1e Mon Sep 17 00:00:00 2001 From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org> Date: Mon, 17 Jul 2017 18:53:58 +0300 Subject: [PATCH] sql: allow DDL in sql iproto Closes #2608 --- src/box/sql/build.c | 4 +++- test/sql/iproto.result | 35 +++++++++++++++++++++++++++++++++++ test/sql/iproto.test.lua | 10 ++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/src/box/sql/build.c b/src/box/sql/build.c index 5db98d2de6..91689f04ff 100644 --- a/src/box/sql/build.c +++ b/src/box/sql/build.c @@ -25,6 +25,7 @@ #include "sqliteInt.h" #include "vdbeInt.h" #include "tarantoolInt.h" +#include "box/session.h" #ifndef SQLITE_OMIT_SHARED_CACHE /* @@ -1917,7 +1918,8 @@ static void createSpace( } sqlite3VdbeAddOp2(v, OP_SCopy, iSpaceId, iFirstCol /* spaceId */); - sqlite3VdbeAddOp2(v, OP_Integer, 1, iFirstCol+1 /* owner */); + sqlite3VdbeAddOp2(v, OP_Integer, current_user()->uid, + iFirstCol+1 /* owner */); sqlite3VdbeAddOp4(v, OP_String8, 0, iFirstCol+2 /* name */, 0, sqlite3DbStrDup(pParse->db, p->zName), diff --git a/test/sql/iproto.result b/test/sql/iproto.result index 3931824b86..319360ac8b 100644 --- a/test/sql/iproto.result +++ b/test/sql/iproto.result @@ -281,6 +281,41 @@ cn:execute('select :value', parameters) --- - error: Bind value type MAP for parameter ':value' is not supported ... +-- gh-2608 SQL iproto DDL +cn:execute('create table test2(id primary key, a, b, c)') +--- +- rowcount: 3 +... +box.space.test2.name +--- +- test2 +... +cn:execute('insert into test2 values (1, 1, 1, 1)') +--- +- rowcount: 1 +... +cn:execute('select * from test2') +--- +- metadata: [{'name': id}, {'name': 'a'}, {'name': 'b'}, {'name': 'c'}] + rows: + - [1, 1, 1, 1] +... +cn:execute('create index test2_a_b_index on test2(a, b)') +--- +- rowcount: 1 +... +#box.space.test2.index +--- +- 1 +... +cn:execute('drop table test2') +--- +- rowcount: 1 +... +box.space.test2 +--- +- null +... cn:close() --- ... diff --git a/test/sql/iproto.test.lua b/test/sql/iproto.test.lua index 1085405b46..a8ae4fd1c1 100644 --- a/test/sql/iproto.test.lua +++ b/test/sql/iproto.test.lua @@ -109,6 +109,16 @@ parameters[1] = {} parameters[1][':value'] = {kek = 300} cn:execute('select :value', parameters) +-- gh-2608 SQL iproto DDL +cn:execute('create table test2(id primary key, a, b, c)') +box.space.test2.name +cn:execute('insert into test2 values (1, 1, 1, 1)') +cn:execute('select * from test2') +cn:execute('create index test2_a_b_index on test2(a, b)') +#box.space.test2.index +cn:execute('drop table test2') +box.space.test2 + cn:close() box.schema.user.revoke('guest', 'read,write,execute', 'universe') box.sql.execute('drop table test') -- GitLab