diff options
author | Sergei Golubchik <serg@mariadb.org> | 2016-06-29 21:18:32 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2016-06-30 11:43:02 +0200 |
commit | 70390771956847394122af43acdcdb1c7dac5910 (patch) | |
tree | c53646fff1629694aef3474078246c1c02714863 /sql | |
parent | 0a056c9b5302c24ee4eaa9cc92bd6697125f94b7 (diff) | |
download | mariadb-git-70390771956847394122af43acdcdb1c7dac5910.tar.gz |
change vcol->non_deterministic to vcol->flags
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/field.h | 12 | ||||
-rw-r--r-- | sql/item.h | 7 | ||||
-rw-r--r-- | sql/table.cc | 26 | ||||
-rw-r--r-- | sql/unireg.cc | 2 |
5 files changed, 22 insertions, 27 deletions
diff --git a/sql/field.cc b/sql/field.cc index 054865c6513..5c9ea0ee5cd 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -9766,7 +9766,7 @@ bool check_expression(Virtual_column_info *vcol, const char *type, res.errors= 0; ret= vcol->expr_item->walk(&Item::check_vcol_func_processor, 0, &res); - vcol->non_deterministic= res.errors & VCOL_NON_DETERMINISTIC; + vcol->flags= res.errors; if (ret || (res.errors & diff --git a/sql/field.h b/sql/field.h index 1f75d96a9de..c19d35eb9ab 100644 --- a/sql/field.h +++ b/sql/field.h @@ -546,6 +546,12 @@ inline bool is_temporal_type_with_time(enum_field_types type) } } +/* Bits for type of vcol expression */ +#define VCOL_DETERMINISTIC 0 /* Normal (no bit set) */ +#define VCOL_UNKNOWN 1 /* UDF used; Need fix_fields() to know */ +#define VCOL_NON_DETERMINISTIC 2 +#define VCOL_TIME_FUNC 4 +#define VCOL_IMPOSSIBLE 8 /* Virtual_column_info is the class to contain additional @@ -571,18 +577,18 @@ private: public: /* Flag indicating that the field is physically stored in the database */ bool stored_in_db; - bool non_deterministic; bool utf8; /* Already in utf8 */ /* The expression to compute the value of the virtual column */ Item *expr_item; /* Text representation of the defining expression */ LEX_STRING expr_str; LEX_STRING name; /* Name of constraint */ + uint flags; Virtual_column_info() : field_type((enum enum_field_types)MYSQL_TYPE_VIRTUAL), - in_partitioning_expr(FALSE), stored_in_db(FALSE), non_deterministic(FALSE), - utf8(TRUE), expr_item(NULL) + in_partitioning_expr(FALSE), stored_in_db(FALSE), + utf8(TRUE), expr_item(NULL), flags(0) { expr_str.str= name.str= NULL; name.length= 0; diff --git a/sql/item.h b/sql/item.h index 4a5efad0048..31d87b9f8e4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -32,13 +32,6 @@ C_MODE_START #include <ma_dyncol.h> C_MODE_END -/* Bits for type of vcol expression */ -#define VCOL_DETERMINISTIC 0 /* Normal (no bit set) */ -#define VCOL_UNKNOWN 1 /* UDF used; Need fix_fields() to know */ -#define VCOL_NON_DETERMINISTIC 2 -#define VCOL_TIME_FUNC 4 -#define VCOL_IMPOSSIBLE 8 - class Protocol; struct TABLE_LIST; void item_init(void); /* Init item functions */ diff --git a/sql/table.cc b/sql/table.cc index 20444114381..3a865ab2fad 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -2208,7 +2208,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, vcol_info->expr_str.str= expr; vcol_info->expr_str.length= expr_length; vcol_screen_pos+= expr_length; - vcol_info->non_deterministic= flags & 1; + vcol_info->flags= flags; vcol_info->stored_in_db= 0; switch (type) { @@ -2578,15 +2578,6 @@ static bool fix_vcol_expr(THD *thd, /* fix_fields could change the expression */ func_expr= vcol->expr_item; - /* - Mark what kind of default / virtual fields the table has - Here we assume that things has not changed since table was created. - If we decide to not trust functions, we could instead call - expr_item->walk(&Item::check_vcol_func_processor) - */ - if (vcol->stored_in_db && vcol->non_deterministic) - table->s->non_determinstic_insert= 1; - /* Number of columns will be checked later */ thd->where= save_where; if (unlikely(func_expr->result_type() == ROW_RESULT)) @@ -2602,10 +2593,9 @@ static bool fix_vcol_expr(THD *thd, goto end; } -#ifdef PARANOID /* Walk through the Item tree checking if all items are valid - to be part of the virtual column + to be part of the virtual column */ Item::vcol_func_processor_result res; res.errors= 0; @@ -2614,10 +2604,17 @@ static bool fix_vcol_expr(THD *thd, if (error || (res.errors & VCOL_IMPOSSIBLE)) { my_error(ER_VIRTUAL_COLUMN_FUNCTION_IS_NOT_ALLOWED, MYF(0), res.name, - "???", field_name); + "???", field->field_name); goto end; } -#endif + vcol->flags= res.errors; + + /* + Mark what kind of default / virtual fields the table has + */ + if (vcol->stored_in_db && vcol->flags & VCOL_NON_DETERMINISTIC) + table->s->non_determinstic_insert= 1; + result= FALSE; end: @@ -2759,7 +2756,6 @@ Virtual_column_info *unpack_vcol_info_from_frm(THD *thd, fix_vcol_expr() to mark if we are using non deterministic functions. */ vcol_storage.vcol_info->stored_in_db= vcol->stored_in_db; - vcol_storage.vcol_info->non_deterministic= vcol->non_deterministic; vcol_storage.vcol_info->name= vcol->name; vcol_storage.vcol_info->utf8= vcol->utf8; /* Validate the Item tree. */ diff --git a/sql/unireg.cc b/sql/unireg.cc index 33a54268da8..45c55fa1af9 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -576,7 +576,7 @@ static void pack_expression(uchar **buff, Virtual_column_info *vcol, int2store((*buff)+2, vcol->expr_str.length); (*buff)[4]= (uchar) type; (*buff)[5]= vcol->name.length; - (*buff)[6]= vcol->non_deterministic; // 1 bit used for now + (*buff)[6]= vcol->flags; (*buff)+= FRM_VCOL_NEW_HEADER_SIZE; memcpy((*buff), vcol->name.str, vcol->name.length); (*buff)+= vcol->name.length; |