diff options
Diffstat (limited to 'sql/table.cc')
-rw-r--r-- | sql/table.cc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sql/table.cc b/sql/table.cc index 6d1a3a7f8d8..380da5fcd7b 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1962,6 +1962,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, unireg_check == Field::TIMESTAMP_DN_FIELD) { reg_field->default_value= new (&share->mem_root) Virtual_column_info(); + reg_field->default_value->set_vcol_type(VCOL_DEFAULT); reg_field->default_value->stored_in_db= 1; share->default_expressions++; } @@ -2361,6 +2362,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, if (!(vcol_info= new (&share->mem_root) Virtual_column_info())) goto err; + /* The following can only be true for check_constraints */ if (field_nr != UINT_MAX16) @@ -2370,6 +2372,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, } vcol_screen_pos+= FRM_VCOL_NEW_HEADER_SIZE; + vcol_info->set_vcol_type((enum_vcol_info_type) type); vcol_info->name.length= name_length; if (name_length) vcol_info->name.str= strmake_root(&share->mem_root, @@ -2811,6 +2814,20 @@ static bool fix_and_check_vcol_expr(THD *thd, TABLE *table, "???", "?????"); DBUG_RETURN(1); } + else if (res.errors & VCOL_AUTO_INC) + { + /* + An auto_increment field may not be used in an expression for + a check constraint, a default value or a generated column + + Note that this error condition is not detected during parsing + of the statement because the field item does not have a field + pointer at that time + */ + my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), + "AUTO_INCREMENT", vcol->get_vcol_type_name(), res.name); + DBUG_RETURN(1); + } vcol->flags= res.errors; if (vcol->flags & VCOL_SESSION_FUNC) @@ -2879,6 +2896,7 @@ unpack_vcol_info_from_frm(THD *thd, MEM_ROOT *mem_root, TABLE *table, if (error) goto end; + vcol_storage.vcol_info->set_vcol_type(vcol->get_vcol_type()); vcol_storage.vcol_info->stored_in_db= vcol->stored_in_db; vcol_storage.vcol_info->name= vcol->name; vcol_storage.vcol_info->utf8= vcol->utf8; |