File: gh-2549-many-columns.test.lua

package info (click to toggle)
tarantool 2.6.0-1.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 85,396 kB
  • sloc: ansic: 513,775; cpp: 69,493; sh: 25,650; python: 19,190; perl: 14,973; makefile: 4,176; yacc: 1,329; sql: 1,074; pascal: 620; ruby: 190; awk: 18; lisp: 7
file content (42 lines) | stat: -rwxr-xr-x 1,128 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
#!/usr/bin/env tarantool
-- The maximum number of columns in sql is 2000. This test checks it.

test = require("sqltester")
test:plan(2)

success_column_count = 2000
fail_column_count = 2001

test:execsql("DROP TABLE IF EXISTS t1")
test:execsql("DROP TABLE IF EXISts t2")

local function form_create_statement(name, column_count)
	create_statement = 'CREATE TABLE ' .. name .. '('
	for i = 1,column_count do
		if i > 1 then create_statement = create_statement .. ',' end
		create_statement = create_statement .. 's' .. i .. ' INT'
		if i == 1 then create_statement = create_statement .. ' PRIMARY KEY' end
	end
	create_statement = create_statement .. ')'
	return create_statement
end

success_statement = form_create_statement("t1", success_column_count)
fail_statement = form_create_statement("t2", fail_column_count)

test:do_execsql_test(
	"columns-1.1",
	success_statement, {
		-- <columns-1.1>
		-- <columns-1.1>
	})

test:do_catchsql_test(
	"columns-1.2",
	fail_statement, {
		-- <columns-1.2>
		1, "Failed to create space 'T2': space column count 2001 exceeds the limit (2000)"
		-- <columns-1.2>
	})

test:finish_test()