mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
ufter revview fix (BUG#2120)
mysql-test/r/derived.result: test of error handling in derived tables with UPDATE & DELETE mysql-test/t/derived.test: test of error handling in derived tables with UPDATE & DELETE sql/mysql_priv.h: opened tables counter added to avoid loop of tables calculating in lock_tables sql/sql_acl.cc: opened tables counter added to avoid loop of tables calculating in lock_tables, here it is just for compatibility sql/sql_base.cc: removed unneeded assignment opened tables counter added to avoid loop of tables calculating in lock_tables commentary fixed sql/sql_derived.cc: mysql_derived made static variable res moved in place where it used priveleges written in correct place sql/sql_handler.cc: opened tables counter added to avoid loop of tables calculating in lock_tables sql/sql_parse.cc: mistyping in commentary fixed
This commit is contained in:
@ -1308,7 +1308,6 @@ static int open_unireg_entry(THD *thd, TABLE *entry, const char *db,
|
||||
bzero((char*) &table_list, sizeof(table_list)); // just for safe
|
||||
table_list.db=(char*) db;
|
||||
table_list.real_name=(char*) name;
|
||||
table_list.next=0;
|
||||
safe_mutex_assert_owner(&LOCK_open);
|
||||
|
||||
if ((error=lock_table_name(thd,&table_list)))
|
||||
@ -1357,24 +1356,40 @@ err:
|
||||
DBUG_RETURN(1);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
** open all tables in list
|
||||
*****************************************************************************/
|
||||
/*
|
||||
Open all tables in list
|
||||
|
||||
int open_tables(THD *thd,TABLE_LIST *start)
|
||||
SYNOPSIS
|
||||
open_tables()
|
||||
thd - thread handler
|
||||
start - list of tables
|
||||
counter - number of opened tables will be return using this parameter
|
||||
|
||||
RETURN
|
||||
0 - OK
|
||||
-1 - error
|
||||
*/
|
||||
|
||||
int open_tables(THD *thd, TABLE_LIST *start, uint *counter)
|
||||
{
|
||||
TABLE_LIST *tables;
|
||||
bool refresh;
|
||||
int result=0;
|
||||
DBUG_ENTER("open_tables");
|
||||
*counter= 0;
|
||||
|
||||
thd->current_tablenr= 0;
|
||||
restart:
|
||||
thd->proc_info="Opening tables";
|
||||
for (tables=start ; tables ; tables=tables->next)
|
||||
{
|
||||
/*
|
||||
Ignore placeholders for derived tables. After derived tables
|
||||
processing, link to created temporary table will be put here.
|
||||
*/
|
||||
if (tables->derived)
|
||||
continue;
|
||||
(*counter)++;
|
||||
if (!tables->table &&
|
||||
!(tables->table= open_table(thd,
|
||||
tables->db,
|
||||
@ -1533,14 +1548,19 @@ TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type)
|
||||
thd - thread handler
|
||||
tables - list of tables for open&locking
|
||||
|
||||
RETURN
|
||||
0 - ok
|
||||
-1 - error
|
||||
|
||||
NOTE
|
||||
The lock will automaticly be freed by close_thread_tables()
|
||||
*/
|
||||
|
||||
int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
DBUG_ENTER("open_n_lock_tables");
|
||||
if (open_tables(thd, tables) || lock_tables(thd, tables))
|
||||
DBUG_ENTER("simple_open_n_lock_tables");
|
||||
uint counter;
|
||||
if (open_tables(thd, tables, &counter) || lock_tables(thd, tables, counter))
|
||||
DBUG_RETURN(-1); /* purecov: inspected */
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
@ -1551,10 +1571,14 @@ int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables)
|
||||
tables processing.
|
||||
|
||||
SYNOPSIS
|
||||
simple_open_n_lock_tables()
|
||||
open_and_lock_tables()
|
||||
thd - thread handler
|
||||
tables - list of tables for open&locking
|
||||
|
||||
RETURN
|
||||
0 - ok
|
||||
-1 - error
|
||||
|
||||
NOTE
|
||||
The lock will automaticly be freed by close_thread_tables()
|
||||
*/
|
||||
@ -1562,7 +1586,8 @@ int simple_open_n_lock_tables(THD *thd, TABLE_LIST *tables)
|
||||
int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
|
||||
{
|
||||
DBUG_ENTER("open_and_lock_tables");
|
||||
if (open_tables(thd, tables) || lock_tables(thd, tables))
|
||||
uint counter;
|
||||
if (open_tables(thd, tables, &counter) || lock_tables(thd, tables, counter))
|
||||
DBUG_RETURN(-1); /* purecov: inspected */
|
||||
fix_tables_pointers(thd->lex->all_selects_list);
|
||||
DBUG_RETURN(mysql_handle_derived(thd->lex));
|
||||
@ -1576,6 +1601,7 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
|
||||
lock_tables()
|
||||
thd Thread handler
|
||||
tables Tables to lock
|
||||
count umber of opened tables
|
||||
|
||||
NOTES
|
||||
You can't call lock_tables twice, as this would break the dead-lock-free
|
||||
@ -1587,7 +1613,7 @@ int open_and_lock_tables(THD *thd, TABLE_LIST *tables)
|
||||
-1 Error
|
||||
*/
|
||||
|
||||
int lock_tables(THD *thd,TABLE_LIST *tables)
|
||||
int lock_tables(THD *thd, TABLE_LIST *tables, uint count)
|
||||
{
|
||||
TABLE_LIST *table;
|
||||
if (!tables)
|
||||
@ -1596,12 +1622,6 @@ int lock_tables(THD *thd,TABLE_LIST *tables)
|
||||
if (!thd->locked_tables)
|
||||
{
|
||||
DBUG_ASSERT(thd->lock == 0); // You must lock everything at once
|
||||
uint count=0;
|
||||
for (table = tables ; table ; table=table->next)
|
||||
{
|
||||
if (!table->derived)
|
||||
count++;
|
||||
}
|
||||
TABLE **start,**ptr;
|
||||
if (!(ptr=start=(TABLE**) sql_alloc(sizeof(TABLE*)*count)))
|
||||
return -1;
|
||||
@ -2207,7 +2227,6 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name,
|
||||
#ifndef NO_EMBEDDED_ACCESS_CHECKS
|
||||
/* Ensure that we have access right to all columns */
|
||||
if (!(table->grant.privilege & SELECT_ACL) &&
|
||||
!tables->derived &&
|
||||
check_grant_all_columns(thd,SELECT_ACL,table))
|
||||
DBUG_RETURN(-1);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user