summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2012-06-23 15:00:05 -0700
committerIgor Babaev <igor@askmonty.org>2012-06-23 15:00:05 -0700
commit20f3f4a273202ef539314acbbdbb67ab91376ab6 (patch)
tree4081cb30864a2cdf9184bdc8c31216d2c7ce2947 /sql
parente7bfda3b3cc59ba3fe4fe7e7e4307704a464f97f (diff)
parentd9c3a3e39e4c5a6f060b7bbc1646ca74c123fbab (diff)
downloadmariadb-git-20f3f4a273202ef539314acbbdbb67ab91376ab6.tar.gz
Merge 5.2->5.3
Diffstat (limited to 'sql')
-rw-r--r--sql/field.h4
-rw-r--r--sql/table.cc20
-rw-r--r--sql/unireg.cc23
-rw-r--r--sql/unireg.h5
4 files changed, 33 insertions, 19 deletions
diff --git a/sql/field.h b/sql/field.h
index d83980c2a29..208f1e381f5 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -2217,6 +2217,10 @@ public:
{
return (flags & (BINCMP_FLAG | BINARY_FLAG)) != 0;
}
+ uint virtual_col_expr_maxlen()
+ {
+ return 255 - FRM_VCOL_HEADER_SIZE(interval != NULL);
+ }
};
diff --git a/sql/table.cc b/sql/table.cc
index ff104103374..05fb5593842 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1257,25 +1257,33 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
/*
Get virtual column data stored in the .frm file as follows:
- byte 1 = 1 (always 1 to allow for future extensions)
+ byte 1 = 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] = optional interval_id for sql_type (only if byte 1 == 2)
+ next byte ... = virtual column expression (text data)
*/
vcol_info= new Virtual_column_info();
- if ((uint)vcol_screen_pos[0] != 1)
+ bool opt_interval_id= (uint)vcol_screen_pos[0] == 2;
+ field_type= (enum_field_types) (uchar) vcol_screen_pos[1];
+ if (opt_interval_id)
+ interval_nr= (uint)vcol_screen_pos[3];
+ else if ((uint)vcol_screen_pos[0] != 1)
{
error= 4;
goto free_and_err;
}
- field_type= (enum_field_types) (uchar) vcol_screen_pos[1];
fld_stored_in_db= (bool) (uint) vcol_screen_pos[2];
- vcol_expr_length= vcol_info_length-(uint)FRM_VCOL_HEADER_SIZE;
+ vcol_expr_length= vcol_info_length -
+ (uint)(FRM_VCOL_HEADER_SIZE(opt_interval_id));
if (!(vcol_info->expr_str.str=
(char *)memdup_root(&share->mem_root,
- vcol_screen_pos+(uint)FRM_VCOL_HEADER_SIZE,
+ vcol_screen_pos +
+ (uint) FRM_VCOL_HEADER_SIZE(opt_interval_id),
vcol_expr_length)))
goto free_and_err;
+ if (opt_interval_id)
+ interval_nr= (uint) vcol_screen_pos[3];
vcol_info->expr_str.length= vcol_expr_length;
vcol_screen_pos+= vcol_info_length;
share->vfields++;
diff --git a/sql/unireg.cc b/sql/unireg.cc
index 589833541d9..13b0e044ef8 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,
diff --git a/sql/unireg.h b/sql/unireg.h
index 4d9062df7d9..01aac50670a 100644
--- a/sql/unireg.h
+++ b/sql/unireg.h
@@ -217,10 +217,7 @@
#define DEFAULT_KEY_CACHE_NAME "default"
/* The length of the header part for each virtual column in the .frm file */
-#define FRM_VCOL_HEADER_SIZE 3
-
-/* Maximum length of the defining expression for a virtual columns */
-#define VIRTUAL_COLUMN_EXPRESSION_MAXLEN 255 - FRM_VCOL_HEADER_SIZE
+#define FRM_VCOL_HEADER_SIZE(b) (3 + test(b))
/* Include prototypes for unireg */