summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_delete.cc7
-rw-r--r--sql/sql_lex.cc29
-rw-r--r--sql/sql_parse.cc98
3 files changed, 72 insertions, 62 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 269633aa709..f21dbb10712 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -254,9 +254,9 @@ cleanup:
*/
int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
{
- TABLE_LIST *delete_table_list=
- (TABLE_LIST*)thd->lex->select_lex.table_list.first;
- DBUG_ENTER(" mysql_prepare_delete");
+ TABLE_LIST *delete_table_list= ((TABLE_LIST*) thd->lex->
+ select_lex.table_list.first);
+ DBUG_ENTER("mysql_prepare_delete");
if (setup_conds(thd, delete_table_list, conds) ||
setup_ftfuncs(&thd->lex->select_lex))
@@ -267,6 +267,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds)
my_error(ER_UPDATE_TABLE_USED, MYF(0), table_list->real_name);
DBUG_RETURN(-1);
}
+ DBUG_RETURN(0);
}
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 995f3702ab3..e0e8fed29c8 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -1636,17 +1636,21 @@ void st_select_lex::print_limit(THD *thd, String *str)
/*
- Unlink first table from global table list and first must outer select list
- (lex->select_lex)
+ Unlink first table from global table list and first table from outer select
+ list (lex->select_lex)
SYNOPSIS
unlink_first_table()
- tables - global table list
- global_first - save first global table passed using this parameter
- local_first - save first local table passed using this parameter
+ tables Global table list
+ global_first Save first global table here
+ local_first Save first local table here
+
+ NORES
+ global_first & local_first are used to save result for link_first_table_back
RETURN
global list without first table
+
*/
TABLE_LIST *st_lex::unlink_first_table(TABLE_LIST *tables,
TABLE_LIST **global_first,
@@ -1655,16 +1659,15 @@ TABLE_LIST *st_lex::unlink_first_table(TABLE_LIST *tables,
*global_first= tables;
*local_first= (TABLE_LIST*)select_lex.table_list.first;
/*
- exclude from global table list
+ Exclude from global table list
*/
tables= tables->next;
/*
and from local list if it is not the same
*/
- if (&select_lex != all_selects_list)
- select_lex.table_list.first= (gptr)(*local_first)->next;
- else
- select_lex.table_list.first= (gptr)tables;
+ select_lex.table_list.first= ((&select_lex != all_selects_list) ?
+ (gptr) (*local_first)->next :
+ (gptr) tables);
(*global_first)->next= 0;
return tables;
}
@@ -1675,9 +1678,9 @@ TABLE_LIST *st_lex::unlink_first_table(TABLE_LIST *tables,
SYNOPSIS
link_first_table_back()
- tables - global table list
- global_first - save first global table
- local_first - save first local table
+ tables Global table list
+ global_first Saved first global table
+ local_first Saved first local table
RETURN
global list
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index cf8369b778d..1e3beeca8a9 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2136,8 +2136,7 @@ mysql_execute_command(THD *thd)
if (grant_option)
{
/* Check that the first table has CREATE privilege */
- bool error= check_grant(thd, CREATE_ACL, tables, 0, 1, 0);
- if (error)
+ if (check_grant(thd, CREATE_ACL, tables, 0, 1, 0))
goto error;
}
if (strlen(tables->real_name) > NAME_LEN)
@@ -2638,14 +2637,14 @@ unsent_create_error:
{
TABLE_LIST *aux_tables=
(TABLE_LIST *)thd->lex->auxilliary_table_list.first;
-
TABLE_LIST *target_tbl;
uint table_count;
multi_delete *result;
+
if ((res= multi_delete_precheck(thd, tables, &table_count)))
break;
- // condition will be TRUE on SP re esexcuting
+ /* condition will be TRUE on SP re-excuting */
if (select_lex->item_list.elements != 0)
select_lex->item_list.empty();
if (add_item_to_list(thd, new Item_null()))
@@ -3387,18 +3386,18 @@ error:
0 - OK
1 - access denied, error is sent to client
*/
-int check_one_table_access(THD *thd, ulong privilege,
- TABLE_LIST *tables)
+
+int check_one_table_access(THD *thd, ulong privilege, TABLE_LIST *tables)
{
if (check_access(thd, privilege, tables->db, &tables->grant.privilege,0,0))
return 1;
- // Show only 1 table for check_grant
+ /* Show only 1 table for check_grant */
if (grant_option && check_grant(thd, privilege, tables, 0, 1, 0))
return 1;
- // check rights on tables of subselect (if exists)
+ /* Check rights on tables of subselect (if exists) */
TABLE_LIST *subselects_tables;
if ((subselects_tables= tables->next))
{
@@ -3851,6 +3850,7 @@ void mysql_init_multi_delete(LEX *lex)
When you modify mysql_parse(), you may need to mofify
mysql_test_parse_for_slave() in this same file.
*/
+
void mysql_parse(THD *thd, char *inBuf, uint length)
{
DBUG_ENTER("mysql_parse");
@@ -4928,14 +4928,15 @@ int mysql_drop_index(THD *thd, TABLE_LIST *table_list, List<Alter_drop> &drop)
SYNOPSIS
multi_update_precheck()
- thd - thread handler
- tables - global table list
+ thd Thread handler
+ tables Global table list
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 Error (message is sent to user)
+ -1 Error (message is not sent to user)
*/
+
int multi_update_precheck(THD *thd, TABLE_LIST *tables)
{
DBUG_ENTER("multi_update_precheck");
@@ -5016,14 +5017,14 @@ int multi_update_precheck(THD *thd, TABLE_LIST *tables)
SYNOPSIS
multi_delete_precheck()
- thd - thread handler
- tables - global table list
- table_count - pointer to table counter
+ thd Thread handler
+ tables Global table list
+ table_count Pointer to table counter
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 error (message is sent to user)
+ -1 error (message is not sent to user)
*/
int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
{
@@ -5083,14 +5084,15 @@ int multi_delete_precheck(THD *thd, TABLE_LIST *tables, uint *table_count)
SYNOPSIS
multi_delete_precheck()
- thd - thread handler
- tables - global table list
+ thd Thread handler
+ tables Global table list
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 Error (message is sent to user)
+ -1 Error (message is not sent to user)
*/
+
int insert_select_precheck(THD *thd, TABLE_LIST *tables)
{
DBUG_ENTER("insert_select_precheck");
@@ -5109,14 +5111,15 @@ int insert_select_precheck(THD *thd, TABLE_LIST *tables)
SYNOPSIS
update_precheck()
- thd - thread handler
- tables - global table list
+ thd Thread handler
+ tables Global table list
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 Error (message is sent to user)
+ -1 Error (message is not sent to user)
*/
+
int update_precheck(THD *thd, TABLE_LIST *tables)
{
DBUG_ENTER("update_precheck");
@@ -5135,20 +5138,21 @@ int update_precheck(THD *thd, TABLE_LIST *tables)
SYNOPSIS
delete_precheck()
- thd - thread handler
- tables - global table list
+ thd Thread handler
+ tables Global table list
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 error (message is sent to user)
+ -1 error (message is not sent to user)
*/
+
int delete_precheck(THD *thd, TABLE_LIST *tables)
{
DBUG_ENTER("delete_precheck");
if (check_one_table_access(thd, DELETE_ACL, tables))
DBUG_RETURN(1);
- // Set privilege for the WHERE clause
+ /* Set privilege for the WHERE clause */
tables->grant.want_privilege=(SELECT_ACL & ~tables->grant.privilege);
DBUG_RETURN(0);
}
@@ -5159,14 +5163,15 @@ int delete_precheck(THD *thd, TABLE_LIST *tables)
SYNOPSIS
insert_precheck()
- thd - thread handler
- tables - global table list
+ thd Thread handler
+ tables Global table list
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 error (message is sent to user)
+ -1 error (message is not sent to user)
*/
+
int insert_precheck(THD *thd, TABLE_LIST *tables, bool update)
{
LEX *lex= thd->lex;
@@ -5192,15 +5197,16 @@ int insert_precheck(THD *thd, TABLE_LIST *tables, bool update)
SYNOPSIS
create_table_precheck()
- thd - thread handler
- tables - global table list
- create_table - table which will be created
+ thd Thread handler
+ tables Global table list
+ create_table Table which will be created
RETURN VALUE
- 0 - OK
- 1 - error (message is sent to user)
- -1 - error (message is not sent to user)
+ 0 OK
+ 1 Error (message is sent to user)
+ -1 Error (message is not sent to user)
*/
+
int create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table)
{