Below is the list of changes that have just been committed into a local
5.2 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
1.2161 06/03/07 09:04:31 msvensson@shellback.(none) +12 -0
Merge shellback.(none):/home/msvensson/mysql/mysql-5.1
into shellback.(none):/home/msvensson/mysql/mysql-5.2
sql/share/errmsg.txt
1.84 06/03/07 09:04:25 msvensson@shellback.(none) +0 -0
Auto merged
sql/sql_yacc.yy
1.464 06/03/07 09:04:24 msvensson@shellback.(none) +0 -0
Auto merged
sql/sql_trigger.cc
1.49 06/03/07 09:04:24 msvensson@shellback.(none) +0 -0
Auto merged
sql/item.h
1.193 06/03/07 09:04:24 msvensson@shellback.(none) +0 -0
Auto merged
sql/item.cc
1.170 06/03/07 09:04:24 msvensson@shellback.(none) +0 -0
Auto merged
sql/handler.cc
1.218 06/03/07 09:04:23 msvensson@shellback.(none) +0 -0
Auto merged
sql/ha_innodb.cc
1.259 06/03/07 09:04:23 msvensson@shellback.(none) +0 -0
Auto merged
scripts/make_binary_distribution.sh
1.112 06/03/07 09:04:23 msvensson@shellback.(none) +0 -0
Auto merged
mysql-test/t/innodb.test
1.131 06/03/07 09:04:23 msvensson@shellback.(none) +0 -0
Auto merged
mysql-test/r/innodb.result
1.166 06/03/07 09:04:23 msvensson@shellback.(none) +0 -0
Auto merged
mysql-test/lib/mtr_process.pl
1.29 06/03/07 09:04:23 msvensson@shellback.(none) +0 -0
Auto merged
configure.in
1.340 06/03/07 09:04:22 msvensson@shellback.(none) +0 -0
Auto merged
# 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: shellback.(none)
# Root: /home/msvensson/mysql/mysql-5.2/RESYNC
--- 1.339/configure.in 2006-02-22 21:22:44 +01:00
+++ 1.340/configure.in 2006-03-07 09:04:22 +01:00
@@ -334,6 +334,9 @@
# mysqld requires -fno-implicit-templates.
# Disable exceptions as they seams to create problems with gcc and threads.
# mysqld doesn't use run-time-type-checking, so we disable it.
+ # We should use -Wno-invalid-offsetof flag to disable some warnings from gcc
+ # regarding offset() usage in C++ which are done in a safe manner in the
+ # server
CXXFLAGS="$CXXFLAGS -fno-implicit-templates -fno-exceptions -fno-rtti"
AC_DEFINE([HAVE_EXPLICIT_TEMPLATE_INSTANTIATION],
[1], [Defined by configure. Use explicit template instantiation.])
@@ -589,10 +592,10 @@
# Make thread safe client
AC_ARG_ENABLE(thread-safe-client,
- [ --enable-thread-safe-client
- Compile the client with threads.],
+ [ --disable-thread-safe-client
+ Compile the client without threads.],
[ THREAD_SAFE_CLIENT=$enableval ],
- [ THREAD_SAFE_CLIENT=no ]
+ [ THREAD_SAFE_CLIENT=yes ]
)
# compile with strings functions in assembler
@@ -1564,7 +1567,8 @@
fi
AC_ARG_WITH(debug,
- [ --without-debug Build a production version without debugging code],
+ [ --with-debug Add debug code
+ --with-debug=full Add debug code (adds memory checker, very slow)],
[with_debug=$withval],
[with_debug=no])
if test "$with_debug" = "yes"
@@ -1587,8 +1591,8 @@
then
AC_ARG_WITH([fast-mutexes],
AC_HELP_STRING([--with-fast-mutexes],
- [compile with fast mutexes (default is enabled)]),
- [with_fast_mutexes=$withval], [with_fast_mutexes=yes])
+ [Compile with fast mutexes (default is disabled)]),
+ [with_fast_mutexes=$withval], [with_fast_mutexes=no])
fi
if test "$with_fast_mutexes" = "yes"
@@ -2471,6 +2475,8 @@
dnl client is just using plain-old libs.
sql_client_dirs="strings regex mysys libmysql client"
linked_client_targets="linked_libmysql_sources"
+
+AM_CONDITIONAL(THREAD_SAFE_CLIENT, test "$THREAD_SAFE_CLIENT" != "no")
if test "$THREAD_SAFE_CLIENT" != "no"
then
--- 1.217/sql/handler.cc 2006-02-22 00:45:33 +01:00
+++ 1.218/sql/handler.cc 2006-03-07 09:04:23 +01:00
@@ -64,7 +64,11 @@
NULL, NULL, NULL,
create_default,
NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- HTON_NO_FLAGS
+ NULL, /* alter_tablespace */
+ NULL, /* fill_files_table */
+ HTON_NO_FLAGS, /* flags */
+ NULL, /* binlog_func */
+ NULL /* binlog_log_query */
};
static SHOW_COMP_OPTION have_yes= SHOW_OPTION_YES;
@@ -3147,7 +3151,7 @@
bool check_table_binlog_row_based(THD *thd, TABLE *table)
{
return
- binlog_row_based &&
+ thd->current_stmt_binlog_row_based &&
thd && (thd->options & OPTION_BIN_LOG) &&
(table->s->tmp_table == NO_TMP_TABLE) &&
binlog_filter->db_ok(table->s->db.str);
--- 1.169/sql/item.cc 2006-02-22 00:45:34 +01:00
+++ 1.170/sql/item.cc 2006-03-07 09:04:24 +01:00
@@ -375,9 +375,6 @@
void Item::cleanup()
{
DBUG_ENTER("Item::cleanup");
- DBUG_PRINT("info", ("Item: 0x%lx, name %s, original name %s",
- this, name ? name : "(null)",
- orig_name ? orig_name : "null"));
fixed=0;
marker= 0;
if (orig_name)
@@ -5151,9 +5148,9 @@
if (item_ref->ref_type() == VIEW_REF)
{
Item *item_ref_ref= *(item_ref->ref);
- DBUG_ASSERT((*ref)->type() == FIELD_ITEM &&
- (item_ref_ref->type() == FIELD_ITEM));
- return (*ref == item_ref_ref);
+ DBUG_ASSERT((*ref)->real_item()->type() == FIELD_ITEM &&
+ (item_ref_ref->real_item()->type() == FIELD_ITEM));
+ return ((*ref)->real_item() == item_ref_ref->real_item());
}
}
return FALSE;
--- 1.192/sql/item.h 2006-02-22 00:45:34 +01:00
+++ 1.193/sql/item.h 2006-03-07 09:04:24 +01:00
@@ -164,7 +164,8 @@
virtual my_decimal *val_decimal(Hybrid_type *val, my_decimal *buf) const;
virtual String *val_str(Hybrid_type *val, String *buf, uint8 decimals) const;
static const Hybrid_type_traits *instance();
- Hybrid_type_traits() {};
+ Hybrid_type_traits() {}
+ virtual ~Hybrid_type_traits() {}
};
@@ -339,6 +340,7 @@
bool save_resolve_in_select_list;
public:
+ Name_resolution_context_state() {} /* Remove gcc warning */
TABLE_LIST *save_next_local;
public:
@@ -1055,6 +1057,7 @@
class Item_num: public Item
{
public:
+ Item_num() {} /* Remove gcc warning */
virtual Item_num *neg()= 0;
Item *safe_charset_converter(CHARSET_INFO *tocs);
};
@@ -1626,7 +1629,6 @@
str_value.length(), collation.collation);
}
Item *safe_charset_converter(CHARSET_INFO *tocs);
- String *const_string() { return &str_value; }
inline void append(char *str, uint length) { str_value.append(str, length); }
void print(String *str);
// to prevent drop fixed flag (no need parent cleanup call)
@@ -1928,9 +1930,10 @@
{
Item *ref;
public:
- Item_int_with_ref(longlong i, Item *ref_arg) :Item_int(i), ref(ref_arg)
+ Item_int_with_ref(longlong i, Item *ref_arg, my_bool unsigned_arg) :
+ Item_int(i), ref(ref_arg)
{
- unsigned_flag= ref_arg->unsigned_flag;
+ unsigned_flag= unsigned_arg;
}
int save_in_field(Field *field, bool no_conversions)
{
--- 1.463/sql/sql_yacc.yy 2006-02-22 21:22:45 +01:00
+++ 1.464/sql/sql_yacc.yy 2006-03-07 09:04:24 +01:00
@@ -48,12 +48,7 @@
#define yyoverflow(A,B,C,D,E,F) {ulong val= *(F); if (my_yyoverflow((B), (D), &val))
{ yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }}
-#define WARN_DEPRECATED(A,B) \
- push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN, \
- ER_WARN_DEPRECATED_SYNTAX, \
- ER(ER_WARN_DEPRECATED_SYNTAX), (A), (B));
-
-#define YYERROR_UNLESS(A) \
+#define YYERROR_UNLESS(A) \
if (!(A)) \
{ \
yyerror(ER(ER_SYNTAX_ERROR)); \
@@ -1343,7 +1338,7 @@
lex->create_info.options= $3;
- if (!(lex->et= new event_timed())) // implicitly calls event_timed::init()
+ if (!(lex->et= new Event_timed())) // implicitly calls Event_timed::init()
YYABORT;
/*
@@ -1419,6 +1414,8 @@
break;
case EVEX_BAD_PARAMS:
my_error(ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG, MYF(0));
+ case EVEX_MICROSECOND_UNSUP:
+ my_error(ER_NOT_SUPPORTED_YET, MYF(0), "MICROSECOND");
YYABORT;
break;
}
@@ -1474,6 +1471,9 @@
;
ev_starts: /* empty */
+ {
+ Lex->et->init_starts(YYTHD, new Item_func_now_local());
+ }
| STARTS_SYM expr
{
LEX *lex= Lex;
@@ -2463,10 +2463,10 @@
uint ip= sp->instructions();
uint n;
- n= ctx->diff_handlers(lab->ctx);
+ n= ctx->diff_handlers(lab->ctx, TRUE); /* Exclusive the dest. */
if (n)
sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
- n= ctx->diff_cursors(lab->ctx);
+ n= ctx->diff_cursors(lab->ctx, TRUE); /* Exclusive the dest. */
if (n)
sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
i= new sp_instr_jump(ip, ctx);
@@ -2495,10 +2495,10 @@
uint ip= sp->instructions();
uint n;
- n= ctx->diff_handlers(lab->ctx);
+ n= ctx->diff_handlers(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
sp->add_instr(new sp_instr_hpop(ip++, ctx, n));
- n= ctx->diff_cursors(lab->ctx);
+ n= ctx->diff_cursors(lab->ctx, FALSE); /* Inclusive the dest. */
if (n)
sp->add_instr(new sp_instr_cpop(ip++, ctx, n));
i= new sp_instr_jump(ip, ctx, lab->ip); /* Jump back */
@@ -3484,7 +3484,7 @@
uint expr_len= (uint)($4 - $2) - 1;
lex->part_info->list_of_part_fields= FALSE;
lex->part_info->part_expr= $3;
- lex->part_info->part_func_string= $2+1;
+ lex->part_info->part_func_string= (char* ) sql_memdup($2+1, expr_len);
lex->part_info->part_func_len= expr_len;
}
;
@@ -3496,7 +3496,7 @@
uint expr_len= (uint)($4 - $2) - 1;
lex->part_info->list_of_subpart_fields= FALSE;
lex->part_info->subpart_expr= $3;
- lex->part_info->subpart_func_string= $2+1;
+ lex->part_info->subpart_func_string= (char* ) sql_memdup($2+1, expr_len);
lex->part_info->subpart_func_len= expr_len;
}
;
@@ -4004,6 +4004,13 @@
create_table_option:
ENGINE_SYM opt_equal storage_engines { Lex->create_info.db_type= $3;
Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE; }
+ | TYPE_SYM opt_equal storage_engines
+ {
+ Lex->create_info.db_type= $3;
+ WARN_DEPRECATED(yythd, "5.2", "TYPE=storage_engine",
+ "'ENGINE=storage_engine'");
+ Lex->create_info.used_fields|= HA_CREATE_USED_ENGINE;
+ }
| MAX_ROWS opt_equal ulonglong_num { Lex->create_info.max_rows= $3;
Lex->create_info.used_fields|= HA_CREATE_USED_MAX_ROWS;}
| MIN_ROWS opt_equal ulonglong_num { Lex->create_info.min_rows= $3;
Lex->create_info.used_fields|= HA_CREATE_USED_MIN_ROWS;}
| AVG_ROW_LENGTH opt_equal ulong_num { Lex->create_info.avg_row_length=$3;
Lex->create_info.used_fields|= HA_CREATE_USED_AVG_ROW_LENGTH;}
@@ -4817,7 +4824,7 @@
*/
{
LEX *lex=Lex;
- event_timed *et;
+ Event_timed *et;
if (lex->et)
{
@@ -4830,7 +4837,7 @@
}
lex->spname= 0;//defensive programming
- if (!(et= new event_timed()))// implicitly calls event_timed::init()
+ if (!(et= new Event_timed()))// implicitly calls Event_timed::init()
YYABORT;
lex->et = et;
@@ -4906,7 +4913,7 @@
{
LEX *lex=Lex;
lex->spname= $3; //use lex's spname to hold the new name
- //the original name is in the event_timed object
+ //the original name is in the Event_timed object
$$= 1;
}
;
@@ -5360,11 +5367,8 @@
RESTORE_SYM table_or_tables
{
Lex->sql_command = SQLCOM_RESTORE_TABLE;
- push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DEPRECATED_STATEMENT,
- ER(ER_WARN_DEPRECATED_STATEMENT),
- "RESTORE TABLE", "5.2",
- "mysqldump, mysql, MySQL Administrator");
+ WARN_DEPRECATED(yythd, "5.2", "RESTORE TABLE",
+ "MySQL Administrator (mysqldump, mysql)");
}
table_list FROM TEXT_STRING_sys
{
@@ -5375,11 +5379,8 @@
BACKUP_SYM table_or_tables
{
Lex->sql_command = SQLCOM_BACKUP_TABLE;
- push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DEPRECATED_STATEMENT,
- ER(ER_WARN_DEPRECATED_STATEMENT),
- "BACKUP TABLE", "5.2",
- "mysqldump, mysql, MySQL Administrator");
+ WARN_DEPRECATED(yythd, "5.2", "BACKUP TABLE",
+ "MySQL Administrator (mysqldump, mysql)");
}
table_list TO_SYM TEXT_STRING_sys
{
@@ -7729,7 +7730,7 @@
YYABORT;
}
- if (!(lex->et= new event_timed()))
+ if (!(lex->et= new Event_timed()))
YYABORT;
if (!lex->et_compile_phase)
@@ -8222,7 +8223,7 @@
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_SHOW_STORAGE_ENGINES;
- WARN_DEPRECATED("SHOW TABLE TYPES", "SHOW [STORAGE] ENGINES");
+ WARN_DEPRECATED(yythd, "5.2", "SHOW TABLE TYPES", "'SHOW [STORAGE] ENGINES'");
}
| opt_storage ENGINES_SYM
{
@@ -8258,7 +8259,7 @@
lex->option_type= $1;
if (prepare_schema_table(YYTHD, lex, 0, SCH_STATUS))
YYABORT;
- }
+ }
| INNOBASE_SYM STATUS_SYM
{
LEX *lex= Lex;
@@ -8269,19 +8270,19 @@
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
YYABORT;
}
- WARN_DEPRECATED("SHOW INNODB STATUS", "SHOW ENGINE INNODB STATUS");
+ WARN_DEPRECATED(yythd, "5.2", "SHOW INNODB STATUS", "'SHOW ENGINE INNODB
STATUS'");
}
| MUTEX_SYM STATUS_SYM
{
LEX *lex= Lex;
- lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
+ lex->sql_command = SQLCOM_SHOW_ENGINE_MUTEX;
if (!(lex->create_info.db_type=
ha_resolve_by_legacy_type(YYTHD, DB_TYPE_INNODB)))
{
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "InnoDB");
YYABORT;
}
- WARN_DEPRECATED("SHOW MUTEX STATUS", "SHOW ENGINE INNODB MUTEX");
+ WARN_DEPRECATED(yythd, "5.2", "SHOW MUTEX STATUS", "'SHOW ENGINE INNODB
MUTEX'");
}
| opt_full PROCESSLIST_SYM
{ Lex->sql_command= SQLCOM_SHOW_PROCESSLIST;}
@@ -8320,7 +8321,7 @@
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "BerkeleyDB");
YYABORT;
}
- WARN_DEPRECATED("SHOW BDB LOGS", "SHOW ENGINE BDB LOGS");
+ WARN_DEPRECATED(yythd, "5.2", "SHOW BDB LOGS", "'SHOW ENGINE BDB LOGS'");
}
| LOGS_SYM
{
@@ -8332,7 +8333,7 @@
my_error(ER_UNKNOWN_STORAGE_ENGINE, MYF(0), "BerkeleyDB");
YYABORT;
}
- WARN_DEPRECATED("SHOW LOGS", "SHOW ENGINE BDB LOGS");
+ WARN_DEPRECATED(yythd, "5.2", "SHOW LOGS", "'SHOW ENGINE BDB LOGS'");
}
| GRANTS
{
@@ -8453,7 +8454,7 @@
{
Lex->sql_command = SQLCOM_SHOW_CREATE_EVENT;
Lex->spname= $3;
- Lex->et= new event_timed();
+ Lex->et= new Event_timed();
if (!Lex->et)
YYABORT;
Lex->et->init_definer(YYTHD);
@@ -8686,11 +8687,8 @@
LOAD TABLE_SYM table_ident FROM MASTER_SYM
{
LEX *lex=Lex;
- push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN,
- ER_WARN_DEPRECATED_STATEMENT,
- ER(ER_WARN_DEPRECATED_STATEMENT),
- "LOAD TABLE FROM MASTER", "5.2",
- "mysqldump, mysql, MySQL Administrator");
+ WARN_DEPRECATED(yythd, "5.2", "LOAD TABLE FROM MASTER",
+ "MySQL Administrator (mysqldump, mysql)");
if (lex->sphead)
{
my_error(ER_SP_BADSTATEMENT, MYF(0), "LOAD TABLE");
@@ -10929,7 +10927,7 @@
trigger_tail:
TRIGGER_SYM remember_name sp_name trg_action_time trg_event
- ON table_ident FOR_SYM EACH_SYM ROW_SYM
+ ON remember_name table_ident FOR_SYM remember_name EACH_SYM ROW_SYM
{
LEX *lex= Lex;
sp_head *sp;
@@ -10946,6 +10944,8 @@
sp->init(lex);
lex->trigger_definition_begin= $2;
+ lex->ident.str= $7;
+ lex->ident.length= $10 - $7;
sp->m_type= TYPE_ENUM_TRIGGER;
lex->sphead= sp;
@@ -10973,7 +10973,7 @@
sp->init_strings(YYTHD, lex, $3);
/* Restore flag if it was cleared above */
- YYTHD->client_capabilities |= $<ulong_num>11;
+ YYTHD->client_capabilities |= $<ulong_num>13;
sp->restore_thd_mem_root(YYTHD);
if (sp->is_not_allowed_in_function("trigger"))
@@ -10983,15 +10983,11 @@
We have to do it after parsing trigger body, because some of
sp_proc_stmt alternatives are not saving/restoring LEX, so
lex->query_tables can be wiped out.
-
- QQ: What are other consequences of this?
-
- QQ: Could we loosen lock type in certain cases ?
*/
- if (!lex->select_lex.add_table_to_list(YYTHD, $7,
+ if (!lex->select_lex.add_table_to_list(YYTHD, $8,
(LEX_STRING*) 0,
TL_OPTION_UPDATING,
- TL_WRITE))
+ TL_IGNORE))
YYABORT;
}
;
--- 1.83/sql/share/errmsg.txt 2006-02-22 21:22:45 +01:00
+++ 1.84/sql/share/errmsg.txt 2006-03-07 09:04:25 +01:00
@@ -5018,7 +5018,7 @@
ger "Unbekannte Speicher-Engine '%s'"
por "Motor de tabela desconhecido '%s'"
spa "Desconocido motor de tabla '%s'"
-ER_WARN_DEPRECATED_SYNTAX
+ER_UNUSED_1
eng "'%s' is deprecated; use '%s' instead"
ger "'%s' ist veraltet. Bitte benutzen Sie '%s'"
por "'%s' é desatualizado. Use '%s' em seu lugar"
@@ -5781,7 +5781,7 @@
eng "No datetime expression provided"
ER_COL_COUNT_DOESNT_MATCH_CORRUPTED
eng "Column count of mysql.%s is wrong. Expected %d, found %d. Table probably
corrupted"
-ER_EVENT_CANNOT_LOAD_FROM_TABLE
+ER_CANNOT_LOAD_FROM_TABLE
eng "Cannot load from mysql.%s. Table probably corrupted. See error log."
ER_EVENT_CANNOT_DELETE
eng "Failed to delete the event from mysql.event"
@@ -5810,10 +5810,14 @@
eng "Table storage engine '%-.64s' does not support the create option '%.64s'"
ER_CANT_CHANGE_TX_ISOLATION 25001
eng "Transaction isolation level can't be changed while a transaction is in progress"
-ER_WARN_DEPRECATED_STATEMENT
- eng "The '%s' statement is deprecated and will be removed in MySQL %s. Please
use client programs (e.g. %s) instead."
-
-ER_TABLE_NEEDS_UPGRADE
- eng "Table upgrade required. Please do \"REPAIR TABLE `%-.32s`\" to fix it!"
+ER_WARN_DEPRECATED
+ eng "The syntax '%s' is deprecated and will be removed in MySQL %s. Please use
%s instead."
ER_SP_NO_AGGREGATE 42000
eng "AGGREGATE is not supported for stored functions"
+ER_TEMP_TABLE_PREVENTS_SWITCH_OUT_OF_RBR
+ eng "Cannot switch out of the row-based binary log format when the session has open
temporary tables"
+ER_STORED_FUNCTION_PREVENTS_SWITCH_BINLOG_FORMAT
+ eng "Cannot change the binary logging format inside a stored function or trigger"
+ER_NDB_CANT_SWITCH_BINLOG_FORMAT
+ eng "The NDB cluster engine does not support changing the binlog format on the fly yet"
+
--- 1.48/sql/sql_trigger.cc 2006-02-15 01:23:52 +01:00
+++ 1.49/sql/sql_trigger.cc 2006-03-07 09:04:24 +01:00
@@ -65,7 +65,6 @@
*/
static const int TRG_NUM_REQUIRED_PARAMETERS= 4;
-static const int TRG_MAX_VERSIONS= 3;
/*
Structure representing contents of .TRN file which are used to support
@@ -318,8 +317,7 @@
{
LEX *lex= thd->lex;
TABLE *table= tables->table;
- char file_buff[FN_REFLEN], trigname_buff[FN_REFLEN],
- trigname_path[FN_REFLEN];
+ char file_buff[FN_REFLEN], trigname_buff[FN_REFLEN];
LEX_STRING file, trigname_file;
LEX_STRING *trg_def, *name;
ulonglong *trg_sql_mode;
@@ -472,12 +470,11 @@
definer_host->str, NullS) - trg_definer->str;
if (!sql_create_definition_file(NULL, &file, &triggers_file_type,
- (gptr)this, triggers_file_parameters,
- TRG_MAX_VERSIONS))
+ (gptr)this, triggers_file_parameters, 0))
return 0;
err_with_cleanup:
- my_delete(trigname_path, MYF(MY_WME));
+ my_delete(trigname_buff, MYF(MY_WME));
return 1;
}
@@ -497,7 +494,8 @@
True - error
*/
-static bool rm_trigger_file(char *path, char *db, char *table_name)
+static bool rm_trigger_file(char *path, const char *db,
+ const char *table_name)
{
build_table_filename(path, FN_REFLEN-1, db, table_name, triggers_file_ext);
return my_delete(path, MYF(MY_WME));
@@ -519,7 +517,8 @@
True - error
*/
-static bool rm_trigname_file(char *path, char *db, char *trigger_name)
+static bool rm_trigname_file(char *path, const char *db,
+ const char *trigger_name)
{
build_table_filename(path, FN_REFLEN-1, db, trigger_name, trigname_file_ext);
return my_delete(path, MYF(MY_WME));
@@ -527,6 +526,35 @@
/*
+ Helper function that saves .TRG file for Table_triggers_list object.
+
+ SYNOPSIS
+ save_trigger_file()
+ triggers Table_triggers_list object for which file should be saved
+ db Name of database for subject table
+ table_name Name of subject table
+
+ RETURN VALUE
+ FALSE Success
+ TRUE Error
+*/
+
+static bool save_trigger_file(Table_triggers_list *triggers, const char *db,
+ const char *table_name)
+{
+ char file_buff[FN_REFLEN];
+ LEX_STRING file;
+
+ file.length= build_table_filename(file_buff, FN_REFLEN-1, db, table_name,
+ triggers_file_ext);
+ file.str= file_buff;
+ return sql_create_definition_file(NULL, &file, &triggers_file_type,
+ (gptr)triggers, triggers_file_parameters,
+ 0);
+}
+
+
+/*
Drop trigger for table.
SYNOPSIS
@@ -579,16 +607,7 @@
}
else
{
- char file_buff[FN_REFLEN];
- LEX_STRING file;
-
- file.length= build_table_filename(file_buff, FN_REFLEN-1,
- tables->db, tables->table_name,
- triggers_file_ext);
- file.str= file_buff;
- if (sql_create_definition_file(NULL, &file, &triggers_file_type,
- (gptr)this, triggers_file_parameters,
- TRG_MAX_VERSIONS))
+ if (save_trigger_file(this, tables->db, tables->table_name))
return 1;
}
@@ -827,12 +846,12 @@
if (!names_only && triggers->prepare_record1_accessors(table))
DBUG_RETURN(1);
- char *trg_name_buff;
List_iterator_fast<ulonglong> itm(triggers->definition_modes_list);
List_iterator_fast<LEX_STRING> it_definer(triggers->definers_list);
LEX *old_lex= thd->lex, lex;
sp_rcontext *save_spcont= thd->spcont;
ulong save_sql_mode= thd->variables.sql_mode;
+ LEX_STRING *on_table_name;
thd->lex= &lex;
@@ -898,6 +917,21 @@
&table->mem_root))
goto err_with_lex_cleanup;
+ if (!(on_table_name= (LEX_STRING*) alloc_root(&table->mem_root,
+ sizeof(LEX_STRING))))
+ goto err_with_lex_cleanup;
+ *on_table_name= lex.ident;
+ if (triggers->on_table_names_list.push_back(on_table_name,
&table->mem_root))
+ goto err_with_lex_cleanup;
+
+ /*
+ Let us check that we correctly update trigger definitions when we
+ rename tables with triggers.
+ */
+ DBUG_ASSERT(!my_strcasecmp(table_alias_charset, lex.query_tables->db, db)
&&
+ !my_strcasecmp(table_alias_charset, lex.query_tables->table_name,
+ table_name));
+
if (names_only)
{
lex_end(&lex);
@@ -1063,7 +1097,7 @@
lex->query_tables= 0;
lex->query_tables_last= &lex->query_tables;
DBUG_RETURN(sp_add_to_query_tables(thd, lex, trig->m_db.str,
- trigname.trigger_table.str, TL_WRITE));
+ trigname.trigger_table.str, TL_IGNORE));
}
@@ -1132,6 +1166,219 @@
DBUG_RETURN(result);
}
+
+/*
+ Update .TRG file after renaming triggers' subject table
+ (change name of table in triggers' definitions).
+
+ SYNOPSIS
+ change_table_name_in_triggers()
+ thd Thread context
+ db_name Database of subject table
+ old_table_name Old subject table's name
+ new_table_name New subject table's name
+
+ RETURN VALUE
+ FALSE Success
+ TRUE Failure
+*/
+
+bool
+Table_triggers_list::change_table_name_in_triggers(THD *thd,
+ const char *db_name,
+ LEX_STRING *old_table_name,
+ LEX_STRING *new_table_name)
+{
+ char path_buff[FN_REFLEN];
+ LEX_STRING *def, *on_table_name, new_def;
+ ulonglong *sql_mode;
+ ulong save_sql_mode= thd->variables.sql_mode;
+ List_iterator_fast<LEX_STRING> it_def(definitions_list);
+ List_iterator_fast<LEX_STRING> it_on_table_name(on_table_names_list);
+ List_iterator_fast<ulonglong> it_mode(definition_modes_list);
+ uint on_q_table_name_len, before_on_len;
+ String buff;
+
+ DBUG_ASSERT(definitions_list.elements == on_table_names_list.elements &&
+ definitions_list.elements == definition_modes_list.elements);
+
+ while ((def= it_def++))
+ {
+ on_table_name= it_on_table_name++;
+ thd->variables.sql_mode= *(it_mode++);
+
+ /* Construct CREATE TRIGGER statement with new table name. */
+ buff.length(0);
+ before_on_len= on_table_name->str - def->str;
+ buff.append(def->str, before_on_len);
+ buff.append(STRING_WITH_LEN("ON "));
+ append_identifier(thd, &buff, new_table_name->str, new_table_name->length);
+ buff.append(STRING_WITH_LEN(" "));
+ on_q_table_name_len= buff.length() - before_on_len;
+ buff.append(on_table_name->str + on_table_name->length,
+ def->length - (before_on_len + on_table_name->length));
+ /*
+ It is OK to allocate some memory on table's MEM_ROOT since this
+ table instance will be thrown out at the end of rename anyway.
+ */
+ new_def.str= memdup_root(&table->mem_root, buff.ptr(), buff.length());
+ new_def.length= buff.length();
+ on_table_name->str= new_def.str + before_on_len;
+ on_table_name->length= on_q_table_name_len;
+ *def= new_def;
+ }
+
+ thd->variables.sql_mode= save_sql_mode;
+
+ if (thd->is_fatal_error)
+ return TRUE; /* OOM */
+
+ if (save_trigger_file(this, db_name, new_table_name->str))
+ return TRUE;
+ if (rm_trigger_file(path_buff, db_name, old_table_name->str))
+ {
+ (void) rm_trigger_file(path_buff, db_name, new_table_name->str);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/*
+ Iterate though Table_triggers_list::names_list list and update .TRN files
+ after renaming triggers' subject table.
+
+ SYNOPSIS
+ change_table_name_in_trignames()
+ db_name Database of subject table
+ new_table_name New subject table's name
+ stopper Pointer to Table_triggers_list::names_list at
+ which we should stop updating.
+
+ RETURN VALUE
+ 0 Success
+ non-0 Failure, pointer to Table_triggers_list::names_list element
+ for which update failed.
+*/
+
+LEX_STRING*
+Table_triggers_list::change_table_name_in_trignames(const char *db_name,
+ LEX_STRING *new_table_name,
+ LEX_STRING *stopper)
+{
+ char trigname_buff[FN_REFLEN];
+ struct st_trigname trigname;
+ LEX_STRING trigname_file;
+ LEX_STRING *trigger;
+ List_iterator_fast<LEX_STRING> it_name(names_list);
+
+ while ((trigger= it_name++) != stopper)
+ {
+ trigname_file.length= build_table_filename(trigname_buff, FN_REFLEN-1,
+ db_name, trigger->str,
+ trigname_file_ext);
+ trigname_file.str= trigname_buff;
+
+ trigname.trigger_table= *new_table_name;
+
+ if (sql_create_definition_file(NULL, &trigname_file, &trigname_file_type,
+ (gptr)&trigname, trigname_file_parameters,
+ 0))
+ return trigger;
+ }
+
+ return 0;
+}
+
+
+/*
+ Update .TRG and .TRN files after renaming triggers' subject table.
+
+ SYNOPSIS
+ change_table_name()
+ thd Thread context
+ db Old database of subject table
+ old_table Old name of subject table
+ new_db New database for subject table
+ new_table New name of subject table
+
+ NOTE
+ This method tries to leave trigger related files in consistent state,
+ i.e. it either will complete successfully, or will fail leaving files
+ in their initial state.
+
+ RETURN VALUE
+ FALSE Success
+ TRUE Error
+*/
+
+bool Table_triggers_list::change_table_name(THD *thd, const char *db,
+ const char *old_table,
+ const char *new_db,
+ const char *new_table)
+{
+ TABLE table;
+ bool result= 0;
+ LEX_STRING *err_trigname;
+ DBUG_ENTER("change_table_name");
+
+ bzero(&table, sizeof(table));
+ init_alloc_root(&table.mem_root, 8192, 0);
+
+ safe_mutex_assert_owner(&LOCK_open);
+
+ if (Table_triggers_list::check_n_load(thd, db, old_table, &table, TRUE))
+ {
+ result= 1;
+ goto end;
+ }
+ if (table.triggers)
+ {
+ LEX_STRING_WITH_INIT old_table_name(old_table, strlen(old_table));
+ LEX_STRING_WITH_INIT new_table_name(new_table, strlen(new_table));
+ /*
+ Since triggers should be in the same schema as their subject tables
+ moving table with them between two schemas raises too many questions.
+ (E.g. what should happen if in new schema we already have trigger
+ with same name ?).
+ */
+ if (my_strcasecmp(table_alias_charset, db, new_db))
+ {
+ my_error(ER_TRG_IN_WRONG_SCHEMA, MYF(0));
+ result= 1;
+ goto end;
+ }
+ if (table.triggers->change_table_name_in_triggers(thd, db,
+ &old_table_name,
+ &new_table_name))
+ {
+ result= 1;
+ goto end;
+ }
+ if ((err_trigname= table.triggers->change_table_name_in_trignames(
+ db, &new_table_name, 0)))
+ {
+ /*
+ If we were unable to update one of .TRN files properly we will
+ revert all changes that we have done and report about error.
+ We assume that we will be able to undo our changes without errors
+ (we can't do much if there will be an error anyway).
+ */
+ (void) table.triggers->change_table_name_in_trignames(db,
+ &old_table_name,
+ err_trigname);
+ (void) table.triggers->change_table_name_in_triggers(thd, db,
+ &new_table_name,
+ &old_table_name);
+ result= 1;
+ goto end;
+ }
+ }
+end:
+ delete table.triggers;
+ free_root(&table.mem_root, MYF(0));
+ DBUG_RETURN(result);
+}
bool Table_triggers_list::process_triggers(THD *thd, trg_event_type event,
--- 1.258/sql/ha_innodb.cc 2006-02-15 01:23:52 +01:00
+++ 1.259/sql/ha_innodb.cc 2006-03-07 09:04:23 +01:00
@@ -237,8 +237,11 @@
innobase_show_status, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
+ NULL, /* alter_tablespace */
NULL, /* Fill FILES table */
- HTON_NO_FLAGS
+ HTON_NO_FLAGS,
+ NULL, /* binlog_func */
+ NULL /* binlog_log_query */
};
| Thread |
|---|
| • bk commit into 5.2 tree (msvensson:1.2161) | msvensson | 7 Mar |