Bug #3481 | wrong syntax (last comma) does not return syntax error | ||
---|---|---|---|
Submitted: | 15 Apr 2004 23:44 | Modified: | 28 Apr 2004 16:42 |
Reporter: | Thomas Mayer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 4.0.18 | OS: | Linux (Suse Linux 8.2) |
Assigned to: | Antony Curtis | CPU Architecture: | Any |
[15 Apr 2004 23:44]
Thomas Mayer
[15 Apr 2004 23:59]
Thomas Mayer
-- and even totally wrong: create table test2 ( myfield tinyint(2),,, myfield2 tinyint(2),,,,, ,,, , ); -- that's funny :-)
[16 Apr 2004 0:01]
Thomas Mayer
-- The right syntax should of course be create table test ( myfield tinyint(2) );
[16 Apr 2004 1:21]
Marko Mäkelä
According to ISO/IEC 9075-2:2003, trailing commas are not allowed: <table element list> ::= <left paren> <table element> [ { <comma> <table element> }... ] <right paren>
[19 Apr 2004 8:48]
Antony Curtis
The following patch fixes the behaviour. ===== sql/sql_yacc.yy 1.227 vs edited ===== --- 1.227/sql/sql_yacc.yy Wed Mar 10 09:50:15 2004 +++ edited/sql/sql_yacc.yy Mon Apr 19 17:16:33 2004 @@ -945,7 +945,7 @@ ; column_def: - field_spec check_constraint + field_spec opt_check_constraint | field_spec references { Lex->col_list.empty(); /* Alloced by sql_alloc */ @@ -963,20 +963,31 @@ { Lex->col_list.empty(); /* Alloced by sql_alloc */ } + | constraint opt_check_constraint + { + Lex->col_list.empty(); /* Alloced by sql_alloc */ + } | opt_constraint check_constraint { Lex->col_list.empty(); /* Alloced by sql_alloc */ } ; -check_constraint: +opt_check_constraint: /* empty */ - | CHECK_SYM expr + | check_constraint + ; + +check_constraint: + CHECK_SYM expr ; opt_constraint: /* empty */ - | CONSTRAINT opt_ident; + | constraint; + +constraint: + CONSTRAINT opt_ident; field_spec: field_ident
[28 Apr 2004 10:27]
Michael Widenius
Antony, don't forget to add a test case for this
[28 Apr 2004 16:42]
Antony Curtis
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release. If necessary, you can access the source repository and build the latest available version, including the bugfix, yourself. More information about accessing the source trees is available at http://www.mysql.com/doc/en/Installing_source_tree.html Additional info: Patch + testcase pushed into 4.0 repository