1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00
This commit is contained in:
Igor Babaev
2011-05-20 12:47:39 -07:00
99 changed files with 4333 additions and 1174 deletions

View File

@ -1169,7 +1169,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
If we would use locks, then we have to ensure we are not using
TL_WRITE_DELAYED as having two such locks can cause table corruption.
*/
if (open_normal_and_derived_tables(thd, table_list, 0))
if (open_normal_and_derived_tables(thd, table_list, 0, DT_INIT))
goto error;
if ((values= its++))
@ -1253,7 +1253,10 @@ static int mysql_test_update(Prepared_statement *stmt,
open_tables(thd, &table_list, &table_count, 0))
goto error;
if (table_list->multitable_view)
if (mysql_handle_derived(thd->lex, DT_INIT))
goto error;
if (table_list->is_multitable())
{
DBUG_ASSERT(table_list->view != 0);
DBUG_PRINT("info", ("Switch to multi-update"));
@ -1267,9 +1270,16 @@ static int mysql_test_update(Prepared_statement *stmt,
thd->fill_derived_tables() is false here for sure (because it is
preparation of PS, so we even do not check it).
*/
if (mysql_handle_derived(thd->lex, &mysql_derived_prepare))
if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT) ||
table_list->handle_derived(thd->lex, DT_PREPARE))
goto error;
if (!table_list->updatable)
{
my_error(ER_NON_UPDATABLE_TABLE, MYF(0), table_list->alias, "UPDATE");
goto error;
}
#ifndef NO_EMBEDDED_ACCESS_CHECKS
/* Force privilege re-checking for views after they have been opened. */
want_privilege= (table_list->view ? UPDATE_ACL :
@ -1322,12 +1332,18 @@ error:
static bool mysql_test_delete(Prepared_statement *stmt,
TABLE_LIST *table_list)
{
uint table_count= 0;
THD *thd= stmt->thd;
LEX *lex= stmt->lex;
DBUG_ENTER("mysql_test_delete");
if (delete_precheck(thd, table_list) ||
open_normal_and_derived_tables(thd, table_list, 0))
open_tables(thd, &table_list, &table_count, 0))
goto error;
if (mysql_handle_derived(thd->lex, DT_INIT) ||
mysql_handle_list_of_derived(thd->lex, table_list, DT_MERGE_FOR_INSERT) ||
mysql_handle_list_of_derived(thd->lex, table_list, DT_PREPARE))
goto error;
if (!table_list->table)
@ -1385,7 +1401,8 @@ static int mysql_test_select(Prepared_statement *stmt,
goto error;
}
if (open_normal_and_derived_tables(thd, tables, 0))
if (open_normal_and_derived_tables(thd, tables, 0,
DT_PREPARE | DT_CREATE))
goto error;
thd->used_tables= 0; // Updated by setup_fields
@ -1446,7 +1463,8 @@ static bool mysql_test_do_fields(Prepared_statement *stmt,
if (tables && check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE))
DBUG_RETURN(TRUE);
if (open_normal_and_derived_tables(thd, tables, 0))
if (open_normal_and_derived_tables(thd, tables, 0,
DT_PREPARE | DT_CREATE))
DBUG_RETURN(TRUE);
DBUG_RETURN(setup_fields(thd, 0, *values, MARK_COLUMNS_NONE, 0, 0));
}
@ -1476,7 +1494,8 @@ static bool mysql_test_set_fields(Prepared_statement *stmt,
if ((tables &&
check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) ||
open_normal_and_derived_tables(thd, tables, 0))
open_normal_and_derived_tables(thd, tables, 0,
DT_PREPARE | DT_CREATE))
goto error;
while ((var= it++))
@ -1513,7 +1532,7 @@ static bool mysql_test_call_fields(Prepared_statement *stmt,
if ((tables &&
check_table_access(thd, SELECT_ACL, tables, UINT_MAX, FALSE)) ||
open_normal_and_derived_tables(thd, tables, 0))
open_normal_and_derived_tables(thd, tables, 0, DT_PREPARE))
goto err;
while ((item= it++))
@ -1588,6 +1607,7 @@ select_like_stmt_test_with_open(Prepared_statement *stmt,
int (*specific_prepare)(THD *thd),
ulong setup_tables_done_option)
{
uint table_count= 0;
DBUG_ENTER("select_like_stmt_test_with_open");
/*
@ -1596,7 +1616,8 @@ select_like_stmt_test_with_open(Prepared_statement *stmt,
prepared EXPLAIN yet so derived tables will clean up after
themself.
*/
if (open_normal_and_derived_tables(stmt->thd, tables, 0))
THD *thd= stmt->thd;
if (open_tables(thd, &tables, &table_count, 0))
DBUG_RETURN(TRUE);
DBUG_RETURN(select_like_stmt_test(stmt, specific_prepare,
@ -1641,7 +1662,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
create_table->skip_temporary= true;
}
if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0))
if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0,
DT_PREPARE | DT_CREATE))
DBUG_RETURN(TRUE);
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE))
@ -1659,7 +1681,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt)
we validate metadata of all CREATE TABLE statements,
which keeps metadata validation code simple.
*/
if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0))
if (open_normal_and_derived_tables(stmt->thd, lex->query_tables, 0,
DT_PREPARE))
DBUG_RETURN(TRUE);
}
@ -1694,7 +1717,7 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
if (create_view_precheck(thd, tables, view, lex->create_view_mode))
goto err;
if (open_normal_and_derived_tables(thd, tables, 0))
if (open_normal_and_derived_tables(thd, tables, 0, DT_PREPARE))
goto err;
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
@ -2430,6 +2453,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
/* Fix ORDER list */
for (order= sl->order_list.first; order; order= order->next)
order->item= &order->item_ptr;
sl->handle_derived(lex, DT_REINIT);
/* clear the no_error flag for INSERT/UPDATE IGNORE */
sl->no_error= FALSE;
@ -2473,9 +2497,6 @@ void reinit_stmt_before_use(THD *thd, LEX *lex)
}
lex->current_select= &lex->select_lex;
/* restore original list used in INSERT ... SELECT */
if (lex->leaf_tables_insert)
lex->select_lex.leaf_tables= lex->leaf_tables_insert;
if (lex->result)
{