mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-11114 Cannot drop column referenced by CHECK constraint: Unknown column 'a' in 'virtual column function'
clarify the error message
This commit is contained in:
@ -136,3 +136,7 @@ insert into t1(c1) values(1);
|
||||
ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1`
|
||||
insert into t1(c1) values(2);
|
||||
drop table t1;
|
||||
create table t1 (a int, b int, check(a>0));
|
||||
alter table t1 drop column a;
|
||||
ERROR 42S22: Unknown column 'a' in 'CHECK'
|
||||
drop table t1;
|
||||
|
@ -541,10 +541,10 @@ DROP FUNCTION f1;
|
||||
CREATE PROCEDURE p1(par INT) CREATE TABLE t1 (a INT DEFAULT par);
|
||||
ERROR HY000: Function or expression 'par' cannot be used in the DEFAULT clause of `a`
|
||||
CREATE TABLE t1 (a INT DEFAULT par);
|
||||
ERROR 42S22: Unknown column 'par' in 'virtual column function'
|
||||
ERROR 42S22: Unknown column 'par' in 'DEFAULT'
|
||||
CREATE PROCEDURE p1() CREATE TABLE t1 (a INT DEFAULT par);
|
||||
CALL p1;
|
||||
ERROR 42S22: Unknown column 'par' in 'virtual column function'
|
||||
ERROR 42S22: Unknown column 'par' in 'DEFAULT'
|
||||
DROP PROCEDURE p1;
|
||||
CREATE TABLE t1 (a INT DEFAULT VALUES(a));
|
||||
ERROR HY000: Function or expression 'values()' cannot be used in the DEFAULT clause of `a`
|
||||
|
@ -78,3 +78,11 @@ create table t1(c1 int, c2 int as (c1 + 1), check (c2 > 2));
|
||||
insert into t1(c1) values(1);
|
||||
insert into t1(c1) values(2);
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# MDEV-11114 Cannot drop column referenced by CHECK constraint: Unknown column 'a' in 'virtual column function'
|
||||
#
|
||||
create table t1 (a int, b int, check(a>0));
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
alter table t1 drop column a;
|
||||
drop table t1;
|
||||
|
@ -1060,6 +1060,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table,
|
||||
|
||||
expr_str.length(parse_vcol_keyword.length);
|
||||
expr_str.append((char*)pos, expr_length);
|
||||
thd->where= vcol_type_name(static_cast<enum_vcol_info_type>(type));
|
||||
|
||||
switch (type) {
|
||||
case VCOL_GENERATED_VIRTUAL:
|
||||
@ -2691,13 +2692,9 @@ static bool fix_vcol_expr(THD *thd, Virtual_column_info *vcol)
|
||||
const enum enum_mark_columns save_mark_used_columns= thd->mark_used_columns;
|
||||
thd->mark_used_columns= MARK_COLUMNS_NONE;
|
||||
|
||||
const char *save_where= thd->where;
|
||||
thd->where= "virtual column function";
|
||||
|
||||
int error= vcol->expr->fix_fields(thd, &vcol->expr);
|
||||
|
||||
thd->mark_used_columns= save_mark_used_columns;
|
||||
thd->where= save_where;
|
||||
|
||||
if (unlikely(error))
|
||||
{
|
||||
|
Reference in New Issue
Block a user