MDEV-24602: Cannot specify a name for a column check constraint - #2773
MDEV-24602: Cannot specify a name for a column check constraint#2773an3l wants to merge 5 commits into
Conversation
d7c8188 to
6ed55d0
Compare
| `b` char(1) DEFAULT NULL, | ||
| PRIMARY KEY (`a`), | ||
| KEY `b` (`new_b`), | ||
| CONSTRAINT `CONSTRAINT_1` CHECK (`a` + `new_b` > 0), |
There was a problem hiding this comment.
I don't understand. Why did you change how constraints are printed?
There was a problem hiding this comment.
Because of mysqldump that uses show create table and added constraint for json_valid that for the test mysqldump.test returned duplicate error constraint (duplicating when dumping mysql.global_priv table).
There was a problem hiding this comment.
for what table/test there was a duplicate error constraint? why?
There was a problem hiding this comment.
Have updated with the new commit as well PR description with questions and problems for the patch.
There was a problem hiding this comment.
The patch should be functional - no problems for the patch :).
1fb93f6 to
efeb4b6
Compare
ffb2f87 to
73b7130
Compare
vuvova
left a comment
There was a problem hiding this comment.
See inline comments. Global comments:
- please put MDEV-24602 and MDEV-24598 in two different commits. They could still be in the same PR, just different commits.
- in MDEV-24598 you need to handle the case when an existing table (created before your fix) has duplicate constraint names. What will happen in this case? Will ALTER TABLE work?
| packet->append(STRING_WITH_LEN(" CONSTRAINT ")); | ||
| packet->append(field->check_constraint->name.str); | ||
| } | ||
| } |
There was a problem hiding this comment.
In case of create or alter table with new constraint name, there is no visible constraint name in show create.
Like:
`t0` int(11) DEFAULT NULL,
`t1` int(11) DEFAULT NULL CHECK (`t1` > 0),
`t2` int(11) DEFAULT NULL CHECK (`t2` > 0),
- `t3` int(11) DEFAULT NULL CHECK (`t3` > 0)
+ `t3` int(11) DEFAULT NULL CONSTRAINT t_field CHECK (`t3` > 0)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT CONSTRAINT_NAME, TABLE_NAME, CONSTRAINT_TYPE
FROM information_schema.TABLE_CONSTRAINTS WHERE
@@ -408,7 +408,7 @@
show create table t;
Table Create Table
t CREATE TABLE `t` (
- `t1` int(11) DEFAULT NULL CHECK (`t1` > 3.14)
+ `t1` int(11) DEFAULT NULL CONSTRAINT t1_greater_pi_check CHECK (`t1` > 3.14)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
SELECT * from INFORMATION_SCHEMA.CHECK_CONSTRAINTS WHERE
CONSTRAINT_SCHEMA = 'test';
| $$= $1; | ||
| $$->check_constraint= $3; | ||
| $$->check_constraint->name= $2; | ||
| } |
There was a problem hiding this comment.
please, rebase your PR to 10.5. I suspect this hunk might be a problem there.
There was a problem hiding this comment.
Yes, seems there are some problems with 10.5. ⚒️
Update: Here is the rebased version of this PR for 10.5 https://github.com/an3l/server/commits/bb-10.5-anel-MDEV-24602-field-constraint-v5/
…ches table name" This reverts commit 8639e28.
- Name of the field check constraint is the same as the name of the field. - Add check of field name and table constraint names, that is done during `mysql_prepare_create_table()` - Closes PR MariaDB#2773 - Reviewer: <>
- `ALTER TABLE MODIFY_SYM` should use `column_def` instead of `field_spec` what is inline with documentation ``` alter_specification: MODIFY [COLUMN] [IF EXISTS] col_name column_definition [FIRST | AFTER col_name] ``` - Closes PR MariaDB#2773 -Reviewer: <>
- Adding parser rule for named constraint - Closes PR MariaDB#2773 - Reviewer: <>
73b7130 to
6bfbba8
Compare
- Name of the field check constraint is the same as the name of the field. - Add check of field name and table constraint names, that is done during `mysql_prepare_create_table()` - Closes PR MariaDB#2773 - Reviewer: <>
- `ALTER TABLE MODIFY_SYM` should use `column_def` instead of `field_spec` what is inline with documentation ``` alter_specification: MODIFY [COLUMN] [IF EXISTS] col_name column_definition [FIRST | AFTER col_name] ``` - Closes PR MariaDB#2773 -Reviewer: <>
- Adding parser rule for named constraint - Closes PR MariaDB#2773 - Reviewer: <>
- Name of the field check constraint is the same as the name of the field. - Add check of field name and table constraint names, that is done during `mysql_prepare_create_table()` - Closes PR MariaDB#2773 - Reviewer: <>
- `ALTER TABLE MODIFY_SYM` should use `column_def` instead of
`field_spec` what is inline with documentation
```
alter_specification:
MODIFY [COLUMN] [IF EXISTS] col_name column_definition
[FIRST | AFTER col_name]
```
- Closes PR MariaDB#2773
-Reviewer: <>
- Adding parser rule for named constraint - Closes PR MariaDB#2773 - Reviewer: <>
table check constraints (table check constraints name checks are done in
mysql_prepare_create)constraints for adding constraint make it possible by changes done in
parser, what is inline with documentation