Commit 70390771 authored by Sergei Golubchik's avatar Sergei Golubchik

change vcol->non_deterministic to vcol->flags

parent 0a056c9b
......@@ -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 &
......
......@@ -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 @@ class Virtual_column_info: public Sql_alloc
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;
......
......@@ -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 */
......
......@@ -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,7 +2593,6 @@ 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
......@@ -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. */
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment