diff options
author | bar@mysql.com <> | 2005-07-14 17:49:19 +0500 |
---|---|---|
committer | bar@mysql.com <> | 2005-07-14 17:49:19 +0500 |
commit | 6fd6fa517b9a660b8d0c81dcebcd880058f9561a (patch) | |
tree | d28f11ab1965d877c7c4f4f794fe6ecb2e308766 /sql | |
parent | c64128cc580ed7c27c5a7668c96ae8eac559a2bb (diff) | |
parent | b51edd37757ace1a4750971e0061aaaf9fcb8654 (diff) | |
download | mariadb-git-6fd6fa517b9a660b8d0c81dcebcd880058f9561a.tar.gz |
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/usr/home/bar/mysql-5.0
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_prepare.cc | 43 | ||||
-rw-r--r-- | sql/sql_select.cc | 6 | ||||
-rw-r--r-- | sql/sql_select.h | 2 |
3 files changed, 31 insertions, 20 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 6d11518198c..e163e71e416 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -106,6 +106,7 @@ public: virtual ~Prepared_statement(); void setup_set_params(); virtual Query_arena::Type type() const; + virtual void close_cursor(); }; static void execute_stmt(THD *thd, Prepared_statement *stmt, @@ -1986,10 +1987,7 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) cursor= stmt->cursor; if (cursor && cursor->is_open()) - { - my_error(ER_EXEC_STMT_WITH_OPEN_CURSOR, MYF(0)); - DBUG_VOID_RETURN; - } + stmt->close_cursor(); DBUG_ASSERT(thd->free_list == NULL); mysql_reset_thd_for_next_command(thd); @@ -2284,6 +2282,7 @@ void mysql_stmt_reset(THD *thd, char *packet) if (!(stmt= find_prepared_statement(thd, stmt_id, "mysql_stmt_reset"))) DBUG_VOID_RETURN; + stmt->close_cursor(); /* will reset statement params */ cursor= stmt->cursor; if (cursor && cursor->is_open()) { @@ -2295,12 +2294,6 @@ void mysql_stmt_reset(THD *thd, char *packet) stmt->state= Query_arena::PREPARED; - /* - Clear parameters from data which could be set by - mysql_stmt_send_long_data() call. - */ - reset_stmt_params(stmt); - mysql_reset_thd_for_next_command(thd); send_ok(thd); @@ -2448,10 +2441,17 @@ void Prepared_statement::setup_set_params() Prepared_statement::~Prepared_statement() { if (cursor) + { + if (cursor->is_open()) + { + cursor->close(FALSE); + free_items(); + free_root(cursor->mem_root, MYF(0)); + } cursor->Cursor::~Cursor(); - free_items(); - if (cursor) - free_root(cursor->mem_root, MYF(0)); + } + else + free_items(); delete lex->result; } @@ -2460,3 +2460,20 @@ Query_arena::Type Prepared_statement::type() const { return PREPARED_STATEMENT; } + + +void Prepared_statement::close_cursor() +{ + if (cursor && cursor->is_open()) + { + thd->change_list= cursor->change_list; + cursor->close(FALSE); + cleanup_stmt_and_thd_after_use(this, thd); + free_root(cursor->mem_root, MYF(0)); + } + /* + Clear parameters from data which could be set by + mysql_stmt_send_long_data() call. + */ + reset_stmt_params(this); +} diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 66e783a2103..524fc784422 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1915,12 +1915,6 @@ Cursor::close(bool is_active) } -Cursor::~Cursor() -{ - if (is_open()) - close(FALSE); -} - /*********************************************************************/ /* diff --git a/sql/sql_select.h b/sql/sql_select.h index ac3e8898cc6..9285e33be33 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -408,7 +408,7 @@ public: void set_unit(SELECT_LEX_UNIT *unit_arg) { unit= unit_arg; } Cursor(THD *thd); - ~Cursor(); + ~Cursor() {} }; |