1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
sql/field.cc:
  Auto merged
sql/ha_berkeley.cc:
  Auto merged
sql/ha_federated.cc:
  Auto merged
sql/examples/ha_tina.cc:
  Auto merged
sql/ha_innodb.cc:
  Auto merged
sql/ha_myisam.cc:
  Auto merged
sql/ha_myisammrg.cc:
  Auto merged
sql/ha_ndbcluster.cc:
  Auto merged
sql/handler.h:
  Auto merged
sql/sql_select.cc:
  Auto merged
sql/sql_select.h:
  Auto merged
This commit is contained in:
unknown
2005-07-21 00:04:18 +02:00
16 changed files with 155 additions and 99 deletions

View File

@ -1724,12 +1724,14 @@ Cursor::Cursor(THD *thd)
/* We will overwrite it at open anyway. */
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
thr_lock_owner_init(&lock_id, &thd->lock_info);
bzero((void*) ht_info, sizeof(ht_info));
}
void
Cursor::init_from_thd(THD *thd)
{
Engine_info *info;
/*
We need to save and reset thd->mem_root, otherwise it'll be freed
later in mysql_parse.
@ -1761,15 +1763,16 @@ Cursor::init_from_thd(THD *thd)
thd->lock_info.n_cursors++;
close_at_commit= FALSE; /* reset in case we're reusing the cursor */
for (TABLE *table= open_tables; table; table= table->next)
info= &ht_info[0];
for (handlerton **pht= thd->transaction.stmt.ht; *pht; pht++)
{
const handlerton *ht= table->file->ht;
if (ht)
close_at_commit|= (ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT);
else
const handlerton *ht= *pht;
close_at_commit|= (ht->flags & HTON_CLOSE_CURSORS_AT_COMMIT);
if (ht->create_cursor_read_view)
{
close_at_commit= TRUE; /* handler status is unknown */
break;
info->ht= ht;
info->read_view= (ht->create_cursor_read_view)();
++info;
}
}
/*
@ -1865,6 +1868,9 @@ Cursor::fetch(ulong num_rows)
/* save references to memory, allocated during fetch */
thd->set_n_backup_item_arena(this, &backup_arena);
for (Engine_info *info= ht_info; info->read_view ; info++)
(info->ht->set_cursor_read_view)(info->read_view);
join->fetch_limit+= num_rows;
error= sub_select(join, join_tab, 0);
@ -1881,6 +1887,9 @@ Cursor::fetch(ulong num_rows)
/* Grab free_list here to correctly free it in close */
thd->restore_backup_item_arena(this, &backup_arena);
for (Engine_info *info= ht_info; info->read_view; info++)
(info->ht->set_cursor_read_view)(0);
if (error == NESTED_LOOP_CURSOR_LIMIT)
{
/* Fetch limit worked, possibly more rows are there */
@ -1921,6 +1930,13 @@ Cursor::close(bool is_active)
else
(void) join->select_lex->cleanup();
for (Engine_info *info= ht_info; info->read_view; info++)
{
(info->ht->close_cursor_read_view)(info->read_view);
info->read_view= 0;
info->ht= 0;
}
if (is_active)
close_thread_tables(thd);
else