Draft: sql: make sql lower-case
Summary
- fix: apply lower-casing to sql/no-pk-space.test.lua
NO_DOC=fix after a cherry-pick NO_TEST=fix after a cherry-pick NO_CHANGELOG=fix after a cherry-pick
- fix: sql: fix assertion in case FK or CK declared first
NO_DOC=fix after a cherry-pick NO_TEST=fix after a cherry-pick NO_CHANGELOG=fix after a cherry-pick
- fix: sql: recompile expired prepared statements
NO_DOC=fix after a cherry-pick NO_TEST=fix after a cherry-pick NO_CHANGELOG=fix after a cherry-pick
- sql: second lookup for constraint names
This patch add second lookup for constraint name in the DROP CONSTRAINT statement.
Part of #4467
@TarantoolBot document Title: Second lookup for names in SQL
Since all names are now case sensitive, a second lookup is now supported to maintain backward compatibility. A second lookup by name will be performed if the object was not found by name in the first lookup and if the name is not enclosed in double quotation marks. The name for the second lookup is normalized using old rules.
- sql: second lookup for index names
This patch add second lookup for index name in the following cases:
- index in INDEXED BY clause;
- index in DROP INDEX statement;
- index in PRAGMA statement.
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: second lookup for function names
This patch adds second lookup for function names in expressions.
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: second lookup for column names
This patch add second lookup for column name in the following cases:
- columns in tuple foreign key creation clause;
- columns in field foreign key creation clause;
- columns in primary key creation clause;
- columns in unique constraint creation clause;
- columns in expressions;
- columns in UPDATE TABLE statement;
- columns in INSERT INTO statement;
- columns in CREATE INDEX statement;
Also, second lookup for table name in expressions also now supported.
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: second lookup for space names
This patch add second lookup for space name in the following cases:
- foreign table in tuple foreign key creation clause;
- foreign table in field foreign key creation clause;
- table in DROP TABLE statement;
- view in DROP VIEW statement;
- table in SELECT FROM statement;
- table in DELETE FROM statement;
- table in TRUNCATE TABLE statement;
- table in UPDATE TABLE statement;
- table in INSERT INTO statement;
- table in CREATE INDEX statement;
- table in DROP INDEX statement;
- table in PRAGMA statement;
- table in SHOW CREATE TABLE statement;
- table in CREATE TRIGGER statement;
- table in ALTER TABLE statements;
Table names in expressions will be supported in subsequent commits.
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: second lookup for collation names
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: second lookup for savepoint names
This patch introduces a second lookup for the savepoint name in the "RELEASE savepoint_name" and "ROLLBACK TO savepoint_name" statements.
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: make SQL case-sensitive
This patch makes identifiers in SQL case sensitive. Prior to this patch, these identifiers were normalized unless they were enclosed in double quotes.
Part of #4467
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: check column name in index definition
After this patch, the column name will be checked for being an ID before resolution, not after.
Closes #8365
NO_DOC=bugfix in debug NO_CHANGELOG=bugfix in debug
- sql: introduce sql_coll_id_by_expr()
This patch introduces the sql_coll_id_by_expr() function. This function is used to search for a collation based on a given expression.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce sql_coll_id_by_token()
This patch introduces the sql_coll_id_by_token() function. This function is used to search for a collation based on a given token.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce sql_fieldno_by_item()
This patch introduces the sql_fieldno_by_item() function. This function is used to search for a space field based on a given element of the struct ExprList.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce sql_fieldno_by_expr()
This patch introduces the sql_fieldno_by_expr() function. This function is used to search for a space field based on a given expression.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce sql_fieldno_by_id()
This patch introduces the sql_fieldno_by_id() function. This function is used to search for a space field based on a given element of the struct IdList.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce sql_index_id_by_src()
This patch introduces the sql_index_id_by_src() function. This function is used to search for an index based on a given element of the struct SrcList.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce sql_space_by_src()
This patch introduces the sql_space_by_src() function. This function is used to search for a space based on a given element of the struct SrcList. The main purpose of this function is to introduce a second lookup for spaces, so this function is not used where a second lookup is not required.
Needed for #4467
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: check index for DROP INDEX before runtime
Before this patch, the existence of an index for a DROP INDEX statement was checked at runtime. This is quite inconvenient for #4467, so this will now be checked when creating the VDBE.
Needed for #4467
NO_DOC=no user-visible changes NO_TEST=no user-visible changes NO_CHANGELOG=no user-visible changes
- sql: refactor pragma.c
This patch refactors functions in pragma.c and fixes an issue with incorrectly ordered arguments in sql_pragma_index_info().
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: remove unused struct Expr flags
This patch removes the EP_InfixFunc, EP_DblQuoted and EP_Alias flags as they are not used.
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: remove unused functions
This patch removes the sql_id_eq_str_expr() and vdbe_emit_stat_space_clear() functions as they are no longer used.
NO_DOC=refactoring NO_TEST=refactoring NO_CHANGELOG=refactoring
- sql: introduce variations of DROP CONSTRAINT
This patch introduces variations of DROP CONSTRAINT with a declared constraint type.
Closes #9112
@TarantoolBot document Title: upgrade of DROP CONSTRAINT
Now, instead of just ALTER TABLE table DROP CONSTRAINT constraint;
we
have 8 operator variants:
- Statement to drop PRIMARY KEY, UNIQUE, tuple FOREIGN NEY or tuple CHECK constraints:
ALTER TABLE tab_name DROP CONSTRAINT constr_name;
This statement cannot drop a constraint if constr_name
matches
more than one constraint.
- Statement to drop field FOREIGN NEY or field CHECK constraints:
ALTER TABLE tab_name DROP CONSTRAINT field_name.constr_name;
This statement cannot drop a constraint if constr_name
matches
more than one constraint for the field_name
field.
- Statement to drop PRIMARY KEY constraint:
ALTER TABLE tab_name DROP CONSTRAINT constr_name PRIMARY KEY;
- Statement to drop UNIQUE constraint:
ALTER TABLE tab_name DROP CONSTRAINT constr_name UNIQUE;
- Statement to drop tuple FOREIGN KEY constraint:
ALTER TABLE tab_name DROP CONSTRAINT constr_name FOREIGN KEY;
- Statement to drop tuple CHECK constraint:
ALTER TABLE tab_name DROP CONSTRAINT constr_name CHECK;
- Statement to drop field FOREIGN KEY constraint:
ALTER TABLE tab_name DROP CONSTRAINT field_name.constr_name FOREIGN KEY;
- Statement to drop field CHECK constraint:
ALTER TABLE tab_name DROP CONSTRAINT field_name.constr_name CHECK;
- sql: disallow DROP CONSTRAINT for ambiguous name
This patch prohibits DROP CONSTRAINT if more than one constraint matches a given name.
Part of #9112
NO_DOC=will be added later NO_CHANGELOG=will be added later
- sql: syntax construction to drop field constraints
This patch introduces "ALTER TABLE table_name DROP CONSTRAINT field_name.constraint_name" which can be used to drop field constraints. Also, after this patch, field constraints cannot be dropped using "ALTER TABLE table_name DROP CONSTRAINT constraint_name;".
Part of #9112
NO_DOC=will be added later NO_CHANGELOG=will be added later
- box: improve error message for constraint violation
The wording "Check constraint 'constr_name' failed for tuple" implies that the tuple should follow. This patch adds the missed "a" article.
Closes #9045
NO_DOC=minor NO_CHANGELOG=minor
- box: add
space_by_name
andspace_index_by_name
for arbitrary strings
Change original space_by_name
to space_by_name0
and
space_index_by_name
to space_index_by_name0
, since they accept
NULL-terminated names, and add space_by_name
and space_index_by_name
for arbitrary strings.
Needed for #8146
NO_CHANGELOG=refactoring NO_DOC=refactoring NO_TEST=refactoring
- sql: introduce a function sql_fuzz
SQL fuzzing test requires an entrypoint for SQL engine and the most suitable function for such purpose is sql_stmt_compile(). However, this function is not in a public API, and we don't want to expose it as public function. As a solution function sql_fuzz() is introduced, it is defined under a macro FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION.
Needed for #4826
NO_CHANGELOG=internal NO_DOC=internal NO_TEST=internal
- trivia: add string conversion to upper case
In some cases we need to convert a string to upper case (e.g., when normalizing a lower-case field name for SQL): add helper functions that do this in-place or by creating a copy of the original string.
Needed for #8098
NO_DOC=internal NO_CHANGELOG=internal
- core: build fix for recent gcc
/home/shiny/dev/tarantool/src/lib/core/coio_task.c:114:58:
error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument
and not in the later argument [-Werror=calloc-transposed-args]
114 | struct cord *cord = (struct cord *)calloc(sizeof(struct cord), 1);
NO_TEST=build fix NO_CHANGELOG=build fix NO_DOC=build fix
Close #... Docs follow-up: not necessary / new issue