3399 Dmitry Lenev 2010-12-06
Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY
TABLES privilege to allow temp table operations).
Review fixes in progress. Fixed small issues,
removed indentation changes.
modified:
sql/sql_admin.cc
sql/sql_base.cc
sql/sql_class.h
sql/sql_parse.cc
sql/sql_prepare.cc
3398 Dmitry Lenev 2010-12-03
Prerequisite patch for Bug#27480 (Extend CREATE TEMPORARY
TABLES privilege to allow temp table operations).
Review fixes in progress. Fixed outdated function description.
modified:
sql/sql_base.cc
=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc 2010-12-03 06:42:19 +0000
+++ b/sql/sql_admin.cc 2010-12-06 10:36:38 +0000
@@ -355,68 +355,68 @@ static bool mysql_admin_table(THD* thd,
table->next_global= save_next_global;
table->next_local= save_next_local;
thd->open_options&= ~extra_open_options;
- }
-
- /*
- If open_and_lock_tables() failed, close_thread_tables() will close
- the table and table->table can therefore be invalid.
- */
- if (open_error)
- table->table= NULL;
- /*
- Under locked tables, we know that the table can be opened,
- so any errors opening the table are logical errors.
- In these cases it does not make sense to try to repair.
- */
- if (open_error && thd->locked_tables_mode)
- {
- result_code= HA_ADMIN_FAILED;
- goto send_result;
- }
-#ifdef WITH_PARTITION_STORAGE_ENGINE
- if (table->table)
- {
/*
- Set up which partitions that should be processed
- if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION ..
- CACHE INDEX/LOAD INDEX for specified partitions
+ If open_and_lock_tables() failed, close_thread_tables() will close
+ the table and table->table can therefore be invalid.
*/
- Alter_info *alter_info= &lex->alter_info;
+ if (open_error)
+ table->table= NULL;
- if (alter_info->flags & ALTER_ADMIN_PARTITION)
+ /*
+ Under locked tables, we know that the table can be opened,
+ so any errors opening the table are logical errors.
+ In these cases it does not make sense to try to repair.
+ */
+ if (open_error && thd->locked_tables_mode)
{
- if (!table->table->part_info)
- {
- my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
- DBUG_RETURN(TRUE);
- }
- uint num_parts_found;
- uint num_parts_opt= alter_info->partition_names.elements;
- num_parts_found= set_part_state(alter_info, table->table->part_info,
- PART_ADMIN);
- if (num_parts_found != num_parts_opt &&
- (!(alter_info->flags & ALTER_ALL_PARTITION)))
+ result_code= HA_ADMIN_FAILED;
+ goto send_result;
+ }
+#ifdef WITH_PARTITION_STORAGE_ENGINE
+ if (table->table)
+ {
+ /*
+ Set up which partitions that should be processed
+ if ALTER TABLE t ANALYZE/CHECK/OPTIMIZE/REPAIR PARTITION ..
+ CACHE INDEX/LOAD INDEX for specified partitions
+ */
+ Alter_info *alter_info= &lex->alter_info;
+
+ if (alter_info->flags & ALTER_ADMIN_PARTITION)
{
- char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
- size_t length;
- DBUG_PRINT("admin", ("sending non existent partition error"));
- protocol->prepare_for_resend();
- protocol->store(table_name, system_charset_info);
- protocol->store(operator_name, system_charset_info);
- protocol->store(STRING_WITH_LEN("error"), system_charset_info);
- length= my_snprintf(buff, sizeof(buff),
- ER(ER_DROP_PARTITION_NON_EXISTENT),
- table_name);
- protocol->store(buff, length, system_charset_info);
- if(protocol->write())
+ if (!table->table->part_info)
+ {
+ my_error(ER_PARTITION_MGMT_ON_NONPARTITIONED, MYF(0));
+ DBUG_RETURN(TRUE);
+ }
+ uint num_parts_found;
+ uint num_parts_opt= alter_info->partition_names.elements;
+ num_parts_found= set_part_state(alter_info, table->table->part_info,
+ PART_ADMIN);
+ if (num_parts_found != num_parts_opt &&
+ (!(alter_info->flags & ALTER_ALL_PARTITION)))
+ {
+ char buff[FN_REFLEN + MYSQL_ERRMSG_SIZE];
+ size_t length;
+ DBUG_PRINT("admin", ("sending non existent partition error"));
+ protocol->prepare_for_resend();
+ protocol->store(table_name, system_charset_info);
+ protocol->store(operator_name, system_charset_info);
+ protocol->store(STRING_WITH_LEN("error"), system_charset_info);
+ length= my_snprintf(buff, sizeof(buff),
+ ER(ER_DROP_PARTITION_NON_EXISTENT),
+ table_name);
+ protocol->store(buff, length, system_charset_info);
+ if(protocol->write())
+ goto err;
+ my_eof(thd);
goto err;
- my_eof(thd);
- goto err;
+ }
}
}
- }
#endif
+ }
DBUG_PRINT("admin", ("table: 0x%lx", (long) table->table));
if (prepare_func)
@@ -851,6 +851,7 @@ send_result_message:
trans_commit_implicit(thd);
close_thread_tables(thd);
thd->mdl_context.release_transactional_locks();
+
/*
If it is CHECK TABLE v1, v2, v3, and v1, v2, v3 are views, we will run
separate open_tables() for each CHECK TABLE argument.
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2010-12-03 09:18:42 +0000
+++ b/sql/sql_base.cc 2010-12-06 10:36:38 +0000
@@ -2687,7 +2687,6 @@ bool open_table(THD *thd, TABLE_LIST *ta
DBUG_PRINT("info",("Using locked table"));
goto reset;
}
-
/*
Is this table a view and not a base table?
(it is work around to allow to open view with locked tables,
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2010-12-02 08:07:11 +0000
+++ b/sql/sql_class.h 2010-12-06 10:36:38 +0000
@@ -3697,21 +3697,21 @@ public:
#define CF_CAN_GENERATE_ROW_EVENTS (1U << 9)
/**
- Identifies statements that can directly update a rpl info table.
-*/
-#define CF_WRITE_RPL_INFO_COMMAND (1U << 12)
-
-/**
Identifies statements which may deal with temporary tables and for which
temporary tables should be pre-opened to simplify privilege checks.
*/
-#define CF_PREOPEN_TMP_TABLES (1U << 12)
+#define CF_PREOPEN_TMP_TABLES (1U << 10)
/**
Identfies statements for which open handlers should be closed in the
beginning of the statement.
*/
-#define CF_HA_CLOSE (1U << 13)
+#define CF_HA_CLOSE (1U << 11)
+
+/**
+ Identifies statements that can directly update a rpl info table.
+*/
+#define CF_WRITE_RPL_INFO_COMMAND (1U << 12)
/* Bits in server_command_flags */
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2010-12-02 09:21:50 +0000
+++ b/sql/sql_parse.cc 2010-12-06 10:36:38 +0000
@@ -2153,7 +2153,7 @@ mysql_execute_command(THD *thd)
res= execute_sqlcom_select(thd, all_tables);
break;
}
- case SQLCOM_PREPARE:
+case SQLCOM_PREPARE:
{
mysql_sql_stmt_prepare(thd);
break;
@@ -2395,7 +2395,6 @@ mysql_execute_command(THD *thd)
if ((res= create_table_precheck(thd, select_tables, create_table)))
goto end_with_restore_list;
-
/* Might have been updated in create_table_precheck */
create_info.alias= create_table->alias;
@@ -2590,7 +2589,6 @@ end_with_restore_list:
goto error;
DBUG_ASSERT(first_table == all_tables && first_table != 0);
-
if (check_one_table_access(thd, INDEX_ACL, all_tables))
goto error; /* purecov: inspected */
/*
@@ -3646,7 +3644,6 @@ end_with_restore_list:
if (check_global_access(thd,RELOAD_ACL))
goto error;
-
if (first_table && lex->type & REFRESH_READ_LOCK)
{
/* Check table-level privileges. */
=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc 2010-12-02 06:57:30 +0000
+++ b/sql/sql_prepare.cc 2010-12-06 10:36:38 +0000
@@ -1985,9 +1985,8 @@ static bool check_prepared_statement(Pre
/*
Open temporary tables that are known now. Temporary tables added by
- prelocking will be opened afterwards (after the switch below).
+ prelocking will be opened afterwards (during open_tables()).
*/
-
if (sql_command_flags[sql_command] & CF_PREOPEN_TMP_TABLES)
{
if (open_and_process_temporary_table_list(thd, tables))
@@ -2124,7 +2123,6 @@ static bool check_prepared_statement(Pre
}
break;
}
-
if (res == 0)
DBUG_RETURN(stmt->is_sql_prepare() ?
FALSE : (send_prep_stmt(stmt, 0) || thd->protocol->flush()));
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-trunk-bugfixing branch (Dmitry.Lenev:3398 to 3399)Bug#27480 | Dmitry Lenev | 6 Dec |