[MDEV-12890] constraint name in column constraints Created: 2017-05-24 Updated: 2018-02-14 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Data Definition - Alter Table |
| Affects Version/s: | 10.2 |
| Fix Version/s: | 10.2 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Andrii Nikitin (Inactive) | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | Compatibility | ||
| Issue Links: |
|
||||||||
| Description |
|
According to the sql standard the following is valid command:
Oracle grammar examples indicate the same:
But both 10.2.6 and 10.3.0 show syntax error:
|
| Comments |
| Comment by Elena Stepanova [ 2017-05-24 ] | ||||||||||||||||
|
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. | ||||||||||||||||
| Comment by Andrii Nikitin (Inactive) [ 2017-05-24 ] | ||||||||||||||||
|
I don't see any reason why "b INT CHECK (b>2)" is valid column definition but "b INT constraint bc CHECK (b>2)" is invalid , except that this path was overlooked during implementation of linked task; sorry that my description doesn't make explicit stress on that. | ||||||||||||||||
| Comment by Elena Stepanova [ 2017-05-24 ] | ||||||||||||||||
|
I think the main reason is that there were no actual grammar changes here, the existing syntax is the legacy from the times where people cared less about complying with the standard. It's just the constraints were ignored earlier, and now they are actually used; but both variants that work now were grammatically acceptable before, e.g. you can do in previous versions
or
it won't complain. But it will complain about
| ||||||||||||||||
| Comment by Andrii Nikitin (Inactive) [ 2017-05-24 ] | ||||||||||||||||
|
I am not sure what are we discussing here - if there was any reason to not implement discussed variant of syntax during mentioned | ||||||||||||||||
| Comment by Sergei Golubchik [ 2018-02-14 ] | ||||||||||||||||
|
For the reference, the standard syntax is
So "CONSTRAINT name" can be specified for any constraint, also for UNIQUE and NOT NULL, not only for CHECK |