mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Fixed two bugs related to column level constraints
- CREATE TABLE ... SELECT drops constraints for columns that are both in the create and select part. - Fixed by copying the constraint in Column_definiton::redefine_stage1_common() - If one has both a default expression and check constraint for a column, one can get the error "Expression for field `a` is refering to uninitialized field `a`. - Fixed by ignoring default expressions for current column when checking for CHECK constraint
This commit is contained in:
@ -111,3 +111,20 @@ long_enough_name CREATE TABLE `long_enough_name` (
|
||||
CONSTRAINT `constr` CHECK (`f6` >= 0)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
DROP TABLE long_enough_name;
|
||||
create table t1 (a int check (a>10)) select 100 as 'a';
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` int(11) DEFAULT NULL CHECK (`a` > 10)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
create table t1 (a text default(length(now())) check (length(a) > 1));
|
||||
insert into t1 values ();
|
||||
insert into t1 values ("ccc");
|
||||
insert into t1 values ("");
|
||||
ERROR 23000: CONSTRAINT `t1.a` failed for `test`.`t1`
|
||||
select * from t1;
|
||||
a
|
||||
19
|
||||
ccc
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user