* [tarantool-patches] [PATCH 0/2] Fix wrong field count in bytecode for ANALYZE
@ 2019-03-18 23:51 Nikita Pettik
2019-03-18 23:51 ` [tarantool-patches] [PATCH 1/2] sql: fix OP_MakeRecord argument of ANALYZE bytecode Nikita Pettik
2019-03-18 23:51 ` [tarantool-patches] [PATCH 2/2] schema: add exact field count to SQL stat spaces Nikita Pettik
0 siblings, 2 replies; 6+ messages in thread
From: Nikita Pettik @ 2019-03-18 23:51 UTC (permalink / raw)
To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik
Branch: https://github.com/tarantool/tarantool/tree/np/fix-analyze-makerecord
First patch fixes obvious bug in VDBE bytecode for ANALYZE SQL
statement. To prevent similar bugs in the future, second patch
explicitly sets field count for _sql_stat1 and _sql_stat4 system
spaces.
Nikita Pettik (2):
sql: fix OP_MakeRecord argument of ANALYZE bytecode
schema: add exact field count to SQL stat spaces
src/box/bootstrap.snap | Bin 1831 -> 1840 bytes
src/box/lua/upgrade.lua | 29 ++++++++++++++-
src/box/sql/analyze.c | 2 +-
test/box-py/bootstrap.result | 6 ++--
test/box/access_misc.result | 4 +--
...{sql-statN-index-drop.result => analyze.result} | 17 +++++++++
...-statN-index-drop.test.lua => analyze.test.lua} | 6 ++++
test/sql/upgrade.result | 39 +++++++++++++++++++--
test/sql/upgrade.test.lua | 13 +++++++
9 files changed, 107 insertions(+), 9 deletions(-)
rename test/sql/{sql-statN-index-drop.result => analyze.result} (86%)
rename test/sql/{sql-statN-index-drop.test.lua => analyze.test.lua} (91%)
--
2.15.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tarantool-patches] [PATCH 1/2] sql: fix OP_MakeRecord argument of ANALYZE bytecode
2019-03-18 23:51 [tarantool-patches] [PATCH 0/2] Fix wrong field count in bytecode for ANALYZE Nikita Pettik
@ 2019-03-18 23:51 ` Nikita Pettik
2019-03-18 23:51 ` [tarantool-patches] [PATCH 2/2] schema: add exact field count to SQL stat spaces Nikita Pettik
1 sibling, 0 replies; 6+ messages in thread
From: Nikita Pettik @ 2019-03-18 23:51 UTC (permalink / raw)
To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik
Accidentally, wrong number of fields was passed to OP_MakeRecord opcode
which encodes tuple to be inserted to _sql_stat1 space: instead of three
fields (as format of space says), four were specified. Since this system
space doesn't feature exact field count, this insertion was successfully
processed. What is more, this additional field was invisible for SQL
means since it is out of space format (so it didn't get to resulting set
of SELECT * FROM _sql_stat1; queries). This patch fixes number of fields
to be encoded of this particular OP_MakeRecord.
---
src/box/sql/analyze.c | 2 +-
.../sql/{sql-statN-index-drop.result => analyze.result} | 17 +++++++++++++++++
.../{sql-statN-index-drop.test.lua => analyze.test.lua} | 6 ++++++
3 files changed, 24 insertions(+), 1 deletion(-)
rename test/sql/{sql-statN-index-drop.result => analyze.result} (86%)
rename test/sql/{sql-statN-index-drop.test.lua => analyze.test.lua} (91%)
diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index ea5cbc39b..9d3df8a15 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -996,7 +996,7 @@ vdbe_emit_analyze_space(struct Parse *parse, struct space *space)
FIELD_TYPE_STRING,
FIELD_TYPE_STRING,
field_type_MAX };
- sqlVdbeAddOp4(v, OP_MakeRecord, tab_name_reg, 4, tmp_reg,
+ sqlVdbeAddOp4(v, OP_MakeRecord, tab_name_reg, 3, tmp_reg,
(char *)types, sizeof(types));
sqlVdbeAddOp4(v, OP_IdxInsert, tmp_reg, 0, 0,
(char *)stat1, P4_SPACEPTR);
diff --git a/test/sql/sql-statN-index-drop.result b/test/sql/analyze.result
similarity index 86%
rename from test/sql/sql-statN-index-drop.result
rename to test/sql/analyze.result
index 760595188..42210ea13 100644
--- a/test/sql/sql-statN-index-drop.result
+++ b/test/sql/analyze.result
@@ -45,6 +45,23 @@ box.sql.execute("SELECT * FROM \"_sql_stat1\";")
- ['T2', 'I1', '1 1']
- ['T2', 'T2', '1 1']
...
+-- Make sure that tuples in spaces with statistics don't
+-- containt fields out of format.
+--
+box.space._sql_stat1:select()
+---
+- - ['T1', 'I1', '1 1']
+ - ['T1', 'T1', '1 1']
+ - ['T2', 'I1', '1 1']
+ - ['T2', 'T2', '1 1']
+...
+box.space._sql_stat4:select()
+---
+- - ['T1', 'I1', '1', '0', '0', !!binary kQI=]
+ - ['T1', 'T1', '1', '0', '0', !!binary kQE=]
+ - ['T2', 'I1', '1', '0', '0', !!binary kQI=]
+ - ['T2', 'T2', '1', '0', '0', !!binary kQE=]
+...
-- Dropping an index.
box.sql.execute("DROP INDEX i1 ON t1;")
---
diff --git a/test/sql/sql-statN-index-drop.test.lua b/test/sql/analyze.test.lua
similarity index 91%
rename from test/sql/sql-statN-index-drop.test.lua
rename to test/sql/analyze.test.lua
index 35f22910c..ba31d5fbc 100644
--- a/test/sql/sql-statN-index-drop.test.lua
+++ b/test/sql/analyze.test.lua
@@ -17,6 +17,12 @@ box.sql.execute("ANALYZE;")
box.sql.execute("SELECT * FROM \"_sql_stat4\";")
box.sql.execute("SELECT * FROM \"_sql_stat1\";")
+-- Make sure that tuples in spaces with statistics don't
+-- containt fields out of format.
+--
+box.space._sql_stat1:select()
+box.space._sql_stat4:select()
+
-- Dropping an index.
box.sql.execute("DROP INDEX i1 ON t1;")
--
2.15.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tarantool-patches] [PATCH 2/2] schema: add exact field count to SQL stat spaces
2019-03-18 23:51 [tarantool-patches] [PATCH 0/2] Fix wrong field count in bytecode for ANALYZE Nikita Pettik
2019-03-18 23:51 ` [tarantool-patches] [PATCH 1/2] sql: fix OP_MakeRecord argument of ANALYZE bytecode Nikita Pettik
@ 2019-03-18 23:51 ` Nikita Pettik
2019-03-21 13:31 ` [tarantool-patches] " Vladislav Shpilevoy
1 sibling, 1 reply; 6+ messages in thread
From: Nikita Pettik @ 2019-03-18 23:51 UTC (permalink / raw)
To: tarantool-patches; +Cc: v.shpilevoy, Nikita Pettik
As a rule, system spaces don't feature exact field count. There is a
reason for that: almost all of them have on replace triggers, which
extract data from tuple and verify it. However, _sql_stat1 and
_sql_stat4 spaces containing SQL specific statistics don't have such
triggers. Hence, one can insert tuple to this space with greater number
of fields, than format says. To prevent this, let's explicitly set exact
field count to number of fields in format.
---
src/box/bootstrap.snap | Bin 1831 -> 1840 bytes
src/box/lua/upgrade.lua | 29 ++++++++++++++++++++++++++++-
test/box-py/bootstrap.result | 6 +++---
test/box/access_misc.result | 4 ++--
test/sql/upgrade.result | 39 +++++++++++++++++++++++++++++++++++++--
test/sql/upgrade.test.lua | 13 +++++++++++++
6 files changed, 83 insertions(+), 8 deletions(-)
diff --git a/src/box/bootstrap.snap b/src/box/bootstrap.snap
index 0bb446fb6903ac3ef630c419b909f7db3df0372a..920015b32da9c3e309ba6cb5af4caa1c7049827a 100644
GIT binary patch
delta 1836
zcmV+{2h;ec4zLc88Gke}FfC^=V>e+lWivT83Q2BrbYX5|WjY`*Vq`RBH)dolV`4Wl
zEi`0fWi2>iGhr=eH#B8AH(@q7Gh|^3RzqxWV{1AfdwmKD)w&D1%?7mq&i3~;xTOF9
z0000ewJ-euP-Qg$N=Hl&Nx&MZ0EmJh2!bF8hF~g#3d>-Ct$zXTCIY_*ogGZB3l?S0
zv`A!1vQm;X!`;3}iK7Sr06;-1K&mLsN`bnTU{D4DK@<UnOeqD~0M!8H09ih#ZqA~%
z92dQquZw)?I~!lGWVX_HcU}g;mdu~t`WAUx&+@pfQJ4XD?@N9T#ZGFTXW#1;=32CU
z`0BI|+xKqBZGYdonie!fKWsx0+$$T<{0y>`csHkR-#`Cnzu)^+|JnS~*k!FyN{yOy
zB>}H}HBOaW0ItsQwQmdWu*T{u{kwA;5cVul1>nQQj2Zn8^sp9dRMwF=uFi4E6Cpcv
zZp>&=($}D-O<70c>KrSr8pM3RtHy+Kb&f~W=)?Bswtq@k2SexN0u!XAi>%6*3tn`#
z0H`x4F1*9r&DZ1Q&35mTq`;zou<N^5H5cBYB`Jy&+t0<51Fp`I)x{gz&qY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xaiyL&vvbKES-e0i
R9JX=Dom4Gm<qp*lt?e55T{r*$
diff --git a/src/box/lua/upgrade.lua b/src/box/lua/upgrade.lua
index c72711ff7..4d0435e8e 100644
--- a/src/box/lua/upgrade.lua
+++ b/src/box/lua/upgrade.lua
@@ -616,6 +616,32 @@ local function upgrade_to_2_1_0()
upgrade_priv_to_2_1_0()
end
+--------------------------------------------------------------------------------
+-- Tarantool 2.1.1
+--------------------------------------------------------------------------------
+
+local function upgrade_to_2_1_2()
+ local _sql_stat1 = box.space[box.schema.SQL_STAT1_ID]
+ local _sql_stat4 = box.space[box.schema.SQL_STAT4_ID]
+ local _sql_stat1_def = box.space._space:get(box.schema.SQL_STAT1_ID):totable()
+ local _sql_stat4_def = box.space._space:get(box.schema.SQL_STAT4_ID):totable()
+ -- Set exact field count as the number of fields in format.
+ -- It makes sense since in contrast to other system spaces,
+ -- there is no on replace triggers which can verify content
+ -- of tuples to be inserted.
+ _sql_stat1_def[5] = #_sql_stat1:format()
+ _sql_stat4_def[5] = #_sql_stat4:format()
+ -- Just in case, erase all statistics before update.
+ for _, t in _sql_stat1.index[0]:pairs() do
+ _sql_stat1:delete({t[1], t[2]})
+ end
+ for _, t in _sql_stat4.index[0]:pairs() do
+ _sql_stat4:delete({t[1], t[2], t[6]})
+ end
+ box.space._space:replace(_sql_stat1_def)
+ box.space._space:replace(_sql_stat4_def)
+end
+
local function get_version()
local version = box.space._schema:get{'version'}
if version == nil then
@@ -643,7 +669,8 @@ local function upgrade(options)
{version = mkversion(1, 7, 7), func = upgrade_to_1_7_7, auto = true},
{version = mkversion(1, 10, 0), func = upgrade_to_1_10_0, auto = true},
{version = mkversion(1, 10, 2), func = upgrade_to_1_10_2, auto = true},
- {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0, auto = true}
+ {version = mkversion(2, 1, 0), func = upgrade_to_2_1_0, auto = true},
+ {version = mkversion(2, 1, 2), func = upgrade_to_2_1_2, auto = true}
}
for _, handler in ipairs(handlers) do
diff --git a/test/box-py/bootstrap.result b/test/box-py/bootstrap.result
index 3e4394557..0ba533596 100644
--- a/test/box-py/bootstrap.result
+++ b/test/box-py/bootstrap.result
@@ -4,7 +4,7 @@ box.internal.bootstrap()
box.space._schema:select{}
---
- - ['max_id', 511]
- - ['version', 2, 1, 0]
+ - ['version', 2, 1, 2]
...
box.space._cluster:select{}
---
@@ -73,9 +73,9 @@ box.space._space:select{}
'type': 'unsigned'}]]
- [340, 1, '_space_sequence', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'},
{'name': 'sequence_id', 'type': 'unsigned'}, {'name': 'is_generated', 'type': 'boolean'}]]
- - [348, 1, '_sql_stat1', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+ - [348, 1, '_sql_stat1', 'memtx', 3, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
'type': 'string'}, {'name': 'stat', 'type': 'string'}]]
- - [349, 1, '_sql_stat4', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+ - [349, 1, '_sql_stat4', 'memtx', 6, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
'type': 'string'}, {'name': 'neq', 'type': 'string'}, {'name': 'nlt', 'type': 'string'},
{'name': 'ndlt', 'type': 'string'}, {'name': 'sample', 'type': 'scalar'}]]
- [356, 1, '_fk_constraint', 'memtx', 0, {}, [{'name': 'name', 'type': 'string'},
diff --git a/test/box/access_misc.result b/test/box/access_misc.result
index 4ffeb386a..5449834da 100644
--- a/test/box/access_misc.result
+++ b/test/box/access_misc.result
@@ -813,9 +813,9 @@ box.space._space:select()
'type': 'unsigned'}]]
- [340, 1, '_space_sequence', 'memtx', 0, {}, [{'name': 'id', 'type': 'unsigned'},
{'name': 'sequence_id', 'type': 'unsigned'}, {'name': 'is_generated', 'type': 'boolean'}]]
- - [348, 1, '_sql_stat1', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+ - [348, 1, '_sql_stat1', 'memtx', 3, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
'type': 'string'}, {'name': 'stat', 'type': 'string'}]]
- - [349, 1, '_sql_stat4', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+ - [349, 1, '_sql_stat4', 'memtx', 6, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
'type': 'string'}, {'name': 'neq', 'type': 'string'}, {'name': 'nlt', 'type': 'string'},
{'name': 'ndlt', 'type': 'string'}, {'name': 'sample', 'type': 'scalar'}]]
- [356, 1, '_fk_constraint', 'memtx', 0, {}, [{'name': 'name', 'type': 'string'},
diff --git a/test/sql/upgrade.result b/test/sql/upgrade.result
index 02ab9b42b..1b1bb4c8c 100644
--- a/test/sql/upgrade.result
+++ b/test/sql/upgrade.result
@@ -30,12 +30,12 @@ box.space._space.index['name']:get('_trigger')
...
box.space._space.index['name']:get('_sql_stat1')
---
-- [348, 1, '_sql_stat1', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+- [348, 1, '_sql_stat1', 'memtx', 3, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
'type': 'string'}, {'name': 'stat', 'type': 'string'}]]
...
box.space._space.index['name']:get('_sql_stat4')
---
-- [349, 1, '_sql_stat4', 'memtx', 0, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
+- [349, 1, '_sql_stat4', 'memtx', 6, {}, [{'name': 'tbl', 'type': 'string'}, {'name': 'idx',
'type': 'string'}, {'name': 'neq', 'type': 'string'}, {'name': 'nlt', 'type': 'string'},
{'name': 'ndlt', 'type': 'string'}, {'name': 'sample', 'type': 'scalar'}]]
...
@@ -158,3 +158,38 @@ test_run:cmd('cleanup server upgrade')
---
- true
...
+work_dir = 'sql/upgrade/2.1.0/'
+---
+...
+test_run:cmd('create server upgrade210 with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
+---
+- true
+...
+test_run:cmd('start server upgrade210')
+---
+- true
+...
+test_run:switch('upgrade210')
+---
+- true
+...
+box.space._sql_stat1.field_count
+---
+- 3
+...
+box.space._sql_stat4.field_count
+---
+- 6
+...
+test_run:switch('default')
+---
+- true
+...
+test_run:cmd('stop server upgrade210')
+---
+- true
+...
+test_run:cmd('cleanup server upgrade210')
+---
+- true
+...
diff --git a/test/sql/upgrade.test.lua b/test/sql/upgrade.test.lua
index cd4dd3cca..9ca3f18e2 100644
--- a/test/sql/upgrade.test.lua
+++ b/test/sql/upgrade.test.lua
@@ -53,3 +53,16 @@ box.sql.execute("DROP TABLE T_OUT;")
test_run:switch('default')
test_run:cmd('stop server upgrade')
test_run:cmd('cleanup server upgrade')
+
+work_dir = 'sql/upgrade/2.1.0/'
+test_run:cmd('create server upgrade210 with script="sql/upgrade/upgrade.lua", workdir="' .. work_dir .. '"')
+test_run:cmd('start server upgrade210')
+
+test_run:switch('upgrade210')
+
+box.space._sql_stat1.field_count
+box.space._sql_stat4.field_count
+
+test_run:switch('default')
+test_run:cmd('stop server upgrade210')
+test_run:cmd('cleanup server upgrade210')
--
2.15.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tarantool-patches] Re: [PATCH 2/2] schema: add exact field count to SQL stat spaces
2019-03-18 23:51 ` [tarantool-patches] [PATCH 2/2] schema: add exact field count to SQL stat spaces Nikita Pettik
@ 2019-03-21 13:31 ` Vladislav Shpilevoy
2019-03-21 15:22 ` n.pettik
0 siblings, 1 reply; 6+ messages in thread
From: Vladislav Shpilevoy @ 2019-03-21 13:31 UTC (permalink / raw)
To: Nikita Pettik, tarantool-patches
On that branch tests sql-tap/gh2548-select-compound-limit.test.lua
and sql-tap/gh2250-trigger-chain-limit.test.lua fail.
On 19/03/2019 02:51, Nikita Pettik wrote:
> As a rule, system spaces don't feature exact field count. There is a
> reason for that: almost all of them have on replace triggers, which
> extract data from tuple and verify it. However, _sql_stat1 and
> _sql_stat4 spaces containing SQL specific statistics don't have such
> triggers. Hence, one can insert tuple to this space with greater number
> of fields, than format says. To prevent this, let's explicitly set exact
> field count to number of fields in format.
> ---
> src/box/bootstrap.snap | Bin 1831 -> 1840 bytes
> src/box/lua/upgrade.lua | 29 ++++++++++++++++++++++++++++-
> test/box-py/bootstrap.result | 6 +++---
> test/box/access_misc.result | 4 ++--
> test/sql/upgrade.result | 39 +++++++++++++++++++++++++++++++++++++--
> test/sql/upgrade.test.lua | 13 +++++++++++++
> 6 files changed, 83 insertions(+), 8 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tarantool-patches] Re: [PATCH 2/2] schema: add exact field count to SQL stat spaces
2019-03-21 13:31 ` [tarantool-patches] " Vladislav Shpilevoy
@ 2019-03-21 15:22 ` n.pettik
2019-03-21 15:39 ` Vladislav Shpilevoy
0 siblings, 1 reply; 6+ messages in thread
From: n.pettik @ 2019-03-21 15:22 UTC (permalink / raw)
To: tarantool-patches; +Cc: Vladislav Shpilevoy
> On 21 Mar 2019, at 16:31, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote:
>
> On that branch tests sql-tap/gh2548-select-compound-limit.test.lua
> and sql-tap/gh2250-trigger-chain-limit.test.lua fail.
Are you sure? Travis is green; on my local machine both
release and debug builds pass these tests as well (memtx
and vinyl cases). Could you check it again, or provide more
details concerning fails?
> On 19/03/2019 02:51, Nikita Pettik wrote:
>> As a rule, system spaces don't feature exact field count. There is a
>> reason for that: almost all of them have on replace triggers, which
>> extract data from tuple and verify it. However, _sql_stat1 and
>> _sql_stat4 spaces containing SQL specific statistics don't have such
>> triggers. Hence, one can insert tuple to this space with greater number
>> of fields, than format says. To prevent this, let's explicitly set exact
>> field count to number of fields in format.
>> ---
>> src/box/bootstrap.snap | Bin 1831 -> 1840 bytes
>> src/box/lua/upgrade.lua | 29 ++++++++++++++++++++++++++++-
>> test/box-py/bootstrap.result | 6 +++---
>> test/box/access_misc.result | 4 ++--
>> test/sql/upgrade.result | 39 +++++++++++++++++++++++++++++++++++++--
>> test/sql/upgrade.test.lua | 13 +++++++++++++
>> 6 files changed, 83 insertions(+), 8 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [tarantool-patches] Re: [PATCH 2/2] schema: add exact field count to SQL stat spaces
2019-03-21 15:22 ` n.pettik
@ 2019-03-21 15:39 ` Vladislav Shpilevoy
0 siblings, 0 replies; 6+ messages in thread
From: Vladislav Shpilevoy @ 2019-03-21 15:39 UTC (permalink / raw)
To: n.pettik, tarantool-patches, Kirill Yukhin
On 21/03/2019 18:22, n.pettik wrote:
>
>
>> On 21 Mar 2019, at 16:31, Vladislav Shpilevoy <v.shpilevoy@tarantool.org> wrote:
>>
>> On that branch tests sql-tap/gh2548-select-compound-limit.test.lua
>> and sql-tap/gh2250-trigger-chain-limit.test.lua fail.
>
> Are you sure? Travis is green; on my local machine both
> release and debug builds pass these tests as well (memtx
> and vinyl cases). Could you check it again, or provide more
> details concerning fails?
Hmm, I do not know, what it was, but now they pass :)
LGTM.
>
>> On 19/03/2019 02:51, Nikita Pettik wrote:
>>> As a rule, system spaces don't feature exact field count. There is a
>>> reason for that: almost all of them have on replace triggers, which
>>> extract data from tuple and verify it. However, _sql_stat1 and
>>> _sql_stat4 spaces containing SQL specific statistics don't have such
>>> triggers. Hence, one can insert tuple to this space with greater number
>>> of fields, than format says. To prevent this, let's explicitly set exact
>>> field count to number of fields in format.
>>> ---
>>> src/box/bootstrap.snap | Bin 1831 -> 1840 bytes
>>> src/box/lua/upgrade.lua | 29 ++++++++++++++++++++++++++++-
>>> test/box-py/bootstrap.result | 6 +++---
>>> test/box/access_misc.result | 4 ++--
>>> test/sql/upgrade.result | 39 +++++++++++++++++++++++++++++++++++++--
>>> test/sql/upgrade.test.lua | 13 +++++++++++++
>>> 6 files changed, 83 insertions(+), 8 deletions(-)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-03-21 15:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 23:51 [tarantool-patches] [PATCH 0/2] Fix wrong field count in bytecode for ANALYZE Nikita Pettik
2019-03-18 23:51 ` [tarantool-patches] [PATCH 1/2] sql: fix OP_MakeRecord argument of ANALYZE bytecode Nikita Pettik
2019-03-18 23:51 ` [tarantool-patches] [PATCH 2/2] schema: add exact field count to SQL stat spaces Nikita Pettik
2019-03-21 13:31 ` [tarantool-patches] " Vladislav Shpilevoy
2019-03-21 15:22 ` n.pettik
2019-03-21 15:39 ` Vladislav Shpilevoy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox