#At file:///mnt/raid/alik/MySQL/bzr/00/bug27480/mysql-5.5-runtime-bug27480.2/ based on revid:alik@stripped
3121 Alexander Nozdrin 2010-08-20
Bug#27480 (Extend CREATE TEMPORARY TABLES privilege
to allow temp table operations) -- prerequisite patch #5:
rename open_table() to open_base_table_or_view().
modified:
sql/mdl.cc
sql/sql_admin.cc
sql/sql_base.cc
sql/sql_base.h
sql/sql_cache.cc
sql/sql_class.h
sql/sql_handler.cc
sql/sql_insert.cc
sql/sql_partition.cc
sql/sql_prepare.cc
sql/sql_table.cc
sql/sql_view.cc
sql/table.cc
sql/table.h
=== modified file 'sql/mdl.cc'
--- a/sql/mdl.cc 2010-08-12 13:50:23 +0000
+++ b/sql/mdl.cc 2010-08-20 16:09:49 +0000
@@ -1481,8 +1481,8 @@ MDL_context::find_ticket(MDL_request *md
Unlike exclusive locks, shared locks are acquired one by
one. This is interface is chosen to simplify introduction of
the new locking API to the system. MDL_context::try_acquire_lock()
- is currently used from open_table(), and there we have only one
- table to work with.
+ is currently used from open_base_table_or_view(), and there we have only
+ one table to work with.
This function may also be used to try to acquire an exclusive
lock on a destination table, by ALTER TABLE ... RENAME.
=== modified file 'sql/sql_admin.cc'
--- a/sql/sql_admin.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_admin.cc 2010-08-20 16:09:49 +0000
@@ -208,7 +208,7 @@ static int prepare_for_repair(THD *thd,
Now we should be able to open the partially repaired table
to finish the repair in the handler later on.
*/
- if (open_table(thd, table_list, thd->mem_root, &ot_ctx))
+ if (open_base_table_or_view(thd, table_list, thd->mem_root, &ot_ctx))
{
error= send_check_errmsg(thd, table_list, "repair",
"Failed to open partially repaired table");
=== modified file 'sql/sql_base.cc'
--- a/sql/sql_base.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_base.cc 2010-08-20 16:09:49 +0000
@@ -2472,7 +2472,7 @@ bool MDL_deadlock_handler::handle_condit
@param[in] flags flags MYSQL_OPEN_FORCE_SHARED_MDL,
MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL or
MYSQL_OPEN_FAIL_ON_MDL_CONFLICT
- @sa open_table().
+ @sa open_base_table_or_view().
@param[out] mdl_ticket Only modified if there was no error.
If we managed to acquire an MDL
lock, contains a reference to the
@@ -2618,7 +2618,7 @@ tdc_wait_for_old_version(THD *thd, const
/**
- Open a base table.
+ Open a base table or a view.
@param thd Thread context.
@param table_list Open first table in list.
@@ -2653,8 +2653,10 @@ tdc_wait_for_old_version(THD *thd, const
TABLE_LIST::view is set for views).
*/
-bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
- Open_table_context *ot_ctx)
+bool open_base_table_or_view(THD *thd,
+ TABLE_LIST *table_list,
+ MEM_ROOT *mem_root,
+ Open_table_context *ot_ctx)
{
reg1 TABLE *table;
char key[MAX_DBKEY_LENGTH];
@@ -2665,7 +2667,7 @@ bool open_table(THD *thd, TABLE_LIST *ta
int error;
TABLE_SHARE *share;
my_hash_value_type hash_value;
- DBUG_ENTER("open_table");
+ DBUG_ENTER("open_base_table_or_view");
DBUG_ASSERT(!table_list->table);
@@ -3362,9 +3364,9 @@ unlink_all_closed_tables(THD *thd, MYSQL
/*
When closing the table, we must remove it
from thd->open_tables list.
- We rely on the fact that open_table() that was used
- in reopen_tables() always links the opened table
- to the beginning of the open_tables list.
+ We rely on the fact that open_base_table_or_view() that was used in
+ reopen_tables() always links the opened table to the beginning of
+ the open_tables list.
*/
DBUG_ASSERT(thd->open_tables == m_reopen_array[reopen_count]);
@@ -3418,7 +3420,7 @@ Locked_tables_list::reopen_tables(THD *t
continue;
/* Links into thd->open_tables upon success */
- if (open_table(thd, table_list, thd->mem_root, &ot_ctx))
+ if (open_base_table_or_view(thd, table_list, thd->mem_root, &ot_ctx))
{
unlink_all_closed_tables(thd, 0, reopen_count);
return TRUE;
@@ -4083,8 +4085,8 @@ thr_lock_type read_lock_type_for_table(T
one of its elements is processed.
@param[in] has_prelocking_list Indicates that prelocking set/list for
this statement has already been built.
- @param[in] ot_ctx Context of open_table used to recover from
- locking failures.
+ @param[in] ot_ctx Context of open_base_table_or_view()
+ used to recover from locking failures.
@param[out] need_prelocking Set to TRUE if it was detected that this
statement will require prelocked mode for
its execution, not touched otherwise.
@@ -4225,7 +4227,8 @@ open_and_process_routine(THD *thd, Query
@param[in] tables Table list element to be processed.
@param[in,out] counter Number of tables which are open.
@param[in] flags Bitmap of flags to modify how the tables
- will be open, see open_table() description
+ will be open, see
+ open_base_table_or_view() description
for details.
@param[in] prelocking_strategy Strategy which specifies how the
prelocking set should be extended
@@ -4233,7 +4236,7 @@ open_and_process_routine(THD *thd, Query
@param[in] has_prelocking_list Indicates that prelocking set/list for
this statement has already been built.
@param[in] ot_ctx Context used to recover from a failed
- open_table() attempt.
+ open_base_table_or_view() attempt.
@param[in] new_frm_mem Temporary MEM_ROOT to be used for
parsing .FRMs for views.
@@ -4369,12 +4372,12 @@ open_and_process_table(THD *thd, LEX *le
*/
No_such_table_error_handler no_such_table_handler;
thd->push_internal_handler(&no_such_table_handler);
- error= open_table(thd, tables, new_frm_mem, ot_ctx);
+ error= open_base_table_or_view(thd, tables, new_frm_mem, ot_ctx);
thd->pop_internal_handler();
safe_to_ignore_table= no_such_table_handler.safely_trapped_errors();
}
else
- error= open_table(thd, tables, new_frm_mem, ot_ctx);
+ error= open_base_table_or_view(thd, tables, new_frm_mem, ot_ctx);
free_root(new_frm_mem, MYF(MY_KEEP_PREALLOC));
@@ -4382,7 +4385,7 @@ open_and_process_table(THD *thd, LEX *le
{
if (! ot_ctx->can_recover_from_failed_open() && safe_to_ignore_table)
{
- DBUG_PRINT("info", ("open_table: ignoring table '%s'.'%s'",
+ DBUG_PRINT("info", ("open_base_table_or_view: ignoring table '%s'.'%s'",
tables->db, tables->alias));
error= FALSE;
}
@@ -4538,7 +4541,8 @@ extern "C" uchar *schema_set_get_key(con
@param tables_end End of list of tables.
@param lock_wait_timeout Seconds to wait before timeout.
@param flags Bitmap of flags to modify how the tables will be
- open, see open_table() description for details.
+ open, see open_base_table_or_view() description
+ for details.
@retval FALSE Success.
@retval TRUE Failure (e.g. connection was killed)
@@ -4609,7 +4613,8 @@ lock_table_names(THD *thd,
should be searched for.
@param tables_end End of list of tables.
@param flags Bitmap of flags to modify how the tables will be
- open, see open_table() description for details.
+ open, see open_base_table_or_view() description for
+ details.
@retval FALSE Success.
@retval TRUE Failure (e.g. connection was killed)
@@ -4669,7 +4674,8 @@ open_tables_check_upgradable_mdl(THD *th
for "SELECT f1()").
@param[out] counter Number of tables which were open.
@param[in] flags Bitmap of flags to modify how the tables will be
- open, see open_table() description for details.
+ open, see open_base_table_or_view() description
+ for details.
@param[in] prelocking_strategy Strategy which specifies how prelocking
algorithm should work for this statement.
@@ -5217,7 +5223,8 @@ static bool check_lock_and_start_stmt(TH
@param[in] table_l table to open is first table in this list
@param[in] lock_type lock to use for table
@param[in] flags options to be used while opening and locking
- table (see open_table(), mysql_lock_tables())
+ table (see open_base_table_or_view(),
+ mysql_lock_tables())
@return table
@retval != NULL OK, opened table returned
@@ -5280,16 +5287,16 @@ TABLE *open_n_lock_single_table(THD *thd
lock_flags Flags passed to mysql_lock_table
NOTE
- This function doesn't do anything like SP/SF/views/triggers analysis done
- in open_table()/lock_tables(). It is intended for opening of only one
- concrete table. And used only in special contexts.
+ This function doesn't do anything like SP/SF/views/triggers analysis done
+ in open_base_table_or_view()/lock_tables(). It is intended for opening
+ of only one concrete table. And used only in special contexts.
RETURN VALUES
table Opened table
0 Error
-
+
If ok, the following are also set:
- table_list->lock_type lock_type
+ table_list->lock_type lock_type
table_list->table table
*/
@@ -5312,7 +5319,8 @@ TABLE *open_ltable(THD *thd, TABLE_LIST
/* This function can't properly handle requests for such metadata locks. */
DBUG_ASSERT(table_list->mdl_request.type < MDL_SHARED_NO_WRITE);
- while ((error= open_table(thd, table_list, thd->mem_root, &ot_ctx)) &&
+ while ((error= open_base_table_or_view(thd, table_list, thd->mem_root,
+ &ot_ctx)) &&
ot_ctx.can_recover_from_failed_open())
{
/*
=== modified file 'sql/sql_base.h'
--- a/sql/sql_base.h 2010-08-20 16:00:19 +0000
+++ b/sql/sql_base.h 2010-08-20 16:09:49 +0000
@@ -91,7 +91,7 @@ TABLE_SHARE *get_cached_table_share(cons
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type update,
uint lock_flags);
-/* mysql_lock_tables() and open_table() flags bits */
+/* mysql_lock_tables() and open_base_table_or_view() flags bits */
#define MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK 0x0001
#define MYSQL_OPEN_IGNORE_FLUSH 0x0002
/* MYSQL_OPEN_TEMPORARY_ONLY (0x0004) is not used anymore. */
@@ -133,8 +133,10 @@ TABLE *open_ltable(THD *thd, TABLE_LIST
MYSQL_OPEN_SKIP_TEMPORARY |\
MYSQL_OPEN_HAS_MDL_LOCK)
-bool open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root,
- Open_table_context *ot_ctx);
+bool open_base_table_or_view(THD *thd,
+ TABLE_LIST *table_list,
+ MEM_ROOT *mem_root,
+ Open_table_context *ot_ctx);
bool open_new_frm(THD *thd, TABLE_SHARE *share, const char *alias,
uint db_stat, uint prgflag,
uint ha_open_flags, TABLE *outparam, TABLE_LIST *table_desc,
@@ -466,7 +468,7 @@ inline bool open_and_lock_tables(THD *th
/**
A context of open_tables() function, used to recover
- from a failed open_table() or open_routine() attempt.
+ from a failed open_base_table_or_view() or open_routine() attempt.
*/
class Open_table_context
@@ -519,7 +521,7 @@ private:
tables or to the "lock_wait_timeout" system variable for regular tables.
*/
ulong m_timeout;
- /* open_table() flags. */
+ /* open_base_table_or_view() flags. */
uint m_flags;
/** Back off action. */
enum enum_open_table_action m_action;
=== modified file 'sql/sql_cache.cc'
--- a/sql/sql_cache.cc 2010-07-24 01:36:21 +0000
+++ b/sql/sql_cache.cc 2010-08-20 16:09:49 +0000
@@ -312,8 +312,8 @@ TODO list:
tables_used->table->file->register_used_filenames(callback,
first_argument);
- QC improvement suggested by Monty:
- - Add a counter in open_table() for how many MERGE (ISAM or MyISAM)
- tables are cached in the table cache.
+ - Add a counter in open_base_table_or_view() for how many MERGE (ISAM
+ or MyISAM) tables are cached in the table cache.
(This will be trivial when we have the new table cache in place I
have been working on)
- After this we can add the following test around the for loop in
=== modified file 'sql/sql_class.h'
--- a/sql/sql_class.h 2010-08-20 16:00:19 +0000
+++ b/sql/sql_class.h 2010-08-20 16:09:49 +0000
@@ -1028,8 +1028,8 @@ public:
/**
This constructor initializes Open_tables_state instance which can only
be used as backup storage. To prepare Open_tables_state instance for
- operations which open/lock/close tables (e.g. open_table()) one has to
- call init_open_tables_state().
+ operations which open/lock/close tables (e.g.
+ open_base_table_or_view()) one has to call init_open_tables_state().
*/
Open_tables_state() : state_flags(0U) { }
=== modified file 'sql/sql_handler.cc'
--- a/sql/sql_handler.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_handler.cc 2010-08-20 16:09:49 +0000
@@ -273,7 +273,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST
from open_tables(), thd->open_tables will contain only the opened
table.
- See open_table() back-off comments for more details.
+ See open_base_table_or_view() back-off comments for more details.
*/
backup_open_tables= thd->open_tables;
thd->set_open_tables(NULL);
@@ -287,7 +287,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST
/*
We use open_tables() here, rather than, say,
- open_ltable() or open_table() because we would like to be able
+ open_ltable() or open_base_table_or_view() because we would like to be able
to open a temporary table.
*/
=== modified file 'sql/sql_insert.cc'
--- a/sql/sql_insert.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_insert.cc 2010-08-20 16:09:49 +0000
@@ -3573,7 +3573,7 @@ static TABLE *create_table_from_items(TH
not be written: 1) it would be wrong (imagine we're in CREATE SELECT: we
don't want to delete from it) 2) it would be written before the CREATE
TABLE, which is a wrong order. So we keep binary logging disabled when we
- open_table().
+ open_base_table_or_view().
*/
{
if (!mysql_create_table_no_lock(thd, create_table->db,
@@ -3590,7 +3590,7 @@ static TABLE *create_table_from_items(TH
Here we open the destination table, on which we already have
an exclusive metadata lock.
*/
- if (open_table(thd, create_table, thd->mem_root, &ot_ctx))
+ if (open_base_table_or_view(thd, create_table, thd->mem_root, &ot_ctx))
{
quick_rm_table(create_info->db_type, create_table->db,
table_case_name(create_info, create_table->table_name),
=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc 2010-08-18 11:29:04 +0000
+++ b/sql/sql_partition.cc 2010-08-20 16:09:49 +0000
@@ -5377,8 +5377,8 @@ the generated partition syntax in a corr
We use the old partitioning also for the new table. We do this
by assigning the partition_info from the table loaded in
- open_table to the partition_info struct used by mysql_create_table
- later in this method.
+ open_base_table_or_view to the partition_info struct used by
+ mysql_create_table later in this method.
Case IIb:
There was a partitioning before and there is no new one defined.
=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_prepare.cc 2010-08-20 16:09:49 +0000
@@ -1301,7 +1301,7 @@ static bool mysql_test_insert(Prepared_s
DBUG_RETURN(FALSE);
error:
- /* insert_values is cleared in open_table */
+ /* insert_values is cleared in open_base_table_or_view */
DBUG_RETURN(TRUE);
}
=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_table.cc 2010-08-20 16:09:49 +0000
@@ -4503,7 +4503,7 @@ bool mysql_create_like_table(THD* thd, T
to work. The table will be closed by close_thread_table() at
the end of this branch.
*/
- if (open_table(thd, table, thd->mem_root, &ot_ctx))
+ if (open_base_table_or_view(thd, table, thd->mem_root, &ot_ctx))
goto err;
int result __attribute__((unused))=
@@ -6538,7 +6538,7 @@ bool mysql_alter_table(THD *thd,char *ne
*/
table_list->mdl_request.ticket= mdl_ticket;
}
- if (open_table(thd, table_list, thd->mem_root, &ot_ctx))
+ if (open_base_table_or_view(thd, table_list, thd->mem_root, &ot_ctx))
{
goto err_with_mdl;
}
=== modified file 'sql/sql_view.cc'
--- a/sql/sql_view.cc 2010-08-20 16:00:19 +0000
+++ b/sql/sql_view.cc 2010-08-20 16:09:49 +0000
@@ -1203,10 +1203,10 @@ bool mysql_make_view(THD *thd, File_pars
re-execution of a prepared statement we don't prefer
a temporary table to the view, if the view name was shadowed
with a temporary table with the same name.
- This assignment ensures that on re-execution open_table() will
- not try to call find_temporary_table() for this TABLE_LIST,
- but will invoke open_table_from_share(), which will
- eventually call this function.
+ This assignment ensures that on re-execution open_base_table_or_view()
+ will not try to call find_temporary_table() for this TABLE_LIST, but
+ will invoke open_table_from_share(), which will eventually call this
+ function.
*/
table->open_type= OT_BASE_ONLY;
=== modified file 'sql/table.cc'
--- a/sql/table.cc 2010-08-18 11:29:04 +0000
+++ b/sql/table.cc 2010-08-20 16:09:49 +0000
@@ -318,8 +318,9 @@ TABLE_SHARE *alloc_table_share(TABLE_LIS
Since alloc_table_share() can be called without any locking (for
example, ha_create_table... functions), we do not assign a table
map id here. Instead we assign a value that is not used
- elsewhere, and then assign a table map id inside open_table()
- under the protection of the LOCK_open mutex.
+ elsewhere, and then assign a table map id inside
+ open_base_table_or_view() under the protection of the LOCK_open
+ mutex.
*/
share->table_map_id= ~0UL;
share->cached_row_logging_check= -1;
=== modified file 'sql/table.h'
--- a/sql/table.h 2010-08-19 18:03:20 +0000
+++ b/sql/table.h 2010-08-20 16:09:49 +0000
@@ -1000,9 +1000,9 @@ public:
or we should not automatically set its value during execution of current
statement then the variable contains TIMESTAMP_NO_AUTO_SET (i.e. 0).
- Value of this variable is set for each statement in open_table() and
- if needed cleared later in statement processing code (see mysql_update()
- as example).
+ Value of this variable is set for each statement in
+ open_base_table_or_view() and if needed cleared later in statement
+ processing code (see mysql_update() as example).
*/
timestamp_auto_set_type timestamp_field_type;
table_map map; /* ID bit of table (1,2,4,8,16...) */
Attachment: [text/bzr-bundle] bzr/alik@sun.com-20100820160949-qrw39qwes0vo5mto.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5-bugfixing branch (alik:3121) Bug#27480 | Alexander Nozdrin | 20 Aug |