Bug #35578 Parser allows useless/illegal CREATE TABLE syntax
Submitted: 26 Mar 2008 17:59 Modified: 26 Aug 2008 21:20
Reporter: Paul DuBois
Status: Closed
Category:Server: Parser Severity:S3 (Non-critical)
Version:4.1 and up OS:Any
Assigned to: Marc Alff Target Version:
Triage: D3 (Medium)

[26 Mar 2008 17:59] Paul DuBois
Description:
For CREATE TABLE syntax, the parser allows:

CONSTRAINT [symbol] [CHECK(expr)]

This syntax, with a missing CHECK, is not in the SQL-2003 spec.

See

http://savage.net.au/SQL/sql-2003-2.bnf.html#column%20definition

The parser also allows:

[CONSTRAINT [symbol]] CHECK(expr)

This one is in the SQL-2003 spec.
However, the parser does not implement the syntax properly,
since the rule 'check_constraint:' does not contain the parenthesis.

How to repeat:
Examine sql_yacc.yy.
[26 Mar 2008 22:09] Valeriy Kravchuk
Thank you for a bug report. Verified just as described:

mysql> create table tc (c1 int, constraint chk);
Query OK, 0 rows affected (0.16 sec)

mysql> select version();
+--------------------------+
| version()                |
+--------------------------+
| 5.0.56-enterprise-gpl-nt |
+--------------------------+
1 row in set (0.03 sec)
[13 May 2008 0:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/46638

ChangeSet@1.2644, 2008-05-12 16:29:50-06:00, malff@lambda.hsd1.co.comcast.net. +3 -0
  Bug#35578 (Parser allows useless/illegal CREATE TABLE syntax)
  
  Fix the (still non supported) CHECK syntax to:
  - enforce that parenthesis are present in the "CHECK ( <expr> )" syntax,
  per the SQL specification
  - enforce that "CONSTRAINT <name>" alone, without any constraint, is illegal,
  per the SQL specification
  
  Fixing this also resolves 3 shift/reduce conflicts in the grammar.
[12 Jun 2008 17:22] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/47785
[12 Jun 2008 17:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/47787
[13 Aug 2008 22:46] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51578

2762 Marc Alff	2008-08-13
      Bug#35578 (Parser allows useless/illegal CREATE TABLE syntax)
      
      Fix the (still non supported) CHECK syntax to:
      - enforce that parenthesis are present in the "CHECK ( <expr> )" syntax,
      per the SQL specification
      - enforce that "CONSTRAINT <name>" alone, without any constraint, is illegal,
      per the SQL specification
      
      Fixing this also resolves 3 shift/reduce conflicts in the grammar.
[13 Aug 2008 23:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/51584

2764 Marc Alff	2008-08-13 [merge]
      Merge 6.0-bugteam -> local bugfix branch
[26 Aug 2008 21:20] Paul DuBois
Noted in 6.0.7 changelog.
[26 Aug 2008 22:17] Marc Alff
See related Bug#11714, which was fixed by this change.
[26 Aug 2008 23:05] Marc Alff
See related Bug#38696, which was fixed by this change
[28 Aug 2008 22:15] Bugs System
Pushed into 6.0.7-alpha  (revid:cbell@mysql.com-20080822132131-uveo6wiuecy6m2b8) (version
source revid:cbell@mysql.com-20080822132131-uveo6wiuecy6m2b8) (pib:3)
[13 Sep 2008 23:11] Bugs System
Pushed into 6.0.7-alpha  (revid:marc.alff@sun.com-20080813204529-kqlg9vpz5blphfwx)
(version source revid:hakan@mysql.com-20080725175322-8wgujj5xuzrjz3ke) (pib:3)