Below is the list of changes that have just been committed into a local
5.1 repository of msvensson. When msvensson does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-12-05 10:54:17+01:00, msvensson@neptunus.(none) +4 -0
Merge bk-internal:/home/bk/mysql-5.1-maint
into neptunus.(none):/home/msvensson/mysql/mysql-5.1-maint
MERGE: 1.2303.47.75
sql/mysql_priv.h@stripped, 2006-12-05 10:54:11+01:00, msvensson@neptunus.(none) +0 -0
Auto merged
MERGE: 1.462.1.2
sql/sql_class.h@stripped, 2006-12-05 10:54:11+01:00, msvensson@neptunus.(none) +0 -0
Auto merged
MERGE: 1.326.5.1
sql/sql_parse.cc@stripped, 2006-12-05 10:54:12+01:00, msvensson@neptunus.(none) +0 -0
Auto merged
MERGE: 1.608.1.2
sql/sql_table.cc@stripped, 2006-12-05 10:54:12+01:00, msvensson@neptunus.(none) +0 -0
Auto merged
MERGE: 1.372.1.7
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: msvensson
# Host: neptunus.(none)
# Root: /home/msvensson/mysql/mysql-5.1-maint/RESYNC
--- 1.463/sql/mysql_priv.h 2006-12-05 10:54:24 +01:00
+++ 1.464/sql/mysql_priv.h 2006-12-05 10:54:24 +01:00
@@ -893,7 +893,7 @@ bool handle_select(THD *thd, LEX *lex, s
bool mysql_select(THD *thd, Item ***rref_pointer_array,
TABLE_LIST *tables, uint wild_num, List<Item> &list,
COND *conds, uint og_num, ORDER *order, ORDER *group,
- Item *having, ORDER *proc_param, ulong select_type,
+ Item *having, ORDER *proc_param, ulonglong select_type,
select_result *result, SELECT_LEX_UNIT *unit,
SELECT_LEX *select_lex);
void free_underlaid_joins(THD *thd, SELECT_LEX *select);
@@ -919,7 +919,7 @@ void sp_prepare_create_field(THD *thd, c
int prepare_create_field(create_field *sql_field,
uint *blob_columns,
int *timestamps, int *timestamps_with_niladic,
- uint table_flags);
+ longlong table_flags);
bool mysql_create_table(THD *thd,const char *db, const char *table_name,
HA_CREATE_INFO *create_info,
List<create_field> &fields, List<Key> &keys,
@@ -1653,14 +1653,9 @@ extern TYPELIB log_output_typelib;
/* optional things, have_* variables */
extern SHOW_COMP_OPTION have_innodb;
-extern SHOW_COMP_OPTION have_example_db;
-extern SHOW_COMP_OPTION have_archive_db;
extern SHOW_COMP_OPTION have_csv_db;
-extern SHOW_COMP_OPTION have_federated_db;
-extern SHOW_COMP_OPTION have_blackhole_db;
extern SHOW_COMP_OPTION have_ndbcluster;
extern SHOW_COMP_OPTION have_partition_db;
-extern SHOW_COMP_OPTION have_merge_db;
extern handlerton *partition_hton;
extern handlerton *myisam_hton;
@@ -1723,7 +1718,7 @@ void unlock_table_names(THD *thd, TABLE_
/* old unireg functions */
void unireg_init(ulong options);
-void unireg_end(void);
+void unireg_end(void) __attribute__((noreturn));
bool mysql_create_frm(THD *thd, const char *file_name,
const char *db, const char *table,
HA_CREATE_INFO *create_info,
@@ -2009,7 +2004,7 @@ inline bool is_user_table(TABLE * table)
*/
#ifndef EMBEDDED_LIBRARY
-extern "C" void unireg_abort(int exit_code);
+extern "C" void unireg_abort(int exit_code) __attribute__((noreturn));
void kill_delayed_threads(void);
bool check_stack_overrun(THD *thd, long margin, char *dummy);
#else
--- 1.329/sql/sql_class.h 2006-12-05 10:54:24 +01:00
+++ 1.330/sql/sql_class.h 2006-12-05 10:54:24 +01:00
@@ -2182,9 +2182,7 @@ class select_dumpvar :public select_resu
ha_rows row_count;
public:
List<my_var> var_list;
- List<Item_func_set_user_var> vars;
- List<Item_splocal> local_vars;
- select_dumpvar(void) { var_list.empty(); local_vars.empty(); vars.empty(); row_count=0;}
+ select_dumpvar() { var_list.empty(); row_count= 0;}
~select_dumpvar() {}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &items);
--- 1.609/sql/sql_parse.cc 2006-12-05 10:54:24 +01:00
+++ 1.610/sql/sql_parse.cc 2006-12-05 10:54:24 +01:00
@@ -2089,7 +2089,12 @@ bool dispatch_command(enum enum_server_c
#ifdef __WIN__
sleep(1); // must wait after eof()
#endif
- send_eof(thd); // This is for 'quit request'
+ /*
+ The client is next going to send a COM_QUIT request (as part of
+ mysql_close()). Make the life simpler for the client by sending
+ the response for the coming COM_QUIT in advance
+ */
+ send_eof(thd);
close_connection(thd, 0, 1);
close_thread_tables(thd); // Free before kill
kill_mysql();
@@ -5192,7 +5197,6 @@ create_sp_error:
break;
}
-end:
thd->proc_info="query end";
/*
--- 1.377/sql/sql_table.cc 2006-12-05 10:54:25 +01:00
+++ 1.378/sql/sql_table.cc 2006-12-05 10:54:25 +01:00
@@ -3654,10 +3654,12 @@ make_unique_key_name(const char *field_n
flags flags for build_table_filename().
FN_FROM_IS_TMP old_name is temporary.
FN_TO_IS_TMP new_name is temporary.
+ NO_FRM_RENAME Don't rename the FRM file
+ but only the table in the storage engine.
RETURN
- 0 OK
- != 0 Error
+ FALSE OK
+ TRUE Error
*/
bool
@@ -3706,7 +3708,7 @@ mysql_rename_table(handlerton *base, con
if (!file || !(error=file->rename_table(from_base, to_base)))
{
- if (rename_file_ext(from,to,reg_ext))
+ if (!(flags & NO_FRM_RENAME) && rename_file_ext(from,to,reg_ext))
{
error=my_errno;
/* Restore old file name */
@@ -5247,6 +5249,51 @@ bool alter_table_manage_keys(TABLE *tabl
/*
Alter table
+
+ SYNOPSIS
+ mysql_alter_table()
+ thd Thread handle
+ new_db If there is a RENAME clause
+ new_name If there is a RENAME clause
+ lex_create_info Information from the parsing phase. Since some
+ clauses are common to CREATE and ALTER TABLE, the
+ data is stored in lex->create_info. The non-common
+ is stored in lex->alter_info.
+ table_list The table to change.
+ fields lex->create_list - List of fields to be changed,
+ added or dropped.
+ keys lex->key_list - List of keys to be changed, added or
+ dropped.
+ order_num How many ORDER BY fields has been specified.
+ order List of fields to ORDER BY.
+ ignore Whether we have ALTER IGNORE TABLE
+ alter_info Information from the parsing phase specific to ALTER
+ TABLE and not shared with CREATE TABLE.
+ do_send_ok Whether to call send_ok() on success.
+
+ DESCRIPTION
+ This is a veery long function and is everything but the kitchen sink :)
+ It is used to alter a table and not only by ALTER TABLE but also
+ CREATE|DROP INDEX are mapped on this function.
+
+ When the ALTER TABLE statement just does a RENAME or ENABLE|DISABLE KEYS,
+ or both, then this function short cuts its operation by renaming
+ the table and/or enabling/disabling the keys. In this case, the FRM is
+ not changed, directly by mysql_alter_table. However, if there is a
+ RENAME + change of a field, or an index, the short cut is not used.
+ See how `fields` is used to generate the new FRM regarding the structure
+ of the fields. The same is done for the indices of the table.
+
+ Important is the fact, that this function tries to do as little work as
+ possible, by finding out whether a intermediate table is needed to copy
+ data into and when finishing the altering to use it as the original table.
+ For this reason the function compare_tables() is called, which decides
+ based on all kind of data how similar are the new and the original
+ tables.
+
+ RETURN VALUES
+ FALSE OK
+ TRUE Error
*/
bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
@@ -5265,7 +5312,7 @@ bool mysql_alter_table(THD *thd,char *ne
char reg_path[FN_REFLEN+1];
ha_rows copied,deleted;
uint db_create_options, used_fields;
- handlerton *old_db_type, *new_db_type;
+ handlerton *old_db_type, *new_db_type, *save_old_db_type;
legacy_db_type table_type;
HA_CREATE_INFO *create_info;
frm_type_enum frm_type;
@@ -5569,7 +5616,7 @@ view_err:
DBUG_RETURN(error);
}
- /* Full alter table */
+ /* We have to do full alter table */
/* Let new create options override the old ones */
if (!(used_fields & HA_CREATE_USED_MIN_ROWS))
@@ -6088,8 +6135,8 @@ view_err:
old data and index files. Create also symlinks to point at
the new tables.
Copy data.
- At end, rename temporary tables and symlinks to temporary table
- to final table name.
+ At end, rename intermediate tables, and symlinks to intermediate
+ table, to final table name.
Remove old table and old symlinks
If rename is made to another database:
@@ -6150,6 +6197,7 @@ view_err:
/* table is a normal table: Create temporary table in same directory */
build_table_filename(path, sizeof(path), new_db, tmp_name, "",
FN_IS_TMP);
+ /* Open our intermediate table */
new_table=open_temporary_table(thd, path, new_db, tmp_name,0);
}
if (!new_table)
@@ -6366,7 +6414,7 @@ view_err:
if (new_table)
{
- /* close temporary table that will be the new table */
+ /* Close the intermediate table that will be the new table */
intern_close_table(new_table);
my_free((gptr) new_table,MYF(0));
}
@@ -6380,7 +6428,7 @@ view_err:
/*
Data is copied. Now we rename the old table to a temp name,
- rename the new one to the old name, remove all entries from the old table
+ rename the new one to the old name, remove all entries about the old table
from the cache, free all locks, close the old table and remove it.
*/
@@ -6407,7 +6455,7 @@ view_err:
{
/*
Win32 and InnoDB can't drop a table that is in use, so we must
- close the original table at before doing the rename
+ close the original table before doing the rename
*/
table->s->version= 0; // Force removal of table def
close_cached_table(thd, table);
@@ -6421,6 +6469,21 @@ view_err:
error=0;
+ save_old_db_type= old_db_type;
+
+ /*
+ This leads to the storage engine (SE) not being notified for renames in
+ mysql_rename_table(), because we just juggle with the FRM and nothing
+ more. If we have an intermediate table, then we notify the SE that
+ it should become the actual table. Later, we will recycle the old table.
+ However, in case of ALTER TABLE RENAME there might be no intermediate
+ table. This is when the old and new tables are compatible, according to
+ compare_table(). Then, we need one additional call to
+ mysql_rename_table() with flag NO_FRM_RENAME, which does nothing else but
+ actual rename in the SE and the FRM is not touched. Note that, if the
+ table is renamed and the SE is also changed, then an intermediate table
+ is created and the additional call will not take place.
+ */
if (!need_copy_table)
new_db_type=old_db_type= NULL; // this type cannot happen in regular ALTER
if (mysql_rename_table(old_db_type, db, table_name, db, old_name,
@@ -6430,8 +6493,11 @@ view_err:
VOID(quick_rm_table(new_db_type, new_db, tmp_name, FN_IS_TMP));
}
else if (mysql_rename_table(new_db_type,new_db,tmp_name,new_db,
- new_alias, FN_FROM_IS_TMP) ||
+ new_alias, FN_FROM_IS_TMP) ||
(new_name != table_name || new_db != db) && // we also do rename
+ (need_copy_table ||
+ mysql_rename_table(save_old_db_type, db, table_name, new_db,
+ new_alias, NO_FRM_RENAME)) &&
Table_triggers_list::change_table_name(thd, db, table_name,
new_db, new_alias))
{
@@ -6442,6 +6508,7 @@ view_err:
VOID(mysql_rename_table(old_db_type, db, old_name, db, alias,
FN_FROM_IS_TMP));
}
+
if (error)
{
/*
@@ -6473,6 +6540,7 @@ view_err:
goto err;
}
}
+
if (thd->lock || new_name != table_name || no_table_reopen) // True if WIN32
{
/*
@@ -6539,10 +6607,7 @@ view_err:
DBUG_ASSERT(!(mysql_bin_log.is_open() && thd->current_stmt_binlog_row_based &&
(create_info->options & HA_LEX_CREATE_TMP_TABLE)));
write_bin_log(thd, TRUE, thd->query, thd->query_length);
- /*
- TODO RONM: This problem needs to handled for Berkeley DB partitions
- as well
- */
+
if (ha_check_storage_engine_flag(old_db_type,HTON_FLUSH_AFTER_RENAME))
{
/*
| Thread |
|---|
| • bk commit into 5.1 tree (msvensson:1.2348) | msvensson | 5 Dec |