55
55
NOW_FUNC, TRIG_COND_FUNC,
56
56
SUSERVAR_FUNC, GUSERVAR_FUNC, COLLATE_FUNC,
57
57
EXTRACT_FUNC, CHAR_TYPECAST_FUNC, FUNC_SP, UDF_FUNC,
58
NEG_FUNC, GSYSVAR_FUNC };
59
59
enum optimize_type { OPTIMIZE_NONE,OPTIMIZE_KEY,OPTIMIZE_OP, OPTIMIZE_NULL,
61
61
enum Type type() const { return FUNC_ITEM; }
362
362
Item_func_unsigned(Item *a) :Item_func_signed(a) {}
363
363
const char *func_name() const { return "cast_as_unsigned"; }
364
364
void fix_length_and_dec()
365
{ max_length=args[0]->max_length; unsigned_flag=1; }
366
max_length= min(args[0]->max_length, DECIMAL_MAX_PRECISION + 2);
366
369
longlong val_int();
367
370
virtual void print(String *str, enum_query_type query_type);
1295
1298
enum Item_result cached_result_type;
1296
1299
user_var_entry *entry;
1298
The entry_thd variable is used:
1301
The entry_thread_id variable is used:
1299
1302
1) to skip unnecessary updates of the entry field (see above);
1300
1303
2) to reset the entry field that was initialized in the other thread
1301
1304
(for example, an item tree of a trigger that updates user variables
1302
may be shared between several connections, and the entry_thd field
1305
may be shared between several connections, and the entry_thread_id field
1303
1306
prevents updates of one connection user variables from a concurrent
1304
1307
connection calling the same trigger that initially updated some
1305
1308
user variable it the first connection context).
1310
my_thread_id entry_thread_id;
1308
1311
char buffer[MAX_FIELD_WIDTH];
1310
1313
my_decimal decimal_buff;
1321
1324
LEX_STRING name; // keep it public
1322
1325
Item_func_set_user_var(LEX_STRING a,Item *b)
1323
1326
:Item_func(b), cached_result_type(INT_RESULT),
1324
entry(NULL), entry_thd(NULL), name(a)
1327
entry(NULL), entry_thread_id(0), name(a)
1326
1329
enum Functype functype() const { return SUSERVAR_FUNC; }
1327
1330
double val_real();
1427
1430
/* A system variable */
1432
#define GET_SYS_VAR_CACHE_LONG 1
1433
#define GET_SYS_VAR_CACHE_DOUBLE 2
1434
#define GET_SYS_VAR_CACHE_STRING 4
1429
1436
class Item_func_get_system_var :public Item_func
1432
enum_var_type var_type;
1439
enum_var_type var_type, orig_var_type;
1433
1440
LEX_STRING component;
1441
longlong cached_llval;
1443
String cached_strval;
1444
my_bool cached_null_value;
1445
query_id_t used_query_id;
1446
uchar cache_present;
1435
1449
Item_func_get_system_var(sys_var *var_arg, enum_var_type var_type_arg,
1436
1450
LEX_STRING *component_arg, const char *name_arg,
1437
1451
size_t name_len_arg);
1438
bool fix_fields(THD *thd, Item **ref);
1440
Stubs for pure virtual methods. Should never be called: this
1441
item is always substituted with a constant in fix_fields().
1443
double val_real() { DBUG_ASSERT(0); return 0.0; }
1444
longlong val_int() { DBUG_ASSERT(0); return 0; }
1445
String* val_str(String*) { DBUG_ASSERT(0); return 0; }
1446
void fix_length_and_dec() { DBUG_ASSERT(0); }
1452
enum Functype functype() const { return GSYSVAR_FUNC; }
1453
void fix_length_and_dec();
1454
void print(String *str, enum_query_type query_type);
1455
bool const_item() const { return true; }
1456
table_map used_tables() const { return 0; }
1457
enum Item_result result_type() const;
1458
enum_field_types field_type() const;
1461
String* val_str(String*);
1447
1462
/* TODO: fix to support views */
1448
1463
const char *func_name() const { return "get_system_var"; }