summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-10-23 10:27:34 +0300
committerunknown <bell@sanja.is.com.ua>2004-10-23 10:27:34 +0300
commit814d720ed99eef879f7b2f528fb110290e1ece8e (patch)
tree5dee3a8b913873fe40e6fdc68a1b5f3a1155a795 /sql
parent9f1751c5b66a0567456d668ad5e6bde930b35cad (diff)
parentdb4683c62ee090b537ed50758a84e74c940c1288 (diff)
downloadmariadb-git-814d720ed99eef879f7b2f528fb110290e1ece8e.tar.gz
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-sub-4.1 sql/sql_parse.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_class.cc6
-rw-r--r--sql/sql_parse.cc36
2 files changed, 30 insertions, 12 deletions
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index f1c75a3b365..9dcff60dfed 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -222,7 +222,7 @@ THD::THD()
init();
/* Initialize sub structures */
- init_alloc_root(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
+ init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
user_connect=(USER_CONN *)0;
hash_init(&user_vars, &my_charset_bin, USER_VARS_HASH_SIZE, 0, 0,
(hash_get_key) get_var_key,
@@ -258,7 +258,7 @@ THD::THD()
transaction.trans_log.end_of_file= max_binlog_cache_size;
}
#endif
- init_alloc_root(&transaction.mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
+ init_sql_alloc(&transaction.mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
{
ulong tmp=sql_rnd_with_mutex();
randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::query_id);
@@ -1421,7 +1421,7 @@ Item_arena::Item_arena(bool init_mem_root)
state(CONVENTIONAL_EXECUTION)
{
if (init_mem_root)
- init_alloc_root(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
+ init_sql_alloc(&mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a01b8c895c3..e407865f715 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2018,6 +2018,7 @@ mysql_execute_command(THD *thd)
CHARSET_INFO *to_cs= thd->variables.collation_connection;
bool need_conversion;
user_var_entry *entry;
+ String *pstr= &str;
uint32 unused;
/*
Convert @var contents to string in connection character set. Although
@@ -2033,26 +2034,43 @@ mysql_execute_command(THD *thd)
String *pstr;
my_bool is_var_null;
pstr= entry->val_str(&is_var_null, &str, NOT_FIXED_DEC);
+ /*
+ NULL value of variable checked early as entry->value so here
+ we can't get NULL in normal conditions
+ */
DBUG_ASSERT(!is_var_null);
if (!pstr)
- send_error(thd, ER_OUT_OF_RESOURCES);
- DBUG_ASSERT(pstr == &str);
+ {
+ res= -1;
+ break; // EOM (error should be reported by allocator)
+ }
}
else
+ {
+ /*
+ variable absent or equal to NULL, so we need to set variable to
+ something reasonable to get readable error message during parsing
+ */
str.set("NULL", 4, &my_charset_latin1);
+ }
+
need_conversion=
- String::needs_conversion(str.length(), str.charset(), to_cs, &unused);
+ String::needs_conversion(pstr->length(), pstr->charset(),
+ to_cs, &unused);
- query_len= need_conversion? (str.length() * to_cs->mbmaxlen) :
- str.length();
+ query_len= need_conversion? (pstr->length() * to_cs->mbmaxlen) :
+ pstr->length();
if (!(query_str= alloc_root(&thd->mem_root, query_len+1)))
- send_error(thd, ER_OUT_OF_RESOURCES);
+ {
+ res= -1;
+ break; // EOM (error should be reported by allocator)
+ }
if (need_conversion)
- query_len= copy_and_convert(query_str, query_len, to_cs, str.ptr(),
- str.length(), str.charset());
+ query_len= copy_and_convert(query_str, query_len, to_cs, pstr->ptr(),
+ pstr->length(), pstr->charset());
else
- memcpy(query_str, str.ptr(), str.length());
+ memcpy(query_str, pstr->ptr(), pstr->length());
query_str[query_len]= 0;
}
else