From 56d01c8058e7d5ff9877ddb293a982655b138182 Mon Sep 17 00:00:00 2001
From: Bulat Niatshin <theairvideo@gmail.com>
Date: Mon, 7 Aug 2017 15:35:06 +0300
Subject: [PATCH] sql: check identifier length limit

- In Tarantool there are no limit on space identifier. Check that there
are also no limit on name lengths in SQL.

- Implement sql-tap/gh2127-identifier-max-length.test.lua

Closes #2127
---
 .../gh2127-indentifier-max-length.test.lua    | 98 +++++++++++++++++++
 1 file changed, 98 insertions(+)
 create mode 100755 test/sql-tap/gh2127-indentifier-max-length.test.lua

diff --git a/test/sql-tap/gh2127-indentifier-max-length.test.lua b/test/sql-tap/gh2127-indentifier-max-length.test.lua
new file mode 100755
index 0000000000..13f43430f7
--- /dev/null
+++ b/test/sql-tap/gh2127-indentifier-max-length.test.lua
@@ -0,0 +1,98 @@
+#!/usr/bin/env tarantool
+test = require("sqltester")
+
+test:plan(4)
+
+local tt = {}
+local table_word = "АААААААААА"
+
+-- Create 30kb table name
+for i=1,300 do
+	table.insert(tt, table_word)
+end
+
+local table_name = table.concat(tt)
+
+-- Execute CREATE TABLE statement with 30kb table identifier
+test:do_execsql_test(
+	"identifier-1.1",
+	"CREATE TABLE " .. table_name .. "(a INT PRIMARY KEY);"
+	, {
+	    -- <identifier-1.1>
+
+	    -- <identifier-1.1>
+	})
+
+local vt = {}
+local view_word = "BBBBBBBBBB"
+
+-- Create 30kb view name
+for i=1, 300 do
+	table.insert(vt, view_word)
+end
+
+local view_name = table.concat(vt)
+
+test:do_execsql_test(
+	"identifier-1.2",
+	"CREATE VIEW " .. view_name .. " AS SELECT 1; "
+	, {
+	    -- <identifier-1.2>
+	    -- <identifier-1.2>
+	})
+
+local it = {}
+local index_word = "ЕЕЕЕЕЕЕЕЕЕ"
+
+-- Create 30kb index name
+for i=1, 300 do
+	table.insert(it, index_word)
+end
+
+local index_name = table.concat(it)
+
+local field_table = {}
+local field_word = 'ДДДДДДДДД'
+
+-- Create 30kb field name
+for i=1, 300 do
+	table.insert(field_table, field_word)
+end
+
+local field_name = table.concat(field_table)
+local create_table = "CREATE TABLE t1(" .. field_name .. " INT PRIMARY KEY);"
+
+test:execsql(create_table)
+test:do_execsql_test(
+	"identifier-1.3",
+	"CREATE INDEX " .. index_name .. " ON t1(" .. field_name .. ");"
+	, {
+	   -- <identifier-1.3>
+	   --
+	})
+
+
+local trig_table = {}
+local trigger_word = "ССССССССС"
+
+for i=1, 300 do
+	table.insert(trig_table, trigger_word)
+end
+
+local trigger_name = table.concat(trig_table)
+
+test:do_execsql_test(
+	"identifier-1.4",
+	"CREATE TRIGGER " .. trigger_name ..
+	[[
+	BEFORE UPDATE ON t1
+	BEGIN
+		SELECT 1;
+	END;
+	]]
+	, {
+	    -- <identifier-1.4>
+	    -- <identifier-1.5>
+	})
+
+test:finish_test()
-- 
GitLab