1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00
This commit is contained in:
bell@sanja.is.com.ua
2004-02-09 15:49:11 +02:00
32 changed files with 790 additions and 394 deletions

View File

@ -733,7 +733,7 @@ static bool mysql_test_select_fields(Prepared_statement *stmt,
DBUG_RETURN(1);
#endif
if ((&lex->select_lex != lex->all_selects_list &&
lex->unit.create_total_list(thd, lex, &tables, 0)))
lex->unit.create_total_list(thd, lex, &tables)))
DBUG_RETURN(1);
if (open_and_lock_tables(thd, tables))
@ -746,21 +746,27 @@ static bool mysql_test_select_fields(Prepared_statement *stmt,
}
else
{
fix_tables_pointers(lex->all_selects_list);
if (!result && !(result= new select_send()))
{
send_error(thd, ER_OUT_OF_RESOURCES);
DBUG_RETURN(1);
}
JOIN *join= new JOIN(thd, fields, select_options, result);
thd->used_tables= 0; // Updated by setup_fields
if (join->prepare(&select_lex->ref_pointer_array,
(TABLE_LIST*)select_lex->get_table_list(),
wild_num, conds, og_num, order, group, having, proc,
select_lex, unit))
Statement backup;
/*
we do not want to have in statement memory all that junk,
which will be created by preparation => substitute memory
from original thread pool
*/
thd->set_n_backup_item_arena(&thd->stmt_backup, &backup);
if ((unit->prepare(thd, result, 0)))
{
thd->restore_backup_item_arena(&backup);
DBUG_RETURN(1);
}
thd->restore_backup_item_arena(&backup);
if (send_prep_stmt(stmt, fields.elements) ||
thd->protocol_simple.send_fields(&fields, 0)
#ifndef EMBEDDED_LIBRARY
@ -768,7 +774,7 @@ static bool mysql_test_select_fields(Prepared_statement *stmt,
#endif
)
DBUG_RETURN(1);
join->cleanup();
unit->cleanup();
}
DBUG_RETURN(0);
}
@ -899,6 +905,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
thd->stmt_backup.set_statement(thd);
thd->set_statement(stmt);
thd->current_statement= stmt;
if (alloc_query(thd, packet, packet_length))
goto alloc_query_err;
@ -929,6 +936,7 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length)
cleanup_items(thd->free_list);
stmt->set_statement(thd);
thd->set_statement(&thd->stmt_backup);
thd->current_statement= 0;
if (init_param_items(stmt))
goto init_param_err;
@ -947,6 +955,7 @@ alloc_query_err:
thd->stmt_map.erase(stmt);
DBUG_RETURN(1);
insert_stmt_err:
thd->current_statement= 0;
delete stmt;
DBUG_RETURN(1);
}
@ -980,6 +989,7 @@ void mysql_stmt_execute(THD *thd, char *packet)
stmt->query_id= thd->query_id;
thd->stmt_backup.set_statement(thd);
thd->set_statement(stmt);
thd->current_statement= stmt;
thd->free_list= 0;
/*
@ -1011,17 +1021,21 @@ void mysql_stmt_execute(THD *thd, char *packet)
/* Fix ORDER list */
for (order=(ORDER *)sl->order_list.first ; order ; order=order->next)
order->item= (Item **)(order+1);
/*
TODO: When the new table structure is ready, then have a status bit
to indicate the table is altered, and re-do the setup_*
and open the tables back.
*/
for (TABLE_LIST *tables= (TABLE_LIST*) sl->table_list.first;
tables;
tables= tables->next)
{
tables->table= 0; // safety - nasty init
tables->table_list= 0;
}
}
/*
TODO: When the new table structure is ready, then have a status bit
to indicate the table is altered, and re-do the setup_*
and open the tables back.
*/
for (TABLE_LIST *tables= (TABLE_LIST*) stmt->lex->select_lex.table_list.first;
tables;
tables= tables->next)
tables->table= 0; // safety - nasty init
#ifndef EMBEDDED_LIBRARY
if (stmt->param_count && setup_params_data(stmt))
@ -1051,6 +1065,7 @@ void mysql_stmt_execute(THD *thd, char *packet)
cleanup_items(stmt->free_list);
free_root(&thd->mem_root, MYF(0));
thd->set_statement(&thd->stmt_backup);
thd->current_statement= 0;
DBUG_VOID_RETURN;
}