diff options
author | unknown <pem@mysql.comhem.se> | 2005-06-01 12:18:41 +0200 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2005-06-01 12:18:41 +0200 |
commit | 77bd9d36e6c703045e01de655952f98f79e6332a (patch) | |
tree | 07365c13a3a8a2fdc4f0b9ef7733476f8d8909df /sql | |
parent | abbdab6ac9be805170ebdae4d0c68dc9c2ab9de4 (diff) | |
download | mariadb-git-77bd9d36e6c703045e01de655952f98f79e6332a.tar.gz |
Fixed BUG#10961: Stored procedures: crash if select * from dual
Have to catch errors from SELECT when opening a cursor.
mysql-test/r/sp.result:
New test case for BUG#10961.
mysql-test/t/sp.test:
New test case for BUG#10961.
sql/protocol.h:
Init data in Protocol_cursor constructor, for error cases.
sql/sp_head.cc:
Catch "hidden" errors during SELECT when opening a cursor.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/protocol.h | 4 | ||||
-rw-r--r-- | sql/sp_head.cc | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/sql/protocol.h b/sql/protocol.h index 01331ef64ba..5b402cb2669 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -159,8 +159,8 @@ public: MYSQL_ROWS **prev_record; ulong row_count; - Protocol_cursor() {} - Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc) {} + Protocol_cursor() :data(NULL) {} + Protocol_cursor(THD *thd_arg, MEM_ROOT *ini_alloc) :Protocol_simple(thd_arg), alloc(ini_alloc), data(NULL) {} bool prepare_for_send(List<Item> *item_list) { row_count= 0; diff --git a/sql/sp_head.cc b/sql/sp_head.cc index fcca1b51d1c..c17c8b81cb2 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -1913,7 +1913,19 @@ sp_instr_copen::execute(THD *thd, uint *nextp) else res= lex_keeper->reset_lex_and_exec_core(thd, nextp, FALSE, this); - c->post_open(thd, (lex_keeper ? TRUE : FALSE)); + /* + Work around the fact that errors in selects are not returned properly + (but instead converted into a warning), so if a condition handler + caught, we have lost the result code. + */ + if (!res) + { + uint dummy1, dummy2; + + if (thd->spcont->found_handler(&dummy1, &dummy2)) + res= -1; + } + c->post_open(thd, (lex_keeper && !res ? TRUE : FALSE)); } DBUG_RETURN(res); |