diff options
author | Igor Babaev <igor@askmonty.org> | 2012-06-18 22:32:17 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2012-06-18 22:32:17 -0700 |
commit | 0c69f22032abd6f162829ee31c5ee7d34b84e107 (patch) | |
tree | e524ff3959bfbe1bb63324a8cbcb01c6087909d4 /sql/unireg.cc | |
parent | 64aa1fcb1354ffa24999a1512258c897116b0928 (diff) | |
download | mariadb-git-0c69f22032abd6f162829ee31c5ee7d34b84e107.tar.gz |
Fixed bug mdev-354.
Virtual columns of ENUM and SET data types were not supported properly
in the original patch that introduced virtual columns into MariaDB 5.2.
The problem was that for any virtual column the patch used the
interval_id field of the definition of the column in the frm file as
a reference to the virtual column expression.
The fix stores the optional interval_id of the virtual column in the
extended header of the virtual column expression.
Diffstat (limited to 'sql/unireg.cc')
-rw-r--r-- | sql/unireg.cc | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/sql/unireg.cc b/sql/unireg.cc index dde755462dd..537066fa528 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -670,18 +670,19 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type, } if (field->vcol_info) { + uint col_expr_maxlen= field->virtual_col_expr_maxlen(); tmp_len= system_charset_info->cset->charpos(system_charset_info, field->vcol_info->expr_str.str, field->vcol_info->expr_str.str + field->vcol_info->expr_str.length, - VIRTUAL_COLUMN_EXPRESSION_MAXLEN); + col_expr_maxlen); if (tmp_len < field->vcol_info->expr_str.length) { my_error(ER_WRONG_STRING_LENGTH, MYF(0), field->vcol_info->expr_str.str,"VIRTUAL COLUMN EXPRESSION", - (uint) VIRTUAL_COLUMN_EXPRESSION_MAXLEN); + col_expr_maxlen); DBUG_RETURN(1); } /* @@ -690,7 +691,7 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type, expressions saved in the frm file for virtual columns. */ vcol_info_length+= field->vcol_info->expr_str.length+ - (uint)FRM_VCOL_HEADER_SIZE; + FRM_VCOL_HEADER_SIZE(field->interval!=NULL); } totlength+= field->length; @@ -886,8 +887,9 @@ static bool pack_fields(File file, List<Create_field> &create_fields, the additional data saved for the virtual field */ buff[12]= cur_vcol_expr_len= field->vcol_info->expr_str.length + - (uint)FRM_VCOL_HEADER_SIZE; - vcol_info_length+= cur_vcol_expr_len+(uint)FRM_VCOL_HEADER_SIZE; + FRM_VCOL_HEADER_SIZE(field->interval!=NULL); + vcol_info_length+= cur_vcol_expr_len + + FRM_VCOL_HEADER_SIZE(field->interval!=NULL); buff[13]= (uchar) MYSQL_TYPE_VIRTUAL; } int2store(buff+15, field->comment.length); @@ -992,17 +994,20 @@ static bool pack_fields(File file, List<Create_field> &create_fields, { /* Pack each virtual field as follows: - byte 1 = 1 (always 1 to allow for future extensions) + byte 1 = interval_id == 0 ? 1 : 2 byte 2 = sql_type byte 3 = flags (as of now, 0 - no flags, 1 - field is physically stored) - byte 4-... = virtual column expression (text data) + [byte 4] = possible interval_id for sql_type + next byte ... = virtual column expression (text data) */ if (field->vcol_info && field->vcol_info->expr_str.length) { - buff[0]= (uchar)1; + buff[0]= (uchar)(1 + test(field->interval_id)); buff[1]= (uchar) field->sql_type; buff[2]= (uchar) field->stored_in_db; - if (my_write(file, buff, 3, MYF_RW)) + if (field->interval_id) + buff[3]= (uchar) field->interval_id; + if (my_write(file, buff, 3 + test(field->interval_id), MYF_RW)) DBUG_RETURN(1); if (my_write(file, (uchar*) field->vcol_info->expr_str.str, |