summaryrefslogtreecommitdiff
path: root/sql/sql_prepare.cc
diff options
context:
space:
mode:
authorkonstantin@mysql.com <>2006-04-19 21:12:24 +0400
committerkonstantin@mysql.com <>2006-04-19 21:12:24 +0400
commit6d277eb89d5a73aa7737823bab47b7c8b6b933a7 (patch)
tree3a919693817bb02c60969288c717da48637b57c7 /sql/sql_prepare.cc
parenteee166d859a9cd88cdea49981e57299bd0165cec (diff)
parentc49e6f8869c150dfebc3b181cdeb8394ad81db5b (diff)
downloadmariadb-git-6d277eb89d5a73aa7737823bab47b7c8b6b933a7.tar.gz
Merge mysql.com:/opt/local/work/tmp_merge
into mysql.com:/opt/local/work/mysql-5.1-merge
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r--sql/sql_prepare.cc17
1 files changed, 13 insertions, 4 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index ced15b3f728..e0cf9095a22 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1848,10 +1848,13 @@ void mysql_stmt_prepare(THD *thd, const char *packet, uint packet_length)
if (! (stmt= new Prepared_statement(thd, &thd->protocol_prep)))
DBUG_VOID_RETURN; /* out of memory: error is set in Sql_alloc */
- if (thd->stmt_map.insert(stmt))
+ if (thd->stmt_map.insert(thd, stmt))
{
- delete stmt;
- DBUG_VOID_RETURN; /* out of memory */
+ /*
+ The error is set in the insert. The statement itself
+ will be also deleted there (this is how the hash works).
+ */
+ DBUG_VOID_RETURN;
}
/* Reset warnings from previous command */
@@ -2028,11 +2031,17 @@ void mysql_sql_stmt_prepare(THD *thd)
DBUG_VOID_RETURN; /* out of memory */
}
- if (stmt->set_name(name) || thd->stmt_map.insert(stmt))
+ /* Set the name first, insert should know that this statement has a name */
+ if (stmt->set_name(name))
{
delete stmt;
DBUG_VOID_RETURN;
}
+ if (thd->stmt_map.insert(thd, stmt))
+ {
+ /* The statement is deleted and an error is set if insert fails */
+ DBUG_VOID_RETURN;
+ }
if (stmt->prepare(query, query_len+1))
{