mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1
into sanja.is.com.ua:/home/bell/mysql/bk/work-derived2-4.1 sql/mysql_priv.h: Auto merged sql/sql_base.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_parse.cc: Auto merged sql/sql_select.cc: Auto merged
This commit is contained in:
@ -1789,34 +1789,9 @@ mysql_execute_command(THD *thd)
|
||||
#endif
|
||||
}
|
||||
#endif /* !HAVE_REPLICATION */
|
||||
/*
|
||||
TODO: make derived tables processing 'inside' SELECT processing.
|
||||
TODO: solve problem with depended derived tables in subselects
|
||||
*/
|
||||
if (lex->derived_tables)
|
||||
{
|
||||
for (SELECT_LEX *sl= lex->all_selects_list;
|
||||
sl;
|
||||
sl= sl->next_select_in_list())
|
||||
{
|
||||
for (TABLE_LIST *cursor= sl->get_table_list();
|
||||
cursor;
|
||||
cursor= cursor->next)
|
||||
{
|
||||
if (cursor->derived && (res=mysql_derived(thd, lex,
|
||||
cursor->derived,
|
||||
cursor)))
|
||||
{
|
||||
if (res < 0 || thd->net.report_error)
|
||||
send_error(thd,thd->killed ? ER_SERVER_SHUTDOWN : 0);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (&lex->select_lex != lex->all_selects_list &&
|
||||
lex->sql_command != SQLCOM_CREATE_TABLE &&
|
||||
lex->unit.create_total_list(thd, lex, &tables, 0))
|
||||
lex->unit.create_total_list(thd, lex, &tables))
|
||||
DBUG_VOID_RETURN;
|
||||
|
||||
/*
|
||||
@ -1875,7 +1850,6 @@ mysql_execute_command(THD *thd)
|
||||
}
|
||||
else
|
||||
thd->send_explain_fields(result);
|
||||
fix_tables_pointers(lex->all_selects_list);
|
||||
res= mysql_explain_union(thd, &thd->lex->unit, result);
|
||||
MYSQL_LOCK *save_lock= thd->lock;
|
||||
thd->lock= (MYSQL_LOCK *)0;
|
||||
@ -1918,7 +1892,6 @@ mysql_execute_command(THD *thd)
|
||||
(res= open_and_lock_tables(thd,tables))))
|
||||
break;
|
||||
|
||||
fix_tables_pointers(lex->all_selects_list);
|
||||
res= mysql_do(thd, *lex->insert_list);
|
||||
if (thd->net.report_error)
|
||||
res= -1;
|
||||
@ -2127,7 +2100,7 @@ mysql_execute_command(THD *thd)
|
||||
lex->select_lex.table_list.first= (byte*) (tables);
|
||||
create_table->next= 0;
|
||||
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_VOID_RETURN;
|
||||
|
||||
ulong want_priv= ((lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) ?
|
||||
@ -2342,6 +2315,8 @@ mysql_execute_command(THD *thd)
|
||||
if (grant_option)
|
||||
{
|
||||
TABLE_LIST old_list,new_list;
|
||||
bzero((char*) &old_list, sizeof(old_list));
|
||||
bzero((char*) &new_list, sizeof(new_list)); // Safety
|
||||
old_list=table[0];
|
||||
new_list=table->next[0];
|
||||
old_list.next=new_list.next=0;
|
||||
@ -2673,23 +2648,15 @@ mysql_execute_command(THD *thd)
|
||||
}
|
||||
if (!walk)
|
||||
{
|
||||
if (lex->derived_tables)
|
||||
{
|
||||
// are we trying to delete derived table?
|
||||
for (walk= (TABLE_LIST*) tables; walk; walk= walk->next)
|
||||
{
|
||||
if (!strcmp(auxi->real_name,walk->alias) &&
|
||||
walk->derived)
|
||||
{
|
||||
net_printf(thd, ER_NON_UPDATABLE_TABLE,
|
||||
auxi->real_name, "DELETE");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
net_printf(thd, ER_NONUNIQ_TABLE, auxi->real_name);
|
||||
goto error;
|
||||
}
|
||||
if (walk->derived)
|
||||
{
|
||||
net_printf(thd, ER_NON_UPDATABLE_TABLE,
|
||||
auxi->real_name, "DELETE");
|
||||
goto error;
|
||||
}
|
||||
walk->lock_type= auxi->lock_type;
|
||||
auxi->table_list= walk; // Remember corresponding table
|
||||
}
|
||||
@ -2703,21 +2670,27 @@ mysql_execute_command(THD *thd)
|
||||
break;
|
||||
/* Fix tables-to-be-deleted-from list to point at opened tables */
|
||||
for (auxi=(TABLE_LIST*) aux_tables ; auxi ; auxi=auxi->next)
|
||||
auxi->table= auxi->table_list->table;
|
||||
if (&lex->select_lex != lex->all_selects_list)
|
||||
{
|
||||
for (TABLE_LIST *t= select_lex->get_table_list();
|
||||
t; t= t->next)
|
||||
auxi->table= auxi->table_list->table;
|
||||
/*
|
||||
Multi-delete can't be constucted over-union => we always have
|
||||
single SELECT on top and have to check underlayed SELECTs of it
|
||||
*/
|
||||
for (SELECT_LEX_UNIT *un= lex->select_lex.first_inner_unit();
|
||||
un;
|
||||
un= un->next_unit())
|
||||
{
|
||||
if (find_real_table_in_list(t->table_list->next, t->db, t->real_name))
|
||||
if (un->first_select()->linkage != DERIVED_TABLE_TYPE &&
|
||||
un->check_updateable(auxi->table_list->db,
|
||||
auxi->table_list->real_name))
|
||||
{
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), t->real_name);
|
||||
my_error(ER_UPDATE_TABLE_USED, MYF(0), auxi->table_list->real_name);
|
||||
res= -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fix_tables_pointers(lex->all_selects_list);
|
||||
|
||||
if (!thd->is_fatal_error && (result= new multi_delete(thd,aux_tables,
|
||||
table_count)))
|
||||
{
|
||||
@ -2962,7 +2935,6 @@ mysql_execute_command(THD *thd)
|
||||
if (tables && ((res= check_table_access(thd, SELECT_ACL, tables,0)) ||
|
||||
(res= open_and_lock_tables(thd,tables))))
|
||||
break;
|
||||
fix_tables_pointers(lex->all_selects_list);
|
||||
if (!(res= sql_set_variables(thd, &lex->var_list)))
|
||||
send_ok(thd);
|
||||
if (thd->net.report_error)
|
||||
|
Reference in New Issue
Block a user