summaryrefslogtreecommitdiff
path: root/sql/sql_cursor.cc
diff options
context:
space:
mode:
authorMikael Ronstrom <mikael@mysql.com>2009-02-17 13:24:09 +0100
committerMikael Ronstrom <mikael@mysql.com>2009-02-17 13:24:09 +0100
commit6db314c628b103b7c4d7fc0ba4c21eda6e6a349e (patch)
tree8414a0bf16f74515368a6a4ebc7ea528e8f982a2 /sql/sql_cursor.cc
parent805e8ffb9ec3ae7b9353d65f33e4eb20284876ae (diff)
parent6bd93f670271eaf2bd79bd7fa538e9baaa7dcb0f (diff)
downloadmariadb-git-6db314c628b103b7c4d7fc0ba4c21eda6e6a349e.tar.gz
Merged Performance Version 0.2.1 with latest 5.1 tree (last push 11 feb 14.01.13 2009)
Diffstat (limited to 'sql/sql_cursor.cc')
-rw-r--r--sql/sql_cursor.cc18
1 files changed, 13 insertions, 5 deletions
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 1f6c9fdee53..553342f155b 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -86,6 +86,7 @@ class Materialized_cursor: public Server_side_cursor
List<Item> item_list;
ulong fetch_limit;
ulong fetch_count;
+ bool is_rnd_inited;
public:
Materialized_cursor(select_result *result, TABLE *table);
@@ -197,7 +198,11 @@ int mysql_open_cursor(THD *thd, uint flags, select_result *result,
such command is SHOW VARIABLES or SHOW STATUS.
*/
if (rc)
+ {
+ if (result_materialize->materialized_cursor)
+ delete result_materialize->materialized_cursor;
goto err_open;
+ }
if (sensitive_cursor->is_open())
{
@@ -549,7 +554,8 @@ Materialized_cursor::Materialized_cursor(select_result *result_arg,
:Server_side_cursor(&table_arg->mem_root, result_arg),
table(table_arg),
fetch_limit(0),
- fetch_count(0)
+ fetch_count(0),
+ is_rnd_inited(0)
{
fake_unit.init_query();
fake_unit.thd= table->in_use;
@@ -606,11 +612,12 @@ int Materialized_cursor::open(JOIN *join __attribute__((unused)))
THD *thd= fake_unit.thd;
int rc;
Query_arena backup_arena;
-
thd->set_n_backup_active_arena(this, &backup_arena);
/* Create a list of fields and start sequential scan */
- rc= (result->prepare(item_list, &fake_unit) ||
- table->file->ha_rnd_init(TRUE));
+ rc= result->prepare(item_list, &fake_unit);
+ if (!rc && !(rc= table->file->ha_rnd_init(TRUE)))
+ is_rnd_inited= 1;
+
thd->restore_active_arena(this, &backup_arena);
if (rc == 0)
{
@@ -685,7 +692,8 @@ void Materialized_cursor::close()
{
/* Free item_list items */
free_items();
- (void) table->file->ha_rnd_end();
+ if (is_rnd_inited)
+ (void) table->file->ha_rnd_end();
/*
We need to grab table->mem_root to prevent free_tmp_table from freeing:
the cursor object was allocated in this memory.