diff options
author | unknown <bell@sanja.is.com.ua> | 2004-02-09 14:47:41 +0200 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-02-09 14:47:41 +0200 |
commit | 8302f040b7314c0b6b4e28ead2394cdb4d0e8d5d (patch) | |
tree | 7becaf2ef2ba2bf3f53d6afad2278b7aaeda40e0 /sql/sql_prepare.cc | |
parent | 61f0e69cb60b9db858bad3b6de6fa0b8b2f03899 (diff) | |
parent | 33e2cd7bdbd0d10703471f7ddaf8b02a7adc89cf (diff) | |
download | mariadb-git-8302f040b7314c0b6b4e28ead2394cdb4d0e8d5d.tar.gz |
Merge sanja.is.com.ua:/home/bell/mysql/bk/work-derived2-4.1/
into sanja.is.com.ua:/home/bell/mysql/bk/work-prepared-4.1
sql/sql_lex.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_select.cc:
Auto merged
Diffstat (limited to 'sql/sql_prepare.cc')
-rw-r--r-- | sql/sql_prepare.cc | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1d5233d5803..b08b71c08e9 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -752,14 +752,21 @@ static bool mysql_test_select_fields(Prepared_statement *stmt, 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 @@ -767,7 +774,7 @@ static bool mysql_test_select_fields(Prepared_statement *stmt, #endif ) DBUG_RETURN(1); - join->cleanup(); + unit->cleanup(); } DBUG_RETURN(0); } @@ -898,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; @@ -928,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; @@ -946,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); } @@ -979,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; /* @@ -1008,17 +1019,21 @@ void mysql_stmt_execute(THD *thd, char *packet) order->item= (Item **)(order+1); 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)) @@ -1048,6 +1063,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; } |