diff options
author | unknown <pem@mysql.comhem.se> | 2004-01-09 09:36:37 +0100 |
---|---|---|
committer | unknown <pem@mysql.comhem.se> | 2004-01-09 09:36:37 +0100 |
commit | b092868307a92bfc103df5ebfaf95f3f45b92cd8 (patch) | |
tree | 727512acc3723695943c2c2e98fb7d75a41f96d5 | |
parent | 03b652cfbf9c06a9d22111d1069ae1926b584af4 (diff) | |
download | mariadb-git-b092868307a92bfc103df5ebfaf95f3f45b92cd8.tar.gz |
Fix BUG#2269: Lost connect if stored procedure called before USE
(And some minor correction of cursor open)
sql/sp_head.cc:
Detect some errors that doesn't result in a non-zero return code in
the SP execution loop.
(Also corrected the cursor post_open() call.)
sql/sp_rcontext.cc:
Corrected the semantics of cursor post_open().
sql/sp_rcontext.h:
Corrected the semantics of cursor post_open().
-rw-r--r-- | sql/sp_head.cc | 10 | ||||
-rw-r--r-- | sql/sp_rcontext.cc | 9 | ||||
-rw-r--r-- | sql/sp_rcontext.h | 2 |
3 files changed, 13 insertions, 8 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 11fa6ab20fa..b263fb22c0e 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -286,6 +286,7 @@ sp_head::execute(THD *thd) if (ctx) ctx->clear_handler(); + thd->query_error= 0; do { sp_instr *i; @@ -318,10 +319,11 @@ sp_head::execute(THD *thd) continue; } } - } while (ret == 0 && !thd->killed); + } while (ret == 0 && !thd->killed && !thd->query_error); - DBUG_PRINT("info", ("ret=%d killed=%d", ret, thd->killed)); - if (thd->killed) + DBUG_PRINT("info", ("ret=%d killed=%d query_error=%d", + ret, thd->killed, thd->query_error)); + if (thd->killed || thd->query_error) ret= -1; /* If the DB has changed, the pointer has changed too, but the original thd->db will then have been freed */ @@ -1032,7 +1034,7 @@ sp_instr_copen::execute(THD *thd, uint *nextp) res= -1; else res= exec_stmt(thd, lex); - c->post_open(thd, (res == 0 ? TRUE : FALSE)); + c->post_open(thd, (lex ? TRUE : FALSE)); } *nextp= m_ip+1; diff --git a/sql/sp_rcontext.cc b/sql/sp_rcontext.cc index f328cdb7285..0b2b20fe3b3 100644 --- a/sql/sp_rcontext.cc +++ b/sql/sp_rcontext.cc @@ -153,12 +153,15 @@ sp_cursor::pre_open(THD *thd) } void -sp_cursor::post_open(THD *thd, my_bool isopen) +sp_cursor::post_open(THD *thd, my_bool was_opened) { thd->net.no_send_eof= m_nseof; // Restore the originals thd->protocol= m_oprot; - m_isopen= isopen; - m_current_row= m_prot->data; + if (was_opened) + { + m_isopen= was_opened; + m_current_row= m_prot->data; + } } int diff --git a/sql/sp_rcontext.h b/sql/sp_rcontext.h index 7a9271ed06a..1b83d3518b6 100644 --- a/sql/sp_rcontext.h +++ b/sql/sp_rcontext.h @@ -220,7 +220,7 @@ public: LEX * pre_open(THD *thd); void - post_open(THD *thd, my_bool isopen); + post_open(THD *thd, my_bool was_opened); int close(THD *thd); |