[MDEV-27360] Column level CHECK constraint is not SQL Standard compliant Created: 2021-12-24 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Create Table |
| Affects Version/s: | 10.3, 10.4, 10.5, 10.6, 10.7, 10.8 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Alexander Barkov |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||
| Description |
|
SQL-2016 says:
Which should mean that a column CHECK constraint inside a <column definition> can refer only to THIS column. It cannot refer to OTHER columns. It impies that this CREATE statement is not valid:
MariaDB allows this statement as an extension. But in some cases this can be a reason for bugs. See MDEV-27359. OracleOracle 21c does not allow this statement:
SQL ServerSQL Server 2019 does not allow this statement:
IBM DB2DB2 Developer C 11.1 does not allow this statement:
PostgreSQLPostgreSQL allows this statement, but pg_dump shows that it actually moves the constraint to the table level, which makes it SQL compliant:
However, PostgreSQL moves even correct column level constraints to the table level:
Possible solutions
In case if we decide to move crossed constraints from the column to the table level (#3 or #4), a warning or a note should probably be issued. |