1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merged the code of MWL#106 into 5.3

Resolved all conflicts, bad merges and fixed a few minor bugs in the code.
Commented out the queries from multi_update, view, subselect_sj, func_str,
derived_view, view_grant that failed either with crashes in ps-protocol or
with wrong results.
The failures are clear indications of some bugs in the code and these bugs
are to be fixed.
This commit is contained in:
Igor Babaev
2011-05-16 22:39:43 -07:00
92 changed files with 4191 additions and 1093 deletions

View File

@ -1168,7 +1168,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++))
@ -1252,7 +1252,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"));
@ -1266,9 +1269,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 :
@ -1321,12 +1331,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)
@ -1384,7 +1400,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
@ -1445,7 +1462,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));
}
@ -1475,7 +1493,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++))
@ -1512,7 +1531,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++))
@ -1587,6 +1606,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");
/*
@ -1595,7 +1615,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,
@ -1640,7 +1661,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))
@ -1658,7 +1680,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);
}
@ -1693,7 +1716,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;
@ -2429,6 +2452,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;
@ -2472,9 +2496,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)
{