-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prior to this patch, region on fiber was reset during select(), get(), count(), max(), or min(). This would result in an error if one of these operations was used in a user-defined function in SQL. After this patch, these functions truncate region instead of resetting it. Closes #5427
- Loading branch information
Showing
5 changed files
with
264 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
-- test-run result file version 2 | ||
test_run = require('test_run').new() | ||
| --- | ||
| ... | ||
engine = test_run:get_cfg('engine') | ||
| --- | ||
| ... | ||
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}}) | ||
| --- | ||
| ... | ||
|
||
box.execute([[CREATE TABLE t (b STRING PRIMARY KEY);]]) | ||
| --- | ||
| - row_count: 1 | ||
| ... | ||
box.execute([[INSERT INTO t VALUES ('aaaaaaaaaaaa');]]) | ||
| --- | ||
| - row_count: 1 | ||
| ... | ||
test_run:cmd("setopt delimiter ';'"); | ||
| --- | ||
| - true | ||
| ... | ||
box.schema.func.create('CORRUPT_SELECT', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T:select() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
| --- | ||
| ... | ||
box.schema.func.create('CORRUPT_GET', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T:get('aaaaaaaaaaaa') | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
| --- | ||
| ... | ||
box.schema.func.create('CORRUPT_COUNT', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T:count() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
| --- | ||
| ... | ||
box.schema.func.create('CORRUPT_MAX', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T.index[0]:max() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
| --- | ||
| ... | ||
box.schema.func.create('CORRUPT_MIN', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T.index[0]:min() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
| --- | ||
| ... | ||
test_run:cmd("setopt delimiter ''"); | ||
| --- | ||
| - true | ||
| ... | ||
|
||
box.execute([[select CORRUPT_SELECT(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
| --- | ||
| - metadata: | ||
| - name: COLUMN_1 | ||
| type: integer | ||
| rows: | ||
| - [1] | ||
| ... | ||
box.execute([[select CORRUPT_GET(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
| --- | ||
| - metadata: | ||
| - name: COLUMN_1 | ||
| type: integer | ||
| rows: | ||
| - [1] | ||
| ... | ||
box.execute([[select CORRUPT_COUNT(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
| --- | ||
| - metadata: | ||
| - name: COLUMN_1 | ||
| type: integer | ||
| rows: | ||
| - [1] | ||
| ... | ||
box.execute([[select CORRUPT_MAX(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
| --- | ||
| - metadata: | ||
| - name: COLUMN_1 | ||
| type: integer | ||
| rows: | ||
| - [1] | ||
| ... | ||
box.execute([[select CORRUPT_MIN(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
| --- | ||
| - metadata: | ||
| - name: COLUMN_1 | ||
| type: integer | ||
| rows: | ||
| - [1] | ||
| ... | ||
|
||
box.execute([[DROP TABLE t;]]) | ||
| --- | ||
| - row_count: 1 | ||
| ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
test_run = require('test_run').new() | ||
engine = test_run:get_cfg('engine') | ||
_ = box.space._session_settings:update('sql_default_engine', {{'=', 2, engine}}) | ||
|
||
box.execute([[CREATE TABLE t (b STRING PRIMARY KEY);]]) | ||
box.execute([[INSERT INTO t VALUES ('aaaaaaaaaaaa');]]) | ||
test_run:cmd("setopt delimiter ';'"); | ||
box.schema.func.create('CORRUPT_SELECT', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T:select() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
box.schema.func.create('CORRUPT_GET', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T:get('aaaaaaaaaaaa') | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
box.schema.func.create('CORRUPT_COUNT', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T:count() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
box.schema.func.create('CORRUPT_MAX', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T.index[0]:max() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
box.schema.func.create('CORRUPT_MIN', { | ||
language = 'LUA', | ||
returns = 'integer', | ||
body = [[ | ||
function(x) | ||
box.space.T.index[0]:min() | ||
return 1 | ||
end]], | ||
is_sandboxed = false, | ||
param_list = { "string" }, | ||
exports = { 'LUA', 'SQL' }, | ||
is_deterministic = false, | ||
if_not_exists = true | ||
}); | ||
test_run:cmd("setopt delimiter ''"); | ||
|
||
box.execute([[select CORRUPT_SELECT(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
box.execute([[select CORRUPT_GET(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
box.execute([[select CORRUPT_COUNT(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
box.execute([[select CORRUPT_MAX(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
box.execute([[select CORRUPT_MIN(t.b) from t where t.b = ? and t.b <= ? order by t.b;]], {"aaaaaaaaaaaa", "aaaaaaaaaaaa"}) | ||
|
||
box.execute([[DROP TABLE t;]]) |