Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
b3e11d33
Commit
b3e11d33
authored
Jun 15, 2016
by
Alexander Barkov
Committed by
Sergei Golubchik
Jun 30, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding a comment why we need column_default_non_parenthesized_expr
(a new rule in sql_yacc.yy)
parent
fb67cde2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
sql/sql_yacc.yy
sql/sql_yacc.yy
+28
-0
No files found.
sql/sql_yacc.yy
View file @
b3e11d33
...
...
@@ -9512,6 +9512,34 @@ dyncall_create_list:
}
;
/*
Expressions that the parser allows in a column DEFAULT clause
without parentheses. These expressions cannot end with a COLLATE clause.
If we allowed any "expr" in DEFAULT clause, there would be a confusion
in queries like this:
CREATE TABLE t1 (a TEXT DEFAULT 'a' COLLATE latin1_bin);
It would be not clear what COLLATE stands for:
- the collation of the column `a`, or
- the collation of the string literal 'a'
This restriction allows to parse the above query unambiguiusly:
COLLATE belongs to the column rather than the literal.
If one needs COLLATE to belong to the literal, parentheses must be used:
CREATE TABLE t1 (a TEXT DEFAULT ('a' COLLATE latin1_bin));
Note: the COLLATE clause is rather meaningless here, but the query
is syntactically correct.
Note, some of the expressions are not actually allowed in DEFAULT,
e.g. sum_expr, window_func_expr, ROW(...), VALUES().
We could move them to simple_expr, but that would make
these two queries return a different error messages:
CREATE TABLE t1 (a INT DEFAULT AVG(1));
CREATE TABLE t1 (a INT DEFAULT (AVG(1)));
The first query would return "syntax error".
Currenly both return:
Function or expression 'avg(' is not allowed for 'DEFAULT' ...
*/
column_default_non_parenthesized_expr:
simple_ident
| function_call_keyword
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment