Skip to content
Snippets Groups Projects
Commit 974bce9a authored by Kirill Yukhin's avatar Kirill Yukhin
Browse files

sql: Limit number of terms in SELECT compoind stmts

Right now SQL query compiler is run on top of fiber's stack,
which is limited to 64KB by default, so maximum
number of entities in compound SELECT statement should be less than
50 (verified by experiment) or stack guard will be triggered.

In future we'll introduce heuristic which should understand that
query is 'complex' and run compilation in separate thread with larger
stack. This will also allow us not to block Tarantool while compiling
the query.

Closes #2548
parent 44ba745d
No related branches found
No related tags found
No related merge requests found
......@@ -77,9 +77,13 @@
** if the number of terms is too large. In practice, most SQL
** never has more than 3 or 4 terms. Use a value of 0 to disable
** any limit on the number of terms in a compount SELECT.
**
** Tarantool: gh-2548: Fiber stack is 64KB by default, so maximum
** number of entities should be less than 50 or stack guard will be
** triggered.
*/
#ifndef SQLITE_MAX_COMPOUND_SELECT
# define SQLITE_MAX_COMPOUND_SELECT 500
# define SQLITE_MAX_COMPOUND_SELECT 50
#endif
/*
......
box.cfg{wal_mode='none'}
table_count = 51
for _, term in ipairs({'UNION', 'UNION ALL', 'INTERSECT', 'EXCEPT'}) do
for i = 1,table_count do
drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';\n'
box.sql.execute(drop_string)
end
for i = 1,table_count do
create_string = 'CREATE TABLE t' .. i .. ' (s1 int primary key, s2 int);\n'
box.sql.execute(create_string)
end
for i = 1,table_count do
insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ');\n'
box.sql.execute(insert_string)
end
select_string = ''
for i = 1,table_count-1 do
if i > 1 then select_string = select_string .. ' ' .. term .. ' ' end
select_string = select_string .. 'SELECT * FROM t' .. i
end
if not pcall(function() box.sql.execute(select_string) end) then
print('not ok')
end
select_string = select_string .. ' ' .. term ..' ' .. 'SELECT * FROM t' .. table_count
if pcall(function() box.sql.execute(select_string) end) then
print('not ok')
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment