diff options
author | unknown <monty@mysql.com> | 2005-03-16 22:59:06 +0200 |
---|---|---|
committer | unknown <monty@mysql.com> | 2005-03-16 22:59:06 +0200 |
commit | 06f59b28ab4e2c2d4a67c50d56b734c96750ed8b (patch) | |
tree | 119cb9dbad08d53c1b012a9b6a5a4b37020923e4 /sql/item_func.cc | |
parent | 284b8b8b63bec8f2d246f6748ab695baa9aaf746 (diff) | |
parent | f9792042eb815d6b5e1e4dfe0da599b2e1599424 (diff) | |
download | mariadb-git-06f59b28ab4e2c2d4a67c50d56b734c96750ed8b.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/home/my/mysql-5.0
sql/item_func.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 117 |
1 files changed, 107 insertions, 10 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index bec91f7e90a..684ba814cd4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3294,12 +3294,28 @@ Item_func_set_user_var::fix_length_and_dec() } -bool Item_func_set_user_var::update_hash(void *ptr, uint length, - Item_result type, - CHARSET_INFO *cs, - Derivation dv) +/* + Set value to user variable. + + SYNOPSYS + update_hash() + entry - pointer to structure representing variable + set_null - should we set NULL value ? + ptr - pointer to buffer with new value + length - length of new value + type - type of new value + cs - charset info for new value + dv - derivation for new value + + RETURN VALUE + False - success, True - failure +*/ + +static bool +update_hash(user_var_entry *entry, bool set_null, void *ptr, uint length, + Item_result type, CHARSET_INFO *cs, Derivation dv) { - if ((null_value=args[0]->null_value)) + if (set_null) { char *pos= (char*) entry+ ALIGN_SIZE(sizeof(user_var_entry)); if (entry->value && entry->value != pos) @@ -3332,7 +3348,7 @@ bool Item_func_set_user_var::update_hash(void *ptr, uint length, entry->value=0; if (!(entry->value=(char*) my_realloc(entry->value, length, MYF(MY_ALLOW_ZERO_PTR)))) - goto err; + return 1; } } if (type == STRING_RESULT) @@ -3348,11 +3364,21 @@ bool Item_func_set_user_var::update_hash(void *ptr, uint length, entry->collation.set(cs, dv); } return 0; +} - err: - current_thd->fatal_error(); // Probably end of memory - null_value= 1; - return 1; + +bool +Item_func_set_user_var::update_hash(void *ptr, uint length, Item_result type, + CHARSET_INFO *cs, Derivation dv) +{ + if (::update_hash(entry, (null_value= args[0]->null_value), + ptr, length, type, cs, dv)) + { + current_thd->fatal_error(); // Probably end of memory + null_value= 1; + return 1; + } + return 0; } @@ -3878,6 +3904,77 @@ bool Item_func_get_user_var::eq(const Item *item, bool binary_cmp) const } +bool Item_user_var_as_out_param::fix_fields(THD *thd, TABLE_LIST *tables, + Item **ref) +{ + DBUG_ASSERT(fixed == 0); + if (Item::fix_fields(thd, tables, ref) || + !(entry= get_variable(&thd->user_vars, name, 1))) + return TRUE; + entry->type= STRING_RESULT; + /* + Let us set the same collation which is used for loading + of fields in LOAD DATA INFILE. + (Since Item_user_var_as_out_param is used only there). + */ + entry->collation.set(thd->variables.collation_database); + entry->update_query_id= thd->query_id; + return FALSE; +} + + +void Item_user_var_as_out_param::set_null_value(CHARSET_INFO* cs) +{ + if (::update_hash(entry, TRUE, 0, 0, STRING_RESULT, cs, + DERIVATION_IMPLICIT)) + current_thd->fatal_error(); // Probably end of memory +} + + +void Item_user_var_as_out_param::set_value(const char *str, uint length, + CHARSET_INFO* cs) +{ + if (::update_hash(entry, FALSE, (void*)str, length, STRING_RESULT, cs, + DERIVATION_IMPLICIT)) + current_thd->fatal_error(); // Probably end of memory +} + + +double Item_user_var_as_out_param::val_real() +{ + DBUG_ASSERT(0); + return 0.0; +} + + +longlong Item_user_var_as_out_param::val_int() +{ + DBUG_ASSERT(0); + return 0; +} + + +String* Item_user_var_as_out_param::val_str(String *str) +{ + DBUG_ASSERT(0); + return 0; +} + + +my_decimal* Item_user_var_as_out_param::val_decimal(my_decimal *decimal_buffer) +{ + DBUG_ASSERT(0); + return 0; +} + + +void Item_user_var_as_out_param::print(String *str) +{ + str->append('@'); + str->append(name.str,name.length); +} + + longlong Item_func_inet_aton::val_int() { DBUG_ASSERT(fixed == 1); |