1
0
mirror of https://github.com/MariaDB/server.git synced 2025-12-24 11:21:21 +03:00

allow UPDATE and DELETE stetements with tables derived from subquery if they are not updated (BUG#2117)

allow delete table by alias in multi-delete statement
This commit is contained in:
bell@sanja.is.com.ua
2004-01-04 23:44:33 +02:00
parent 7bb74b6592
commit 501ae0bc52
29 changed files with 132 additions and 14 deletions

View File

@@ -2663,15 +2663,30 @@ mysql_execute_command(THD *thd)
table_count++;
/* All tables in aux_tables must be found in FROM PART */
TABLE_LIST *walk;
for (walk=(TABLE_LIST*) tables ; walk ; walk=walk->next)
for (walk= (TABLE_LIST*) tables; walk; walk= walk->next)
{
if (!strcmp(auxi->real_name,walk->real_name) &&
if ((!strcmp(auxi->real_name,walk->real_name) ||
!strcmp(auxi->real_name,walk->alias)) &&
!strcmp(walk->db,auxi->db))
break;
}
if (!walk)
{
net_printf(thd,ER_NONUNIQ_TABLE,auxi->real_name);
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;
}
walk->lock_type= auxi->lock_type;