Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Minor
-
Resolution: Unresolved
-
10.2(EOL)
Description
According to the sql standard the following is valid command:
CREATE TABLE Table_1 ( |
column_1 SMALLINT |
CONSTRAINT constraint_1 CHECK(column_1<400), |
column_2 CHAR(5)); |
Oracle grammar examples indicate the same:
CREATE TABLE employees_demo |
( employee_id NUMBER(6)
|
, first_name VARCHAR2(20)
|
, last_name VARCHAR2(25)
|
CONSTRAINT emp_last_name_nn_demo NOT NULL |
, email VARCHAR2(25)
|
CONSTRAINT emp_email_nn_demo NOT NULL |
...
|
But both 10.2.6 and 10.3.0 show syntax error:
mysql> CREATE TABLE Table_1 (
|
-> column_1 SMALLINT
|
-> CONSTRAINT constraint_1 CHECK(column_1<400),
|
-> column_2 CHAR(5));
|
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400),
|
column_2 CHAR(5))' at line 3
|
Attachments
Issue Links
- relates to
-
MDEV-7563 Support CHECK constraint as in (or close to) SQL Standard
-
- Closed
-
Activity
Affects Version/s | 10.3.0 [ 22127 ] | |
Affects Version/s | 10.2.6 [ 22527 ] | |
Issue Type | Bug [ 1 ] | Task [ 3 ] |
Fix Version/s | 10.3 [ 22126 ] |
Issue Type | Task [ 3 ] | Bug [ 1 ] |
Affects Version/s | 10.2 [ 14601 ] |
Fix Version/s | 10.2 [ 14601 ] | |
Fix Version/s | 10.3 [ 22126 ] |
Summary | CHECK CONSTRAINT still needs one more grammar path | constraint name in column constraints |
Description |
According to [online manual|https://mariadb.com/kb/en/sql-99/constraint_type-check-constraint/] following is valid command:
{code:sql} CREATE TABLE Table_1 ( column_1 SMALLINT CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, column_2 CHAR(5)); {code} [Oracle grammar examples|http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2062833] indicate the same: {code:sql} CREATE TABLE employees_demo ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) CONSTRAINT emp_last_name_nn_demo NOT NULL , email VARCHAR2(25) CONSTRAINT emp_email_nn_demo NOT NULL ... {code} But both 10.2.6 and 10.3.0 show syntax error: {noformat} mysql> CREATE TABLE Table_1 ( -> column_1 SMALLINT -> CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, -> column_2 CHAR(5)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, column_2 CHAR(5))' at line 3 {noformat} |
According to the sql standard the following is valid command:
{code:sql} CREATE TABLE Table_1 ( column_1 SMALLINT CONSTRAINT constraint_1 CHECK(column_1<400), column_2 CHAR(5)); {code} [Oracle grammar examples|http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2062833] indicate the same: {code:sql} CREATE TABLE employees_demo ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) CONSTRAINT emp_last_name_nn_demo NOT NULL , email VARCHAR2(25) CONSTRAINT emp_email_nn_demo NOT NULL ... {code} But both 10.2.6 and 10.3.0 show syntax error: {noformat} mysql> CREATE TABLE Table_1 ( -> column_1 SMALLINT -> CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, -> column_2 CHAR(5)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, column_2 CHAR(5))' at line 3 {noformat} |
Description |
According to the sql standard the following is valid command:
{code:sql} CREATE TABLE Table_1 ( column_1 SMALLINT CONSTRAINT constraint_1 CHECK(column_1<400), column_2 CHAR(5)); {code} [Oracle grammar examples|http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2062833] indicate the same: {code:sql} CREATE TABLE employees_demo ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) CONSTRAINT emp_last_name_nn_demo NOT NULL , email VARCHAR2(25) CONSTRAINT emp_email_nn_demo NOT NULL ... {code} But both 10.2.6 and 10.3.0 show syntax error: {noformat} mysql> CREATE TABLE Table_1 ( -> column_1 SMALLINT -> CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, -> column_2 CHAR(5)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, column_2 CHAR(5))' at line 3 {noformat} |
According to the sql standard the following is valid command:
{code:sql} CREATE TABLE Table_1 ( column_1 SMALLINT CONSTRAINT constraint_1 CHECK(column_1<400), column_2 CHAR(5)); {code} [Oracle grammar examples|http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2062833] indicate the same: {code:sql} CREATE TABLE employees_demo ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) CONSTRAINT emp_last_name_nn_demo NOT NULL , email VARCHAR2(25) CONSTRAINT emp_email_nn_demo NOT NULL ... {code} But both 10.2.6 and 10.3.0 show syntax error: {noformat} mysql> CREATE TABLE Table_1 ( -> column_1 SMALLINT -> CONSTRAINT constraint_1 CHECK(column_1<400), -> column_2 CHAR(5)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, column_2 CHAR(5))' at line 3 {noformat} |
Description |
According to the sql standard the following is valid command:
{code:sql} CREATE TABLE Table_1 ( column_1 SMALLINT CONSTRAINT constraint_1 CHECK(column_1<400), column_2 CHAR(5)); {code} [Oracle grammar examples|http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2062833] indicate the same: {code:sql} CREATE TABLE employees_demo ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) CONSTRAINT emp_last_name_nn_demo NOT NULL , email VARCHAR2(25) CONSTRAINT emp_email_nn_demo NOT NULL ... {code} But both 10.2.6 and 10.3.0 show syntax error: {noformat} mysql> CREATE TABLE Table_1 ( -> column_1 SMALLINT -> CONSTRAINT constraint_1 CHECK(column_1<400), -> column_2 CHAR(5)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400) NOT DEFERRABLE, column_2 CHAR(5))' at line 3 {noformat} |
According to the sql standard the following is valid command:
{code:sql} CREATE TABLE Table_1 ( column_1 SMALLINT CONSTRAINT constraint_1 CHECK(column_1<400), column_2 CHAR(5)); {code} [Oracle grammar examples|http://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_7002.htm#i2062833] indicate the same: {code:sql} CREATE TABLE employees_demo ( employee_id NUMBER(6) , first_name VARCHAR2(20) , last_name VARCHAR2(25) CONSTRAINT emp_last_name_nn_demo NOT NULL , email VARCHAR2(25) CONSTRAINT emp_email_nn_demo NOT NULL ... {code} But both 10.2.6 and 10.3.0 show syntax error: {noformat} mysql> CREATE TABLE Table_1 ( -> column_1 SMALLINT -> CONSTRAINT constraint_1 CHECK(column_1<400), -> column_2 CHAR(5)); ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CONSTRAINT constraint_1 CHECK(column_1<400), column_2 CHAR(5))' at line 3 {noformat} |
Priority | Major [ 3 ] | Minor [ 4 ] |
Status | Open [ 1 ] | Confirmed [ 10101 ] |
Workflow | MariaDB v3 [ 80911 ] | MariaDB v4 [ 143941 ] |
Please note that SQL-99 is not a MariaDB manual, it's the standard, of which MariaDB only implements a subset. Here is the documentation of the feature syntax in current MariaDB: https://mariadb.com/kb/en/mariadb/constraint/
You can either have CHECK(expression) as a part of a column definition, or CONSTRAINT [constraint_name] CHECK (expression). The latter goes outside the column definition; the page doesn't say that, it should probably be added as an explicit note; it is indeed not implemented as a part of a column definition, which the example in the description is about. [NOT] DEFERRABLE is not implemented either.
I've converted it into a task.