forked from tarantool/tarantool
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: properly check result of decimal parsing
This patch fixes a crash that can occur when SQL parses a decimal literal that represents a number greater than or equal to 10^38. Closes tarantool#9469 NO_DOC=bugfix
- Loading branch information
Showing
5 changed files
with
45 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
## bugfix/sql | ||
|
||
* Fixed a crash when a decimal literal represented a decimal number greater | ||
than or equal to 10^38 is parsed in SQL (gh-9469). |
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,34 @@ | ||
local server = require('luatest.server') | ||
local t = require('luatest') | ||
|
||
local g = t.group() | ||
|
||
g.before_all(function() | ||
g.server = server:new({alias = 'master'}) | ||
g.server:start() | ||
end) | ||
|
||
g.after_all(function() | ||
g.server:stop() | ||
end) | ||
|
||
g.test_exists = function() | ||
g.server:exec(function() | ||
local dec = '111111111111111111111111111111111111111.0' | ||
local sql = ([[SELECT %s;]]):format(dec) | ||
local exp = ([[Invalid decimal: '%s']]):format(dec) | ||
local res, err = box.execute(sql) | ||
t.assert(res == nil) | ||
t.assert_equals(err.message, exp) | ||
|
||
sql = ([[SELECT -%s;]]):format(dec) | ||
res, err = box.execute(sql) | ||
t.assert(res == nil) | ||
t.assert_equals(err.message, exp) | ||
|
||
sql = ([[CREATE TABLE T(i DEC PRIMARY KEY DEFAULT(%s);]]):format(dec) | ||
res, err = box.execute(sql) | ||
t.assert(res == nil) | ||
t.assert_equals(err.message, exp) | ||
end) | ||
end |