File: gh2548-select-compound-limit.test.lua

package info (click to toggle)
tarantool 2.6.0-1.4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 85,412 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,178; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (65 lines) | stat: -rwxr-xr-x 2,271 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env tarantool
test = require("sqltester")
test:plan(9)

-- box.cfg{wal_mode='none'}

table_count = 31

select_string_last = ''

for _, term in ipairs({'UNION', 'UNION ALL', 'INTERSECT', 'EXCEPT'}) do
    select_string = ''
    test:do_test("Positive COMPOUND "..term,
                 function()
                     for i = 1,table_count do
                         drop_string = 'DROP TABLE IF EXISTS t' .. i .. ';\n'
                         test:execsql(drop_string)
                     end

                     for i = 1,table_count do
                         create_string = 'CREATE TABLE t' .. i .. ' (s1 int primary key, s2 int);\n'
                         test:execsql(create_string)
                     end

                     for i = 1,table_count do
                         insert_string = 'INSERT INTO t' .. i .. ' VALUES (0,' .. i .. ');\n'
                         test:execsql(insert_string)
                     end

                     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
                     return pcall( function() test:execsql(select_string) end)
                 end,
                 true)
    test:do_test("Negative COMPOUND "..term,
                 function()
                     select_string = select_string .. ' ' .. term ..' ' .. 'SELECT * FROM t' .. table_count
                     return  pcall(function() test:execsql(select_string) end)
                 end,
                 false)

    select_string_last = select_string

--    if not pcall(function() box.execute(select_string) end) then
--        print('not ok')
--    end

--    select_string = select_string .. ' ' .. term ..' ' .. 'SELECT * FROM t' .. table_count
--    if pcall(function() box.execute(select_string) end) then
--        print('not ok')
--    end
end


test:do_catchsql_test(
    "gh2548-select-compound-limit-2",
    select_string_last, {
        -- <gh2548-select-compound-limit-2>
        1, "The number of UNION or EXCEPT or INTERSECT operations 31 exceeds the limit (30)"
        -- </gh2548-select-compound-limit-2>
    })

test:finish_test()