Below is the list of changes that have just been committed into a local
5.2 repository of emurphy. When emurphy 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/16 09:44:44 elliot@stripped +11 -0
Merge mysql.com:/home/emurphy/src/mysql/bk-clean/tmp_merge
into mysql.com:/home/emurphy/src/mysql/bk-clean/mysql-5.2-merge
sql/sql_yacc.yy
1.465 06/03/16 09:44:34 elliot@stripped +0 -0
Auto merged
sql/sql_trigger.cc
1.53 06/03/16 09:44:34 elliot@stripped +0 -0
Auto merged
sql/item.cc
1.174 06/03/16 09:44:34 elliot@stripped +0 -0
Auto merged
sql/handler.cc
1.221 06/03/16 09:44:33 elliot@stripped +0 -0
Auto merged
sql/ha_innodb.cc
1.262 06/03/16 09:44:33 elliot@stripped +0 -0
Auto merged
mysql-test/t/trigger-grant.test
1.10 06/03/16 09:44:33 elliot@stripped +0 -4
Auto merged
mysql-test/t/innodb.test
1.134 06/03/16 09:44:33 elliot@stripped +0 -0
Auto merged
mysql-test/r/trigger-grant.result
1.7 06/03/16 09:44:33 elliot@stripped +0 -0
Auto merged
mysql-test/r/innodb.result
1.168 06/03/16 09:44:33 elliot@stripped +0 -0
Auto merged
mysql-test/mysql-test-run.pl
1.86 06/03/16 09:44:33 elliot@stripped +0 -0
Auto merged
configure.in
1.343 06/03/16 09:44:33 elliot@stripped +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: elliot
# Host: xan.(none)
# Root: /home/emurphy/src/mysql/bk-clean/mysql-5.2-merge/RESYNC
--- 1.342/configure.in 2006-03-08 15:21:03 +01:00
+++ 1.343/configure.in 2006-03-16 09:44:33 +01:00
@@ -214,7 +214,7 @@
test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
# Not critical since the generated file is distributed
-AC_PROG_YACC
+AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL'])
AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf)
AC_CHECK_PROG(DVIS, tex, manual.dvi)
--- 1.220/sql/handler.cc 2006-03-08 15:21:04 +01:00
+++ 1.221/sql/handler.cc 2006-03-16 09:44:33 +01:00
@@ -3137,10 +3137,12 @@
correct for the table.
A row in the given table should be replicated if:
- - Row-based replication is on
- - It is not a temporary table
+ - Row-based replication is enabled in the current thread
- The binlog is enabled
- - The table shall be binlogged (binlog_*_db rules)
+ - It is not a temporary table
+ - The binary log is open
+ - The database the table resides in shall be binlogged (binlog_*_db rules)
+ - table is not mysql.event
*/
#ifdef HAVE_ROW_BASED_REPLICATION
@@ -3154,7 +3156,10 @@
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);
+ mysql_bin_log.is_open() &&
+ binlog_filter->db_ok(table->s->db.str) &&
+ (strcmp(table->s->db.str, "mysql") ||
+ strcmp(table->s->table_name.str, "event"));
}
}
@@ -3204,40 +3209,81 @@
#endif /* HAVE_ROW_BASED_REPLICATION */
-int handler::ha_write_row(byte *buf)
+int handler::ha_external_lock(THD *thd, int lock_type)
{
+ DBUG_ENTER("handler::ha_external_lock");
int error;
- if (likely(!(error= write_row(buf))))
+ if (unlikely(error= external_lock(thd, lock_type)))
+ DBUG_RETURN(error);
+#ifdef HAVE_ROW_BASED_REPLICATION
+ if (table->file->is_injective())
+ DBUG_RETURN(0);
+
+ /*
+ There is a number of statements that are logged statement-based
+ but call external lock. For these, we do not need to generate a
+ table map.
+
+ TODO: The need for this switch is an indication that the model for
+ locking combined with row-based replication needs to be looked
+ over. Ideally, no such special handling should be needed.
+ */
+ switch (thd->lex->sql_command)
{
+ case SQLCOM_TRUNCATE:
+ case SQLCOM_ALTER_TABLE:
+ DBUG_RETURN(0);
+ }
+
+ /*
+ If we are locking a table for writing, we generate a table map.
+ For all other kinds of locks, we don't do anything.
+ */
+ if (lock_type == F_WRLCK && check_table_binlog_row_based(thd, table))
+ {
+ int const has_trans= table->file->has_transactions();
+ error= thd->binlog_write_table_map(table, has_trans);
+ if (unlikely(error))
+ DBUG_RETURN(error);
+ }
+#endif
+ DBUG_RETURN(0);
+}
+
+int handler::ha_write_row(byte *buf)
+{
+ int error;
+ if (unlikely(error= write_row(buf)))
+ return error;
#ifdef HAVE_ROW_BASED_REPLICATION
- error= binlog_log_row<Write_rows_log_event>(table, 0, buf);
+ if (unlikely(error= binlog_log_row<Write_rows_log_event>(table, 0, buf)))
+ return error;
#endif
- }
- return error;
+ return 0;
}
int handler::ha_update_row(const byte *old_data, byte *new_data)
{
int error;
- if (likely(!(error= update_row(old_data, new_data))))
- {
+ if (unlikely(error= update_row(old_data, new_data)))
+ return error;
#ifdef HAVE_ROW_BASED_REPLICATION
- error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data);
+ if (unlikely(error= binlog_log_row<Update_rows_log_event>(table, old_data, new_data)))
+ return error;
#endif
- }
- return error;
+ return 0;
}
int handler::ha_delete_row(const byte *buf)
{
int error;
- if (likely(!(error= delete_row(buf))))
- {
+ if (unlikely(error= delete_row(buf)))
+ return error;
#ifdef HAVE_ROW_BASED_REPLICATION
- error= binlog_log_row<Delete_rows_log_event>(table, buf, 0);
+ if (unlikely(error= binlog_log_row<Delete_rows_log_event>(table, buf, 0)))
+ return error;
#endif
- }
- return error;
+ return 0;
}
--- 1.464/sql/sql_yacc.yy 2006-03-08 19:06:08 +01:00
+++ 1.465/sql/sql_yacc.yy 2006-03-16 09:44:34 +01:00
@@ -826,7 +826,7 @@
%type <symbol> FUNC_ARG0 FUNC_ARG1 FUNC_ARG2 FUNC_ARG3 keyword keyword_sp
-%type <lex_user> user grant_user get_definer
+%type <lex_user> user grant_user
%type <charset>
opt_collate
@@ -881,8 +881,9 @@
sp_c_chistics sp_a_chistics sp_chistic sp_c_chistic xa
load_data opt_field_or_var_spec fields_or_vars opt_load_data_set_spec
definer view_replace_or_algorithm view_replace view_algorithm_opt
- view_algorithm view_or_trigger_tail view_suid view_tail view_list_opt
- view_list view_select view_check_option trigger_tail
+ view_algorithm view_or_trigger_or_sp view_or_trigger_or_sp_tail
+ view_suid view_tail view_list_opt view_list view_select
+ view_check_option trigger_tail sp_tail
install uninstall partition_entry binlog_base64_event
END_OF_INPUT
@@ -1252,78 +1253,6 @@
lex->name=$4.str;
lex->create_info.options=$3;
}
- | CREATE udf_func_type FUNCTION_SYM sp_name
- {
- LEX *lex=Lex;
- lex->spname= $4;
- lex->udf.type= $2;
- }
- create_function_tail
- {}
- | CREATE PROCEDURE sp_name
- {
- LEX *lex= Lex;
- sp_head *sp;
-
- if (lex->sphead)
- {
- my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "PROCEDURE");
- YYABORT;
- }
- /* Order is important here: new - reset - init */
- sp= new sp_head();
- sp->reset_thd_mem_root(YYTHD);
- sp->init(lex);
-
- sp->m_type= TYPE_ENUM_PROCEDURE;
- lex->sphead= sp;
- /*
- * We have to turn of CLIENT_MULTI_QUERIES while parsing a
- * stored procedure, otherwise yylex will chop it into pieces
- * at each ';'.
- */
- $<ulong_num>$= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES;
- YYTHD->client_capabilities &= (~CLIENT_MULTI_QUERIES);
- }
- '('
- {
- LEX *lex= Lex;
-
- lex->sphead->m_param_begin= lex->tok_start+1;
- }
- sp_pdparam_list
- ')'
- {
- LEX *lex= Lex;
-
- lex->sphead->m_param_end= lex->tok_start;
- bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
- }
- sp_c_chistics
- {
- LEX *lex= Lex;
-
- lex->sphead->m_chistics= &lex->sp_chistics;
- lex->sphead->m_body_begin= lex->tok_start;
- }
- sp_proc_stmt
- {
- LEX *lex= Lex;
- sp_head *sp= lex->sphead;
-
- if (sp->check_backpatch(YYTHD))
- YYABORT;
- sp->init_strings(YYTHD, lex, $3);
- lex->sql_command= SQLCOM_CREATE_PROCEDURE;
-
- /*
- Restore flag if it was cleared above
- Be careful with counting. the block where we save the value
- is $4.
- */
- YYTHD->client_capabilities |= $<ulong_num>4;
- sp->restore_thd_mem_root(YYTHD);
- }
| CREATE EVENT_SYM opt_if_not_exists sp_name
/*
BE CAREFUL when you add a new rule to update the block where
@@ -1390,7 +1319,7 @@
Lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED;
Lex->create_view_suid= TRUE;
}
- view_or_trigger
+ view_or_trigger_or_sp
{}
| CREATE USER clear_privileges grant_list
{
@@ -5024,7 +4953,7 @@
;
all_or_alt_part_name_list:
- | ALL
+ ALL
{
Lex->alter_info.flags|= ALTER_ALL_PARTITION;
}
@@ -10783,45 +10712,61 @@
lex->nest_level--;
};
+/**************************************************************************
+
+ CREATE VIEW | TRIGGER | PROCEDURE statements.
+
+**************************************************************************/
+
+view_or_trigger_or_sp:
+ definer view_or_trigger_or_sp_tail
+ {}
+ | view_replace_or_algorithm definer view_tail
+ {}
+ ;
+
+view_or_trigger_or_sp_tail:
+ view_tail
+ {}
+ | trigger_tail
+ {}
+ | sp_tail
+ {}
+ ;
+
+/**************************************************************************
+
+ DEFINER clause support.
+
+**************************************************************************/
+
definer:
- get_definer
+ /* empty */
{
- THD *thd= YYTHD;
-
- if (! (thd->lex->definer= create_definer(thd, &$1->user, &$1->host)))
- YYABORT;
+ /*
+ We have to distinguish missing DEFINER-clause from case when
+ CURRENT_USER specified as definer explicitly in order to properly
+ handle CREATE TRIGGER statements which come to replication thread
+ from older master servers (i.e. to create non-suid trigger in this
+ case).
+ */
+ YYTHD->lex->definer= 0;
}
- ;
-
-get_definer:
- opt_current_definer
+ | DEFINER_SYM EQ CURRENT_USER optional_braces
{
- THD *thd= YYTHD;
-
- if (!($$=(LEX_USER*) thd->alloc(sizeof(st_lex_user))))
- YYABORT;
-
- if (get_default_definer(thd, $$))
- YYABORT;
+ if (! (YYTHD->lex->definer= create_default_definer(YYTHD)))
+ YYABORT;
}
| DEFINER_SYM EQ ident_or_text '@' ident_or_text
{
- if (!($$=(LEX_USER*) YYTHD->alloc(sizeof(st_lex_user))))
- YYABORT;
-
- $$->user= $3;
- $$->host= $5;
+ if (!(YYTHD->lex->definer= create_definer(YYTHD, &$3, &$5)))
+ YYABORT;
}
;
-opt_current_definer:
- /* empty */
- | DEFINER_SYM EQ CURRENT_USER optional_braces
- ;
-
/**************************************************************************
- CREATE VIEW statement options.
+ CREATE VIEW statement parts.
**************************************************************************/
@@ -10855,20 +10800,6 @@
{}
;
-view_or_trigger:
- definer view_or_trigger_tail
- {}
- | view_replace_or_algorithm definer view_tail
- {}
- ;
-
-view_or_trigger_tail:
- view_tail
- {}
- | trigger_tail
- {}
- ;
-
view_suid:
/* empty */
{ Lex->create_view_suid= TRUE; }
@@ -10967,7 +10898,7 @@
sp->reset_thd_mem_root(YYTHD);
sp->init(lex);
- lex->trigger_definition_begin= $2;
+ lex->stmt_definition_begin= $2;
lex->ident.str= $7;
lex->ident.length= $10 - $7;
@@ -11013,6 +10944,90 @@
TL_OPTION_UPDATING,
TL_IGNORE))
YYABORT;
+ }
+ ;
+
+/**************************************************************************
+
+ CREATE FUNCTION | PROCEDURE statements parts.
+
+**************************************************************************/
+
+sp_tail:
+ udf_func_type remember_name FUNCTION_SYM sp_name
+ {
+ LEX *lex=Lex;
+ lex->udf.type= $1;
+ lex->stmt_definition_begin= $2;
+ lex->spname= $4;
+ }
+ create_function_tail
+ {}
+ | PROCEDURE remember_name sp_name
+ {
+ LEX *lex= Lex;
+ sp_head *sp;
+
+ if (lex->sphead)
+ {
+ my_error(ER_SP_NO_RECURSIVE_CREATE, MYF(0), "PROCEDURE");
+ YYABORT;
+ }
+
+ lex->stmt_definition_begin= $2;
+
+ /* Order is important here: new - reset - init */
+ sp= new sp_head();
+ sp->reset_thd_mem_root(YYTHD);
+ sp->init(lex);
+
+ sp->m_type= TYPE_ENUM_PROCEDURE;
+ lex->sphead= sp;
+ /*
+ * We have to turn of CLIENT_MULTI_QUERIES while parsing a
+ * stored procedure, otherwise yylex will chop it into pieces
+ * at each ';'.
+ */
+ $<ulong_num>$= YYTHD->client_capabilities & CLIENT_MULTI_QUERIES;
+ YYTHD->client_capabilities &= (~CLIENT_MULTI_QUERIES);
+ }
+ '('
+ {
+ LEX *lex= Lex;
+
+ lex->sphead->m_param_begin= lex->tok_start+1;
+ }
+ sp_pdparam_list
+ ')'
+ {
+ LEX *lex= Lex;
+
+ lex->sphead->m_param_end= lex->tok_start;
+ bzero((char *)&lex->sp_chistics, sizeof(st_sp_chistics));
+ }
+ sp_c_chistics
+ {
+ LEX *lex= Lex;
+
+ lex->sphead->m_chistics= &lex->sp_chistics;
+ lex->sphead->m_body_begin= lex->tok_start;
+ }
+ sp_proc_stmt
+ {
+ LEX *lex= Lex;
+ sp_head *sp= lex->sphead;
+
+ if (sp->check_backpatch(YYTHD))
+ YYABORT;
+ sp->init_strings(YYTHD, lex, $3);
+ lex->sql_command= SQLCOM_CREATE_PROCEDURE;
+ /*
+ Restore flag if it was cleared above
+ Be careful with counting. the block where we save the value
+ is $4.
+ */
+ YYTHD->client_capabilities |= $<ulong_num>4;
+ sp->restore_thd_mem_root(YYTHD);
}
;
--- 1.6/mysql-test/r/trigger-grant.result 2006-02-09 16:32:54 +01:00
+++ 1.7/mysql-test/r/trigger-grant.result 2006-03-16 09:44:33 +01:00
@@ -135,6 +135,7 @@
Warnings:
Note 1449 There is no 'mysqltest_nonexs'@'localhost' registered
INSERT INTO t1 VALUES(6);
+ERROR HY000: There is no 'mysqltest_nonexs'@'localhost' registered
SHOW TRIGGERS;
Trigger Event Table Statement Timing Created sql_mode Definer
trg1 INSERT t1 SET @new_sum = 0 BEFORE NULL mysqltest_inv@localhost
--- 1.9/mysql-test/t/trigger-grant.test 2006-03-08 19:06:07 +01:00
+++ 1.10/mysql-test/t/trigger-grant.test 2006-03-16 09:44:33 +01:00
@@ -317,10 +317,7 @@
# Check that trg2 will not be activated.
-# --error ER_SPECIFIC_ACCESS_DENIED_ERROR
-#
-# TODO: Due to the BUG#13198(SP executes if definer does not exist) the
-# following statement does not fail as it should.
+--error ER_NO_SUCH_USER
INSERT INTO t1 VALUES(6);
#
--- 1.52/sql/sql_trigger.cc 2006-03-08 19:06:08 +01:00
+++ 1.53/sql/sql_trigger.cc 2006-03-16 09:44:34 +01:00
@@ -15,6 +15,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+#define MYSQL_LEX 1
#include "mysql_priv.h"
#include "sp_head.h"
#include "sql_trigger.h"
@@ -270,8 +271,18 @@
log_query.set((char *) 0, 0, system_charset_info); /* reset log_query */
log_query.append(STRING_WITH_LEN("CREATE "));
- append_definer(thd, &log_query, &definer_user, &definer_host);
- log_query.append(thd->lex->trigger_definition_begin);
+
+ if (definer_user.str && definer_host.str)
+ {
+ /*
+ Append definer-clause if the trigger is SUID (a usual trigger in
+ new MySQL versions).
+ */
+
+ append_definer(thd, &log_query, &definer_user, &definer_host);
+ }
+
+ log_query.append(thd->lex->stmt_definition_begin);
}
/* Such a statement can always go directly to binlog, no trans cache. */
@@ -295,17 +306,30 @@
LEX)
tables - table list containing one open table for which the
trigger is created.
- definer_user - [out] after a call it points to 0-terminated string,
- which contains user name part of the actual trigger
- definer. The caller is responsible to provide memory for
+ definer_user - [out] after a call it points to 0-terminated string or
+ contains the NULL-string:
+ - 0-terminated is returned if the trigger is SUID. The
+ string contains user name part of the actual trigger
+ definer.
+ - NULL-string is returned if the trigger is non-SUID.
+ Anyway, the caller is responsible to provide memory for
storing LEX_STRING object.
- definer_host - [out] after a call it points to 0-terminated string,
- which contains host name part of the actual trigger
- definer. The caller is responsible to provide memory for
+ definer_host - [out] after a call it points to 0-terminated string or
+ contains the NULL-string:
+ - 0-terminated string is returned if the trigger is
+ SUID. The string contains host name part of the
+ actual trigger definer.
+ - NULL-string is returned if the trigger is non-SUID.
+ Anyway, the caller is responsible to provide memory for
storing LEX_STRING object.
NOTE
- Assumes that trigger name is fully qualified.
+ - Assumes that trigger name is fully qualified.
+ - NULL-string means the following LEX_STRING instance:
+ { str = 0; length = 0 }.
+ - In other words, definer_user and definer_host should contain
+ simultaneously NULL-strings (non-SUID/old trigger) or valid strings
+ (SUID/new trigger).
RETURN VALUE
False - success
@@ -342,12 +366,30 @@
return 1;
}
- /*
- Definer attribute of the Lex instance is always set in sql_yacc.yy when
- trigger is created.
- */
+ if (!lex->definer)
+ {
+ /*
+ DEFINER-clause is missing.
- DBUG_ASSERT(lex->definer);
+ If we are in slave thread, this means that we received CREATE TRIGGER
+ from the master, that does not support definer in triggers. So, we
+ should mark this trigger as non-SUID. Note that this does not happen
+ when we parse triggers' definitions during opening .TRG file.
+ LEX::definer is ignored in that case.
+
+ Otherwise, we should use CURRENT_USER() as definer.
+
+ NOTE: when CREATE TRIGGER statement is allowed to be executed in PS/SP,
+ it will be required to create the definer below in persistent MEM_ROOT
+ of PS/SP.
+ */
+
+ if (!thd->slave_thread)
+ {
+ if (!(lex->definer= create_default_definer(thd)))
+ return 1;
+ }
+ }
/*
If the specified definer differs from the current user, we should check
@@ -355,10 +397,11 @@
under another user one must have SUPER privilege).
*/
- if (strcmp(lex->definer->user.str, thd->security_ctx->priv_user) ||
- my_strcasecmp(system_charset_info,
- lex->definer->host.str,
- thd->security_ctx->priv_host))
+ if (lex->definer &&
+ (strcmp(lex->definer->user.str, thd->security_ctx->priv_user) ||
+ my_strcasecmp(system_charset_info,
+ lex->definer->host.str,
+ thd->security_ctx->priv_host)))
{
if (check_global_access(thd, SUPER_ACL))
{
@@ -450,8 +493,8 @@
*trg_sql_mode= thd->variables.sql_mode;
#ifndef NO_EMBEDDED_ACCESS_CHECKS
- if (!is_acl_user(lex->definer->host.str,
- lex->definer->user.str))
+ if (lex->definer && !is_acl_user(lex->definer->host.str,
+ lex->definer->user.str))
{
push_warning_printf(thd,
MYSQL_ERROR::WARN_LEVEL_NOTE,
@@ -462,12 +505,30 @@
}
#endif /* NO_EMBEDDED_ACCESS_CHECKS */
- *definer_user= lex->definer->user;
- *definer_host= lex->definer->host;
+ if (lex->definer)
+ {
+ /* SUID trigger. */
+
+ *definer_user= lex->definer->user;
+ *definer_host= lex->definer->host;
- trg_definer->str= trg_definer_holder;
- trg_definer->length= strxmov(trg_definer->str, definer_user->str, "@",
- definer_host->str, NullS) - trg_definer->str;
+ trg_definer->str= trg_definer_holder;
+ trg_definer->length= strxmov(trg_definer->str, definer_user->str, "@",
+ definer_host->str, NullS) - trg_definer->str;
+ }
+ else
+ {
+ /* non-SUID trigger. */
+
+ definer_user->str= 0;
+ definer_user->length= 0;
+
+ definer_host->str= 0;
+ definer_host->length= 0;
+
+ trg_definer->str= (char*) "";
+ trg_definer->length= 0;
+ }
if (!sql_create_definition_file(NULL, &file, &triggers_file_type,
(gptr)this, triggers_file_parameters, 0))
@@ -868,7 +929,7 @@
lex_start(thd, (uchar*)trg_create_str->str, trg_create_str->length);
thd->spcont= 0;
- if (yyparse((void *)thd) || thd->is_fatal_error)
+ if (MYSQLparse((void *)thd) || thd->is_fatal_error)
{
/*
Free lex associated resources.
--- 1.85/mysql-test/mysql-test-run.pl 2006-03-09 19:06:06 +01:00
+++ 1.86/mysql-test/mysql-test-run.pl 2006-03-16 09:44:33 +01:00
@@ -157,6 +157,7 @@
our $path_client_bindir;
our $path_language;
our $path_timefile;
+our $path_snapshot;
our $path_manager_log; # Used by mysqldadmin
our $path_slave_load_tmpdir; # What is this?!
our $path_mysqltest_log;
@@ -198,7 +199,6 @@
our @opt_extra_mysqld_opt;
-our $opt_comment;
our $opt_compress;
our $opt_ssl;
our $opt_skip_ssl;
@@ -320,11 +320,14 @@
our $exe_ndb_mgm;
our $path_ndb_tools_dir;
-our $path_ndb_backup_dir;
+our $path_ndb_data_dir;
+our $path_ndb_slave_data_dir;
our $file_ndb_testrun_log;
our $flag_ndb_status_ok= 1;
our $flag_ndb_slave_status_ok= 1;
+our @data_dir_lst;
+
######################################################################
#
# Function declarations
@@ -405,9 +408,10 @@
{
kill_and_cleanup();
mysql_install_db();
-
-# mysql_loadstd(); FIXME copying from "std_data" .frm and
-# .MGR but there are none?!
+ if ( $opt_force )
+ {
+ save_installed_db();
+ }
}
}
@@ -670,14 +674,6 @@
print '#' x 78, "\n\n";
}
- if ( $opt_comment )
- {
- print "\n";
- print '#' x 78, "\n";
- print "# $opt_comment\n";
- print '#' x 78, "\n\n";
- }
-
foreach my $arg ( @ARGV )
{
if ( $arg =~ /^--skip-/ )
@@ -978,6 +974,22 @@
$path_timefile= "$opt_vardir/log/mysqltest-time";
$path_mysqltest_log= "$opt_vardir/log/mysqltest.log";
+
+ $path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
+
+ # Make a list of all data_dirs
+ @data_dir_lst = (
+ $master->[0]->{'path_myddir'},
+ $master->[1]->{'path_myddir'},
+ $slave->[0]->{'path_myddir'},
+ $slave->[1]->{'path_myddir'},
+ $slave->[2]->{'path_myddir'});
+
+ foreach my $instance (@{$instance_manager->{'instances'}})
+ {
+ push(@data_dir_lst, $instance->{'path_datadir'});
+ }
+
}
@@ -1127,8 +1139,8 @@
$exe_master_mysqld= $exe_master_mysqld || $exe_mysqld;
$exe_slave_mysqld= $exe_slave_mysqld || $exe_mysqld;
- $path_ndb_backup_dir=
- "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
+ $path_ndb_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port";
+ $path_ndb_slave_data_dir= "$opt_vardir/ndbcluster-$opt_ndbcluster_port_slave";
$file_ndb_testrun_log= "$opt_vardir/log/ndb_testrun.log";
}
@@ -1311,21 +1323,7 @@
mkpath("$opt_vardir/tmp");
mkpath($opt_tmpdir) if $opt_tmpdir ne "$opt_vardir/tmp";
- # FIXME do we really need to create these all, or are they
- # created for us when tables are created?
-
- my @data_dir_lst = (
- $master->[0]->{'path_myddir'},
- $master->[1]->{'path_myddir'},
- $slave->[0]->{'path_myddir'},
- $slave->[1]->{'path_myddir'},
- $slave->[2]->{'path_myddir'});
-
- foreach my $instance (@{$instance_manager->{'instances'}})
- {
- push(@data_dir_lst, $instance->{'path_datadir'});
- }
-
+ # Remove old and create new data dirs
foreach my $data_dir (@data_dir_lst)
{
rmtree("$data_dir");
@@ -2241,10 +2239,9 @@
report_failure_and_restart($tinfo);
}
# Save info from this testcase run to mysqltest.log
+ my $testcase_log= mtr_fromfile($path_timefile) if -f $path_timefile;
mtr_tofile($path_mysqltest_log,"CURRENT TEST $tname\n");
- my $testcase_log= mtr_fromfile($path_timefile);
- mtr_tofile($path_mysqltest_log,
- $testcase_log);
+ mtr_tofile($path_mysqltest_log, $testcase_log);
}
# ----------------------------------------------------------------------
@@ -2258,6 +2255,80 @@
}
}
+sub copy_dir($$) {
+ my $from_dir= shift;
+ my $to_dir= shift;
+
+ mkpath("$to_dir");
+ opendir(DIR, "$from_dir")
+ or mtr_error("Can't find $from_dir$!");
+ for(readdir(DIR)) {
+ next if "$_" eq "." or "$_" eq "..";
+ if ( -d "$from_dir/$_" )
+ {
+ copy_dir("$from_dir/$_", "$to_dir/$_");
+ next;
+ }
+ copy("$from_dir/$_", "$to_dir/$_");
+ }
+ closedir(DIR);
+
+}
+
+#
+# Save a snapshot of the installed test db(s)
+# I.e take a snapshot of the var/ dir
+#
+sub save_installed_db () {
+
+ mtr_report("Saving snapshot of installed databases");
+ rmtree($path_snapshot);
+
+ foreach my $data_dir (@data_dir_lst)
+ {
+ my $name= basename($data_dir);
+ copy_dir("$data_dir", "$path_snapshot/$name");
+ }
+}
+
+#
+# Restore snapshot of the installed test db(s)
+# if the snapshot exists
+#
+sub restore_installed_db () {
+
+ if ( -d $path_snapshot)
+ {
+ kill_running_server ();
+
+ mtr_report("Restoring snapshot of databases");
+
+ foreach my $data_dir (@data_dir_lst)
+ {
+ my $name= basename($data_dir);
+ rmtree("$data_dir");
+ copy_dir("$path_snapshot/$name", "$data_dir");
+ }
+ if ($opt_with_ndbcluster)
+ {
+ # Remove the ndb_*_fs dirs, forcing a clean start of ndb
+ rmtree("$path_ndb_data_dir/ndb_1_fs");
+ rmtree("$path_ndb_data_dir/ndb_2_fs");
+
+ if ( $opt_with_ndbcluster_slave )
+ {
+ # Remove also the ndb_*_fs dirs for slave cluster
+ rmtree("$path_ndb_slave_data_dir/ndb_1_fs");
+ }
+ }
+ }
+ else
+ {
+ # No snapshot existed, just stop all processes
+ stop_masters_slaves();
+ }
+}
+
sub report_failure_and_restart ($) {
my $tinfo= shift;
@@ -2265,27 +2336,24 @@
mtr_report_test_failed($tinfo);
mtr_show_failed_diff($tinfo->{'name'});
print "\n";
- if ( ! $opt_force )
+ if ( $opt_force )
{
- my $test_mode= join(" ", @::glob_test_mode) || "default";
- print "Aborting: $tinfo->{'name'} failed in $test_mode mode. ";
- print "To continue, re-run with '--force'.\n";
- if ( ! $opt_gdb and ! $glob_use_running_server and
- ! $opt_ddd and ! $glob_use_embedded_server )
- {
- stop_masters_slaves();
- }
- mtr_exit(1);
+ # Restore the snapshot of the installed test db
+ restore_installed_db();
+ print "Resuming Tests\n\n";
+ return;
}
- # FIXME always terminate on failure?!
+ my $test_mode= join(" ", @::glob_test_mode) || "default";
+ print "Aborting: $tinfo->{'name'} failed in $test_mode mode. ";
+ print "To continue, re-run with '--force'.\n";
if ( ! $opt_gdb and ! $glob_use_running_server and
! $opt_ddd and ! $glob_use_embedded_server )
{
stop_masters_slaves();
}
- $glob_mysqld_restart= 1;
- print "Resuming Tests\n\n";
+ mtr_exit(1);
+
}
@@ -3021,7 +3089,8 @@
$ENV{'NDB_SLAVE_STATUS_OK'}= $flag_ndb_slave_status_ok;
$ENV{'NDB_EXTRA_TEST'}= $opt_ndb_extra_test;
$ENV{'NDB_MGM'}= $exe_ndb_mgm;
- $ENV{'NDB_BACKUP_DIR'}= $path_ndb_backup_dir;
+ $ENV{'NDB_BACKUP_DIR'}= $path_ndb_data_dir;
+ $ENV{'NDB_DATA_DIR'}= $path_ndb_data_dir;
$ENV{'NDB_TOOLS_DIR'}= $path_ndb_tools_dir;
$ENV{'NDB_TOOLS_OUTPUT'}= $file_ndb_testrun_log;
$ENV{'NDB_CONNECTSTRING'}= $opt_ndbconnectstring;
--- 1.167/mysql-test/r/innodb.result 2006-03-08 15:21:03 +01:00
+++ 1.168/mysql-test/r/innodb.result 2006-03-16 09:44:33 +01:00
@@ -1784,7 +1784,7 @@
show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 20
-set global innodb_thread_concurrency=1000;
+set global innodb_thread_concurrency=1001;
show variables like "innodb_thread_concurrency";
Variable_name Value
innodb_thread_concurrency 1000
@@ -2661,6 +2661,32 @@
insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a hex(b) hex(c) filler
+1 61626364656667 61626364656667 boo
+4 D0B1 D0B1 eight
+4 5B 5B five
+4 E880BD E880BD four
+4 E880BDD0B1E880BD E880BDD0B1E880BD seven
+4 E880BDE880BD E880BDE880BD six
+3 71727374757677 71727374757677 three
+2 696A6B696C6D6E 696A6B696C6D6E two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a hex(b) hex(c) filler
+4 05630563 05630563 email
+4 0563 0563 email
+4 05612020 05612020 email
+4 01FC 01FC email
+4 0120 0120 email
+4 00640065 00640065 email
+4 00E400E50068 00E400E50068 email
+4 0000E400 0000E400 email
+4 0000563001FC0563 0000563001FC0563 email
+1 0061006200630064006500660067 0061006200630064006500660067 one
+3 0071007200730074007500760077 0071007200730074007500760077 three
+2 0069006A006B0069006C006D006E 0069006A006B0069006C006D006E two
drop table t1;
drop table t2;
create table t1 (
@@ -2689,6 +2715,32 @@
insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a hex(b) hex(c) filler
+1 61626364656667 61626364656667 boo
+4 D0B1 D0B1 eight
+4 5B 5B five
+4 E880BD E880BD four
+4 E880BDD0B1E880BD E880BDD0B1E880BD seven
+4 E880BDE880BD E880BDE880BD six
+3 71727374757677 71727374757677 three
+2 696A6B696C6D6E 696A6B696C6D6E two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a hex(b) hex(c) filler
+4 05630563 05630563 email
+4 0563 0563 email
+4 05612020 05612020 email
+4 01FC 01FC email
+4 0120 0120 email
+4 00640065 00640065 email
+4 00E400E50068 00E400E50068 email
+4 0000E400 0000E400 email
+4 0000563001FC0563 0000563001FC0563 email
+1 0061006200630064006500660067 0061006200630064006500660067 one
+3 0071007200730074007500760077 0071007200730074007500760077 three
+2 0069006A006B0069006C006D006E 0069006A006B0069006C006D006E two
drop table t1;
drop table t2;
create table t1 (
@@ -2717,6 +2769,32 @@
insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a hex(b) hex(c) filler
+1 61626364656667 61626364656667 boo
+4 D0B1 D0B1 eight
+4 5B 5B five
+4 E880BD E880BD four
+4 E880BDD0B1E880BD E880BDD0B1E880BD seven
+4 E880BDE880BD E880BDE880BD six
+3 71727374757677 71727374757677 three
+2 696A6B696C6D6E 696A6B696C6D6E two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a hex(b) hex(c) filler
+4 0120 0120 email
+4 01FC 01FC email
+4 0563 0563 email
+4 0000563001FC0563 0000563001FC0563 email
+4 0000E400 0000E400 email
+4 00640065 00640065 email
+4 00E400E50068 00E400E50068 email
+4 05612020 05612020 email
+4 05630563 05630563 email
+1 0061006200630064006500660067 0061006200630064006500660067 one
+3 0071007200730074007500760077 0071007200730074007500760077 three
+2 0069006A006B0069006C006D006E 0069006A006B0069006C006D006E two
drop table t1;
drop table t2;
create table t1 (
@@ -2741,9 +2819,92 @@
insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+a hex(b) hex(c) filler
+1 61626364656667 61626364656667 boo
+4 D0B1 D0B1 eight
+4 5B 5B five
+4 E880BD E880BD four
+3 71727374757677 71727374757677 three
+2 696A6B696C6D6E 696A6B696C6D6E two
+select a,hex(b),hex(c),filler from t2 order by filler;
+a hex(b) hex(c) filler
+4 0000E400 0000E400 email
+4 00640065 00640065 email
+4 00E400E50068 00E400E50068 email
+4 0120 0120 email
+4 01FC 01FC email
+4 05612020 05612020 email
+4 0563 0563 email
+1 61626364656667 61626364656667 one
+3 71727374757677 71727374757677 three
+2 696A6B696C6D6E 696A6B696C6D6E two
drop table t1;
drop table t2;
commit;
+set foreign_key_checks=0;
+create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
+create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
+ERROR HY000: Can't create table 'test.t1' (errno: 150)
+set foreign_key_checks=1;
+drop table t2;
+set foreign_key_checks=0;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
+ERROR HY000: Can't create table 'test.t2' (errno: 150)
+set foreign_key_checks=1;
+drop table t1;
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
+create table t1(a varchar(10) primary key) engine = innodb;
+alter table t1 modify column a int;
+Got one of the listed errors
+set foreign_key_checks=1;
+drop table t2,t1;
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+alter table t1 convert to character set utf8;
+set foreign_key_checks=1;
+drop table t2,t1;
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
+rename table t3 to t1;
+ERROR HY000: Error on rename of './test/t3' to './test/t1' (errno: 150)
+set foreign_key_checks=1;
+drop table t2,t3;
+create table t1(a int primary key) row_format=redundant engine=innodb;
+create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
+create table t3(a int primary key) row_format=compact engine=innodb;
+create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
+insert into t1 values(1);
+insert into t3 values(1);
+insert into t2 values(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+insert into t4 values(2);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+insert into t2 values(1);
+insert into t4 values(1);
+update t1 set a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+update t2 set a=2;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+update t3 set a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+update t4 set a=2;
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+truncate t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`))
+truncate t3;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t4`, CONSTRAINT `t4_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t3` (`a`))
+truncate t2;
+truncate t4;
+truncate t1;
+truncate t3;
+drop table t4,t3,t2,t1;
create table t1 (a varchar(255) character set utf8,
b varchar(255) character set utf8,
c varchar(255) character set utf8,
@@ -2757,7 +2918,284 @@
e varchar(255) character set utf8,
key (a,b,c,d,e)) engine=innodb;
ERROR 42000: Specified key was too long; max key length is 3072 bytes
-End of 5.0 tests
+create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
+create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
+create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
+create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
+insert into t1 values (0x41),(0x4120),(0x4100);
+insert into t2 values (0x41),(0x4120),(0x4100);
+ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
+insert into t2 values (0x41),(0x4120);
+insert into t3 values (0x41),(0x4120),(0x4100);
+ERROR 23000: Duplicate entry 'A ' for key 'PRIMARY'
+insert into t3 values (0x41),(0x4100);
+insert into t4 values (0x41),(0x4120),(0x4100);
+ERROR 23000: Duplicate entry 'A' for key 'PRIMARY'
+insert into t4 values (0x41),(0x4100);
+select hex(s1) from t1;
+hex(s1)
+41
+4100
+4120
+select hex(s1) from t2;
+hex(s1)
+4100
+4120
+select hex(s1) from t3;
+hex(s1)
+4100
+41
+select hex(s1) from t4;
+hex(s1)
+4100
+41
+drop table t1,t2,t3,t4;
+create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
+create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
+insert into t2 values(0x42);
+ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+insert into t2 values(0x41);
+select hex(s1) from t2;
+hex(s1)
+4100
+update t1 set s1=0x123456 where a=2;
+select hex(s1) from t2;
+hex(s1)
+4100
+update t1 set s1=0x12 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+update t1 set s1=0x12345678 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+update t1 set s1=0x123457 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+update t1 set s1=0x1220 where a=1;
+select hex(s1) from t2;
+hex(s1)
+1220
+update t1 set s1=0x1200 where a=1;
+select hex(s1) from t2;
+hex(s1)
+1200
+update t1 set s1=0x4200 where a=1;
+select hex(s1) from t2;
+hex(s1)
+4200
+delete from t1 where a=1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+delete from t1 where a=2;
+update t2 set s1=0x4120;
+delete from t1;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+delete from t1 where a!=3;
+select a,hex(s1) from t1;
+a hex(s1)
+3 4120
+select hex(s1) from t2;
+hex(s1)
+4120
+drop table t2,t1;
+create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
+create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+insert into t1 values(1,0x4100),(2,0x41);
+insert into t2 values(0x41);
+select hex(s1) from t2;
+hex(s1)
+41
+update t1 set s1=0x1234 where a=1;
+select hex(s1) from t2;
+hex(s1)
+41
+update t1 set s1=0x12 where a=2;
+select hex(s1) from t2;
+hex(s1)
+12
+delete from t1 where a=1;
+delete from t1 where a=2;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test/t2`, CONSTRAINT `c` FOREIGN KEY (`s1`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE)
+select a,hex(s1) from t1;
+a hex(s1)
+2 12
+select hex(s1) from t2;
+hex(s1)
+12
+drop table t2,t1;
+CREATE TABLE t1 (
+ind enum('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ind enum('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+hex(ind) hex(string1)
+31
+32
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+hex(ind) hex(string1)
+0031
+0032
+drop table t1,t2;
+CREATE TABLE t1 (
+ind set('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ind set('0','1','2') NOT NULL default '0',
+string1 varchar(250) NOT NULL,
+PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+hex(ind) hex(string1)
+31
+32
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+hex(ind) hex(string1)
+0031
+0032
+drop table t1,t2;
+CREATE TABLE t1 (
+ind bit not null,
+string1 varchar(250) NOT NULL,
+PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ind bit not null,
+string1 varchar(250) NOT NULL,
+PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+insert into t1 values(0,''),(1,'');
+insert into t2 values(0,''),(1,'');
+select hex(ind),hex(string1) from t1 order by string1;
+hex(ind) hex(string1)
+0
+1
+select hex(ind),hex(string1) from t2 order by string1;
+hex(ind) hex(string1)
+0
+1
+drop table t1,t2;
+create table t2 (
+a int, b char(10), filler char(10), primary key(a, b(2))
+) character set utf8 engine = innodb;
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+create table t2 (
+a int, b char(10), filler char(10), primary key(a, b(2))
+) character set ucs2 engine = innodb;
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+a hex(b)
+1 61626364656667
+2 6465666768696A6B
+6 D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
+7 D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
+update t1 set b = 'three' where a = 6;
+drop table t1;
+create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+a hex(b)
+1 61626364656667
+2 6465666768696A6B
+6 D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1
+7 D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
+update t1 set b = 'three' where a = 6;
+drop table t1;
+CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
+ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `a` int(11) DEFAULT NULL,
+ KEY `t2_ibfk_0` (`a`),
+ CONSTRAINT `t2_ibfk_0` FOREIGN KEY (`a`) REFERENCES `t1` (`a`),
+ CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a`) REFERENCES `t1` (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+DROP TABLE t2,t1;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+commit;
+set autocommit = 0;
+update t1 set b = 5 where a = 2;
+create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
+set autocommit = 0;
+insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
+(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
+(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
+(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
+(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
+commit;
+commit;
+drop trigger t1t;
+drop table t1;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+insert into t2(a) values (1),(2),(3);
+insert into t3(a) values (1),(2),(3);
+insert into t4(a) values (1),(2),(3);
+insert into t3(a) values (5),(7),(8);
+insert into t4(a) values (5),(7),(8);
+insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
+create trigger t1t before insert on t1 for each row begin
+INSERT INTO t2 SET a = NEW.a;
+end |
+create trigger t2t before insert on t2 for each row begin
+DELETE FROM t3 WHERE a = NEW.a;
+end |
+create trigger t3t before delete on t3 for each row begin
+UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
+end |
+create trigger t4t before update on t4 for each row begin
+UPDATE t5 SET b = b + 1 where a = NEW.a;
+end |
+commit;
+set autocommit = 0;
+update t1 set b = b + 5 where a = 1;
+update t2 set b = b + 5 where a = 1;
+update t3 set b = b + 5 where a = 1;
+update t4 set b = b + 5 where a = 1;
+insert into t5(a) values(20);
+set autocommit = 0;
+insert into t1(a) values(7);
+insert into t2(a) values(8);
+delete from t2 where a = 3;
+update t4 set b = b + 1 where a = 3;
+commit;
+drop trigger t1t;
+drop trigger t2t;
+drop trigger t3t;
+drop trigger t4t;
+drop table t1, t2, t3, t4, t5;
CREATE TABLE t1 (
field1 varchar(8) NOT NULL DEFAULT '',
field2 varchar(8) NOT NULL DEFAULT '',
--- 1.133/mysql-test/t/innodb.test 2006-03-08 15:21:03 +01:00
+++ 1.134/mysql-test/t/innodb.test 2006-03-16 09:44:33 +01:00
@@ -1273,7 +1273,7 @@
# Test for innodb_thread_concurrency variable
show variables like "innodb_thread_concurrency";
-set global innodb_thread_concurrency=1000;
+set global innodb_thread_concurrency=1001;
show variables like "innodb_thread_concurrency";
set global innodb_thread_concurrency=0;
show variables like "innodb_thread_concurrency";
@@ -1610,6 +1610,10 @@
insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
drop table t1;
drop table t2;
@@ -1639,6 +1643,10 @@
insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
drop table t1;
drop table t2;
@@ -1668,6 +1676,10 @@
insert into t2 values (4,_ucs2 0x05630563,_ucs2 0x05630563,'eleven');
insert into t2 values (4,_ucs2 0x0563001fc0563,_ucs2 0x0563001fc0563,'point');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
drop table t1;
drop table t2;
@@ -1693,10 +1705,102 @@
insert into t2 values (4,_ucs2 0x0120,_ucs2 0x0120,'eight');
insert into t2 values (4,_ucs2 0x0563,_ucs2 0x0563,'ten');
insert into t2 values (4,_ucs2 0x05612020,_ucs2 0x05612020,'taken');
+update t1 set filler = 'boo' where a = 1;
+update t2 set filler ='email' where a = 4;
+select a,hex(b),hex(c),filler from t1 order by filler;
+select a,hex(b),hex(c),filler from t2 order by filler;
drop table t1;
drop table t2;
commit;
+# tests for bugs #9802 and #13778
+
+# test that FKs between invalid types are not accepted
+
+set foreign_key_checks=0;
+create table t2 (a int primary key, b int, foreign key (b) references t1(a)) engine = innodb;
+--replace_result $MYSQLTEST_VARDIR . master-data/ ''
+-- error 1005
+create table t1(a char(10) primary key, b varchar(20)) engine = innodb;
+set foreign_key_checks=1;
+drop table t2;
+
+# test that FKs between different charsets are not accepted in CREATE even
+# when f_k_c is 0
+
+set foreign_key_checks=0;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+--replace_result $MYSQLTEST_VARDIR . master-data/ ''
+-- error 1005
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=utf8;
+set foreign_key_checks=1;
+drop table t1;
+
+# test that invalid datatype conversions with ALTER are not allowed
+
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb;
+create table t1(a varchar(10) primary key) engine = innodb;
+-- error 1025,1025
+alter table t1 modify column a int;
+set foreign_key_checks=1;
+drop table t2,t1;
+
+# test that charset conversions with ALTER are allowed when f_k_c is 0
+
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t1(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=latin1;
+alter table t1 convert to character set utf8;
+set foreign_key_checks=1;
+drop table t2,t1;
+
+# test that RENAME does not allow invalid charsets when f_k_c is 0
+
+set foreign_key_checks=0;
+create table t2 (a varchar(10), foreign key (a) references t1(a)) engine = innodb DEFAULT CHARSET=latin1;
+create table t3(a varchar(10) primary key) engine = innodb DEFAULT CHARSET=utf8;
+--replace_result $MYSQLTEST_VARDIR . master-data/ ''
+-- error 1025
+rename table t3 to t1;
+set foreign_key_checks=1;
+drop table t2,t3;
+
+# test that foreign key errors are reported correctly (Bug #15550)
+
+create table t1(a int primary key) row_format=redundant engine=innodb;
+create table t2(a int primary key,constraint foreign key(a)references t1(a)) row_format=compact engine=innodb;
+create table t3(a int primary key) row_format=compact engine=innodb;
+create table t4(a int primary key,constraint foreign key(a)references t3(a)) row_format=redundant engine=innodb;
+
+insert into t1 values(1);
+insert into t3 values(1);
+-- error 1452
+insert into t2 values(2);
+-- error 1452
+insert into t4 values(2);
+insert into t2 values(1);
+insert into t4 values(1);
+-- error 1451
+update t1 set a=2;
+-- error 1452
+update t2 set a=2;
+-- error 1451
+update t3 set a=2;
+-- error 1452
+update t4 set a=2;
+-- error 1451
+truncate t1;
+-- error 1451
+truncate t3;
+truncate t2;
+truncate t4;
+truncate t1;
+truncate t3;
+
+drop table t4,t3,t2,t1;
+
+
#
# Test that we can create a large (>1K) key
#
@@ -1714,7 +1818,272 @@
e varchar(255) character set utf8,
key (a,b,c,d,e)) engine=innodb;
---echo End of 5.0 tests
+
+# test the padding of BINARY types and collations (Bug #14189)
+
+create table t1 (s1 varbinary(2),primary key (s1)) engine=innodb;
+create table t2 (s1 binary(2),primary key (s1)) engine=innodb;
+create table t3 (s1 varchar(2) binary,primary key (s1)) engine=innodb;
+create table t4 (s1 char(2) binary,primary key (s1)) engine=innodb;
+
+insert into t1 values (0x41),(0x4120),(0x4100);
+-- error 1062
+insert into t2 values (0x41),(0x4120),(0x4100);
+insert into t2 values (0x41),(0x4120);
+-- error 1062
+insert into t3 values (0x41),(0x4120),(0x4100);
+insert into t3 values (0x41),(0x4100);
+-- error 1062
+insert into t4 values (0x41),(0x4120),(0x4100);
+insert into t4 values (0x41),(0x4100);
+select hex(s1) from t1;
+select hex(s1) from t2;
+select hex(s1) from t3;
+select hex(s1) from t4;
+drop table t1,t2,t3,t4;
+
+create table t1 (a int primary key,s1 varbinary(3) not null unique) engine=innodb;
+create table t2 (s1 binary(2) not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+
+insert into t1 values(1,0x4100),(2,0x41),(3,0x4120),(4,0x42);
+-- error 1452
+insert into t2 values(0x42);
+insert into t2 values(0x41);
+select hex(s1) from t2;
+update t1 set s1=0x123456 where a=2;
+select hex(s1) from t2;
+-- error 1451
+update t1 set s1=0x12 where a=1;
+-- error 1451
+update t1 set s1=0x12345678 where a=1;
+-- error 1451
+update t1 set s1=0x123457 where a=1;
+update t1 set s1=0x1220 where a=1;
+select hex(s1) from t2;
+update t1 set s1=0x1200 where a=1;
+select hex(s1) from t2;
+update t1 set s1=0x4200 where a=1;
+select hex(s1) from t2;
+-- error 1451
+delete from t1 where a=1;
+delete from t1 where a=2;
+update t2 set s1=0x4120;
+-- error 1451
+delete from t1;
+delete from t1 where a!=3;
+select a,hex(s1) from t1;
+select hex(s1) from t2;
+
+drop table t2,t1;
+
+create table t1 (a int primary key,s1 varchar(2) binary not null unique) engine=innodb;
+create table t2 (s1 char(2) binary not null, constraint c foreign key(s1) references t1(s1) on update cascade) engine=innodb;
+
+insert into t1 values(1,0x4100),(2,0x41);
+insert into t2 values(0x41);
+select hex(s1) from t2;
+update t1 set s1=0x1234 where a=1;
+select hex(s1) from t2;
+update t1 set s1=0x12 where a=2;
+select hex(s1) from t2;
+delete from t1 where a=1;
+-- error 1451
+delete from t1 where a=2;
+select a,hex(s1) from t1;
+select hex(s1) from t2;
+
+drop table t2,t1;
+#
+# Test cases for bug #15308 Problem of Order with Enum Column in Primary Key
+#
+CREATE TABLE t1 (
+ ind enum('0','1','2') NOT NULL default '0',
+ string1 varchar(250) NOT NULL,
+ PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ ind enum('0','1','2') NOT NULL default '0',
+ string1 varchar(250) NOT NULL,
+ PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+drop table t1,t2;
+
+CREATE TABLE t1 (
+ ind set('0','1','2') NOT NULL default '0',
+ string1 varchar(250) NOT NULL,
+ PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ ind set('0','1','2') NOT NULL default '0',
+ string1 varchar(250) NOT NULL,
+ PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+
+INSERT INTO t1 VALUES ('1', ''),('2', '');
+INSERT INTO t2 VALUES ('1', ''),('2', '');
+SELECT hex(ind),hex(string1) FROM t1 ORDER BY string1;
+SELECT hex(ind),hex(string1) FROM t2 ORDER BY string1;
+drop table t1,t2;
+
+CREATE TABLE t1 (
+ ind bit not null,
+ string1 varchar(250) NOT NULL,
+ PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+CREATE TABLE t2 (
+ ind bit not null,
+ string1 varchar(250) NOT NULL,
+ PRIMARY KEY (ind)
+) ENGINE=InnoDB DEFAULT CHARSET=ucs2;
+insert into t1 values(0,''),(1,'');
+insert into t2 values(0,''),(1,'');
+select hex(ind),hex(string1) from t1 order by string1;
+select hex(ind),hex(string1) from t2 order by string1;
+drop table t1,t2;
+
+# tests for bug #14056 Column prefix index on UTF-8 primary key column causes 'Can't find record..'
+
+create table t2 (
+ a int, b char(10), filler char(10), primary key(a, b(2))
+) character set utf8 engine = innodb;
+
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+create table t2 (
+ a int, b char(10), filler char(10), primary key(a, b(2))
+) character set ucs2 engine = innodb;
+
+insert into t2 values (1,'abcdefg','one');
+insert into t2 values (2,'ijkilmn','two');
+insert into t2 values (3, 'qrstuvw','three');
+update t2 set a=5, filler='booo' where a=1;
+drop table t2;
+
+create table t1(a int not null, b char(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+update t1 set b = 'three' where a = 6;
+drop table t1;
+create table t1(a int not null, b text(110),primary key(a,b(100))) engine=innodb default charset=utf8;
+insert into t1 values(1,'abcdefg'),(2,'defghijk');
+insert into t1 values(6,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1);
+insert into t1 values(7,_utf8 0xD0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2);
+select a,hex(b) from t1 order by b;
+update t1 set b = 'three' where a = 6;
+drop table t1;
+
+# Ensure that <tablename>_ibfk_0 is not mistreated as a
+# generated foreign key identifier. (Bug #16387)
+
+CREATE TABLE t1(a INT, PRIMARY KEY(a)) ENGINE=InnoDB;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_1;
+ALTER TABLE t2 ADD CONSTRAINT t2_ibfk_0 FOREIGN KEY (a) REFERENCES t1(a);
+ALTER TABLE t2 DROP FOREIGN KEY t2_ibfk_0;
+SHOW CREATE TABLE t2;
+DROP TABLE t2,t1;
+
+#
+# Test case for bug #16229: MySQL/InnoDB uses full explicit table locks in trigger processing
+#
+
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+commit;
+connection b;
+set autocommit = 0;
+update t1 set b = 5 where a = 2;
+connection a;
+delimiter |;
+create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end |
+delimiter ;|
+set autocommit = 0;
+connection a;
+insert into t1(a) values (10),(20),(30),(40),(50),(60),(70),(80),(90),(100),
+(11),(21),(31),(41),(51),(61),(71),(81),(91),(101),
+(12),(22),(32),(42),(52),(62),(72),(82),(92),(102),
+(13),(23),(33),(43),(53),(63),(73),(83),(93),(103),
+(14),(24),(34),(44),(54),(64),(74),(84),(94),(104);
+connection b;
+commit;
+connection a;
+commit;
+drop trigger t1t;
+drop table t1;
+disconnect a;
+disconnect b;
+#
+# Another trigger test
+#
+connect (a,localhost,root,,);
+connect (b,localhost,root,,);
+connection a;
+create table t1(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t2(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t3(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t4(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+create table t5(a int not null, b int, c int, d int, primary key(a)) engine=innodb;
+insert into t1(a) values (1),(2),(3);
+insert into t2(a) values (1),(2),(3);
+insert into t3(a) values (1),(2),(3);
+insert into t4(a) values (1),(2),(3);
+insert into t3(a) values (5),(7),(8);
+insert into t4(a) values (5),(7),(8);
+insert into t5(a) values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12);
+
+delimiter |;
+create trigger t1t before insert on t1 for each row begin
+ INSERT INTO t2 SET a = NEW.a;
+end |
+
+create trigger t2t before insert on t2 for each row begin
+ DELETE FROM t3 WHERE a = NEW.a;
+end |
+
+create trigger t3t before delete on t3 for each row begin
+ UPDATE t4 SET b = b + 1 WHERE a = OLD.a;
+end |
+
+create trigger t4t before update on t4 for each row begin
+ UPDATE t5 SET b = b + 1 where a = NEW.a;
+end |
+delimiter ;|
+commit;
+set autocommit = 0;
+update t1 set b = b + 5 where a = 1;
+update t2 set b = b + 5 where a = 1;
+update t3 set b = b + 5 where a = 1;
+update t4 set b = b + 5 where a = 1;
+insert into t5(a) values(20);
+connection b;
+set autocommit = 0;
+insert into t1(a) values(7);
+insert into t2(a) values(8);
+delete from t2 where a = 3;
+update t4 set b = b + 1 where a = 3;
+commit;
+drop trigger t1t;
+drop trigger t2t;
+drop trigger t3t;
+drop trigger t4t;
+drop table t1, t2, t3, t4, t5;
+connection default;
+disconnect a;
+disconnect b;
#
# Test that cascading updates leading to duplicate keys give the correct
--- 1.261/sql/ha_innodb.cc 2006-03-08 15:21:03 +01:00
+++ 1.262/sql/ha_innodb.cc 2006-03-16 09:44:33 +01:00
@@ -7,12 +7,12 @@
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* This file defines the InnoDB handler: the interface between MySQL and InnoDB
NOTE: You can only use noninlined InnoDB functions in this file, because we
@@ -44,9 +44,9 @@
#include "ha_innodb.h"
-pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */
- prepare_commit_mutex; /* to force correct commit order in
- binlog */
+pthread_mutex_t innobase_share_mutex, /* to protect innobase_open_files */
+ prepare_commit_mutex; /* to force correct commit order in
+ binlog */
ulong commit_threads= 0;
pthread_mutex_t commit_threads_m;
pthread_cond_t commit_cond;
@@ -57,45 +57,45 @@
/* These variables are used to implement (semi-)synchronous MySQL binlog
replication for InnoDB tables. */
-pthread_cond_t innobase_repl_cond; /* Posix cond variable;
- this variable is signaled
- when enough binlog has been
- sent to slave, so that a
- waiting trx can return the
- 'ok' message to the client
- for a commit */
-pthread_mutex_t innobase_repl_cond_mutex; /* Posix cond variable mutex
- that also protects the next
- innobase_repl_... variables */
-uint innobase_repl_state; /* 1 if synchronous replication
- is switched on and is working
- ok; else 0 */
-uint innobase_repl_file_name_inited = 0; /* This is set to 1 when
- innobase_repl_file_name
- contains meaningful data */
-char* innobase_repl_file_name; /* The binlog name up to which
- we have sent some binlog to
- the slave */
-my_off_t innobase_repl_pos; /* The position in that file
- up to which we have sent the
- binlog to the slave */
-uint innobase_repl_n_wait_threads = 0; /* This tells how many
- transactions currently are
- waiting for the binlog to be
- sent to the client */
-uint innobase_repl_wait_file_name_inited = 0; /* This is set to 1
- when we know the 'smallest'
- wait position */
-char* innobase_repl_wait_file_name; /* NULL, or the 'smallest'
- innobase_repl_file_name that
- a transaction is waiting for */
-my_off_t innobase_repl_wait_pos; /* The smallest position in
- that file that a trx is
- waiting for: the trx can
- proceed and send an 'ok' to
- the client when MySQL has sent
- the binlog up to this position
- to the slave */
+pthread_cond_t innobase_repl_cond; /* Posix cond variable;
+ this variable is signaled
+ when enough binlog has been
+ sent to slave, so that a
+ waiting trx can return the
+ 'ok' message to the client
+ for a commit */
+pthread_mutex_t innobase_repl_cond_mutex; /* Posix cond variable mutex
+ that also protects the next
+ innobase_repl_... variables */
+uint innobase_repl_state; /* 1 if synchronous replication
+ is switched on and is working
+ ok; else 0 */
+uint innobase_repl_file_name_inited = 0; /* This is set to 1 when
+ innobase_repl_file_name
+ contains meaningful data */
+char* innobase_repl_file_name; /* The binlog name up to which
+ we have sent some binlog to
+ the slave */
+my_off_t innobase_repl_pos; /* The position in that file
+ up to which we have sent the
+ binlog to the slave */
+uint innobase_repl_n_wait_threads = 0; /* This tells how many
+ transactions currently are
+ waiting for the binlog to be
+ sent to the client */
+uint innobase_repl_wait_file_name_inited = 0; /* This is set to 1
+ when we know the 'smallest'
+ wait position */
+char* innobase_repl_wait_file_name; /* NULL, or the 'smallest'
+ innobase_repl_file_name that
+ a transaction is waiting for */
+my_off_t innobase_repl_wait_pos; /* The smallest position in
+ that file that a trx is
+ waiting for: the trx can
+ proceed and send an 'ok' to
+ the client when MySQL has sent
+ the binlog up to this position
+ to the slave */
/*-----------------------------------------------------------------*/
@@ -137,26 +137,24 @@
#define HA_INNOBASE_ROWS_IN_TABLE 10000 /* to get optimization right */
#define HA_INNOBASE_RANGE_COUNT 100
-uint innobase_init_flags = 0;
-ulong innobase_cache_size = 0;
-ulong innobase_large_page_size = 0;
+ulong innobase_large_page_size = 0;
/* The default values for the following, type long or longlong, start-up
parameters are declared in mysqld.cc: */
long innobase_mirrored_log_groups, innobase_log_files_in_group,
- innobase_log_buffer_size, innobase_buffer_pool_awe_mem_mb,
- innobase_additional_mem_pool_size, innobase_file_io_threads,
- innobase_lock_wait_timeout, innobase_force_recovery,
- innobase_open_files;
+ innobase_log_buffer_size, innobase_buffer_pool_awe_mem_mb,
+ innobase_additional_mem_pool_size, innobase_file_io_threads,
+ innobase_lock_wait_timeout, innobase_force_recovery,
+ innobase_open_files;
longlong innobase_buffer_pool_size, innobase_log_file_size;
/* The default values for the following char* start-up parameters
are determined in innobase_init below: */
-
+
char* innobase_data_home_dir = NULL;
-char* innobase_data_file_path = NULL;
+char* innobase_data_file_path = NULL;
char* innobase_log_group_home_dir = NULL;
char* innobase_log_arch_dir = NULL;/* unused */
/* The following has a misleading name: starting from 4.0.5, this also
@@ -169,12 +167,12 @@
uint innobase_flush_log_at_trx_commit = 1;
ulong innobase_fast_shutdown = 1;
my_bool innobase_log_archive = FALSE;/* unused */
-my_bool innobase_use_doublewrite = TRUE;
-my_bool innobase_use_checksums = TRUE;
-my_bool innobase_use_large_pages = FALSE;
+my_bool innobase_use_doublewrite = TRUE;
+my_bool innobase_use_checksums = TRUE;
+my_bool innobase_use_large_pages = FALSE;
my_bool innobase_use_native_aio = FALSE;
my_bool innobase_file_per_table = FALSE;
-my_bool innobase_locks_unsafe_for_binlog = FALSE;
+my_bool innobase_locks_unsafe_for_binlog = FALSE;
my_bool innobase_create_status_file = FALSE;
static char *internal_innobase_data_file_path = NULL;
@@ -187,16 +185,14 @@
#define INNOBASE_WAKE_INTERVAL 32
ulong innobase_active_counter = 0;
-char* innobase_home = NULL;
-
-static HASH innobase_open_tables;
+static HASH innobase_open_tables;
-#ifdef __NETWARE__ /* some special cleanup for NetWare */
+#ifdef __NETWARE__ /* some special cleanup for NetWare */
bool nw_panic = FALSE;
#endif
static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
- my_bool not_used __attribute__((unused)));
+ my_bool not_used __attribute__((unused)));
static INNOBASE_SHARE *get_share(const char *table_name);
static void free_share(INNOBASE_SHARE *share);
static int innobase_close_connection(THD* thd);
@@ -211,7 +207,7 @@
MYSQL_HANDLERTON_INTERFACE_VERSION,
"InnoDB",
SHOW_OPTION_YES,
- "Supports transactions, row-level locking, and foreign keys",
+ "Supports transactions, row-level locking, and foreign keys",
DB_TYPE_INNODB,
innobase_init,
0, /* slot */
@@ -225,7 +221,7 @@
innobase_xa_prepare, /* prepare */
innobase_xa_recover, /* recover */
innobase_commit_by_xid, /* commit_by_xid */
- innobase_rollback_by_xid, /* rollback_by_xid */
+ innobase_rollback_by_xid, /* rollback_by_xid */
innobase_create_cursor_view,
innobase_set_cursor_view,
innobase_close_cursor_view,
@@ -261,19 +257,19 @@
SHOW_VAR innodb_status_variables[]= {
{"buffer_pool_pages_data",
- (char*) &export_vars.innodb_buffer_pool_pages_data, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_pages_data, SHOW_LONG},
{"buffer_pool_pages_dirty",
- (char*) &export_vars.innodb_buffer_pool_pages_dirty, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_pages_dirty, SHOW_LONG},
{"buffer_pool_pages_flushed",
(char*) &export_vars.innodb_buffer_pool_pages_flushed, SHOW_LONG},
{"buffer_pool_pages_free",
- (char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_pages_free, SHOW_LONG},
{"buffer_pool_pages_latched",
(char*) &export_vars.innodb_buffer_pool_pages_latched, SHOW_LONG},
{"buffer_pool_pages_misc",
- (char*) &export_vars.innodb_buffer_pool_pages_misc, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_pages_misc, SHOW_LONG},
{"buffer_pool_pages_total",
- (char*) &export_vars.innodb_buffer_pool_pages_total, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_pages_total, SHOW_LONG},
{"buffer_pool_read_ahead_rnd",
(char*) &export_vars.innodb_buffer_pool_read_ahead_rnd, SHOW_LONG},
{"buffer_pool_read_ahead_seq",
@@ -281,71 +277,71 @@
{"buffer_pool_read_requests",
(char*) &export_vars.innodb_buffer_pool_read_requests, SHOW_LONG},
{"buffer_pool_reads",
- (char*) &export_vars.innodb_buffer_pool_reads, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_reads, SHOW_LONG},
{"buffer_pool_wait_free",
- (char*) &export_vars.innodb_buffer_pool_wait_free, SHOW_LONG},
+ (char*) &export_vars.innodb_buffer_pool_wait_free, SHOW_LONG},
{"buffer_pool_write_requests",
(char*) &export_vars.innodb_buffer_pool_write_requests, SHOW_LONG},
{"data_fsyncs",
- (char*) &export_vars.innodb_data_fsyncs, SHOW_LONG},
+ (char*) &export_vars.innodb_data_fsyncs, SHOW_LONG},
{"data_pending_fsyncs",
- (char*) &export_vars.innodb_data_pending_fsyncs, SHOW_LONG},
+ (char*) &export_vars.innodb_data_pending_fsyncs, SHOW_LONG},
{"data_pending_reads",
- (char*) &export_vars.innodb_data_pending_reads, SHOW_LONG},
+ (char*) &export_vars.innodb_data_pending_reads, SHOW_LONG},
{"data_pending_writes",
- (char*) &export_vars.innodb_data_pending_writes, SHOW_LONG},
+ (char*) &export_vars.innodb_data_pending_writes, SHOW_LONG},
{"data_read",
- (char*) &export_vars.innodb_data_read, SHOW_LONG},
+ (char*) &export_vars.innodb_data_read, SHOW_LONG},
{"data_reads",
- (char*) &export_vars.innodb_data_reads, SHOW_LONG},
+ (char*) &export_vars.innodb_data_reads, SHOW_LONG},
{"data_writes",
- (char*) &export_vars.innodb_data_writes, SHOW_LONG},
+ (char*) &export_vars.innodb_data_writes, SHOW_LONG},
{"data_written",
- (char*) &export_vars.innodb_data_written, SHOW_LONG},
+ (char*) &export_vars.innodb_data_written, SHOW_LONG},
{"dblwr_pages_written",
- (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
+ (char*) &export_vars.innodb_dblwr_pages_written, SHOW_LONG},
{"dblwr_writes",
- (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
+ (char*) &export_vars.innodb_dblwr_writes, SHOW_LONG},
{"log_waits",
- (char*) &export_vars.innodb_log_waits, SHOW_LONG},
+ (char*) &export_vars.innodb_log_waits, SHOW_LONG},
{"log_write_requests",
- (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
+ (char*) &export_vars.innodb_log_write_requests, SHOW_LONG},
{"log_writes",
- (char*) &export_vars.innodb_log_writes, SHOW_LONG},
+ (char*) &export_vars.innodb_log_writes, SHOW_LONG},
{"os_log_fsyncs",
- (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
+ (char*) &export_vars.innodb_os_log_fsyncs, SHOW_LONG},
{"os_log_pending_fsyncs",
- (char*) &export_vars.innodb_os_log_pending_fsyncs, SHOW_LONG},
+ (char*) &export_vars.innodb_os_log_pending_fsyncs, SHOW_LONG},
{"os_log_pending_writes",
- (char*) &export_vars.innodb_os_log_pending_writes, SHOW_LONG},
+ (char*) &export_vars.innodb_os_log_pending_writes, SHOW_LONG},
{"os_log_written",
- (char*) &export_vars.innodb_os_log_written, SHOW_LONG},
+ (char*) &export_vars.innodb_os_log_written, SHOW_LONG},
{"page_size",
- (char*) &export_vars.innodb_page_size, SHOW_LONG},
+ (char*) &export_vars.innodb_page_size, SHOW_LONG},
{"pages_created",
- (char*) &export_vars.innodb_pages_created, SHOW_LONG},
+ (char*) &export_vars.innodb_pages_created, SHOW_LONG},
{"pages_read",
- (char*) &export_vars.innodb_pages_read, SHOW_LONG},
+ (char*) &export_vars.innodb_pages_read, SHOW_LONG},
{"pages_written",
- (char*) &export_vars.innodb_pages_written, SHOW_LONG},
+ (char*) &export_vars.innodb_pages_written, SHOW_LONG},
{"row_lock_current_waits",
- (char*) &export_vars.innodb_row_lock_current_waits, SHOW_LONG},
+ (char*) &export_vars.innodb_row_lock_current_waits, SHOW_LONG},
{"row_lock_time",
- (char*) &export_vars.innodb_row_lock_time, SHOW_LONGLONG},
+ (char*) &export_vars.innodb_row_lock_time, SHOW_LONGLONG},
{"row_lock_time_avg",
- (char*) &export_vars.innodb_row_lock_time_avg, SHOW_LONG},
+ (char*) &export_vars.innodb_row_lock_time_avg, SHOW_LONG},
{"row_lock_time_max",
- (char*) &export_vars.innodb_row_lock_time_max, SHOW_LONG},
+ (char*) &export_vars.innodb_row_lock_time_max, SHOW_LONG},
{"row_lock_waits",
- (char*) &export_vars.innodb_row_lock_waits, SHOW_LONG},
+ (char*) &export_vars.innodb_row_lock_waits, SHOW_LONG},
{"rows_deleted",
- (char*) &export_vars.innodb_rows_deleted, SHOW_LONG},
+ (char*) &export_vars.innodb_rows_deleted, SHOW_LONG},
{"rows_inserted",
- (char*) &export_vars.innodb_rows_inserted, SHOW_LONG},
+ (char*) &export_vars.innodb_rows_inserted, SHOW_LONG},
{"rows_read",
- (char*) &export_vars.innodb_rows_read, SHOW_LONG},
+ (char*) &export_vars.innodb_rows_read, SHOW_LONG},
{"rows_updated",
- (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
+ (char*) &export_vars.innodb_rows_updated, SHOW_LONG},
{NullS, NullS, SHOW_LONG}};
/* General functions */
@@ -359,7 +355,7 @@
/*=========================*/
trx_t* trx) /* in: transaction handle */
{
- if (UNIV_LIKELY(srv_thread_concurrency >= SRV_CONCURRENCY_THRESHOLD)) {
+ if (UNIV_LIKELY(!srv_thread_concurrency)) {
return;
}
@@ -376,7 +372,7 @@
/*========================*/
trx_t* trx) /* in: transaction handle */
{
- if (UNIV_LIKELY(srv_thread_concurrency >= SRV_CONCURRENCY_THRESHOLD)) {
+ if (UNIV_LIKELY(!srv_thread_concurrency)) {
return;
}
@@ -414,19 +410,19 @@
int
innobase_release_temporary_latches(
/*===============================*/
- THD *thd)
+ THD *thd)
{
trx_t* trx;
if (!innodb_inited) {
-
+
return 0;
}
trx = (trx_t*) thd->ha_data[innobase_hton.slot];
if (trx) {
- innobase_release_stat_resources(trx);
+ innobase_release_stat_resources(trx);
}
return 0;
}
@@ -464,90 +460,90 @@
return(0);
- } else if (error == (int) DB_DUPLICATE_KEY) {
+ } else if (error == (int) DB_DUPLICATE_KEY) {
- return(HA_ERR_FOUND_DUPP_KEY);
+ return(HA_ERR_FOUND_DUPP_KEY);
- } else if (error == (int) DB_FOREIGN_DUPLICATE_KEY) {
+ } else if (error == (int) DB_FOREIGN_DUPLICATE_KEY) {
return(HA_ERR_FOREIGN_DUPLICATE_KEY);
- } else if (error == (int) DB_RECORD_NOT_FOUND) {
+ } else if (error == (int) DB_RECORD_NOT_FOUND) {
- return(HA_ERR_NO_ACTIVE_RECORD);
+ return(HA_ERR_NO_ACTIVE_RECORD);
- } else if (error == (int) DB_ERROR) {
+ } else if (error == (int) DB_ERROR) {
- return(-1); /* unspecified error */
+ return(-1); /* unspecified error */
- } else if (error == (int) DB_DEADLOCK) {
- /* Since we rolled back the whole transaction, we must
- tell it also to MySQL so that MySQL knows to empty the
- cached binlog for this transaction */
+ } else if (error == (int) DB_DEADLOCK) {
+ /* Since we rolled back the whole transaction, we must
+ tell it also to MySQL so that MySQL knows to empty the
+ cached binlog for this transaction */
- if (thd) {
- ha_rollback(thd);
- }
+ if (thd) {
+ ha_rollback(thd);
+ }
- return(HA_ERR_LOCK_DEADLOCK);
+ return(HA_ERR_LOCK_DEADLOCK);
- } else if (error == (int) DB_LOCK_WAIT_TIMEOUT) {
+ } else if (error == (int) DB_LOCK_WAIT_TIMEOUT) {
/* Starting from 5.0.13, we let MySQL just roll back the
latest SQL statement in a lock wait timeout. Previously, we
rolled back the whole transaction. */
- return(HA_ERR_LOCK_WAIT_TIMEOUT);
+ return(HA_ERR_LOCK_WAIT_TIMEOUT);
- } else if (error == (int) DB_NO_REFERENCED_ROW) {
+ } else if (error == (int) DB_NO_REFERENCED_ROW) {
- return(HA_ERR_NO_REFERENCED_ROW);
+ return(HA_ERR_NO_REFERENCED_ROW);
- } else if (error == (int) DB_ROW_IS_REFERENCED) {
+ } else if (error == (int) DB_ROW_IS_REFERENCED) {
- return(HA_ERR_ROW_IS_REFERENCED);
+ return(HA_ERR_ROW_IS_REFERENCED);
- } else if (error == (int) DB_CANNOT_ADD_CONSTRAINT) {
+ } else if (error == (int) DB_CANNOT_ADD_CONSTRAINT) {
- return(HA_ERR_CANNOT_ADD_FOREIGN);
+ return(HA_ERR_CANNOT_ADD_FOREIGN);
- } else if (error == (int) DB_CANNOT_DROP_CONSTRAINT) {
+ } else if (error == (int) DB_CANNOT_DROP_CONSTRAINT) {
- return(HA_ERR_ROW_IS_REFERENCED); /* TODO: This is a bit
+ return(HA_ERR_ROW_IS_REFERENCED); /* TODO: This is a bit
misleading, a new MySQL error
code should be introduced */
- } else if (error == (int) DB_COL_APPEARS_TWICE_IN_INDEX) {
+ } else if (error == (int) DB_COL_APPEARS_TWICE_IN_INDEX) {
- return(HA_ERR_CRASHED);
+ return(HA_ERR_CRASHED);
- } else if (error == (int) DB_OUT_OF_FILE_SPACE) {
+ } else if (error == (int) DB_OUT_OF_FILE_SPACE) {
- return(HA_ERR_RECORD_FILE_FULL);
+ return(HA_ERR_RECORD_FILE_FULL);
- } else if (error == (int) DB_TABLE_IS_BEING_USED) {
+ } else if (error == (int) DB_TABLE_IS_BEING_USED) {
- return(HA_ERR_WRONG_COMMAND);
+ return(HA_ERR_WRONG_COMMAND);
- } else if (error == (int) DB_TABLE_NOT_FOUND) {
+ } else if (error == (int) DB_TABLE_NOT_FOUND) {
- return(HA_ERR_KEY_NOT_FOUND);
+ return(HA_ERR_KEY_NOT_FOUND);
- } else if (error == (int) DB_TOO_BIG_RECORD) {
+ } else if (error == (int) DB_TOO_BIG_RECORD) {
- return(HA_ERR_TO_BIG_ROW);
+ return(HA_ERR_TO_BIG_ROW);
- } else if (error == (int) DB_CORRUPTION) {
+ } else if (error == (int) DB_CORRUPTION) {
- return(HA_ERR_CRASHED);
- } else if (error == (int) DB_NO_SAVEPOINT) {
+ return(HA_ERR_CRASHED);
+ } else if (error == (int) DB_NO_SAVEPOINT) {
- return(HA_ERR_NO_SAVEPOINT);
- } else if (error == (int) DB_LOCK_TABLE_FULL) {
+ return(HA_ERR_NO_SAVEPOINT);
+ } else if (error == (int) DB_LOCK_TABLE_FULL) {
- return(HA_ERR_LOCK_TABLE_FULL);
- } else {
- return(-1); // Unknown error
- }
+ return(HA_ERR_LOCK_TABLE_FULL);
+ } else {
+ return(-1); // Unknown error
+ }
}
/*****************************************************************
@@ -587,21 +583,21 @@
void
innobase_mysql_print_thd(
/*=====================*/
- FILE* f, /* in: output stream */
- void* input_thd, /* in: pointer to a MySQL THD object */
+ FILE* f, /* in: output stream */
+ void* input_thd, /* in: pointer to a MySQL THD object */
uint max_query_len) /* in: max query length to print, or 0 to
use the default max length */
{
const THD* thd;
- const Security_context *sctx;
+ const Security_context *sctx;
const char* s;
- thd = (const THD*) input_thd;
- /* We probably want to have original user as part of debug output. */
- sctx = &thd->main_security_ctx;
+ thd = (const THD*) input_thd;
+ /* We probably want to have original user as part of debug output. */
+ sctx = &thd->main_security_ctx;
- fprintf(f, "MySQL thread id %lu, query id %lu",
+ fprintf(f, "MySQL thread id %lu, query id %lu",
thd->thread_id, (ulong) thd->query_id);
if (sctx->host) {
putc(' ', f);
@@ -613,10 +609,10 @@
fputs(sctx->ip, f);
}
- if (sctx->user) {
+ if (sctx->user) {
putc(' ', f);
fputs(sctx->user, f);
- }
+ }
if ((s = thd->proc_info)) {
putc(' ', f);
@@ -635,9 +631,8 @@
/* Points to buf or dyn_str. */
char* str = buf;
-
- if (max_query_len == 0)
- {
+
+ if (max_query_len == 0) {
/* ADDITIONAL SAFETY: the default is to print at
most 300 chars to reduce the probability of a
seg fault if there is a race in
@@ -646,23 +641,21 @@
safe */
max_query_len = 300;
}
-
+
len = min(thd->query_length, max_query_len);
- if (len > (sizeof(buf) - 1))
- {
+ if (len > (sizeof(buf) - 1)) {
dyn_str = my_malloc(len + 1, MYF(0));
str = dyn_str;
}
- /* Use strmake to reduce the timeframe for a race,
- compared to fwrite() */
+ /* Use strmake to reduce the timeframe for a race,
+ compared to fwrite() */
len = (uint) (strmake(str, s, len) - str);
putc('\n', f);
fwrite(str, 1, len, f);
- if (dyn_str)
- {
+ if (dyn_str) {
my_free(dyn_str, MYF(0));
}
}
@@ -764,10 +757,10 @@
if (fd2 < 0) {
DBUG_PRINT("error",("Got error %d on dup",fd2));
my_errno=errno;
- my_error(EE_OUT_OF_FILERESOURCES,
- MYF(ME_BELL+ME_WAITTANG),
- filename, my_errno);
- }
+ my_error(EE_OUT_OF_FILERESOURCES,
+ MYF(ME_BELL+ME_WAITTANG),
+ filename, my_errno);
+ }
my_close(fd, MYF(MY_WME));
}
return(fd2);
@@ -788,24 +781,24 @@
ut_ad(thd == current_thd);
- trx = (trx_t*) thd->ha_data[innobase_hton.slot];
+ trx = (trx_t*) thd->ha_data[innobase_hton.slot];
if (trx == NULL) {
- DBUG_ASSERT(thd != NULL);
+ DBUG_ASSERT(thd != NULL);
trx = trx_allocate_for_mysql();
trx->mysql_thd = thd;
trx->mysql_query_str = &(thd->query);
- trx->active_trans = 0;
+ trx->active_trans = 0;
/* Update the info whether we should skip XA steps that eat
CPU time */
trx->support_xa = (ibool)(thd->variables.innodb_support_xa);
- thd->ha_data[innobase_hton.slot] = trx;
+ thd->ha_data[innobase_hton.slot] = trx;
} else {
if (trx->magic_n != TRX_MAGIC_N) {
- mem_analyze_corruption((byte*)trx);
+ mem_analyze_corruption(trx);
ut_a(0);
}
@@ -833,15 +826,14 @@
ha_innobase::ha_innobase(TABLE_SHARE *table_arg)
:handler(&innobase_hton, table_arg),
int_table_flags(HA_REC_NOT_IN_SEQ |
- HA_NULL_IN_KEY |
- HA_CAN_INDEX_BLOBS |
- HA_CAN_SQL_HANDLER |
- HA_NOT_EXACT_COUNT |
- HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS |
- HA_PRIMARY_KEY_IN_READ_INDEX |
- HA_CAN_GEOMETRY |
- HA_TABLE_SCAN_ON_INDEX),
- last_dup_key((uint) -1),
+ HA_NULL_IN_KEY |
+ HA_CAN_INDEX_BLOBS |
+ HA_CAN_SQL_HANDLER |
+ HA_NOT_EXACT_COUNT |
+ HA_PRIMARY_KEY_ALLOW_RANDOM_ACCESS |
+ HA_PRIMARY_KEY_IN_READ_INDEX |
+ HA_CAN_GEOMETRY |
+ HA_TABLE_SCAN_ON_INDEX),
start_of_scan(0),
num_write_row(0)
{}
@@ -883,8 +875,8 @@
/*===================*/
THD* thd) /* in: MySQL thd (connection) object */
{
- /* Register the statement */
- trans_register_ha(thd, FALSE, &innobase_hton);
+ /* Register the statement */
+ trans_register_ha(thd, FALSE, &innobase_hton);
}
/*************************************************************************
@@ -905,11 +897,11 @@
innobase_register_stmt(thd);
- if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
+ if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
- /* No autocommit mode, register for a transaction */
- trans_register_ha(thd, TRUE, &innobase_hton);
- }
+ /* No autocommit mode, register for a transaction */
+ trans_register_ha(thd, TRUE, &innobase_hton);
+ }
}
/* BACKGROUND INFO: HOW THE MYSQL QUERY CACHE WORKS WITH INNODB
@@ -989,7 +981,7 @@
name */
uint full_name_len, /* in: length of the full name, i.e.
len(dbname) + len(tablename) + 1 */
- ulonglong *unused) /* unused for this engine */
+ ulonglong *unused) /* unused for this engine */
{
ibool is_autocommit;
trx_t* trx;
@@ -1000,16 +992,21 @@
if (thd->variables.tx_isolation == ISO_SERIALIZABLE) {
/* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every
plain SELECT if AUTOCOMMIT is not on. */
-
+
return((my_bool)FALSE);
}
- trx = check_trx_exists(thd);
+ trx = check_trx_exists(thd);
if (trx->has_search_latch) {
ut_print_timestamp(stderr);
sql_print_error("The calling thread is holding the adaptive "
"search, latch though calling "
"innobase_query_caching_of_table_permitted.");
+
+ mutex_enter_noninline(&kernel_mutex);
+ trx_print(stderr, trx, 1024);
+ mutex_exit_noninline(&kernel_mutex);
+ ut_error;
}
innobase_release_stat_resources(trx);
@@ -1043,7 +1040,7 @@
return((my_bool)TRUE);
}
-
+
/* Normalize the table name to InnoDB format */
memcpy(norm_name, full_name, full_name_len);
@@ -1057,11 +1054,11 @@
/* The call of row_search_.. will start a new transaction if it is
not yet started */
- if (trx->active_trans == 0) {
+ if (trx->active_trans == 0) {
- innobase_register_trx_and_stmt(thd);
- trx->active_trans = 1;
- }
+ innobase_register_trx_and_stmt(thd);
+ trx->active_trans = 1;
+ }
if (row_search_check_if_query_cache_permitted(trx, norm_name)) {
@@ -1137,7 +1134,7 @@
}
/**************************************************************************
-Obtain a pointer to the MySQL THD object, as in current_thd(). This
+Obtain a pointer to the MySQL THD object, as in current_thd(). This
definition must match the one in sql/ha_innodb.cc! */
extern "C"
void*
@@ -1159,58 +1156,58 @@
ha_innobase::init_table_handle_for_HANDLER(void)
/*============================================*/
{
- row_prebuilt_t* prebuilt;
+ row_prebuilt_t* prebuilt;
- /* If current thd does not yet have a trx struct, create one.
- If the current handle does not yet have a prebuilt struct, create
- one. Update the trx pointers in the prebuilt struct. Normally
- this operation is done in external_lock. */
+ /* If current thd does not yet have a trx struct, create one.
+ If the current handle does not yet have a prebuilt struct, create
+ one. Update the trx pointers in the prebuilt struct. Normally
+ this operation is done in external_lock. */
- update_thd(current_thd);
+ update_thd(current_thd);
- /* Initialize the prebuilt struct much like it would be inited in
- external_lock */
+ /* Initialize the prebuilt struct much like it would be inited in
+ external_lock */
- prebuilt = (row_prebuilt_t*)innobase_prebuilt;
+ prebuilt = (row_prebuilt_t*)innobase_prebuilt;
innobase_release_stat_resources(prebuilt->trx);
- /* If the transaction is not started yet, start it */
+ /* If the transaction is not started yet, start it */
- trx_start_if_not_started_noninline(prebuilt->trx);
+ trx_start_if_not_started_noninline(prebuilt->trx);
- /* Assign a read view if the transaction does not have it yet */
+ /* Assign a read view if the transaction does not have it yet */
- trx_assign_read_view(prebuilt->trx);
+ trx_assign_read_view(prebuilt->trx);
/* Set the MySQL flag to mark that there is an active transaction */
- if (prebuilt->trx->active_trans == 0) {
+ if (prebuilt->trx->active_trans == 0) {
- innobase_register_trx_and_stmt(current_thd);
+ innobase_register_trx_and_stmt(current_thd);
- prebuilt->trx->active_trans = 1;
- }
+ prebuilt->trx->active_trans = 1;
+ }
- /* We did the necessary inits in this function, no need to repeat them
- in row_search_for_mysql */
+ /* We did the necessary inits in this function, no need to repeat them
+ in row_search_for_mysql */
- prebuilt->sql_stat_start = FALSE;
+ prebuilt->sql_stat_start = FALSE;
- /* We let HANDLER always to do the reads as consistent reads, even
- if the trx isolation level would have been specified as SERIALIZABLE */
+ /* We let HANDLER always to do the reads as consistent reads, even
+ if the trx isolation level would have been specified as SERIALIZABLE */
- prebuilt->select_lock_type = LOCK_NONE;
- prebuilt->stored_select_lock_type = LOCK_NONE;
+ prebuilt->select_lock_type = LOCK_NONE;
+ prebuilt->stored_select_lock_type = LOCK_NONE;
- /* Always fetch all columns in the index record */
+ /* Always fetch all columns in the index record */
- prebuilt->hint_need_to_fetch_extra_cols = ROW_RETRIEVE_ALL_COLS;
+ prebuilt->hint_need_to_fetch_extra_cols = ROW_RETRIEVE_ALL_COLS;
- /* We want always to fetch all columns in the whole row? Or do
+ /* We want always to fetch all columns in the whole row? Or do
we???? */
- prebuilt->read_just_key = FALSE;
+ prebuilt->read_just_key = FALSE;
prebuilt->used_in_HANDLER = TRUE;
@@ -1228,12 +1225,12 @@
static char current_dir[3]; /* Set if using current lib */
int err;
bool ret;
- char *default_path;
+ char *default_path;
- DBUG_ENTER("innobase_init");
+ DBUG_ENTER("innobase_init");
- if (have_innodb != SHOW_OPTION_YES)
- goto error;
+ if (have_innodb != SHOW_OPTION_YES)
+ goto error;
ut_a(DATA_MYSQL_TRUE_VARCHAR == (ulint)MYSQL_TYPE_VARCHAR);
@@ -1256,7 +1253,7 @@
}
}
- os_innodb_umask = (ulint)my_umask;
+ os_innodb_umask = (ulint)my_umask;
/* First calculate the default path for innodb_data_home_dir etc.,
in case the user has not given any value.
@@ -1268,20 +1265,20 @@
default_path = mysql_real_data_home;
fil_path_to_mysql_datadir = mysql_real_data_home;
} else {
- /* It's better to use current lib, to keep paths short */
- current_dir[0] = FN_CURLIB;
- current_dir[1] = FN_LIBCHAR;
- current_dir[2] = 0;
- default_path = current_dir;
+ /* It's better to use current lib, to keep paths short */
+ current_dir[0] = FN_CURLIB;
+ current_dir[1] = FN_LIBCHAR;
+ current_dir[2] = 0;
+ default_path = current_dir;
}
ut_a(default_path);
if (specialflag & SPECIAL_NO_PRIOR) {
- srv_set_thread_priorities = FALSE;
+ srv_set_thread_priorities = FALSE;
} else {
- srv_set_thread_priorities = TRUE;
- srv_query_thread_priority = QUERY_PRIOR;
+ srv_set_thread_priorities = TRUE;
+ srv_query_thread_priority = QUERY_PRIOR;
}
/* Set InnoDB initialization parameters according to the values
@@ -1295,11 +1292,11 @@
default_path);
/* Set default InnoDB data file size to 10 MB and let it be
- auto-extending. Thus users can use InnoDB in >= 4.0 without having
+ auto-extending. Thus users can use InnoDB in >= 4.0 without having
to specify any startup options. */
if (!innobase_data_file_path) {
- innobase_data_file_path = (char*) "ibdata1:10M:autoextend";
+ innobase_data_file_path = (char*) "ibdata1:10M:autoextend";
}
/* Since InnoDB edits the argument in the next call, we make another
@@ -1317,22 +1314,22 @@
&srv_auto_extend_last_data_file,
&srv_last_file_size_max);
if (ret == FALSE) {
- sql_print_error(
+ sql_print_error(
"InnoDB: syntax error in innodb_data_file_path");
- my_free(internal_innobase_data_file_path,
+ my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
- goto error;
+ goto error;
}
/* -------------- Log files ---------------------------*/
/* The default dir for log files is the datadir of MySQL */
-
+
if (!innobase_log_group_home_dir) {
- innobase_log_group_home_dir = default_path;
+ innobase_log_group_home_dir = default_path;
}
-#ifdef UNIV_LOG_ARCHIVE
+#ifdef UNIV_LOG_ARCHIVE
/* Since innodb_log_arch_dir has no relevance under MySQL,
starting from 4.0.6 we always set it the same as
innodb_log_group_home_dir: */
@@ -1350,9 +1347,9 @@
sql_print_error("syntax error in innodb_log_group_home_dir, or a "
"wrong number of mirrored log groups");
- my_free(internal_innobase_data_file_path,
+ my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
- goto error;
+ goto error;
}
/* --------------------------------------------------*/
@@ -1369,25 +1366,25 @@
srv_log_buffer_size = (ulint) innobase_log_buffer_size;
srv_flush_log_at_trx_commit = (ulint) innobase_flush_log_at_trx_commit;
- /* We set srv_pool_size here in units of 1 kB. InnoDB internally
- changes the value so that it becomes the number of database pages. */
+ /* We set srv_pool_size here in units of 1 kB. InnoDB internally
+ changes the value so that it becomes the number of database pages. */
+
+ if (innobase_buffer_pool_awe_mem_mb == 0) {
+ /* Careful here: we first convert the signed long int to ulint
+ and only after that divide */
- if (innobase_buffer_pool_awe_mem_mb == 0) {
- /* Careful here: we first convert the signed long int to ulint
- and only after that divide */
-
- srv_pool_size = ((ulint) innobase_buffer_pool_size) / 1024;
- } else {
- srv_use_awe = TRUE;
- srv_pool_size = (ulint)
- (1024 * innobase_buffer_pool_awe_mem_mb);
- srv_awe_window_size = (ulint) innobase_buffer_pool_size;
-
- /* Note that what the user specified as
- innodb_buffer_pool_size is actually the AWE memory window
- size in this case, and the real buffer pool size is
- determined by .._awe_mem_mb. */
- }
+ srv_pool_size = ((ulint) innobase_buffer_pool_size) / 1024;
+ } else {
+ srv_use_awe = TRUE;
+ srv_pool_size = (ulint)
+ (1024 * innobase_buffer_pool_awe_mem_mb);
+ srv_awe_window_size = (ulint) innobase_buffer_pool_size;
+
+ /* Note that what the user specified as
+ innodb_buffer_pool_size is actually the AWE memory window
+ size in this case, and the real buffer pool size is
+ determined by .._awe_mem_mb. */
+ }
srv_mem_pool_size = (ulint) innobase_additional_mem_pool_size;
@@ -1401,9 +1398,9 @@
os_use_large_pages = (ibool) innobase_use_large_pages;
os_large_page_size = (ulint) innobase_large_page_size;
-
+
srv_file_per_table = (ibool) innobase_file_per_table;
- srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
+ srv_locks_unsafe_for_binlog = (ibool) innobase_locks_unsafe_for_binlog;
srv_max_n_open_files = (ulint) innobase_open_files;
srv_innodb_status = (ibool) innobase_create_status_file;
@@ -1417,6 +1414,7 @@
ut_a(DATA_MYSQL_LATIN1_SWEDISH_CHARSET_COLL ==
my_charset_latin1.number);
+ ut_a(DATA_MYSQL_BINARY_CHARSET_COLL == my_charset_bin.number);
/* Store the latin1_swedish_ci character ordering table to InnoDB. For
non-latin1_swedish_ci charsets we use the MySQL comparison functions,
@@ -1428,7 +1426,7 @@
memcpy(srv_latin1_ordering, my_charset_latin1.sort_order, 256);
/* Since we in this module access directly the fields of a trx
- struct, and due to different headers and flags it might happen that
+ struct, and due to different headers and flags it might happen that
mutex_t has a different size in this module and in InnoDB
modules, we check at run time that the size is the same in
these compilation modules. */
@@ -1438,18 +1436,18 @@
err = innobase_start_or_create_for_mysql();
if (err != DB_SUCCESS) {
- my_free(internal_innobase_data_file_path,
+ my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
- goto error;
+ goto error;
}
(void) hash_init(&innobase_open_tables,system_charset_info, 32, 0, 0,
- (hash_get_key) innobase_get_key, 0, 0);
- pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
- pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
- pthread_cond_init(&commit_cond, NULL);
+ (hash_get_key) innobase_get_key, 0, 0);
+ pthread_mutex_init(&innobase_share_mutex, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&prepare_commit_mutex, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&commit_threads_m, MY_MUTEX_INIT_FAST);
+ pthread_mutex_init(&commit_cond_m, MY_MUTEX_INIT_FAST);
+ pthread_cond_init(&commit_cond, NULL);
innodb_inited= 1;
/* If this is a replication slave and we needed to do a crash recovery,
@@ -1460,7 +1458,7 @@
THIS DOES NOT WORK CURRENTLY because replication seems to initialize
glob_mi also after innobase_init. */
-
+
/* if (trx_sys_mysql_master_log_pos != -1) {
ut_memcpy(glob_mi.log_file_name, trx_sys_mysql_master_log_name,
1 + ut_strlen(trx_sys_mysql_master_log_name));
@@ -1469,8 +1467,8 @@
*/
DBUG_RETURN(FALSE);
error:
- have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
- DBUG_RETURN(TRUE);
+ have_innodb= SHOW_OPTION_DISABLED; // If we couldn't use handler
+ DBUG_RETURN(TRUE);
}
/***********************************************************************
@@ -1485,29 +1483,29 @@
DBUG_ENTER("innobase_end");
-#ifdef __NETWARE__ /* some special cleanup for NetWare */
+#ifdef __NETWARE__ /* some special cleanup for NetWare */
if (nw_panic) {
set_panic_flag_for_netware();
}
#endif
if (innodb_inited) {
- srv_fast_shutdown = (ulint) innobase_fast_shutdown;
- innodb_inited = 0;
- if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
- err = 1;
+ srv_fast_shutdown = (ulint) innobase_fast_shutdown;
+ innodb_inited = 0;
+ if (innobase_shutdown_for_mysql() != DB_SUCCESS) {
+ err = 1;
}
- hash_free(&innobase_open_tables);
- my_free(internal_innobase_data_file_path,
+ hash_free(&innobase_open_tables);
+ my_free(internal_innobase_data_file_path,
MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_destroy(&innobase_share_mutex);
- pthread_mutex_destroy(&prepare_commit_mutex);
- pthread_mutex_destroy(&commit_threads_m);
- pthread_mutex_destroy(&commit_cond_m);
- pthread_cond_destroy(&commit_cond);
+ pthread_mutex_destroy(&innobase_share_mutex);
+ pthread_mutex_destroy(&prepare_commit_mutex);
+ pthread_mutex_destroy(&commit_threads_m);
+ pthread_mutex_destroy(&commit_cond_m);
+ pthread_cond_destroy(&commit_cond);
}
- DBUG_RETURN(err);
+ DBUG_RETURN(err);
}
/********************************************************************
@@ -1519,13 +1517,13 @@
/*=====================*/
/* out: TRUE if error */
{
- bool result = 0;
+ bool result = 0;
- DBUG_ENTER("innobase_flush_logs");
+ DBUG_ENTER("innobase_flush_logs");
log_buffer_flush_to_disk();
- DBUG_RETURN(result);
+ DBUG_RETURN(result);
}
/*********************************************************************
@@ -1536,22 +1534,22 @@
/*================*/
trx_t* trx) /* in: transaction handle */
{
- if (trx->conc_state == TRX_NOT_STARTED) {
+ if (trx->conc_state == TRX_NOT_STARTED) {
- return;
- }
+ return;
+ }
#ifdef HAVE_REPLICATION
- THD *thd=current_thd;
+ THD *thd=current_thd;
- if (thd && thd->slave_thread) {
- /* Update the replication position info inside InnoDB */
+ if (thd && thd->slave_thread) {
+ /* Update the replication position info inside InnoDB */
- trx->mysql_master_log_file_name
- = active_mi->rli.group_master_log_name;
- trx->mysql_master_log_pos = ((ib_longlong)
- active_mi->rli.future_group_master_log_pos);
- }
+ trx->mysql_master_log_file_name
+ = active_mi->rli.group_master_log_name;
+ trx->mysql_master_log_pos = ((ib_longlong)
+ active_mi->rli.future_group_master_log_pos);
+ }
#endif /* HAVE_REPLICATION */
trx_commit_for_mysql(trx);
@@ -1572,7 +1570,7 @@
{
trx_t* trx;
- DBUG_ENTER("innobase_start_trx_and_assign_read_view");
+ DBUG_ENTER("innobase_start_trx_and_assign_read_view");
/* Create a new trx struct for thd, if it does not yet have one */
@@ -1594,12 +1592,12 @@
/* Set the MySQL flag to mark that there is an active transaction */
- if (trx->active_trans == 0) {
+ if (trx->active_trans == 0) {
- innobase_register_trx_and_stmt(current_thd);
+ innobase_register_trx_and_stmt(current_thd);
- trx->active_trans = 1;
- }
+ trx->active_trans = 1;
+ }
DBUG_RETURN(0);
}
@@ -1614,13 +1612,13 @@
/* out: 0 */
THD* thd, /* in: MySQL thread handle of the user for whom
the transaction should be committed */
- bool all) /* in: TRUE - commit transaction
- FALSE - the current SQL statement ended */
+ bool all) /* in: TRUE - commit transaction
+ FALSE - the current SQL statement ended */
{
trx_t* trx;
- DBUG_ENTER("innobase_commit");
- DBUG_PRINT("trans", ("ending transaction"));
+ DBUG_ENTER("innobase_commit");
+ DBUG_PRINT("trans", ("ending transaction"));
trx = check_trx_exists(thd);
@@ -1631,11 +1629,11 @@
reserve the kernel mutex, we have to release the search system latch
first to obey the latching order. */
- if (trx->has_search_latch) {
- trx_search_latch_release_if_reserved(trx);
- }
-
- /* The flag trx->active_trans is set to 1 in
+ if (trx->has_search_latch) {
+ trx_search_latch_release_if_reserved(trx);
+ }
+
+ /* The flag trx->active_trans is set to 1 in
1. ::external_lock(),
2. ::start_stmt(),
@@ -1650,65 +1648,66 @@
For the time being, we play safe and do the cleanup though there should
be nothing to clean up. */
- if (trx->active_trans == 0
- && trx->conc_state != TRX_NOT_STARTED) {
-
- sql_print_error("trx->active_trans == 0, but trx->conc_state != "
- "TRX_NOT_STARTED");
+ if (trx->active_trans == 0
+ && trx->conc_state != TRX_NOT_STARTED) {
+
+ sql_print_error("trx->active_trans == 0, but"
+ " trx->conc_state != TRX_NOT_STARTED");
}
- if (all
- || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
-
- /* We were instructed to commit the whole transaction, or
+ if (all
+ || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
+
+ /* We were instructed to commit the whole transaction, or
this is an SQL statement end and autocommit is on */
- /* We need current binlog position for ibbackup to work.
- Note, the position is current because of prepare_commit_mutex */
+ /* We need current binlog position for ibbackup to work.
+ Note, the position is current because of
+ prepare_commit_mutex */
retry:
- if (srv_commit_concurrency > 0)
- {
- pthread_mutex_lock(&commit_cond_m);
- commit_threads++;
- if (commit_threads > srv_commit_concurrency)
- {
- commit_threads--;
- pthread_cond_wait(&commit_cond, &commit_cond_m);
- pthread_mutex_unlock(&commit_cond_m);
- goto retry;
- }
- else
- pthread_mutex_unlock(&commit_cond_m);
- }
-
- trx->mysql_log_file_name = mysql_bin_log.get_log_fname();
- trx->mysql_log_offset =
- (ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;
+ if (srv_commit_concurrency > 0) {
+ pthread_mutex_lock(&commit_cond_m);
+ commit_threads++;
+
+ if (commit_threads > srv_commit_concurrency) {
+ commit_threads--;
+ pthread_cond_wait(&commit_cond,
+ &commit_cond_m);
+ pthread_mutex_unlock(&commit_cond_m);
+ goto retry;
+ }
+ else {
+ pthread_mutex_unlock(&commit_cond_m);
+ }
+ }
+
+ trx->mysql_log_file_name = mysql_bin_log.get_log_fname();
+ trx->mysql_log_offset =
+ (ib_longlong)mysql_bin_log.get_log_file()->pos_in_file;
innobase_commit_low(trx);
- if (srv_commit_concurrency > 0)
- {
- pthread_mutex_lock(&commit_cond_m);
- commit_threads--;
- pthread_cond_signal(&commit_cond);
- pthread_mutex_unlock(&commit_cond_m);
- }
-
- if (trx->active_trans == 2) {
-
- pthread_mutex_unlock(&prepare_commit_mutex);
- }
-
- trx->active_trans = 0;
-
+ if (srv_commit_concurrency > 0) {
+ pthread_mutex_lock(&commit_cond_m);
+ commit_threads--;
+ pthread_cond_signal(&commit_cond);
+ pthread_mutex_unlock(&commit_cond_m);
+ }
+
+ if (trx->active_trans == 2) {
+
+ pthread_mutex_unlock(&prepare_commit_mutex);
+ }
+
+ trx->active_trans = 0;
+
} else {
- /* We just mark the SQL statement ended and do not do a
+ /* We just mark the SQL statement ended and do not do a
transaction commit */
if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some
table in this SQL statement we release it now */
-
+
row_unlock_table_autoinc_for_mysql(trx);
}
/* Store the current undo_no of the transaction so that we
@@ -1720,11 +1719,11 @@
/* Tell the InnoDB server that there might be work for utility
threads: */
- if (trx->declared_to_be_inside_innodb) {
- /* Release our possible ticket in the FIFO */
+ if (trx->declared_to_be_inside_innodb) {
+ /* Release our possible ticket in the FIFO */
- srv_conc_force_exit_innodb(trx);
- }
+ srv_conc_force_exit_innodb(trx);
+ }
srv_active_wake_master_thread();
DBUG_RETURN(0);
@@ -1746,12 +1745,12 @@
int
innobase_report_binlog_offset_and_commit(
/*=====================================*/
- /* out: 0 */
- THD* thd, /* in: user thread */
- void* trx_handle, /* in: InnoDB trx handle */
- char* log_file_name, /* in: latest binlog file name */
- my_off_t end_offset) /* in: the offset in the binlog file
- up to which we wrote */
+ /* out: 0 */
+ THD* thd, /* in: user thread */
+ void* trx_handle, /* in: InnoDB trx handle */
+ char* log_file_name, /* in: latest binlog file name */
+ my_off_t end_offset) /* in: the offset in the binlog file
+ up to which we wrote */
{
trx_t* trx;
@@ -1763,23 +1762,23 @@
trx->mysql_log_offset = (ib_longlong)end_offset;
#ifdef HAVE_REPLICATION
- if (thd->variables.sync_replication) {
- /* Let us store the binlog file name and the position, so that
- we know how long to wait for the binlog to the replicated to
- the slave in synchronous replication. */
+ if (thd->variables.sync_replication) {
+ /* Let us store the binlog file name and the position, so that
+ we know how long to wait for the binlog to the replicated to
+ the slave in synchronous replication. */
- if (trx->repl_wait_binlog_name == NULL) {
+ if (trx->repl_wait_binlog_name == NULL) {
- trx->repl_wait_binlog_name =
- (char*)mem_alloc_noninline(FN_REFLEN + 100);
- }
+ trx->repl_wait_binlog_name =
+ (char*)mem_alloc_noninline(FN_REFLEN + 100);
+ }
- ut_a(strlen(log_file_name) < FN_REFLEN + 100);
+ ut_a(strlen(log_file_name) < FN_REFLEN + 100);
- strcpy(trx->repl_wait_binlog_name, log_file_name);
+ strcpy(trx->repl_wait_binlog_name, log_file_name);
- trx->repl_wait_binlog_pos = (ib_longlong)end_offset;
- }
+ trx->repl_wait_binlog_pos = (ib_longlong)end_offset;
+ }
#endif /* HAVE_REPLICATION */
trx->flush_log_later = TRUE;
@@ -1797,26 +1796,26 @@
void
innobase_store_binlog_offset_and_flush_log(
/*=======================================*/
- char *binlog_name, /* in: binlog name */
- longlong offset) /* in: binlog offset */
+ char* binlog_name, /* in: binlog name */
+ longlong offset) /* in: binlog offset */
{
mtr_t mtr;
assert(binlog_name != NULL);
/* Start a mini-transaction */
- mtr_start_noninline(&mtr);
+ mtr_start_noninline(&mtr);
/* Update the latest MySQL binlog name and offset info
- in trx sys header */
+ in trx sys header */
- trx_sys_update_mysql_binlog_offset(
- binlog_name,
- offset,
- TRX_SYS_MYSQL_LOG_INFO, &mtr);
+ trx_sys_update_mysql_binlog_offset(
+ binlog_name,
+ offset,
+ TRX_SYS_MYSQL_LOG_INFO, &mtr);
- /* Commits the mini-transaction */
- mtr_commit(&mtr);
+ /* Commits the mini-transaction */
+ mtr_commit(&mtr);
/* Synchronous flush of the log buffer to disk */
log_buffer_flush_to_disk();
@@ -1830,106 +1829,107 @@
int
innobase_commit_complete(
/*=====================*/
- /* out: 0 */
- THD* thd) /* in: user thread */
+ /* out: 0 */
+ THD* thd) /* in: user thread */
{
trx_t* trx;
- trx = (trx_t*) thd->ha_data[innobase_hton.slot];
+ trx = (trx_t*) thd->ha_data[innobase_hton.slot];
- if (trx && trx->active_trans) {
+ if (trx && trx->active_trans) {
- trx->active_trans = 0;
+ trx->active_trans = 0;
- if (srv_flush_log_at_trx_commit == 0) {
+ if (srv_flush_log_at_trx_commit == 0) {
- return(0);
- }
+ return(0);
+ }
- trx_commit_complete_for_mysql(trx);
- }
+ trx_commit_complete_for_mysql(trx);
+ }
#ifdef HAVE_REPLICATION
- if (thd->variables.sync_replication
- && trx->repl_wait_binlog_name
- && innobase_repl_state != 0) {
+ if (thd->variables.sync_replication
+ && trx->repl_wait_binlog_name
+ && innobase_repl_state != 0) {
struct timespec abstime;
int cmp;
int ret;
- /* In synchronous replication, let us wait until the MySQL
- replication has sent the relevant binlog segment to the
- replication slave. */
+ /* In synchronous replication, let us wait until the MySQL
+ replication has sent the relevant binlog segment to the
+ replication slave. */
- pthread_mutex_lock(&innobase_repl_cond_mutex);
+ pthread_mutex_lock(&innobase_repl_cond_mutex);
try_again:
- if (innobase_repl_state == 0) {
+ if (innobase_repl_state == 0) {
- pthread_mutex_unlock(&innobase_repl_cond_mutex);
+ pthread_mutex_unlock(&innobase_repl_cond_mutex);
- return(0);
- }
+ return(0);
+ }
- cmp = strcmp(innobase_repl_file_name,
- trx->repl_wait_binlog_name);
- if (cmp > 0
- || (cmp == 0 && innobase_repl_pos
- >= (my_off_t)trx->repl_wait_binlog_pos)) {
- /* We have already sent the relevant binlog to the
- slave: no need to wait here */
+ cmp = strcmp(innobase_repl_file_name,
+ trx->repl_wait_binlog_name);
+ if (cmp > 0
+ || (cmp == 0 && innobase_repl_pos
+ >= (my_off_t)trx->repl_wait_binlog_pos)) {
+ /* We have already sent the relevant binlog to the
+ slave: no need to wait here */
- pthread_mutex_unlock(&innobase_repl_cond_mutex);
+ pthread_mutex_unlock(&innobase_repl_cond_mutex);
-/* printf("Binlog now sent\n"); */
+/* printf("Binlog now sent\n"); */
- return(0);
- }
+ return(0);
+ }
- /* Let us update the info about the minimum binlog position
- of waiting threads in the innobase_repl_... variables */
+ /* Let us update the info about the minimum binlog position
+ of waiting threads in the innobase_repl_... variables */
- if (innobase_repl_wait_file_name_inited != 0) {
- cmp = strcmp(trx->repl_wait_binlog_name,
- innobase_repl_wait_file_name);
- if (cmp < 0
- || (cmp == 0 && (my_off_t)trx->repl_wait_binlog_pos
- <= innobase_repl_wait_pos)) {
- /* This thd has an even lower position, let
- us update the minimum info */
+ if (innobase_repl_wait_file_name_inited != 0) {
+ cmp = strcmp(trx->repl_wait_binlog_name,
+ innobase_repl_wait_file_name);
+ if (cmp < 0
+ || (cmp == 0
+ && (my_off_t)trx->repl_wait_binlog_pos
+ <= innobase_repl_wait_pos)) {
+ /* This thd has an even lower position, let
+ us update the minimum info */
- strcpy(innobase_repl_wait_file_name,
- trx->repl_wait_binlog_name);
+ strcpy(innobase_repl_wait_file_name,
+ trx->repl_wait_binlog_name);
- innobase_repl_wait_pos =
- trx->repl_wait_binlog_pos;
- }
- } else {
- strcpy(innobase_repl_wait_file_name,
- trx->repl_wait_binlog_name);
+ innobase_repl_wait_pos =
+ trx->repl_wait_binlog_pos;
+ }
+ } else {
+ strcpy(innobase_repl_wait_file_name,
+ trx->repl_wait_binlog_name);
- innobase_repl_wait_pos = trx->repl_wait_binlog_pos;
+ innobase_repl_wait_pos = trx->repl_wait_binlog_pos;
- innobase_repl_wait_file_name_inited = 1;
- }
- set_timespec(abstime, thd->variables.sync_replication_timeout);
+ innobase_repl_wait_file_name_inited = 1;
+ }
+ set_timespec(abstime, thd->variables.sync_replication_timeout);
- /* Let us suspend this thread to wait on the condition;
- when replication has progressed far enough, we will release
- these waiting threads. The following call
- pthread_cond_timedwait also atomically unlocks
- innobase_repl_cond_mutex. */
+ /* Let us suspend this thread to wait on the condition;
+ when replication has progressed far enough, we will release
+ these waiting threads. The following call
+ pthread_cond_timedwait also atomically unlocks
+ innobase_repl_cond_mutex. */
- innobase_repl_n_wait_threads++;
+ innobase_repl_n_wait_threads++;
-/* printf("Waiting for binlog to be sent\n"); */
+/* printf("Waiting for binlog to be sent\n"); */
- ret = pthread_cond_timedwait(&innobase_repl_cond,
- &innobase_repl_cond_mutex, &abstime);
- innobase_repl_n_wait_threads--;
+ ret = pthread_cond_timedwait(&innobase_repl_cond,
+ &innobase_repl_cond_mutex, &abstime);
+ innobase_repl_n_wait_threads--;
- if (ret != 0) {
- ut_print_timestamp(stderr);
+ if (ret != 0) {
+ ut_print_timestamp(stderr);
sql_print_error("MySQL synchronous replication was "
"not able to send the binlog to the "
@@ -1949,15 +1949,15 @@
trx->repl_wait_binlog_name,
(ulong) trx->repl_wait_binlog_pos);
- innobase_repl_state = 0;
+ innobase_repl_state = 0;
- pthread_mutex_unlock(&innobase_repl_cond_mutex);
+ pthread_mutex_unlock(&innobase_repl_cond_mutex);
- return(0);
- }
+ return(0);
+ }
- goto try_again;
- }
+ goto try_again;
+ }
#endif // HAVE_REPLICATION
return(0);
}
@@ -1972,56 +1972,56 @@
int
innobase_repl_report_sent_binlog(
/*=============================*/
- /* out: 0 */
- THD* thd, /* in: thread doing the binlog communication to
- the slave */
- char* log_file_name, /* in: binlog file name */
- my_off_t end_offset) /* in: the offset in the binlog file up to
- which we sent the contents to the slave */
+ /* out: 0 */
+ THD* thd, /* in: thread doing the binlog communication to
+ the slave */
+ char* log_file_name, /* in: binlog file name */
+ my_off_t end_offset) /* in: the offset in the binlog file up to
+ which we sent the contents to the slave */
{
- int cmp;
- ibool can_release_threads = 0;
+ int cmp;
+ ibool can_release_threads = 0;
if (!innodb_inited) {
-
+
return 0;
}
- /* If synchronous replication is not switched on, or this thd is
- sending binlog to a slave where we do not need synchronous replication,
- then return immediately */
+ /* If synchronous replication is not switched on, or this thd is
+ sending binlog to a slave where we do not need synchronous replication,
+ then return immediately */
- if (thd->server_id != thd->variables.sync_replication_slave_id) {
+ if (thd->server_id != thd->variables.sync_replication_slave_id) {
- /* Do nothing */
+ /* Do nothing */
- return(0);
- }
+ return(0);
+ }
- pthread_mutex_lock(&innobase_repl_cond_mutex);
+ pthread_mutex_lock(&innobase_repl_cond_mutex);
- if (innobase_repl_state == 0) {
+ if (innobase_repl_state == 0) {
- ut_print_timestamp(stderr);
+ ut_print_timestamp(stderr);
sql_print_warning("Switching MySQL synchronous replication on "
"again at binlog file %s, position %lu",
log_file_name, (ulong) end_offset);
- innobase_repl_state = 1;
- }
+ innobase_repl_state = 1;
+ }
- /* The position should increase monotonically, since just one thread
- is sending the binlog to the slave for which we want synchronous
- replication. Let us check this, and print an error to the .err log
- if that is not the case. */
+ /* The position should increase monotonically, since just one thread
+ is sending the binlog to the slave for which we want synchronous
+ replication. Let us check this, and print an error to the .err log
+ if that is not the case. */
- if (innobase_repl_file_name_inited) {
- cmp = strcmp(log_file_name, innobase_repl_file_name);
+ if (innobase_repl_file_name_inited) {
+ cmp = strcmp(log_file_name, innobase_repl_file_name);
- if (cmp < 0
- || (cmp == 0 && end_offset < innobase_repl_pos)) {
+ if (cmp < 0
+ || (cmp == 0 && end_offset < innobase_repl_pos)) {
- ut_print_timestamp(stderr);
+ ut_print_timestamp(stderr);
sql_print_error("MySQL synchronous replication has "
"sent binlog to the slave up to file "
"%s, position %lu, but now MySQL "
@@ -2030,38 +2030,38 @@
innobase_repl_file_name,
(ulong) innobase_repl_pos,
log_file_name, (ulong) end_offset);
- }
- }
+ }
+ }
- strcpy(innobase_repl_file_name, log_file_name);
- innobase_repl_pos = end_offset;
- innobase_repl_file_name_inited = 1;
+ strcpy(innobase_repl_file_name, log_file_name);
+ innobase_repl_pos = end_offset;
+ innobase_repl_file_name_inited = 1;
- if (innobase_repl_n_wait_threads > 0) {
- /* Let us check if some of the waiting threads doing a trx
- commit can now proceed */
+ if (innobase_repl_n_wait_threads > 0) {
+ /* Let us check if some of the waiting threads doing a trx
+ commit can now proceed */
- cmp = strcmp(innobase_repl_file_name,
- innobase_repl_wait_file_name);
- if (cmp > 0
- || (cmp == 0 && innobase_repl_pos
- >= innobase_repl_wait_pos)) {
+ cmp = strcmp(innobase_repl_file_name,
+ innobase_repl_wait_file_name);
+ if (cmp > 0
+ || (cmp == 0 && innobase_repl_pos
+ >= innobase_repl_wait_pos)) {
- /* Yes, at least one waiting thread can now proceed:
- let us release all waiting threads with a broadcast */
+ /* Yes, at least one waiting thread can now proceed:
+ let us release all waiting threads with a broadcast */
- can_release_threads = 1;
+ can_release_threads = 1;
- innobase_repl_wait_file_name_inited = 0;
- }
- }
+ innobase_repl_wait_file_name_inited = 0;
+ }
+ }
- pthread_mutex_unlock(&innobase_repl_cond_mutex);
+ pthread_mutex_unlock(&innobase_repl_cond_mutex);
- if (can_release_threads) {
+ if (can_release_threads) {
- pthread_cond_broadcast(&innobase_repl_cond);
- }
+ pthread_cond_broadcast(&innobase_repl_cond);
+ }
return(0);
}
@@ -2076,8 +2076,8 @@
/* out: 0 or error number */
THD* thd, /* in: handle to the MySQL thread of the user
whose transaction should be rolled back */
- bool all) /* in: TRUE - commit transaction
- FALSE - the current SQL statement ended */
+ bool all) /* in: TRUE - commit transaction
+ FALSE - the current SQL statement ended */
{
int error = 0;
trx_t* trx;
@@ -2096,19 +2096,19 @@
innobase_release_stat_resources(trx);
- if (trx->auto_inc_lock) {
+ if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we
release it now before a possibly lengthy rollback */
-
+
row_unlock_table_autoinc_for_mysql(trx);
}
- if (all
- || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
+ if (all
+ || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
error = trx_rollback_for_mysql(trx);
- trx->active_trans = 0;
+ trx->active_trans = 0;
} else {
error = trx_rollback_last_sql_stat_for_mysql(trx);
}
@@ -2136,11 +2136,11 @@
innobase_release_stat_resources(trx);
- if (trx->auto_inc_lock) {
+ if (trx->auto_inc_lock) {
/* If we had reserved the auto-inc lock for some table (if
we come here to roll back the latest SQL statement) we
release it now before a possibly lengthy rollback */
-
+
row_unlock_table_autoinc_for_mysql(trx);
}
@@ -2159,12 +2159,12 @@
no savepoint with the given name */
THD* thd, /* in: handle to the MySQL thread of the user
whose transaction should be rolled back */
- void *savepoint) /* in: savepoint data */
+ void* savepoint) /* in: savepoint data */
{
- ib_longlong mysql_binlog_cache_pos;
- int error = 0;
- trx_t* trx;
- char name[64];
+ ib_longlong mysql_binlog_cache_pos;
+ int error = 0;
+ trx_t* trx;
+ char name[64];
DBUG_ENTER("innobase_rollback_to_savepoint");
@@ -2176,11 +2176,11 @@
innobase_release_stat_resources(trx);
- /* TODO: use provided savepoint data area to store savepoint data */
+ /* TODO: use provided savepoint data area to store savepoint data */
- longlong2str((ulint)savepoint, name, 36);
+ longlong2str((ulint)savepoint, name, 36);
- error = (int) trx_rollback_to_savepoint_for_mysql(trx, name,
+ error = (int) trx_rollback_to_savepoint_for_mysql(trx, name,
&mysql_binlog_cache_pos);
DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
}
@@ -2195,19 +2195,19 @@
no savepoint with the given name */
THD* thd, /* in: handle to the MySQL thread of the user
whose transaction should be rolled back */
- void* savepoint) /* in: savepoint data */
+ void* savepoint) /* in: savepoint data */
{
- int error = 0;
- trx_t* trx;
- char name[64];
+ int error = 0;
+ trx_t* trx;
+ char name[64];
DBUG_ENTER("innobase_release_savepoint");
trx = check_trx_exists(thd);
- /* TODO: use provided savepoint data area to store savepoint data */
+ /* TODO: use provided savepoint data area to store savepoint data */
- longlong2str((ulint)savepoint, name, 36);
+ longlong2str((ulint)savepoint, name, 36);
error = (int) trx_release_savepoint_for_mysql(trx, name);
@@ -2222,20 +2222,20 @@
/*===============*/
/* out: always 0, that is, always succeeds */
THD* thd, /* in: handle to the MySQL thread */
- void* savepoint) /* in: savepoint data */
+ void* savepoint) /* in: savepoint data */
{
int error = 0;
trx_t* trx;
DBUG_ENTER("innobase_savepoint");
- /*
- In the autocommit mode there is no sense to set a savepoint
- (unless we are in sub-statement), so SQL layer ensures that
- this method is never called in such situation.
- */
- DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
- thd->in_sub_stmt);
+ /*
+ In the autocommit mode there is no sense to set a savepoint
+ (unless we are in sub-statement), so SQL layer ensures that
+ this method is never called in such situation.
+ */
+ DBUG_ASSERT(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN) ||
+ thd->in_sub_stmt);
trx = check_trx_exists(thd);
@@ -2245,14 +2245,14 @@
innobase_release_stat_resources(trx);
- /* cannot happen outside of transaction */
- DBUG_ASSERT(trx->active_trans);
+ /* cannot happen outside of transaction */
+ DBUG_ASSERT(trx->active_trans);
- /* TODO: use provided savepoint data area to store savepoint data */
- char name[64];
- longlong2str((ulint)savepoint,name,36);
+ /* TODO: use provided savepoint data area to store savepoint data */
+ char name[64];
+ longlong2str((ulint)savepoint,name,36);
- error = (int) trx_savepoint_for_mysql(trx, name, (ib_longlong)0);
+ error = (int) trx_savepoint_for_mysql(trx, name, (ib_longlong)0);
DBUG_RETURN(convert_error_code_to_mysql(error, NULL));
}
@@ -2273,24 +2273,26 @@
ut_a(trx);
- if (trx->active_trans == 0
- && trx->conc_state != TRX_NOT_STARTED) {
-
- sql_print_error("trx->active_trans == 0, but trx->conc_state != "
- "TRX_NOT_STARTED");
+ if (trx->active_trans == 0
+ && trx->conc_state != TRX_NOT_STARTED) {
+
+ sql_print_error("trx->active_trans == 0, but"
+ " trx->conc_state != TRX_NOT_STARTED");
}
if (trx->conc_state != TRX_NOT_STARTED &&
- global_system_variables.log_warnings)
- sql_print_warning("MySQL is closing a connection that has an active "
- "InnoDB transaction. %lu row modifications will "
- "roll back.",
- (ulong)trx->undo_no.low);
+ global_system_variables.log_warnings) {
+ sql_print_warning(
+ "MySQL is closing a connection that has an active "
+ "InnoDB transaction. %lu row modifications will "
+ "roll back.",
+ (ulong) trx->undo_no.low);
+ }
innobase_rollback_trx(trx);
- trx_free_for_mysql(trx);
+ trx_free_for_mysql(trx);
return(0);
}
@@ -2310,7 +2312,7 @@
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
if (prebuilt && prebuilt->table) {
- if (prebuilt->table->comp) {
+ if (dict_table_is_comp(prebuilt->table)) {
return(ROW_TYPE_COMPACT);
} else {
return(ROW_TYPE_REDUNDANT);
@@ -2391,11 +2393,11 @@
/*==============*/
/* out: 1 if error, 0 if success */
const char* name, /* in: table name */
- int mode, /* in: not used */
- uint test_if_locked) /* in: not used */
+ int mode, /* in: not used */
+ uint test_if_locked) /* in: not used */
{
dict_table_t* ib_table;
- char norm_name[1000];
+ char norm_name[1000];
THD* thd;
DBUG_ENTER("ha_innobase::open");
@@ -2424,20 +2426,21 @@
table->s->reclength + table->s->max_key_length
+ MAX_REF_PARTS * 3;
if (!(mysql_byte*) my_multi_malloc(MYF(MY_WME),
- &upd_buff, upd_and_key_val_buff_len,
- &key_val_buff, upd_and_key_val_buff_len,
- NullS)) {
- free_share(share);
+ &upd_buff, upd_and_key_val_buff_len,
+ &key_val_buff, upd_and_key_val_buff_len,
+ NullS)) {
+ free_share(share);
- DBUG_RETURN(1);
- }
+ DBUG_RETURN(1);
+ }
/* Get pointer to a table object in InnoDB dictionary cache */
ib_table = dict_table_get_and_increment_handle_count(
- norm_name, NULL);
- if (NULL == ib_table) {
- ut_print_timestamp(stderr);
+ norm_name, NULL);
+
+ if (NULL == ib_table) {
+ ut_print_timestamp(stderr);
sql_print_error("Cannot find table %s from the internal data "
"dictionary\nof InnoDB though the .frm file "
"for the table exists. Maybe you\nhave "
@@ -2449,15 +2452,15 @@
"http://www.innodb.com/ibman.html\n"
"how you can resolve the problem.\n",
norm_name);
- free_share(share);
- my_free((gptr) upd_buff, MYF(0));
- my_errno = ENOENT;
+ free_share(share);
+ my_free((gptr) upd_buff, MYF(0));
+ my_errno = ENOENT;
- DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
- }
+ DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
+ }
- if (ib_table->ibd_file_missing && !thd->tablespace_op) {
- ut_print_timestamp(stderr);
+ if (ib_table->ibd_file_missing && !thd->tablespace_op) {
+ ut_print_timestamp(stderr);
sql_print_error("MySQL is trying to open a table handle but "
"the .ibd file for\ntable %s does not exist.\n"
"Have you deleted the .ibd file from the "
@@ -2467,13 +2470,13 @@
"http://www.innodb.com/ibman.html\n"
"how you can resolve the problem.\n",
norm_name);
- free_share(share);
- my_free((gptr) upd_buff, MYF(0));
- my_errno = ENOENT;
+ free_share(share);
+ my_free((gptr) upd_buff, MYF(0));
+ my_errno = ENOENT;
dict_table_decrement_handle_count(ib_table);
- DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
- }
+ DBUG_RETURN(HA_ERR_NO_SUCH_TABLE);
+ }
innobase_prebuilt = row_create_prebuilt(ib_table);
@@ -2482,32 +2485,32 @@
/* Looks like MySQL-3.23 sometimes has primary key number != 0 */
- primary_key = table->s->primary_key;
+ primary_key = table->s->primary_key;
key_used_on_scan = primary_key;
/* Allocate a buffer for a 'row reference'. A row reference is
a string of bytes of length ref_length which uniquely specifies
- a row in our table. Note that MySQL may also compare two row
- references for equality by doing a simple memcmp on the strings
- of length ref_length! */
+ a row in our table. Note that MySQL may also compare two row
+ references for equality by doing a simple memcmp on the strings
+ of length ref_length! */
- if (!row_table_got_default_clust_index(ib_table)) {
- if (primary_key >= MAX_KEY) {
+ if (!row_table_got_default_clust_index(ib_table)) {
+ if (primary_key >= MAX_KEY) {
sql_print_error("Table %s has a primary key in InnoDB data "
"dictionary, but not in MySQL!", name);
}
((row_prebuilt_t*)innobase_prebuilt)
->clust_index_was_generated = FALSE;
- /* MySQL allocates the buffer for ref. key_info->key_length
+ /* MySQL allocates the buffer for ref. key_info->key_length
includes space for all key columns + one byte for each column
that may be NULL. ref_length must be as exact as possible to
save space, because all row reference buffers are allocated
based on ref_length. */
-
- ref_length = table->key_info[primary_key].key_length;
+
+ ref_length = table->key_info[primary_key].key_length;
} else {
- if (primary_key != MAX_KEY) {
+ if (primary_key != MAX_KEY) {
sql_print_error("Table %s has no primary key in InnoDB data "
"dictionary, but has one in MySQL! If you "
"created the table with a MySQL version < "
@@ -2522,7 +2525,7 @@
((row_prebuilt_t*)innobase_prebuilt)
->clust_index_was_generated = TRUE;
- ref_length = DATA_ROW_ID_LEN;
+ ref_length = DATA_ROW_ID_LEN;
/* If we automatically created the clustered index, then
MySQL does not know about it, and MySQL must NOT be aware
@@ -2531,11 +2534,12 @@
that key_used_on_scan is the undefined value MAX_KEY.
The column is the row id in the automatical generation case,
and it will never be updated anyway. */
-
+
if (key_used_on_scan != MAX_KEY) {
- sql_print_warning("Table %s key_used_on_scan is %lu even "
- "though there is no primary key inside "
- "InnoDB.", name, (ulong) key_used_on_scan);
+ sql_print_warning(
+ "Table %s key_used_on_scan is %lu even "
+ "though there is no primary key inside "
+ "InnoDB.", name, (ulong) key_used_on_scan);
}
}
@@ -2545,9 +2549,9 @@
/* Init table lock structure */
thr_lock_data_init(&share->lock,&lock,(void*) 0);
- info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
+ info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
- DBUG_RETURN(0);
+ DBUG_RETURN(0);
}
uint
@@ -2564,19 +2568,19 @@
/*====================*/
/* out: 0 */
{
- DBUG_ENTER("ha_innobase::close");
+ DBUG_ENTER("ha_innobase::close");
row_prebuilt_free((row_prebuilt_t*) innobase_prebuilt);
- my_free((gptr) upd_buff, MYF(0));
- free_share(share);
+ my_free((gptr) upd_buff, MYF(0));
+ free_share(share);
/* Tell InnoDB server that there might be work for
utility threads: */
srv_active_wake_master_thread();
- DBUG_RETURN(0);
+ DBUG_RETURN(0);
}
/* The following accessor functions should really be inside MySQL code! */
@@ -2666,7 +2670,7 @@
{
CHARSET_INFO* charset;
enum_field_types mysql_tp;
- int ret;
+ int ret;
DBUG_ASSERT(a_length != UNIV_SQL_NULL);
DBUG_ASSERT(b_length != UNIV_SQL_NULL);
@@ -2675,14 +2679,14 @@
switch (mysql_tp) {
- case MYSQL_TYPE_BIT:
+ case MYSQL_TYPE_BIT:
case MYSQL_TYPE_STRING:
case MYSQL_TYPE_VAR_STRING:
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_BLOB:
case FIELD_TYPE_LONG_BLOB:
- case MYSQL_TYPE_VARCHAR:
+ case MYSQL_TYPE_VARCHAR:
/* Use the charset number to pick the right charset struct for
the comparison. Since the MySQL function get_charset may be
slow before Bar removes the mutex operation there, we first
@@ -2704,21 +2708,21 @@
}
}
- /* Starting from 4.1.3, we use strnncollsp() in comparisons of
- non-latin1_swedish_ci strings. NOTE that the collation order
- changes then: 'b\0\0...' is ordered BEFORE 'b ...'. Users
- having indexes on such data need to rebuild their tables! */
-
- ret = charset->coll->strnncollsp(charset,
- a, a_length,
- b, b_length, 0);
+ /* Starting from 4.1.3, we use strnncollsp() in comparisons of
+ non-latin1_swedish_ci strings. NOTE that the collation order
+ changes then: 'b\0\0...' is ordered BEFORE 'b ...'. Users
+ having indexes on such data need to rebuild their tables! */
+
+ ret = charset->coll->strnncollsp(charset,
+ a, a_length,
+ b, b_length, 0);
if (ret < 0) {
- return(-1);
+ return(-1);
} else if (ret > 0) {
- return(1);
+ return(1);
} else {
- return(0);
- }
+ return(0);
+ }
default:
assert(0);
}
@@ -2759,7 +2763,7 @@
}
if (field->real_type() == FIELD_TYPE_ENUM
- || field->real_type() == FIELD_TYPE_SET) {
+ || field->real_type() == FIELD_TYPE_SET) {
/* MySQL has field->type() a string type for these, but the
data is actually internally stored as an unsigned integer
@@ -2773,58 +2777,58 @@
}
switch (field->type()) {
- /* NOTE that we only allow string types in DATA_MYSQL
- and DATA_VARMYSQL */
- case MYSQL_TYPE_VAR_STRING: /* old <= 4.1 VARCHAR */
- case MYSQL_TYPE_VARCHAR: /* new >= 5.0.3 true VARCHAR */
- if (field->binary()) {
- return(DATA_BINARY);
- } else if (strcmp(
- field->charset()->name,
- "latin1_swedish_ci") == 0) {
- return(DATA_VARCHAR);
- } else {
- return(DATA_VARMYSQL);
- }
- case MYSQL_TYPE_BIT:
- case MYSQL_TYPE_STRING: if (field->binary()) {
-
- return(DATA_FIXBINARY);
- } else if (strcmp(
- field->charset()->name,
- "latin1_swedish_ci") == 0) {
- return(DATA_CHAR);
- } else {
- return(DATA_MYSQL);
- }
- case FIELD_TYPE_NEWDECIMAL:
- return(DATA_FIXBINARY);
- case FIELD_TYPE_LONG:
- case FIELD_TYPE_LONGLONG:
- case FIELD_TYPE_TINY:
- case FIELD_TYPE_SHORT:
- case FIELD_TYPE_INT24:
- case FIELD_TYPE_DATE:
- case FIELD_TYPE_DATETIME:
- case FIELD_TYPE_YEAR:
- case FIELD_TYPE_NEWDATE:
- case FIELD_TYPE_TIME:
- case FIELD_TYPE_TIMESTAMP:
- return(DATA_INT);
- case FIELD_TYPE_FLOAT:
- return(DATA_FLOAT);
- case FIELD_TYPE_DOUBLE:
- return(DATA_DOUBLE);
- case FIELD_TYPE_DECIMAL:
- return(DATA_DECIMAL);
- case FIELD_TYPE_GEOMETRY:
- case FIELD_TYPE_TINY_BLOB:
- case FIELD_TYPE_MEDIUM_BLOB:
- case FIELD_TYPE_BLOB:
- case FIELD_TYPE_LONG_BLOB:
- return(DATA_BLOB);
- default:
- assert(0);
+ /* NOTE that we only allow string types in DATA_MYSQL and
+ DATA_VARMYSQL */
+ case MYSQL_TYPE_VAR_STRING: /* old <= 4.1 VARCHAR */
+ case MYSQL_TYPE_VARCHAR: /* new >= 5.0.3 true VARCHAR */
+ if (field->binary()) {
+ return(DATA_BINARY);
+ } else if (strcmp(
+ field->charset()->name,
+ "latin1_swedish_ci") == 0) {
+ return(DATA_VARCHAR);
+ } else {
+ return(DATA_VARMYSQL);
+ }
+ case MYSQL_TYPE_BIT:
+ case MYSQL_TYPE_STRING: if (field->binary()) {
+
+ return(DATA_FIXBINARY);
+ } else if (strcmp(
+ field->charset()->name,
+ "latin1_swedish_ci") == 0) {
+ return(DATA_CHAR);
+ } else {
+ return(DATA_MYSQL);
+ }
+ case FIELD_TYPE_NEWDECIMAL:
+ return(DATA_FIXBINARY);
+ case FIELD_TYPE_LONG:
+ case FIELD_TYPE_LONGLONG:
+ case FIELD_TYPE_TINY:
+ case FIELD_TYPE_SHORT:
+ case FIELD_TYPE_INT24:
+ case FIELD_TYPE_DATE:
+ case FIELD_TYPE_DATETIME:
+ case FIELD_TYPE_YEAR:
+ case FIELD_TYPE_NEWDATE:
+ case FIELD_TYPE_TIME:
+ case FIELD_TYPE_TIMESTAMP:
+ return(DATA_INT);
+ case FIELD_TYPE_FLOAT:
+ return(DATA_FLOAT);
+ case FIELD_TYPE_DOUBLE:
+ return(DATA_DOUBLE);
+ case FIELD_TYPE_DECIMAL:
+ return(DATA_DECIMAL);
+ case FIELD_TYPE_GEOMETRY:
+ case FIELD_TYPE_TINY_BLOB:
+ case FIELD_TYPE_MEDIUM_BLOB:
+ case FIELD_TYPE_BLOB:
+ case FIELD_TYPE_LONG_BLOB:
+ return(DATA_BLOB);
+ default:
+ assert(0);
}
return(0);
@@ -2866,23 +2870,21 @@
ha_innobase::store_key_val_for_row(
/*===============================*/
/* out: key value length as stored in buff */
- uint keynr, /* in: key number */
+ uint keynr, /* in: key number */
char* buff, /* in/out: buffer for the key value (in MySQL
format) */
uint buff_len,/* in: buffer length */
const mysql_byte* record)/* in: row in MySQL format */
{
- KEY* key_info = table->key_info + keynr;
- KEY_PART_INFO* key_part = key_info->key_part;
- KEY_PART_INFO* end = key_part + key_info->key_parts;
+ KEY* key_info = table->key_info + keynr;
+ KEY_PART_INFO* key_part = key_info->key_part;
+ KEY_PART_INFO* end = key_part + key_info->key_parts;
char* buff_start = buff;
enum_field_types mysql_type;
Field* field;
- ulint blob_len;
- byte* blob_data;
ibool is_null;
- DBUG_ENTER("store_key_val_for_row");
+ DBUG_ENTER("store_key_val_for_row");
/* The format for storing a key field in MySQL is the following:
@@ -2911,19 +2913,19 @@
bzero(buff, buff_len);
- for (; key_part != end; key_part++) {
- is_null = FALSE;
+ for (; key_part != end; key_part++) {
+ is_null = FALSE;
- if (key_part->null_bit) {
- if (record[key_part->null_offset]
+ if (key_part->null_bit) {
+ if (record[key_part->null_offset]
& key_part->null_bit) {
*buff = 1;
is_null = TRUE;
- } else {
+ } else {
*buff = 0;
}
buff++;
- }
+ }
field = key_part->field;
mysql_type = field->type();
@@ -2934,49 +2936,54 @@
ulint len;
byte* data;
ulint key_len;
+ ulint true_len;
CHARSET_INFO* cs;
int error=0;
+ key_len = key_part->length;
+
if (is_null) {
- buff += key_part->length + 2;
-
+ buff += key_len + 2;
+
continue;
}
+ cs = field->charset();
lenlen = (ulint)
(((Field_varstring*)field)->length_bytes);
- data = row_mysql_read_true_varchar(&len,
+ data = row_mysql_read_true_varchar(&len,
(byte*) (record
+ (ulint)get_field_offset(table, field)),
lenlen);
- /* In a column prefix index, we may need to truncate
- the stored value: */
-
- cs = key_part->field->charset();
+ true_len = len;
- if (cs->mbmaxlen > 1 && key_part->length > 0) {
- key_len = (ulint) cs->cset->well_formed_len(cs,
- (const char *) data,
- (const char *) data + key_part->length,
- key_part->length / cs->mbmaxlen,
- &error);
- } else {
- key_len = key_part->length;
+ /* For multi byte character sets we need to calculate
+ the true length of the key */
+
+ if (len > 0 && cs->mbmaxlen > 1) {
+ true_len = (ulint) cs->cset->well_formed_len(cs,
+ (const char *) data,
+ (const char *) data + len,
+ key_len / cs->mbmaxlen,
+ &error);
}
- if (len > key_len) {
- len = key_len;
+ /* In a column prefix index, we may need to truncate
+ the stored value: */
+
+ if (true_len > key_len) {
+ true_len = key_len;
}
/* The length in a key value is always stored in 2
bytes */
- row_mysql_store_true_var_len((byte*)buff, len, 2);
+ row_mysql_store_true_var_len((byte*)buff, true_len, 2);
buff += 2;
- memcpy(buff, data, len);
+ memcpy(buff, data, true_len);
/* Note that we always reserve the maximum possible
length of the true VARCHAR in the key value, though
@@ -2984,68 +2991,76 @@
actual data. The rest of the space was reset to zero
in the bzero() call above. */
- buff += key_part->length;
+ buff += key_len;
} else if (mysql_type == FIELD_TYPE_TINY_BLOB
- || mysql_type == FIELD_TYPE_MEDIUM_BLOB
- || mysql_type == FIELD_TYPE_BLOB
- || mysql_type == FIELD_TYPE_LONG_BLOB) {
+ || mysql_type == FIELD_TYPE_MEDIUM_BLOB
+ || mysql_type == FIELD_TYPE_BLOB
+ || mysql_type == FIELD_TYPE_LONG_BLOB) {
CHARSET_INFO* cs;
ulint key_len;
ulint len;
+ ulint true_len;
int error=0;
+ ulint blob_len;
+ byte* blob_data;
ut_a(key_part->key_part_flag & HA_PART_KEY_SEG);
- if (is_null) {
- buff += key_part->length + 2;
-
+ key_len = key_part->length;
+
+ if (is_null) {
+ buff += key_len + 2;
+
continue;
}
-
- blob_data = row_mysql_read_blob_ref(&blob_len,
+
+ cs = field->charset();
+
+ blob_data = row_mysql_read_blob_ref(&blob_len,
(byte*) (record
+ (ulint)get_field_offset(table, field)),
(ulint) field->pack_length());
+ true_len = blob_len;
+
ut_a(get_field_offset(table, field)
- == key_part->offset);
+ == key_part->offset);
+
+ /* For multi byte character sets we need to calculate
+ the true length of the key */
+
+ if (blob_len > 0 && cs->mbmaxlen > 1) {
+ true_len = (ulint) cs->cset->well_formed_len(cs,
+ (const char *) blob_data,
+ (const char *) blob_data
+ + blob_len,
+ key_len / cs->mbmaxlen,
+ &error);
+ }
/* All indexes on BLOB and TEXT are column prefix
indexes, and we may need to truncate the data to be
stored in the key value: */
- cs = key_part->field->charset();
-
- if (cs->mbmaxlen > 1 && key_part->length > 0) {
- key_len = (ulint) cs->cset->well_formed_len(cs,
- (const char *) blob_data,
- (const char *) blob_data
- + key_part->length,
- key_part->length / cs->mbmaxlen,
- &error);
- } else {
- key_len = key_part->length;
- }
-
- if (blob_len > key_len) {
- blob_len = key_len;
+ if (true_len > key_len) {
+ true_len = key_len;
}
/* MySQL reserves 2 bytes for the length and the
storage of the number is little-endian */
innobase_write_to_2_little_endian(
- (byte*)buff, (ulint)blob_len);
+ (byte*)buff, true_len);
buff += 2;
- memcpy(buff, blob_data, blob_len);
+ memcpy(buff, blob_data, true_len);
/* Note that we always reserve the maximum possible
length of the BLOB prefix in the key value. */
- buff += key_part->length;
+ buff += key_len;
} else {
/* Here we handle all other data types except the
true VARCHAR, BLOB and TEXT. Note that the column
@@ -3053,48 +3068,67 @@
index. */
CHARSET_INFO* cs;
- ulint len;
+ ulint true_len;
+ ulint key_len;
const mysql_byte* src_start;
int error=0;
+ enum_field_types real_type;
+
+ key_len = key_part->length;
+
+ if (is_null) {
+ buff += key_len;
- if (is_null) {
- buff += key_part->length;
-
continue;
}
- /* In a column prefix index, we may need to truncate
- the stored value: */
-
- cs = key_part->field->charset();
src_start = record + key_part->offset;
+ real_type = field->real_type();
+ true_len = key_len;
- if (key_part->length > 0 && cs->mbmaxlen > 1) {
- len = (ulint) cs->cset->well_formed_len(cs,
- (const char *) src_start,
- (const char *) src_start + key_part->length,
- key_part->length / cs->mbmaxlen,
- &error);
- } else {
- len = key_part->length;
+ /* Character set for the field is defined only
+ to fields whose type is string and real field
+ type is not enum or set. For these fields check
+ if character set is multi byte. */
+
+ if (real_type != FIELD_TYPE_ENUM
+ && real_type != FIELD_TYPE_SET
+ && ( mysql_type == MYSQL_TYPE_VAR_STRING
+ || mysql_type == MYSQL_TYPE_STRING)) {
+
+ cs = field->charset();
+
+ /* For multi byte character sets we need to
+ calculate the true length of the key */
+
+ if (key_len > 0 && cs->mbmaxlen > 1) {
+
+ true_len = (ulint)
+ cs->cset->well_formed_len(cs,
+ (const char *)src_start,
+ (const char *)src_start
+ + key_len,
+ key_len / cs->mbmaxlen,
+ &error);
+ }
}
- memcpy(buff, src_start, len);
- buff+=len;
+ memcpy(buff, src_start, true_len);
+ buff += true_len;
- /* Pad the unused space with spaces. Note that no
- padding is ever needed for UCS-2 because in MySQL,
- all UCS2 characters are 2 bytes, as MySQL does not
+ /* Pad the unused space with spaces. Note that no
+ padding is ever needed for UCS-2 because in MySQL,
+ all UCS2 characters are 2 bytes, as MySQL does not
support surrogate pairs, which are needed to represent
characters in the range U+10000 to U+10FFFF. */
- if (len < key_part->length) {
- len = key_part->length - len;
- memset(buff, ' ', len);
- buff+=len;
+ if (true_len < key_len) {
+ ulint pad_len = key_len - true_len;
+ memset(buff, ' ', pad_len);
+ buff += pad_len;
}
}
- }
+ }
ut_a(buff <= buff_start + buff_len);
@@ -3133,38 +3167,39 @@
use exclusive row level locks, for example, if the read is
done in an UPDATE statement. */
- templ_type = ROW_MYSQL_WHOLE_ROW;
+ templ_type = ROW_MYSQL_WHOLE_ROW;
}
if (templ_type == ROW_MYSQL_REC_FIELDS) {
- if (prebuilt->hint_need_to_fetch_extra_cols
- == ROW_RETRIEVE_ALL_COLS) {
+ if (prebuilt->hint_need_to_fetch_extra_cols
+ == ROW_RETRIEVE_ALL_COLS) {
- /* We know we must at least fetch all columns in the key, or
- all columns in the table */
+ /* We know we must at least fetch all columns in the
+ key, or all columns in the table */
- if (prebuilt->read_just_key) {
- /* MySQL has instructed us that it is enough to
- fetch the columns in the key; looks like MySQL
- can set this flag also when there is only a
- prefix of the column in the key: in that case we
- retrieve the whole column from the clustered
- index */
+ if (prebuilt->read_just_key) {
+ /* MySQL has instructed us that it is enough
+ to fetch the columns in the key; looks like
+ MySQL can set this flag also when there is
+ only a prefix of the column in the key: in
+ that case we retrieve the whole column from
+ the clustered index */
- fetch_all_in_key = TRUE;
- } else {
- templ_type = ROW_MYSQL_WHOLE_ROW;
- }
- } else if (prebuilt->hint_need_to_fetch_extra_cols
- == ROW_RETRIEVE_PRIMARY_KEY) {
- /* We must at least fetch all primary key cols. Note that if
- the clustered index was internally generated by InnoDB on the
- row id (no primary key was defined), then
- row_search_for_mysql() will always retrieve the row id to a
- special buffer in the prebuilt struct. */
+ fetch_all_in_key = TRUE;
+ } else {
+ templ_type = ROW_MYSQL_WHOLE_ROW;
+ }
+ } else if (prebuilt->hint_need_to_fetch_extra_cols
+ == ROW_RETRIEVE_PRIMARY_KEY) {
+ /* We must at least fetch all primary key cols. Note
+ that if the clustered index was internally generated
+ by InnoDB on the row id (no primary key was
+ defined), then row_search_for_mysql() will always
+ retrieve the row id to a special buffer in the
+ prebuilt struct. */
- fetch_primary_key_cols = TRUE;
- }
+ fetch_primary_key_cols = TRUE;
+ }
}
clust_index = dict_table_get_first_index_noninline(prebuilt->table);
@@ -3222,15 +3257,15 @@
}
if (table->file->ha_get_bit_in_read_set(i+1) ||
- table->file->ha_get_bit_in_write_set(i+1)) {
+ table->file->ha_get_bit_in_write_set(i+1)) {
/* This field is needed in the query */
goto include_field;
}
if (fetch_primary_key_cols
- && dict_table_col_in_clustered_key(index->table,
- i)) {
+ && dict_table_col_in_clustered_key(
+ index->table, i)) {
/* This field is needed in the query */
goto include_field;
@@ -3281,9 +3316,9 @@
if (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {
templ->mysql_length_bytes = (ulint)
- (((Field_varstring*)field)->length_bytes);
+ (((Field_varstring*)field)->length_bytes);
}
-
+
templ->charset = dtype_get_charset_coll_noninline(
index->table->cols[i].type.prtype);
templ->mbminlen = index->table->cols[i].type.mbminlen;
@@ -3307,7 +3342,7 @@
templ = prebuilt->mysql_template + i;
templ->rec_field_no =
- (index->table->cols + templ->col_no)->clust_pos;
+ (index->table->cols + templ->col_no)->clust_pos;
}
}
}
@@ -3320,18 +3355,18 @@
ha_innobase::write_row(
/*===================*/
/* out: error code */
- mysql_byte* record) /* in: a row in MySQL format */
+ mysql_byte* record) /* in: a row in MySQL format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
- int error;
+ int error;
longlong auto_inc;
longlong dummy;
- ibool auto_inc_used= FALSE;
+ ibool auto_inc_used= FALSE;
- DBUG_ENTER("ha_innobase::write_row");
+ DBUG_ENTER("ha_innobase::write_row");
if (prebuilt->trx !=
- (trx_t*) current_thd->ha_data[innobase_hton.slot]) {
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]) {
sql_print_error("The transaction object for the table handle is at "
"%p, but for the current thread it is at %p",
prebuilt->trx,
@@ -3343,23 +3378,23 @@
"InnoDB: Dump of 200 bytes around transaction.all: ",
stderr);
ut_print_buf(stderr,
- ((byte*)(&(current_thd->ha_data[innobase_hton.slot]))) - 100,
+ ((byte*)(&(current_thd->ha_data[innobase_hton.slot]))) - 100,
200);
putc('\n', stderr);
ut_error;
}
- statistic_increment(current_thd->status_var.ha_write_count,
- &LOCK_status);
+ statistic_increment(current_thd->status_var.ha_write_count,
+ &LOCK_status);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
- table->timestamp_field->set_time();
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_INSERT)
+ table->timestamp_field->set_time();
if ((user_thd->lex->sql_command == SQLCOM_ALTER_TABLE
- || user_thd->lex->sql_command == SQLCOM_OPTIMIZE
- || user_thd->lex->sql_command == SQLCOM_CREATE_INDEX
- || user_thd->lex->sql_command == SQLCOM_DROP_INDEX)
- && num_write_row >= 10000) {
+ || user_thd->lex->sql_command == SQLCOM_OPTIMIZE
+ || user_thd->lex->sql_command == SQLCOM_CREATE_INDEX
+ || user_thd->lex->sql_command == SQLCOM_DROP_INDEX)
+ && num_write_row >= 10000) {
/* ALTER TABLE is COMMITted at every 10000 copied rows.
The IX table lock for the original table has to be re-issued.
As this method will be called on a temporary table where the
@@ -3397,11 +3432,11 @@
no need to re-acquire locks on it. */
/* Altering to InnoDB format */
- innobase_commit(user_thd, 1);
+ innobase_commit(user_thd, 1);
/* Note that this transaction is still active. */
prebuilt->trx->active_trans = 1;
/* We will need an IX lock on the destination table. */
- prebuilt->sql_stat_start = TRUE;
+ prebuilt->sql_stat_start = TRUE;
} else {
/* Ensure that there are no other table locks than
LOCK_IX and LOCK_AUTO_INC on the destination table. */
@@ -3413,26 +3448,26 @@
/* Commit the transaction. This will release the table
locks, so they have to be acquired again. */
- innobase_commit(user_thd, 1);
+ innobase_commit(user_thd, 1);
/* Note that this transaction is still active. */
prebuilt->trx->active_trans = 1;
/* Re-acquire the table lock on the source table. */
row_lock_table_for_mysql(prebuilt, src_table, mode);
/* We will need an IX lock on the destination table. */
- prebuilt->sql_stat_start = TRUE;
+ prebuilt->sql_stat_start = TRUE;
}
}
num_write_row++;
if (last_query_id != user_thd->query_id) {
- prebuilt->sql_stat_start = TRUE;
- last_query_id = user_thd->query_id;
+ prebuilt->sql_stat_start = TRUE;
+ last_query_id = user_thd->query_id;
innobase_release_stat_resources(prebuilt->trx);
}
- if (table->next_number_field && record == table->record[0]) {
+ if (table->next_number_field && record == table->record[0]) {
/* This is the case where the table has an
auto-increment column */
@@ -3442,7 +3477,7 @@
if (0 == dict_table_autoinc_peek(prebuilt->table)) {
/* This call initializes the counter */
- error = innobase_read_and_init_auto_inc(&dummy);
+ error = innobase_read_and_init_auto_inc(&dummy);
if (error) {
/* Deadlock or lock wait timeout */
@@ -3478,10 +3513,10 @@
}
/* We must use the handler code to update the auto-increment
- value to be sure that we increment it correctly. */
+ value to be sure that we increment it correctly. */
- update_auto_increment();
- auto_inc_used = 1;
+ update_auto_increment();
+ auto_inc_used = 1;
}
@@ -3499,34 +3534,34 @@
if (error == DB_SUCCESS && auto_inc_used) {
- /* Fetch the value that was set in the autoincrement field */
+ /* Fetch the value that was set in the autoincrement field */
- auto_inc = table->next_number_field->val_int();
+ auto_inc = table->next_number_field->val_int();
- if (auto_inc != 0) {
+ if (auto_inc != 0) {
/* This call will update the counter according to the
value that was inserted in the table */
- dict_table_autoinc_update(prebuilt->table, auto_inc);
- }
- }
-
- /* A REPLACE command and LOAD DATA INFILE REPLACE handle a duplicate
- key error themselves, and we must update the autoinc counter if we are
- performing those statements. */
-
- if (error == DB_DUPLICATE_KEY && auto_inc_used
- && (user_thd->lex->sql_command == SQLCOM_REPLACE
- || user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT
- || (user_thd->lex->sql_command == SQLCOM_LOAD
- && user_thd->lex->duplicates == DUP_REPLACE))) {
-
- auto_inc = table->next_number_field->val_int();
-
- if (auto_inc != 0) {
- dict_table_autoinc_update(prebuilt->table, auto_inc);
- }
- }
+ dict_table_autoinc_update(prebuilt->table, auto_inc);
+ }
+ }
+
+ /* A REPLACE command and LOAD DATA INFILE REPLACE handle a duplicate
+ key error themselves, and we must update the autoinc counter if we are
+ performing those statements. */
+
+ if (error == DB_DUPLICATE_KEY && auto_inc_used
+ && (user_thd->lex->sql_command == SQLCOM_REPLACE
+ || user_thd->lex->sql_command == SQLCOM_REPLACE_SELECT
+ || (user_thd->lex->sql_command == SQLCOM_LOAD
+ && user_thd->lex->duplicates == DUP_REPLACE))) {
+
+ auto_inc = table->next_number_field->val_int();
+
+ if (auto_inc != 0) {
+ dict_table_autoinc_update(prebuilt->table, auto_inc);
+ }
+ }
innodb_srv_conc_exit_innodb(prebuilt->trx);
@@ -3537,7 +3572,7 @@
func_exit:
innobase_active_small();
- DBUG_RETURN(error);
+ DBUG_RETURN(error);
}
/**************************************************************************
@@ -3549,8 +3584,8 @@
/*================*/
/* out: error number or 0 */
upd_t* uvect, /* in/out: update vector */
- mysql_byte* old_row, /* in: old row in MySQL format */
- mysql_byte* new_row, /* in: new row in MySQL format */
+ mysql_byte* old_row, /* in: old row in MySQL format */
+ mysql_byte* new_row, /* in: new row in MySQL format */
struct st_table* table, /* in: table in MySQL data
dictionary */
mysql_byte* upd_buff, /* in: buffer to use */
@@ -3566,9 +3601,9 @@
ulint n_len;
ulint col_pack_len;
byte* new_mysql_row_col;
- byte* o_ptr;
- byte* n_ptr;
- byte* buf;
+ byte* o_ptr;
+ byte* n_ptr;
+ byte* buf;
upd_field_t* ufield;
ulint col_type;
ulint n_changed = 0;
@@ -3592,7 +3627,7 @@
o_ptr = (byte*) old_row + get_field_offset(table, field);
n_ptr = (byte*) new_row + get_field_offset(table, field);
-
+
/* Use new_mysql_row_col and col_pack_len save the values */
new_mysql_row_col = n_ptr;
@@ -3602,10 +3637,10 @@
n_len = col_pack_len;
/* We use o_ptr and n_ptr to dig up the actual data for
- comparison. */
+ comparison. */
field_mysql_type = field->type();
-
+
col_type = prebuilt->table->cols[i].type.mtype;
switch (col_type) {
@@ -3623,16 +3658,16 @@
/* This is a >= 5.0.3 type true VARCHAR where
the real payload data length is stored in
1 or 2 bytes */
-
+
o_ptr = row_mysql_read_true_varchar(
- &o_len, o_ptr,
- (ulint)
- (((Field_varstring*)field)->length_bytes));
-
+ &o_len, o_ptr,
+ (ulint)
+ (((Field_varstring*)field)->length_bytes));
+
n_ptr = row_mysql_read_true_varchar(
- &n_len, n_ptr,
- (ulint)
- (((Field_varstring*)field)->length_bytes));
+ &n_len, n_ptr,
+ (ulint)
+ (((Field_varstring*)field)->length_bytes));
}
break;
@@ -3657,7 +3692,7 @@
/* The field has changed */
ufield = uvect->fields + n_changed;
-
+
/* Let us use a dummy dfield to make the conversion
from the MySQL column format to the InnoDB format */
@@ -3665,12 +3700,12 @@
if (n_len != UNIV_SQL_NULL) {
buf = row_mysql_store_col_in_innobase_format(
- &dfield,
- (byte*)buf,
- TRUE,
- new_mysql_row_col,
- col_pack_len,
- prebuilt->table->comp);
+ &dfield,
+ (byte*)buf,
+ TRUE,
+ new_mysql_row_col,
+ col_pack_len,
+ dict_table_is_comp(prebuilt->table));
ufield->new_val.data = dfield.data;
ufield->new_val.len = dfield.len;
} else {
@@ -3704,8 +3739,8 @@
ha_innobase::update_row(
/*====================*/
/* out: error number or 0 */
- const mysql_byte* old_row,/* in: old row in MySQL format */
- mysql_byte* new_row)/* in: new row in MySQL format */
+ const mysql_byte* old_row,/* in: old row in MySQL format */
+ mysql_byte* new_row)/* in: new row in MySQL format */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
upd_t* uvect;
@@ -3714,14 +3749,14 @@
DBUG_ENTER("ha_innobase::update_row");
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
- if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
- table->timestamp_field->set_time();
+ if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE)
+ table->timestamp_field->set_time();
if (last_query_id != user_thd->query_id) {
- prebuilt->sql_stat_start = TRUE;
- last_query_id = user_thd->query_id;
+ prebuilt->sql_stat_start = TRUE;
+ last_query_id = user_thd->query_id;
innobase_release_stat_resources(prebuilt->trx);
}
@@ -3775,11 +3810,11 @@
DBUG_ENTER("ha_innobase::delete_row");
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
if (last_query_id != user_thd->query_id) {
- prebuilt->sql_stat_start = TRUE;
- last_query_id = user_thd->query_id;
+ prebuilt->sql_stat_start = TRUE;
+ last_query_id = user_thd->query_id;
innobase_release_stat_resources(prebuilt->trx);
}
@@ -3809,7 +3844,7 @@
}
/**************************************************************************
-Removes a new lock set on a row, if it was not read optimistically. This can
+Removes a new lock set on a row, if it was not read optimistically. This can
be called after a row has been read in the processing of an UPDATE or a DELETE
query, if the option innodb_locks_unsafe_for_binlog is set. */
@@ -3878,15 +3913,15 @@
ha_innobase::index_init(
/*====================*/
/* out: 0 or error number */
- uint keynr, /* in: key (index) number */
- bool sorted) /* in: 1 if result MUST be sorted according to index */
+ uint keynr, /* in: key (index) number */
+ bool sorted) /* in: 1 if result MUST be sorted according to index */
{
- int error = 0;
- DBUG_ENTER("index_init");
+ int error = 0;
+ DBUG_ENTER("index_init");
error = change_active_index(keynr);
- DBUG_RETURN(error);
+ DBUG_RETURN(error);
}
/**********************************************************************
@@ -3896,10 +3931,10 @@
ha_innobase::index_end(void)
/*========================*/
{
- int error = 0;
- DBUG_ENTER("index_end");
- active_index=MAX_KEY;
- DBUG_RETURN(error);
+ int error = 0;
+ DBUG_ENTER("index_end");
+ active_index=MAX_KEY;
+ DBUG_RETURN(error);
}
/*************************************************************************
@@ -3912,15 +3947,15 @@
enum ha_rkey_function find_flag)
{
switch (find_flag) {
- case HA_READ_KEY_EXACT: return(PAGE_CUR_GE);
- /* the above does not require the index to be UNIQUE */
- case HA_READ_KEY_OR_NEXT: return(PAGE_CUR_GE);
+ case HA_READ_KEY_EXACT: return(PAGE_CUR_GE);
+ /* the above does not require the index to be UNIQUE */
+ case HA_READ_KEY_OR_NEXT: return(PAGE_CUR_GE);
case HA_READ_KEY_OR_PREV: return(PAGE_CUR_LE);
case HA_READ_AFTER_KEY: return(PAGE_CUR_G);
case HA_READ_BEFORE_KEY: return(PAGE_CUR_L);
case HA_READ_PREFIX: return(PAGE_CUR_GE);
- case HA_READ_PREFIX_LAST: return(PAGE_CUR_LE);
- case HA_READ_PREFIX_LAST_OR_PREV:return(PAGE_CUR_LE);
+ case HA_READ_PREFIX_LAST: return(PAGE_CUR_LE);
+ case HA_READ_PREFIX_LAST_OR_PREV:return(PAGE_CUR_LE);
/* In MySQL-4.0 HA_READ_PREFIX and HA_READ_PREFIX_LAST always
pass a complete-field prefix of a key value as the search
tuple. I.e., it is not allowed that the last field would
@@ -4001,7 +4036,7 @@
or error number */
mysql_byte* buf, /* in/out: buffer for the returned
row */
- const mysql_byte* key_ptr,/* in: key value; if this is NULL
+ const mysql_byte* key_ptr,/* in: key value; if this is NULL
we position the cursor at the
start or end of index; this can
also contain an InnoDB row id, in
@@ -4016,21 +4051,21 @@
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
ulint mode;
dict_index_t* index;
- ulint match_mode = 0;
- int error;
+ ulint match_mode = 0;
+ int error;
ulint ret;
- DBUG_ENTER("index_read");
+ DBUG_ENTER("index_read");
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
- statistic_increment(current_thd->status_var.ha_read_key_count,
- &LOCK_status);
+ statistic_increment(current_thd->status_var.ha_read_key_count,
+ &LOCK_status);
if (last_query_id != user_thd->query_id) {
- prebuilt->sql_stat_start = TRUE;
- last_query_id = user_thd->query_id;
+ prebuilt->sql_stat_start = TRUE;
+ last_query_id = user_thd->query_id;
innobase_release_stat_resources(prebuilt->trx);
}
@@ -4038,7 +4073,7 @@
index = prebuilt->index;
/* Note that if the index for which the search template is built is not
- necessarily prebuilt->index, but can also be the clustered index */
+ necessarily prebuilt->index, but can also be the clustered index */
if (prebuilt->sql_stat_start) {
build_template(prebuilt, user_thd, table,
@@ -4046,7 +4081,7 @@
}
if (key_ptr) {
- /* Convert the search key value to InnoDB format into
+ /* Convert the search key value to InnoDB format into
prebuilt->search_tuple */
row_sel_convert_mysql_key_to_innobase(prebuilt->search_tuple,
@@ -4059,7 +4094,7 @@
/* We position the cursor to the last or the first entry
in the index */
- dtuple_set_n_fields(prebuilt->search_tuple, 0);
+ dtuple_set_n_fields(prebuilt->search_tuple, 0);
}
mode = convert_search_mode_to_innobase(find_flag);
@@ -4108,15 +4143,15 @@
int
ha_innobase::index_read_last(
/*=========================*/
- /* out: 0, HA_ERR_KEY_NOT_FOUND, or an
+ /* out: 0, HA_ERR_KEY_NOT_FOUND, or an
error code */
- mysql_byte* buf, /* out: fetched row */
- const mysql_byte* key_ptr, /* in: key value, or a prefix of a full
+ mysql_byte* buf, /* out: fetched row */
+ const mysql_byte* key_ptr, /* in: key value, or a prefix of a full
key value */
- uint key_len) /* in: length of the key val or prefix
+ uint key_len) /* in: length of the key val or prefix
in bytes */
{
- return(index_read(buf, key_ptr, key_len, HA_READ_PREFIX_LAST));
+ return(index_read(buf, key_ptr, key_len, HA_READ_PREFIX_LAST));
}
/************************************************************************
@@ -4126,19 +4161,19 @@
ha_innobase::change_active_index(
/*=============================*/
/* out: 0 or error code */
- uint keynr) /* in: use this index; MAX_KEY means always clustered
+ uint keynr) /* in: use this index; MAX_KEY means always clustered
index, even if it was internally generated by
InnoDB */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key=0;
statistic_increment(current_thd->status_var.ha_read_key_count,
- &LOCK_status);
+ &LOCK_status);
DBUG_ENTER("change_active_index");
ut_ad(user_thd == current_thd);
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
active_index = keynr;
@@ -4146,19 +4181,20 @@
key = table->key_info + active_index;
prebuilt->index = dict_table_get_index_noninline(
- prebuilt->table,
- key->name);
- } else {
+ prebuilt->table, key->name);
+ } else {
prebuilt->index = dict_table_get_first_index_noninline(
prebuilt->table);
}
if (!prebuilt->index) {
- sql_print_error("Innodb could not find key n:o %u with name %s "
- "from dict cache for table %s",
- keynr, key ? key->name : "NULL",
- prebuilt->table->name);
- DBUG_RETURN(1);
+ sql_print_error(
+ "Innodb could not find key n:o %u with name %s "
+ "from dict cache for table %s",
+ keynr, key ? key->name : "NULL",
+ prebuilt->table->name);
+
+ DBUG_RETURN(1);
}
assert(prebuilt->search_tuple != 0);
@@ -4190,7 +4226,7 @@
/* out: error number or 0 */
mysql_byte* buf, /* in/out: buffer for the returned
row */
- uint keynr, /* in: use this index */
+ uint keynr, /* in: use this index */
const mysql_byte* key, /* in: key value; if this is NULL
we position the cursor at the
start or end of index */
@@ -4214,9 +4250,9 @@
/*=======================*/
/* out: 0, HA_ERR_END_OF_FILE, or error
number */
- mysql_byte* buf, /* in/out: buffer for next row in MySQL
+ mysql_byte* buf, /* in/out: buffer for next row in MySQL
format */
- uint direction, /* in: ROW_SEL_NEXT or ROW_SEL_PREV */
+ uint direction, /* in: ROW_SEL_NEXT or ROW_SEL_PREV */
uint match_mode) /* in: 0, ROW_SEL_EXACT, or
ROW_SEL_EXACT_PREFIX */
{
@@ -4227,7 +4263,7 @@
DBUG_ENTER("general_fetch");
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
innodb_srv_conc_enter_innodb(prebuilt->trx);
@@ -4263,11 +4299,11 @@
/*====================*/
/* out: 0, HA_ERR_END_OF_FILE, or error
number */
- mysql_byte* buf) /* in/out: buffer for next row in MySQL
+ mysql_byte* buf) /* in/out: buffer for next row in MySQL
format */
{
- statistic_increment(current_thd->status_var.ha_read_next_count,
- &LOCK_status);
+ statistic_increment(current_thd->status_var.ha_read_next_count,
+ &LOCK_status);
return(general_fetch(buf, ROW_SEL_NEXT, 0));
}
@@ -4280,12 +4316,12 @@
/*=========================*/
/* out: 0, HA_ERR_END_OF_FILE, or error
number */
- mysql_byte* buf, /* in/out: buffer for the row */
+ mysql_byte* buf, /* in/out: buffer for the row */
const mysql_byte* key, /* in: key value */
- uint keylen) /* in: key value length */
+ uint keylen) /* in: key value length */
{
- statistic_increment(current_thd->status_var.ha_read_next_count,
- &LOCK_status);
+ statistic_increment(current_thd->status_var.ha_read_next_count,
+ &LOCK_status);
return(general_fetch(buf, ROW_SEL_NEXT, last_match_mode));
}
@@ -4299,7 +4335,7 @@
/*====================*/
/* out: 0, HA_ERR_END_OF_FILE, or error
number */
- mysql_byte* buf) /* in/out: buffer for previous row in MySQL
+ mysql_byte* buf) /* in/out: buffer for previous row in MySQL
format */
{
return(general_fetch(buf, ROW_SEL_PREV, 0));
@@ -4318,19 +4354,19 @@
{
int error;
- DBUG_ENTER("index_first");
- statistic_increment(current_thd->status_var.ha_read_first_count,
- &LOCK_status);
+ DBUG_ENTER("index_first");
+ statistic_increment(current_thd->status_var.ha_read_first_count,
+ &LOCK_status);
- error = index_read(buf, NULL, 0, HA_READ_AFTER_KEY);
+ error = index_read(buf, NULL, 0, HA_READ_AFTER_KEY);
- /* MySQL does not seem to allow this to return HA_ERR_KEY_NOT_FOUND */
+ /* MySQL does not seem to allow this to return HA_ERR_KEY_NOT_FOUND */
- if (error == HA_ERR_KEY_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
- }
+ if (error == HA_ERR_KEY_NOT_FOUND) {
+ error = HA_ERR_END_OF_FILE;
+ }
- DBUG_RETURN(error);
+ DBUG_RETURN(error);
}
/************************************************************************
@@ -4345,19 +4381,19 @@
{
int error;
- DBUG_ENTER("index_last");
- statistic_increment(current_thd->status_var.ha_read_last_count,
- &LOCK_status);
+ DBUG_ENTER("index_last");
+ statistic_increment(current_thd->status_var.ha_read_last_count,
+ &LOCK_status);
- error = index_read(buf, NULL, 0, HA_READ_BEFORE_KEY);
+ error = index_read(buf, NULL, 0, HA_READ_BEFORE_KEY);
- /* MySQL does not seem to allow this to return HA_ERR_KEY_NOT_FOUND */
+ /* MySQL does not seem to allow this to return HA_ERR_KEY_NOT_FOUND */
- if (error == HA_ERR_KEY_NOT_FOUND) {
- error = HA_ERR_END_OF_FILE;
- }
+ if (error == HA_ERR_KEY_NOT_FOUND) {
+ error = HA_ERR_END_OF_FILE;
+ }
- DBUG_RETURN(error);
+ DBUG_RETURN(error);
}
/********************************************************************
@@ -4389,9 +4425,9 @@
try_semi_consistent_read(0);
}
- start_of_scan = 1;
+ start_of_scan = 1;
- return(err);
+ return(err);
}
/*********************************************************************
@@ -4418,11 +4454,11 @@
{
int error;
- DBUG_ENTER("rnd_next");
- statistic_increment(current_thd->status_var.ha_read_rnd_next_count,
- &LOCK_status);
+ DBUG_ENTER("rnd_next");
+ statistic_increment(current_thd->status_var.ha_read_rnd_next_count,
+ &LOCK_status);
- if (start_of_scan) {
+ if (start_of_scan) {
error = index_first(buf);
if (error == HA_ERR_KEY_NOT_FOUND) {
error = HA_ERR_END_OF_FILE;
@@ -4432,7 +4468,7 @@
error = general_fetch(buf, ROW_SEL_NEXT, 0);
}
- DBUG_RETURN(error);
+ DBUG_RETURN(error);
}
/**************************************************************************
@@ -4443,7 +4479,7 @@
/*=================*/
/* out: 0, HA_ERR_KEY_NOT_FOUND,
or error code */
- mysql_byte* buf, /* in/out: buffer for the row */
+ mysql_byte* buf, /* in/out: buffer for the row */
mysql_byte* pos) /* in: primary key value of the row in the
MySQL format, or the row id if the clustered
index was internally generated by InnoDB;
@@ -4457,10 +4493,10 @@
DBUG_DUMP("key", (char*) pos, ref_length);
statistic_increment(current_thd->status_var.ha_read_rnd_count,
- &LOCK_status);
+ &LOCK_status);
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we
@@ -4474,12 +4510,12 @@
}
if (error) {
- DBUG_PRINT("error", ("Got error: %ld", error));
+ DBUG_PRINT("error", ("Got error: %ld", error));
DBUG_RETURN(error);
}
/* Note that we assume the length of the row reference is fixed
- for the table, and it is == ref_length */
+ for the table, and it is == ref_length */
error = index_read(buf, pos, ref_length, HA_READ_KEY_EXACT);
@@ -4489,7 +4525,7 @@
change_active_index(keynr);
- DBUG_RETURN(error);
+ DBUG_RETURN(error);
}
/*************************************************************************
@@ -4510,7 +4546,7 @@
uint len;
ut_ad(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
if (prebuilt->clust_index_was_generated) {
/* No primary key was defined for the table and we
@@ -4528,10 +4564,10 @@
/* We assume that the 'ref' value len is always fixed for the same
table. */
-
+
if (len != ref_length) {
sql_print_error("Stored ref len is %lu, but table ref len is %lu",
- (ulong) len, (ulong) ref_length);
+ (ulong) len, (ulong) ref_length);
}
}
@@ -4553,30 +4589,30 @@
an .ibd file for it (no .ibd extension
in the path, though); otherwise this
is NULL */
- ibool comp) /* in: TRUE=compact record format */
+ ulint flags) /* in: table flags */
{
Field* field;
dict_table_t* table;
ulint n_cols;
- int error;
- ulint col_type;
+ int error;
+ ulint col_type;
ulint col_len;
- ulint nulls_allowed;
+ ulint nulls_allowed;
ulint unsigned_type;
ulint binary_type;
ulint long_true_varchar;
ulint charset_no;
- ulint i;
+ ulint i;
- DBUG_ENTER("create_table_def");
- DBUG_PRINT("enter", ("table_name: %s", table_name));
+ DBUG_ENTER("create_table_def");
+ DBUG_PRINT("enter", ("table_name: %s", table_name));
n_cols = form->s->fields;
/* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */
- table = dict_mem_table_create(table_name, 0, n_cols, comp);
+ table = dict_mem_table_create(table_name, 0, n_cols, flags);
if (path_of_temp_table) {
table->dir_path_of_temp_table =
@@ -4600,7 +4636,7 @@
binary_type = 0;
}
- charset_no = 0;
+ charset_no = 0;
if (dtype_is_string_type(col_type)) {
@@ -4619,7 +4655,7 @@
for a true VARCHAR. Let us subtract that, so that the InnoDB
column length in the InnoDB data dictionary is the real
maximum byte length of the actual data. */
-
+
long_true_varchar = 0;
if (field->type() == MYSQL_TYPE_VARCHAR) {
@@ -4631,15 +4667,15 @@
}
dict_mem_table_add_col(table,
- (char*) field->field_name,
- col_type,
- dtype_form_prtype(
- (ulint)field->type()
- | nulls_allowed | unsigned_type
- | binary_type | long_true_varchar,
- charset_no),
- col_len,
- 0);
+ (char*) field->field_name,
+ col_type,
+ dtype_form_prtype(
+ (ulint)field->type()
+ | nulls_allowed | unsigned_type
+ | binary_type | long_true_varchar,
+ charset_no),
+ col_len,
+ 0);
}
error = row_create_table_for_mysql(table, trx);
@@ -4663,7 +4699,7 @@
{
Field* field;
dict_index_t* index;
- int error;
+ int error;
ulint n_fields;
KEY* key;
KEY_PART_INFO* key_part;
@@ -4671,19 +4707,19 @@
ulint col_type;
ulint prefix_len;
ulint is_unsigned;
- ulint i;
- ulint j;
+ ulint i;
+ ulint j;
ulint* field_lengths;
-
- DBUG_ENTER("create_index");
+
+ DBUG_ENTER("create_index");
key = form->key_info + key_num;
- n_fields = key->key_parts;
+ n_fields = key->key_parts;
- ind_type = 0;
+ ind_type = 0;
- if (key_num == form->s->primary_key) {
+ if (key_num == form->s->primary_key) {
ind_type = ind_type | DICT_CLUSTERED;
}
@@ -4699,7 +4735,7 @@
field_lengths = (ulint*) my_malloc(sizeof(ulint) * n_fields,
MYF(MY_FAE));
-
+
for (i = 0; i < n_fields; i++) {
key_part = key->key_part + i;
@@ -4708,7 +4744,7 @@
bytes of the column to the index field.) The flag does not
seem to be properly set by MySQL. Let us fall back on testing
the length of the key part versus the column. */
-
+
field = NULL;
for (j = 0; j < form->s->fields; j++) {
@@ -4729,39 +4765,36 @@
&is_unsigned, key_part->field);
if (DATA_BLOB == col_type
- || (key_part->length < field->pack_length()
- && field->type() != MYSQL_TYPE_VARCHAR)
- || (field->type() == MYSQL_TYPE_VARCHAR
- && key_part->length < field->pack_length()
- - ((Field_varstring*)field)->length_bytes)) {
+ || (key_part->length < field->pack_length()
+ && field->type() != MYSQL_TYPE_VARCHAR)
+ || (field->type() == MYSQL_TYPE_VARCHAR
+ && key_part->length < field->pack_length()
+ - ((Field_varstring*)field)->length_bytes)) {
- prefix_len = key_part->length;
+ prefix_len = key_part->length;
if (col_type == DATA_INT
- || col_type == DATA_FLOAT
- || col_type == DATA_DOUBLE
- || col_type == DATA_DECIMAL) {
- sql_print_error("MySQL is trying to create a column "
- "prefix index field, on an "
- "inappropriate data type. Table "
- "name %s, column name %s.",
- table_name,
- key_part->field->field_name);
-
- prefix_len = 0;
+ || col_type == DATA_FLOAT
+ || col_type == DATA_DOUBLE
+ || col_type == DATA_DECIMAL) {
+ sql_print_error(
+ "MySQL is trying to create a column "
+ "prefix index field, on an "
+ "inappropriate data type. Table "
+ "name %s, column name %s.",
+ table_name,
+ key_part->field->field_name);
+
+ prefix_len = 0;
}
} else {
- prefix_len = 0;
+ prefix_len = 0;
}
field_lengths[i] = key_part->length;
- /* We assume all fields should be sorted in ascending
- order, hence the '0': */
-
dict_mem_index_add_field(index,
- (char*) key_part->field->field_name,
- 0, prefix_len);
+ (char*) key_part->field->field_name, prefix_len);
}
/* Even though we've defined max_supported_key_part_length, we
@@ -4772,7 +4805,7 @@
error = convert_error_code_to_mysql(error, NULL);
my_free((gptr) field_lengths, MYF(0));
-
+
DBUG_RETURN(error);
}
@@ -4787,14 +4820,13 @@
const char* table_name) /* in: table name */
{
dict_index_t* index;
- int error;
+ int error;
/* We pass 0 as the space id, and determine at a lower level the space
id where to store the table */
index = dict_mem_index_create((char*) table_name,
- (char*) "GEN_CLUST_INDEX",
- 0, DICT_CLUSTERED, 0);
+ (char*) "GEN_CLUST_INDEX", 0, DICT_CLUSTERED, 0);
error = row_create_index_for_mysql(index, trx, NULL);
error = convert_error_code_to_mysql(error, NULL);
@@ -4825,9 +4857,10 @@
char name2[FN_REFLEN];
char norm_name[FN_REFLEN];
THD *thd= current_thd;
- ib_longlong auto_inc_value;
+ ib_longlong auto_inc_value;
+ ulint flags;
- DBUG_ENTER("ha_innobase::create");
+ DBUG_ENTER("ha_innobase::create");
DBUG_ASSERT(thd != NULL);
@@ -4835,21 +4868,21 @@
/* The limit probably should be REC_MAX_N_FIELDS - 3 = 1020,
but we play safe here */
- DBUG_RETURN(HA_ERR_TO_BIG_ROW);
- }
+ DBUG_RETURN(HA_ERR_TO_BIG_ROW);
+ }
/* Get the transaction associated with the current thd, or create one
if not yet created */
-
+
parent_trx = check_trx_exists(current_thd);
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
- trx_search_latch_release_if_reserved(parent_trx);
-
+ trx_search_latch_release_if_reserved(parent_trx);
+
trx = trx_allocate_for_mysql();
-
+
trx->mysql_thd = thd;
trx->mysql_query_str = &((*thd).query);
@@ -4879,18 +4912,24 @@
/* Create the table definition in InnoDB */
+ flags = 0;
+
+ if (form->s->row_type != ROW_TYPE_REDUNDANT) {
+ flags |= DICT_TF_COMPACT;
+ }
+
error = create_table_def(trx, form, norm_name,
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
- form->s->row_type != ROW_TYPE_REDUNDANT);
+ flags);
- if (error) {
+ if (error) {
goto cleanup;
- }
+ }
/* Look for a primary key */
primary_key_no= (form->s->primary_key != MAX_KEY ?
- (int) form->s->primary_key :
+ (int) form->s->primary_key :
-1);
/* Our function row_get_mysql_key_number_for_index assumes
@@ -4907,29 +4946,29 @@
error = create_clustered_index_when_no_primary(trx,
norm_name);
- if (error) {
+ if (error) {
goto cleanup;
- }
+ }
}
if (primary_key_no != -1) {
/* In InnoDB the clustered index must always be created
first */
- if ((error = create_index(trx, form, norm_name,
+ if ((error = create_index(trx, form, norm_name,
(uint) primary_key_no))) {
goto cleanup;
- }
- }
+ }
+ }
for (i = 0; i < form->s->keys; i++) {
if (i != (uint) primary_key_no) {
- if ((error = create_index(trx, form, norm_name, i))) {
+ if ((error = create_index(trx, form, norm_name, i))) {
goto cleanup;
- }
- }
- }
+ }
+ }
+ }
if (current_thd->query != NULL) {
LEX_STRING q;
@@ -4939,7 +4978,7 @@
current_thd->query_length,
current_thd->charset())) {
error = HA_ERR_OUT_OF_MEM;
-
+
goto cleanup;
}
@@ -4954,7 +4993,7 @@
}
}
- innobase_commit_low(trx);
+ innobase_commit_low(trx);
row_mysql_unlock_data_dictionary(trx);
@@ -4971,7 +5010,7 @@
if ((create_info->used_fields & HA_CREATE_USED_AUTO) &&
(create_info->auto_increment_value != 0)) {
- /* Query was ALTER TABLE...AUTO_INCREMENT = x; or
+ /* Query was ALTER TABLE...AUTO_INCREMENT = x; or
CREATE TABLE ...AUTO_INCREMENT = x; Find out a table
definition from the dictionary and get the current value
of the auto increment field. Set a new value to the
@@ -4987,15 +5026,15 @@
srv_active_wake_master_thread();
- trx_free_for_mysql(trx);
+ trx_free_for_mysql(trx);
DBUG_RETURN(0);
cleanup:
innobase_commit_low(trx);
-
+
row_mysql_unlock_data_dictionary(trx);
-
+
trx_free_for_mysql(trx);
DBUG_RETURN(error);
@@ -5015,11 +5054,11 @@
trx_t* trx;
int err;
- DBUG_ENTER("ha_innobase::discard_or_import_tablespace");
+ DBUG_ENTER("ha_innobase::discard_or_import_tablespace");
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
dict_table = prebuilt->table;
trx = prebuilt->trx;
@@ -5092,20 +5131,20 @@
int error;
trx_t* parent_trx;
trx_t* trx;
- THD *thd= current_thd;
+ THD *thd= current_thd;
char norm_name[1000];
- DBUG_ENTER("ha_innobase::delete_table");
+ DBUG_ENTER("ha_innobase::delete_table");
/* Get the transaction associated with the current thd, or create one
if not yet created */
-
+
parent_trx = check_trx_exists(current_thd);
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
- trx_search_latch_release_if_reserved(parent_trx);
+ trx_search_latch_release_if_reserved(parent_trx);
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
@@ -5135,7 +5174,7 @@
normalize_table_name(norm_name, name);
- /* Drop the table in InnoDB */
+ /* Drop the table in InnoDB */
error = row_drop_table_for_mysql(norm_name, trx,
thd->lex->sql_command == SQLCOM_DROP_DB);
@@ -5151,9 +5190,9 @@
srv_active_wake_master_thread();
- innobase_commit_low(trx);
+ innobase_commit_low(trx);
- trx_free_for_mysql(trx);
+ trx_free_for_mysql(trx);
error = convert_error_code_to_mysql(error, NULL);
@@ -5181,13 +5220,13 @@
/* Get the transaction associated with the current thd, or create one
if not yet created */
-
+
parent_trx = check_trx_exists(current_thd);
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
- trx_search_latch_release_if_reserved(parent_trx);
+ trx_search_latch_release_if_reserved(parent_trx);
ptr = strend(path) - 2;
@@ -5202,7 +5241,7 @@
memcpy(namebuf, ptr, len);
namebuf[len] = '/';
namebuf[len + 1] = '\0';
-#ifdef __WIN__
+#ifdef __WIN__
innobase_casedn_str(namebuf);
#endif
trx = trx_allocate_for_mysql();
@@ -5213,7 +5252,7 @@
trx->check_foreigns = FALSE;
}
- error = row_drop_database_for_mysql(namebuf, trx);
+ error = row_drop_database_for_mysql(namebuf, trx);
my_free(namebuf, MYF(0));
/* Flush the log to reduce probability that the .frm files and
@@ -5227,9 +5266,9 @@
srv_active_wake_master_thread();
- innobase_commit_low(trx);
- trx_free_for_mysql(trx);
-#ifdef NO_LONGER_INTERESTED_IN_DROP_DB_ERROR
+ innobase_commit_low(trx);
+ trx_free_for_mysql(trx);
+#ifdef NO_LONGER_INTERESTED_IN_DROP_DB_ERROR
error = convert_error_code_to_mysql(error, NULL);
return(error);
@@ -5256,17 +5295,17 @@
char norm_from[1000];
char norm_to[1000];
- DBUG_ENTER("ha_innobase::rename_table");
+ DBUG_ENTER("ha_innobase::rename_table");
/* Get the transaction associated with the current thd, or create one
if not yet created */
-
+
parent_trx = check_trx_exists(current_thd);
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
- trx_search_latch_release_if_reserved(parent_trx);
+ trx_search_latch_release_if_reserved(parent_trx);
if (lower_case_table_names) {
srv_lower_case_table_names = TRUE;
@@ -5291,9 +5330,9 @@
normalize_table_name(norm_from, from);
normalize_table_name(norm_to, to);
- /* Rename the table in InnoDB */
+ /* Rename the table in InnoDB */
- error = row_rename_table_for_mysql(norm_from, norm_to, trx);
+ error = row_rename_table_for_mysql(norm_from, norm_to, trx);
/* Flush the log to reduce probability that the .frm files and
the InnoDB data dictionary get out-of-sync if the user runs
@@ -5306,8 +5345,8 @@
srv_active_wake_master_thread();
- innobase_commit_low(trx);
- trx_free_for_mysql(trx);
+ innobase_commit_low(trx);
+ trx_free_for_mysql(trx);
error = convert_error_code_to_mysql(error, NULL);
@@ -5322,30 +5361,30 @@
/*==========================*/
/* out: estimated number of
rows */
- uint keynr, /* in: index number */
- key_range *min_key, /* in: start key value of the
- range, may also be 0 */
+ uint keynr, /* in: index number */
+ key_range *min_key, /* in: start key value of the
+ range, may also be 0 */
key_range *max_key) /* in: range end key val, may
- also be 0 */
+ also be 0 */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
KEY* key;
dict_index_t* index;
- mysql_byte* key_val_buff2 = (mysql_byte*) my_malloc(
+ mysql_byte* key_val_buff2 = (mysql_byte*) my_malloc(
table->s->reclength
- + table->s->max_key_length + 100,
+ + table->s->max_key_length + 100,
MYF(MY_FAE));
ulint buff2_len = table->s->reclength
- + table->s->max_key_length + 100;
+ + table->s->max_key_length + 100;
dtuple_t* range_start;
dtuple_t* range_end;
ib_longlong n_rows;
ulint mode1;
ulint mode2;
- void* heap1;
- void* heap2;
+ void* heap1;
+ void* heap2;
- DBUG_ENTER("records_in_range");
+ DBUG_ENTER("records_in_range");
prebuilt->trx->op_info = (char*)"estimating records in index range";
@@ -5361,17 +5400,17 @@
index = dict_table_get_index_noninline(prebuilt->table, key->name);
range_start = dtuple_create_for_mysql(&heap1, key->key_parts);
- dict_index_copy_types(range_start, index, key->key_parts);
+ dict_index_copy_types(range_start, index, key->key_parts);
range_end = dtuple_create_for_mysql(&heap2, key->key_parts);
- dict_index_copy_types(range_end, index, key->key_parts);
+ dict_index_copy_types(range_end, index, key->key_parts);
row_sel_convert_mysql_key_to_innobase(
range_start, (byte*) key_val_buff,
(ulint)upd_and_key_val_buff_len,
index,
(byte*) (min_key ? min_key->key :
- (const mysql_byte*) 0),
+ (const mysql_byte*) 0),
(ulint) (min_key ? min_key->length : 0),
prebuilt->trx);
@@ -5379,21 +5418,21 @@
range_end, (byte*) key_val_buff2,
buff2_len, index,
(byte*) (max_key ? max_key->key :
- (const mysql_byte*) 0),
+ (const mysql_byte*) 0),
(ulint) (max_key ? max_key->length : 0),
prebuilt->trx);
mode1 = convert_search_mode_to_innobase(min_key ? min_key->flag :
- HA_READ_KEY_EXACT);
+ HA_READ_KEY_EXACT);
mode2 = convert_search_mode_to_innobase(max_key ? max_key->flag :
- HA_READ_KEY_EXACT);
+ HA_READ_KEY_EXACT);
n_rows = btr_estimate_n_rows_in_range(index, range_start,
mode1, range_end, mode2);
dtuple_free_for_mysql(heap1);
dtuple_free_for_mysql(heap2);
- my_free((gptr) key_val_buff2, MYF(0));
+ my_free((gptr) key_val_buff2, MYF(0));
prebuilt->trx->op_info = (char*)"";
@@ -5404,7 +5443,7 @@
Add 1 to the value to make sure MySQL does not make the assumption! */
if (n_rows == 0) {
- n_rows = 1;
+ n_rows = 1;
}
DBUG_RETURN((ha_rows) n_rows);
@@ -5424,7 +5463,7 @@
ulonglong estimate;
ulonglong local_data_file_length;
- DBUG_ENTER("estimate_rows_upper_bound");
+ DBUG_ENTER("estimate_rows_upper_bound");
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
@@ -5433,7 +5472,7 @@
update_thd(current_thd);
prebuilt->trx->op_info = (char*)
- "calculating upper bound for table rows";
+ "calculating upper bound for table rows";
/* In case MySQL calls this in the middle of a SELECT query, release
possible adaptive hash latch to avoid deadlocks of threads */
@@ -5443,7 +5482,7 @@
index = dict_table_get_first_index_noninline(prebuilt->table);
local_data_file_length = ((ulonglong) index->stat_n_leaf_pages)
- * UNIV_PAGE_SIZE;
+ * UNIV_PAGE_SIZE;
/* Calculate a minimum length for a clustered index record and from
that an upper bound for the number of rows. Since we only calculate
@@ -5474,7 +5513,7 @@
searches, we pretend that a sequential read takes the same time
as a random disk read, that is, we do not divide the following
by 10, which would be physically realistic. */
-
+
return((double) (prebuilt->table->stat_clustered_index_size));
}
@@ -5486,16 +5525,16 @@
ha_innobase::read_time(
/*===================*/
/* out: estimated time measured in disk seeks */
- uint index, /* in: key number */
+ uint index, /* in: key number */
uint ranges, /* in: how many ranges */
ha_rows rows) /* in: estimated number of rows in the ranges */
{
ha_rows total_rows;
- double time_for_scan;
-
+ double time_for_scan;
+
if (index != table->s->primary_key) {
- /* Not clustered */
- return(handler::read_time(index, ranges, rows));
+ /* Not clustered */
+ return(handler::read_time(index, ranges, rows));
}
if (rows <= 2) {
@@ -5510,7 +5549,7 @@
if ((total_rows = estimate_rows_upper_bound()) < rows) {
- return(time_for_scan);
+ return(time_for_scan);
}
return(ranges + (double) rows / (double) total_rows * time_for_scan);
@@ -5533,18 +5572,18 @@
ulong j;
ulong i;
char path[FN_REFLEN];
- os_file_stat_t stat_info;
+ os_file_stat_t stat_info;
- DBUG_ENTER("info");
+ DBUG_ENTER("info");
- /* If we are forcing recovery at a high level, we will suppress
+ /* If we are forcing recovery at a high level, we will suppress
statistics calculation on tables, because that may crash the
server if an index is badly corrupted. */
- if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
+ if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
- DBUG_VOID_RETURN;
- }
+ DBUG_VOID_RETURN;
+ }
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
@@ -5559,39 +5598,37 @@
trx_search_latch_release_if_reserved(prebuilt->trx);
- ib_table = prebuilt->table;
+ ib_table = prebuilt->table;
- if (flag & HA_STATUS_TIME) {
- /* In sql_show we call with this flag: update then statistics
- so that they are up-to-date */
+ if (flag & HA_STATUS_TIME) {
+ /* In sql_show we call with this flag: update then statistics
+ so that they are up-to-date */
- prebuilt->trx->op_info = (char*)"updating table statistics";
+ prebuilt->trx->op_info = (char*)"updating table statistics";
- dict_update_statistics(ib_table);
+ dict_update_statistics(ib_table);
prebuilt->trx->op_info = (char*)
- "returning various info to MySQL";
+ "returning various info to MySQL";
if (ib_table->space != 0) {
my_snprintf(path, sizeof(path), "%s/%s%s",
- mysql_data_home, ib_table->name,
- ".ibd");
+ mysql_data_home, ib_table->name, ".ibd");
unpack_filename(path,path);
} else {
- my_snprintf(path, sizeof(path), "%s/%s%s",
- mysql_data_home, ib_table->name,
- reg_ext);
-
+ my_snprintf(path, sizeof(path), "%s/%s%s",
+ mysql_data_home, ib_table->name, reg_ext);
+
unpack_filename(path,path);
}
- /* Note that we do not know the access time of the table,
+ /* Note that we do not know the access time of the table,
nor the CHECK TABLE time, nor the UPDATE or INSERT time. */
if (os_file_get_status(path,&stat_info)) {
create_time = stat_info.ctime;
}
- }
+ }
if (flag & HA_STATUS_VARIABLE) {
n_rows = ib_table->stat_n_rows;
@@ -5617,23 +5654,23 @@
n_rows++;
}
- records = (ha_rows)n_rows;
- deleted = 0;
- data_file_length = ((ulonglong)
+ records = (ha_rows)n_rows;
+ deleted = 0;
+ data_file_length = ((ulonglong)
ib_table->stat_clustered_index_size)
- * UNIV_PAGE_SIZE;
- index_file_length = ((ulonglong)
+ * UNIV_PAGE_SIZE;
+ index_file_length = ((ulonglong)
ib_table->stat_sum_of_other_index_sizes)
- * UNIV_PAGE_SIZE;
- delete_length = 0;
- check_time = 0;
-
- if (records == 0) {
- mean_rec_length = 0;
- } else {
- mean_rec_length = (ulong) (data_file_length / records);
- }
- }
+ * UNIV_PAGE_SIZE;
+ delete_length = 0;
+ check_time = 0;
+
+ if (records == 0) {
+ mean_rec_length = 0;
+ } else {
+ mean_rec_length = (ulong) (data_file_length / records);
+ }
+ }
if (flag & HA_STATUS_CONST) {
index = dict_table_get_first_index_noninline(ib_table);
@@ -5659,7 +5696,7 @@
for (j = 0; j < table->key_info[i].key_parts; j++) {
if (j + 1 > index->n_uniq) {
- ut_print_timestamp(stderr);
+ ut_print_timestamp(stderr);
sql_print_error("Index %s of %s has "
"%lu columns unique "
"inside InnoDB, but "
@@ -5675,7 +5712,7 @@
ib_table->name,
(unsigned long)
index->n_uniq, j + 1);
- break;
+ break;
}
if (index->stat_n_diff_key_vals[j + 1] == 0) {
@@ -5683,7 +5720,7 @@
rec_per_key = records;
} else {
rec_per_key = (ha_rows)(records /
- index->stat_n_diff_key_vals[j + 1]);
+ index->stat_n_diff_key_vals[j + 1]);
}
/* Since MySQL seems to favor table scans
@@ -5697,7 +5734,7 @@
rec_per_key = 1;
}
- table->key_info[i].rec_per_key[j]=
+ table->key_info[i].rec_per_key[j]=
rec_per_key >= ~(ulong) 0 ? ~(ulong) 0 :
rec_per_key;
}
@@ -5706,13 +5743,12 @@
}
}
- if (flag & HA_STATUS_ERRKEY) {
+ if (flag & HA_STATUS_ERRKEY) {
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
errkey = (unsigned int) row_get_mysql_key_number_for_index(
- (dict_index_t*)
- trx_get_error_info(prebuilt->trx));
- }
+ (dict_index_t*) trx_get_error_info(prebuilt->trx));
+ }
if (flag & HA_STATUS_AUTO && table->found_next_number_field) {
longlong auto_inc;
@@ -5724,7 +5760,7 @@
the auto-inc counter, and the second call is guaranteed to
succeed. */
- ret = innobase_read_and_init_auto_inc(&auto_inc);
+ ret = innobase_read_and_init_auto_inc(&auto_inc);
if (ret != 0) {
ret = innobase_read_and_init_auto_inc(&auto_inc);
@@ -5737,13 +5773,13 @@
auto_inc = 0;
}
}
-
+
auto_increment_value = auto_inc;
}
prebuilt->trx->op_info = (char*)"";
- DBUG_VOID_RETURN;
+ DBUG_VOID_RETURN;
}
/**************************************************************************
@@ -5752,7 +5788,7 @@
int
ha_innobase::analyze(
-/*=================*/
+/*=================*/
/* out: returns always 0 (success) */
THD* thd, /* in: connection thread handle */
HA_CHECK_OPT* check_opt) /* in: currently ignored */
@@ -5773,7 +5809,7 @@
THD* thd, /* in: connection thread handle */
HA_CHECK_OPT* check_opt) /* in: currently ignored */
{
- return(HA_ADMIN_TRY_ALTER);
+ return(HA_ADMIN_TRY_ALTER);
}
/***********************************************************************
@@ -5786,8 +5822,8 @@
/*===============*/
/* out: HA_ADMIN_CORRUPT or
HA_ADMIN_OK */
- THD* thd, /* in: user thread handle */
- HA_CHECK_OPT* check_opt) /* in: check options, currently
+ THD* thd, /* in: user thread handle */
+ HA_CHECK_OPT* check_opt) /* in: check options, currently
ignored */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
@@ -5795,7 +5831,7 @@
ut_a(prebuilt->trx && prebuilt->trx->magic_n == TRX_MAGIC_N);
ut_a(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
if (prebuilt->mysql_template == NULL) {
/* Build the template; we will use a dummy template
@@ -5810,7 +5846,7 @@
return(HA_ADMIN_OK);
}
- return(HA_ADMIN_CORRUPT);
+ return(HA_ADMIN_CORRUPT);
}
/*****************************************************************
@@ -5823,11 +5859,12 @@
/*==============================*/
/* out: table comment + InnoDB free space +
info on foreign keys */
- const char* comment)/* in: table comment defined by user */
+ const char* comment)/* in: table comment defined by user */
{
uint length = (uint) strlen(comment);
char* str;
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
+ long flen;
/* We do not know if MySQL can call this function before calling
external_lock(). To be safe, update the thd of the current table
@@ -5847,46 +5884,46 @@
trx_search_latch_release_if_reserved(prebuilt->trx);
str = NULL;
- if (FILE* file = os_file_create_tmpfile()) {
- long flen;
+ /* output the data to a temporary file */
+
+ mutex_enter_noninline(&srv_dict_tmpfile_mutex);
+ rewind(srv_dict_tmpfile);
- /* output the data to a temporary file */
- fprintf(file, "InnoDB free: %lu kB",
- (ulong) fsp_get_available_space_in_free_extents(
- prebuilt->table->space));
+ fprintf(srv_dict_tmpfile, "InnoDB free: %lu kB",
+ (ulong) fsp_get_available_space_in_free_extents(
+ prebuilt->table->space));
- dict_print_info_on_foreign_keys(FALSE, file,
+ dict_print_info_on_foreign_keys(FALSE, srv_dict_tmpfile,
prebuilt->trx, prebuilt->table);
- flen = ftell(file);
- if (flen < 0) {
- flen = 0;
- } else if (length + flen + 3 > 64000) {
- flen = 64000 - 3 - length;
- }
-
- /* allocate buffer for the full string, and
- read the contents of the temporary file */
-
- str = my_malloc(length + flen + 3, MYF(0));
-
- if (str) {
- char* pos = str + length;
- if (length) {
- memcpy(str, comment, length);
- *pos++ = ';';
- *pos++ = ' ';
- }
- rewind(file);
- flen = (uint) fread(pos, 1, flen, file);
- pos[flen] = 0;
- }
+ flen = ftell(srv_dict_tmpfile);
+ if (flen < 0) {
+ flen = 0;
+ } else if (length + flen + 3 > 64000) {
+ flen = 64000 - 3 - length;
+ }
+
+ /* allocate buffer for the full string, and
+ read the contents of the temporary file */
+
+ str = my_malloc(length + flen + 3, MYF(0));
- fclose(file);
+ if (str) {
+ char* pos = str + length;
+ if (length) {
+ memcpy(str, comment, length);
+ *pos++ = ';';
+ *pos++ = ' ';
+ }
+ rewind(srv_dict_tmpfile);
+ flen = (uint) fread(pos, 1, flen, srv_dict_tmpfile);
+ pos[flen] = 0;
}
- prebuilt->trx->op_info = (char*)"";
+ mutex_exit_noninline(&srv_dict_tmpfile_mutex);
- return(str ? str : (char*) comment);
+ prebuilt->trx->op_info = (char*)"";
+
+ return(str ? str : (char*) comment);
}
/***********************************************************************
@@ -5901,6 +5938,7 @@
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*)innobase_prebuilt;
char* str = 0;
+ long flen;
ut_a(prebuilt != NULL);
@@ -5910,52 +5948,47 @@
update_thd(current_thd);
- if (FILE* file = os_file_create_tmpfile()) {
- long flen;
+ prebuilt->trx->op_info = (char*)"getting info on foreign keys";
- prebuilt->trx->op_info = (char*)"getting info on foreign keys";
+ /* In case MySQL calls this in the middle of a SELECT query,
+ release possible adaptive hash latch to avoid
+ deadlocks of threads */
- /* In case MySQL calls this in the middle of a SELECT query,
- release possible adaptive hash latch to avoid
- deadlocks of threads */
+ trx_search_latch_release_if_reserved(prebuilt->trx);
- trx_search_latch_release_if_reserved(prebuilt->trx);
+ mutex_enter_noninline(&srv_dict_tmpfile_mutex);
+ rewind(srv_dict_tmpfile);
- /* output the data to a temporary file */
- dict_print_info_on_foreign_keys(TRUE, file,
+ /* output the data to a temporary file */
+ dict_print_info_on_foreign_keys(TRUE, srv_dict_tmpfile,
prebuilt->trx, prebuilt->table);
- prebuilt->trx->op_info = (char*)"";
-
- flen = ftell(file);
- if (flen < 0) {
- flen = 0;
- } else if (flen > 64000 - 1) {
- flen = 64000 - 1;
- }
+ prebuilt->trx->op_info = (char*)"";
- /* allocate buffer for the string, and
- read the contents of the temporary file */
+ flen = ftell(srv_dict_tmpfile);
+ if (flen < 0) {
+ flen = 0;
+ } else if (flen > 64000 - 1) {
+ flen = 64000 - 1;
+ }
- str = my_malloc(flen + 1, MYF(0));
+ /* allocate buffer for the string, and
+ read the contents of the temporary file */
- if (str) {
- rewind(file);
- flen = (uint) fread(str, 1, flen, file);
- str[flen] = 0;
- }
+ str = my_malloc(flen + 1, MYF(0));
- fclose(file);
- } else {
- /* unable to create temporary file */
- str = my_strdup(
-"/* Error: cannot display foreign key constraints */", MYF(0));
+ if (str) {
+ rewind(srv_dict_tmpfile);
+ flen = (uint) fread(str, 1, flen, srv_dict_tmpfile);
+ str[flen] = 0;
}
- return(str);
+ mutex_exit_noninline(&srv_dict_tmpfile_mutex);
+
+ return(str);
}
-int
+int
ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
{
dict_foreign_t* foreign;
@@ -5969,85 +6002,80 @@
mutex_enter_noninline(&(dict_sys->mutex));
foreign = UT_LIST_GET_FIRST(prebuilt->table->foreign_list);
- while (foreign != NULL)
- {
- uint i;
- FOREIGN_KEY_INFO f_key_info;
- LEX_STRING *name= 0;
- const char *tmp_buff;
-
- tmp_buff= foreign->id;
- i= 0;
- while (tmp_buff[i] != '/')
- i++;
- tmp_buff+= i + 1;
- f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff,
- (uint) strlen(tmp_buff), 1);
- tmp_buff= foreign->referenced_table_name;
- i= 0;
- while (tmp_buff[i] != '/')
- i++;
- f_key_info.referenced_db= make_lex_string(thd, 0,
- tmp_buff, i, 1);
- tmp_buff+= i + 1;
- f_key_info.referenced_table= make_lex_string(thd, 0, tmp_buff,
- (uint) strlen(tmp_buff), 1);
-
- for (i= 0;;)
- {
- tmp_buff= foreign->foreign_col_names[i];
- name= make_lex_string(thd, name, tmp_buff, (uint) strlen(tmp_buff), 1);
- f_key_info.foreign_fields.push_back(name);
- tmp_buff= foreign->referenced_col_names[i];
- name= make_lex_string(thd, name, tmp_buff, (uint) strlen(tmp_buff), 1);
- f_key_info.referenced_fields.push_back(name);
- if (++i >= foreign->n_fields)
- break;
- }
-
- ulong length= 0;
- if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE)
- {
- length=17;
- tmp_buff= "ON DELETE CASCADE";
- }
- else if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL)
- {
- length=18;
- tmp_buff= "ON DELETE SET NULL";
- }
- else if (foreign->type == DICT_FOREIGN_ON_DELETE_NO_ACTION)
- {
- length=19;
- tmp_buff= "ON DELETE NO ACTION";
- }
- else if (foreign->type == DICT_FOREIGN_ON_UPDATE_CASCADE)
- {
- length=17;
- tmp_buff= "ON UPDATE CASCADE";
- }
- else if (foreign->type == DICT_FOREIGN_ON_UPDATE_SET_NULL)
- {
- length=18;
- tmp_buff= "ON UPDATE SET NULL";
- }
- else if (foreign->type == DICT_FOREIGN_ON_UPDATE_NO_ACTION)
- {
- length=19;
- tmp_buff= "ON UPDATE NO ACTION";
- }
- f_key_info.constraint_method= make_lex_string(thd,
- f_key_info.constraint_method,
- tmp_buff, length, 1);
-
- FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *)
- thd->memdup((gptr) &f_key_info,
- sizeof(FOREIGN_KEY_INFO)));
- f_key_list->push_back(pf_key_info);
- foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
+ while (foreign != NULL) {
+ uint i;
+ FOREIGN_KEY_INFO f_key_info;
+ LEX_STRING *name= 0;
+ const char *tmp_buff;
+
+ tmp_buff= foreign->id;
+ i= 0;
+ while (tmp_buff[i] != '/')
+ i++;
+ tmp_buff+= i + 1;
+ f_key_info.forein_id= make_lex_string(thd, 0, tmp_buff,
+ (uint) strlen(tmp_buff), 1);
+ tmp_buff= foreign->referenced_table_name;
+ i= 0;
+ while (tmp_buff[i] != '/')
+ i++;
+ f_key_info.referenced_db= make_lex_string(thd, 0,
+ tmp_buff, i, 1);
+ tmp_buff+= i + 1;
+ f_key_info.referenced_table= make_lex_string(thd, 0, tmp_buff,
+ (uint) strlen(tmp_buff), 1);
+
+ for (i= 0;;) {
+ tmp_buff= foreign->foreign_col_names[i];
+ name= make_lex_string(thd, name, tmp_buff,
+ (uint) strlen(tmp_buff), 1);
+ f_key_info.foreign_fields.push_back(name);
+ tmp_buff= foreign->referenced_col_names[i];
+ name= make_lex_string(thd, name, tmp_buff,
+ (uint) strlen(tmp_buff), 1);
+ f_key_info.referenced_fields.push_back(name);
+ if (++i >= foreign->n_fields)
+ break;
+ }
+
+ ulong length= 0;
+ if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE) {
+ length=17;
+ tmp_buff= "ON DELETE CASCADE";
+ }
+ else if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL) {
+ length=18;
+ tmp_buff= "ON DELETE SET NULL";
+ }
+ else if (foreign->type == DICT_FOREIGN_ON_DELETE_NO_ACTION) {
+ length=19;
+ tmp_buff= "ON DELETE NO ACTION";
+ }
+ else if (foreign->type == DICT_FOREIGN_ON_UPDATE_CASCADE) {
+ length=17;
+ tmp_buff= "ON UPDATE CASCADE";
+ }
+ else if (foreign->type == DICT_FOREIGN_ON_UPDATE_SET_NULL) {
+ length=18;
+ tmp_buff= "ON UPDATE SET NULL";
+ }
+ else if (foreign->type == DICT_FOREIGN_ON_UPDATE_NO_ACTION) {
+ length=19;
+ tmp_buff= "ON UPDATE NO ACTION";
+ }
+ f_key_info.constraint_method= make_lex_string(thd,
+ f_key_info.constraint_method,
+ tmp_buff, length, 1);
+
+ FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *)
+ thd->memdup((gptr) &f_key_info,
+ sizeof(FOREIGN_KEY_INFO)));
+ f_key_list->push_back(pf_key_info);
+ foreign = UT_LIST_GET_NEXT(foreign_list, foreign);
}
mutex_exit_noninline(&(dict_sys->mutex));
prebuilt->trx->op_info = (char*)"";
+
DBUG_RETURN(0);
}
@@ -6063,7 +6091,7 @@
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
bool can_switch;
- DBUG_ENTER("ha_innobase::can_switch_engines");
+ DBUG_ENTER("ha_innobase::can_switch_engines");
prebuilt->trx->op_info =
"determining if there are foreign key constraints";
row_mysql_lock_data_dictionary(prebuilt->trx);
@@ -6105,7 +6133,7 @@
void
ha_innobase::free_foreign_key_create_info(
/*======================================*/
- char* str) /* in, own: create info string to free */
+ char* str) /* in, own: create info string to free */
{
if (str) {
my_free(str, MYF(0));
@@ -6120,7 +6148,7 @@
/*===============*/
/* out: 0 or error number */
enum ha_extra_function operation)
- /* in: HA_EXTRA_RETRIEVE_ALL_COLS or some
+ /* in: HA_EXTRA_RETRIEVE_ALL_COLS or some
other flag */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
@@ -6130,38 +6158,38 @@
obsolete! */
switch (operation) {
- case HA_EXTRA_FLUSH:
- if (prebuilt->blob_heap) {
- row_mysql_prebuilt_free_blob_heap(prebuilt);
- }
- break;
- case HA_EXTRA_RESET:
- if (prebuilt->blob_heap) {
- row_mysql_prebuilt_free_blob_heap(prebuilt);
- }
- prebuilt->keep_other_fields_on_keyread = 0;
- prebuilt->read_just_key = 0;
- break;
- case HA_EXTRA_RESET_STATE:
- prebuilt->keep_other_fields_on_keyread = 0;
- prebuilt->read_just_key = 0;
- break;
+ case HA_EXTRA_FLUSH:
+ if (prebuilt->blob_heap) {
+ row_mysql_prebuilt_free_blob_heap(prebuilt);
+ }
+ break;
+ case HA_EXTRA_RESET:
+ if (prebuilt->blob_heap) {
+ row_mysql_prebuilt_free_blob_heap(prebuilt);
+ }
+ prebuilt->keep_other_fields_on_keyread = 0;
+ prebuilt->read_just_key = 0;
+ break;
+ case HA_EXTRA_RESET_STATE:
+ prebuilt->keep_other_fields_on_keyread = 0;
+ prebuilt->read_just_key = 0;
+ break;
case HA_EXTRA_NO_KEYREAD:
- prebuilt->read_just_key = 0;
- break;
- case HA_EXTRA_RETRIEVE_ALL_COLS:
+ prebuilt->read_just_key = 0;
+ break;
+ case HA_EXTRA_RETRIEVE_ALL_COLS:
prebuilt->hint_need_to_fetch_extra_cols
= ROW_RETRIEVE_ALL_COLS;
break;
- case HA_EXTRA_RETRIEVE_PRIMARY_KEY:
+ case HA_EXTRA_RETRIEVE_PRIMARY_KEY:
if (prebuilt->hint_need_to_fetch_extra_cols == 0) {
prebuilt->hint_need_to_fetch_extra_cols
= ROW_RETRIEVE_PRIMARY_KEY;
}
break;
- case HA_EXTRA_KEYREAD:
- prebuilt->read_just_key = 1;
- break;
+ case HA_EXTRA_KEYREAD:
+ prebuilt->read_just_key = 1;
+ break;
case HA_EXTRA_KEYREAD_PRESERVE_FIELDS:
prebuilt->keep_other_fields_on_keyread = 1;
break;
@@ -6187,9 +6215,9 @@
int
ha_innobase::start_stmt(
/*====================*/
- /* out: 0 or error code */
- THD* thd, /* in: handle to the user thread */
- thr_lock_type lock_type)
+ /* out: 0 or error code */
+ THD* thd, /* in: handle to the user thread */
+ thr_lock_type lock_type)
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
@@ -6208,30 +6236,30 @@
innobase_release_stat_resources(trx);
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
- && trx->global_read_view) {
- /* At low transaction isolation levels we let
+ && trx->global_read_view) {
+ /* At low transaction isolation levels we let
each consistent read set its own snapshot */
- read_view_close_for_mysql(trx);
+ read_view_close_for_mysql(trx);
}
prebuilt->sql_stat_start = TRUE;
prebuilt->hint_need_to_fetch_extra_cols = 0;
prebuilt->read_just_key = 0;
- prebuilt->keep_other_fields_on_keyread = FALSE;
+ prebuilt->keep_other_fields_on_keyread = FALSE;
if (!prebuilt->mysql_has_locked) {
- /* This handle is for a temporary table created inside
- this same LOCK TABLES; since MySQL does NOT call external_lock
- in this case, we must use x-row locks inside InnoDB to be
- prepared for an update of a row */
-
- prebuilt->select_lock_type = LOCK_X;
+ /* This handle is for a temporary table created inside
+ this same LOCK TABLES; since MySQL does NOT call external_lock
+ in this case, we must use x-row locks inside InnoDB to be
+ prepared for an update of a row */
+
+ prebuilt->select_lock_type = LOCK_X;
} else {
if (trx->isolation_level != TRX_ISO_SERIALIZABLE
- && thd->lex->sql_command == SQLCOM_SELECT
- && lock_type == TL_READ) {
-
+ && thd->lex->sql_command == SQLCOM_SELECT
+ && lock_type == TL_READ) {
+
/* For other than temporary tables, we obtain
no lock for consistent read (plain SELECT). */
@@ -6241,8 +6269,8 @@
select_lock_type value. The value of
stored_select_lock_type was decided in:
1) ::store_lock(),
- 2) ::external_lock(),
- 3) ::init_table_handle_for_HANDLER(), and
+ 2) ::external_lock(),
+ 3) ::init_table_handle_for_HANDLER(), and
4) :.transactional_table_lock(). */
prebuilt->select_lock_type =
@@ -6250,10 +6278,11 @@
}
if (prebuilt->stored_select_lock_type != LOCK_S
- && prebuilt->stored_select_lock_type != LOCK_X) {
- sql_print_error("stored_select_lock_type is %lu inside "
- "::start_stmt()!",
- prebuilt->stored_select_lock_type);
+ && prebuilt->stored_select_lock_type != LOCK_X) {
+ sql_print_error(
+ "stored_select_lock_type is %lu inside "
+ "::start_stmt()!",
+ prebuilt->stored_select_lock_type);
/* Set the value to LOCK_X: this is just fault
tolerance, we do not know what the correct value
@@ -6266,11 +6295,11 @@
trx->detailed_error[0] = '\0';
/* Set the MySQL flag to mark that there is an active transaction */
- if (trx->active_trans == 0) {
+ if (trx->active_trans == 0) {
- innobase_register_trx_and_stmt(thd);
- trx->active_trans = 1;
- } else {
+ innobase_register_trx_and_stmt(thd);
+ trx->active_trans = 1;
+ } else {
innobase_register_stmt(thd);
}
@@ -6292,9 +6321,9 @@
case ISO_SERIALIZABLE: return(TRX_ISO_SERIALIZABLE);
case ISO_READ_UNCOMMITTED: return(TRX_ISO_READ_UNCOMMITTED);
default: ut_a(0); return(0);
- }
+ }
}
-
+
/**********************************************************************
As MySQL will execute an external lock for every new table it uses when it
starts to process an SQL statement (an exception is when MySQL calls
@@ -6307,14 +6336,14 @@
int
ha_innobase::external_lock(
/*=======================*/
- /* out: 0 */
+ /* out: 0 */
THD* thd, /* in: handle to the user thread */
- int lock_type) /* in: lock type */
+ int lock_type) /* in: lock type */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
- DBUG_ENTER("ha_innobase::external_lock");
+ DBUG_ENTER("ha_innobase::external_lock");
DBUG_PRINT("enter",("lock_type: %d", lock_type));
update_thd(thd);
@@ -6339,14 +6368,14 @@
/* MySQL is setting a new table lock */
trx->detailed_error[0] = '\0';
-
+
/* Set the MySQL flag to mark that there is an active
transaction */
- if (trx->active_trans == 0) {
+ if (trx->active_trans == 0) {
- innobase_register_trx_and_stmt(thd);
- trx->active_trans = 1;
- } else if (trx->n_mysql_tables_in_use == 0) {
+ innobase_register_trx_and_stmt(thd);
+ trx->active_trans = 1;
+ } else if (trx->n_mysql_tables_in_use == 0) {
innobase_register_stmt(thd);
}
@@ -6354,14 +6383,14 @@
prebuilt->mysql_has_locked = TRUE;
if (trx->n_mysql_tables_in_use == 1) {
- trx->isolation_level = innobase_map_isolation_level(
+ trx->isolation_level = innobase_map_isolation_level(
(enum_tx_isolation)
thd->variables.tx_isolation);
}
if (trx->isolation_level == TRX_ISO_SERIALIZABLE
- && prebuilt->select_lock_type == LOCK_NONE
- && (thd->options
+ && prebuilt->select_lock_type == LOCK_NONE
+ && (thd->options
& (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
/* To get serializable execution, we let InnoDB
@@ -6380,20 +6409,22 @@
TABLES if AUTOCOMMIT=1. It does not make much sense to acquire
an InnoDB table lock if it is released immediately at the end
of LOCK TABLES, and InnoDB's table locks in that case cause
- VERY easily deadlocks. We do not set InnoDB table locks when
- MySQL sets them at the start of a stored procedure call
- (MySQL does have thd->in_lock_tables TRUE there). */
+ VERY easily deadlocks.
+
+ We do not set InnoDB table locks if user has not explicitly
+ requested a table lock. Note that thd->in_lock_tables
+ can be TRUE on some cases e.g. at the start of a stored
+ procedure call (SQLCOM_CALL). */
if (prebuilt->select_lock_type != LOCK_NONE) {
if (thd->in_lock_tables &&
- thd->lex->sql_command != SQLCOM_CALL &&
- thd->variables.innodb_table_locks &&
- (thd->options & OPTION_NOT_AUTOCOMMIT)) {
-
- ulint error;
- error = row_lock_table_for_mysql(prebuilt,
- NULL, 0);
+ thd->lex->sql_command == SQLCOM_LOCK_TABLES &&
+ thd->variables.innodb_table_locks &&
+ (thd->options & OPTION_NOT_AUTOCOMMIT)) {
+
+ ulint error = row_lock_table_for_mysql(
+ prebuilt, NULL, 0);
if (error != DB_SUCCESS) {
error = convert_error_code_to_mysql(
@@ -6402,7 +6433,7 @@
}
}
- trx->mysql_n_tables_locked++;
+ trx->mysql_n_tables_locked++;
}
DBUG_RETURN(0);
@@ -6418,9 +6449,9 @@
if (trx->n_mysql_tables_in_use == 0) {
- trx->mysql_n_tables_locked = 0;
+ trx->mysql_n_tables_locked = 0;
prebuilt->used_in_HANDLER = FALSE;
-
+
/* Release a possible FIFO ticket and search latch. Since we
may reserve the kernel mutex, we have to release the search
system latch first to obey the latching order. */
@@ -6428,12 +6459,12 @@
innobase_release_stat_resources(trx);
if (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
- if (trx->active_trans != 0) {
- innobase_commit(thd, TRUE);
+ if (trx->active_trans != 0) {
+ innobase_commit(thd, TRUE);
}
} else {
if (trx->isolation_level <= TRX_ISO_READ_COMMITTED
- && trx->global_read_view) {
+ && trx->global_read_view) {
/* At low transaction isolation levels we let
each consistent read set its own snapshot */
@@ -6453,14 +6484,14 @@
int
ha_innobase::transactional_table_lock(
/*==================================*/
- /* out: error code */
+ /* out: error code */
THD* thd, /* in: handle to the user thread */
- int lock_type) /* in: lock type */
+ int lock_type) /* in: lock type */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
trx_t* trx;
- DBUG_ENTER("ha_innobase::transactional_table_lock");
+ DBUG_ENTER("ha_innobase::transactional_table_lock");
DBUG_PRINT("enter",("lock_type: %d", lock_type));
/* We do not know if MySQL can call this function before calling
@@ -6469,9 +6500,9 @@
update_thd(thd);
- if (prebuilt->table->ibd_file_missing && !current_thd->tablespace_op) {
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB error:\n"
+ if (prebuilt->table->ibd_file_missing && !current_thd->tablespace_op) {
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB error:\n"
"MySQL is trying to use a table handle but the .ibd file for\n"
"table %s does not exist.\n"
"Have you deleted the .ibd file from the database directory under\n"
@@ -6497,8 +6528,8 @@
prebuilt->select_lock_type = LOCK_S;
prebuilt->stored_select_lock_type = LOCK_S;
} else {
- ut_print_timestamp(stderr);
- fprintf(stderr, " InnoDB error:\n"
+ ut_print_timestamp(stderr);
+ fprintf(stderr, " InnoDB error:\n"
"MySQL is trying to set transactional table lock with corrupted lock type\n"
"to table %s, lock type %d does not exist.\n",
prebuilt->table->name, lock_type);
@@ -6508,11 +6539,11 @@
/* MySQL is setting a new transactional table lock */
/* Set the MySQL flag to mark that there is an active transaction */
- if (trx->active_trans == 0) {
+ if (trx->active_trans == 0) {
- innobase_register_trx_and_stmt(thd);
- trx->active_trans = 1;
- }
+ innobase_register_trx_and_stmt(thd);
+ trx->active_trans = 1;
+ }
if (thd->in_lock_tables && thd->variables.innodb_table_locks) {
ulint error = DB_SUCCESS;
@@ -6526,8 +6557,8 @@
if (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) {
- /* Store the current undo_no of the transaction
- so that we know where to roll back if we have
+ /* Store the current undo_no of the transaction
+ so that we know where to roll back if we have
to roll back the next SQL statement */
trx_mark_sql_stat_end(trx);
@@ -6542,11 +6573,13 @@
int
innodb_export_status()
-/*======================*/
+/*==================*/
{
- if (innodb_inited)
- srv_export_innodb_status();
- return 0;
+ if (innodb_inited) {
+ srv_export_innodb_status();
+ }
+
+ return 0;
}
/****************************************************************************
@@ -6565,11 +6598,11 @@
ulint trx_list_start = ULINT_UNDEFINED;
ulint trx_list_end = ULINT_UNDEFINED;
- DBUG_ENTER("innodb_show_status");
+ DBUG_ENTER("innodb_show_status");
- if (have_innodb != SHOW_OPTION_YES) {
- DBUG_RETURN(FALSE);
- }
+ if (have_innodb != SHOW_OPTION_YES) {
+ DBUG_RETURN(FALSE);
+ }
trx = check_trx_exists(thd);
@@ -6601,11 +6634,10 @@
/* allocate buffer for the string, and
read the contents of the temporary file */
- if (!(str = my_malloc(usable_len + 1, MYF(0))))
- {
- mutex_exit_noninline(&srv_monitor_file_mutex);
- DBUG_RETURN(TRUE);
- }
+ if (!(str = my_malloc(usable_len + 1, MYF(0)))) {
+ mutex_exit_noninline(&srv_monitor_file_mutex);
+ DBUG_RETURN(TRUE);
+ }
rewind(srv_monitor_file);
if (flen < MAX_STATUS_SIZE) {
@@ -6632,8 +6664,8 @@
bool result = FALSE;
- if (stat_print(thd, innobase_hton.name, strlen(innobase_hton.name),
- STRING_WITH_LEN(""), str, flen)) {
+ if (stat_print(thd, innobase_hton.name, strlen(innobase_hton.name),
+ STRING_WITH_LEN(""), str, flen)) {
result= TRUE;
}
my_free(str, MYF(0));
@@ -6646,96 +6678,99 @@
bool
innodb_mutex_show_status(
-/*===============*/
- THD* thd, /* in: the MySQL query thread of the caller */
- stat_print_fn *stat_print)
-{
- char buf1[IO_SIZE], buf2[IO_SIZE];
- mutex_t* mutex;
- ulint rw_lock_count= 0;
- ulint rw_lock_count_spin_loop= 0;
- ulint rw_lock_count_spin_rounds= 0;
- ulint rw_lock_count_os_wait= 0;
- ulint rw_lock_count_os_yield= 0;
- ulonglong rw_lock_wait_time= 0;
- uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
- DBUG_ENTER("innodb_mutex_show_status");
+/*=====================*/
+ THD* thd, /* in: the MySQL query thread of the
+ caller */
+ stat_print_fn* stat_print)
+{
+ char buf1[IO_SIZE], buf2[IO_SIZE];
+ mutex_t* mutex;
+ ulint rw_lock_count= 0;
+ ulint rw_lock_count_spin_loop= 0;
+ ulint rw_lock_count_spin_rounds= 0;
+ ulint rw_lock_count_os_wait= 0;
+ ulint rw_lock_count_os_yield= 0;
+ ulonglong rw_lock_wait_time= 0;
+ uint hton_name_len= strlen(innobase_hton.name), buf1len, buf2len;
+ DBUG_ENTER("innodb_mutex_show_status");
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
- mutex_enter(&mutex_list_mutex);
+ mutex_enter(&mutex_list_mutex);
#endif
- mutex = UT_LIST_GET_FIRST(mutex_list);
+ mutex = UT_LIST_GET_FIRST(mutex_list);
- while ( mutex != NULL )
- {
- if (mutex->mutex_type != 1)
- {
- if (mutex->count_using > 0)
- {
- buf1len= my_snprintf(buf1, sizeof(buf1), "%s:%s",
- mutex->cmutex_name, mutex->cfile_name);
- buf2len= my_snprintf(buf2, sizeof(buf2),
- "count=%lu, spin_waits=%lu, spin_rounds=%lu, "
- "os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
- mutex->count_using, mutex->count_spin_loop,
- mutex->count_spin_rounds,
- mutex->count_os_wait, mutex->count_os_yield,
- mutex->lspent_time/1000);
- if (stat_print(thd, innobase_hton.name, hton_name_len,
- buf1, buf1len, buf2, buf2len))
- {
+ while (mutex != NULL) {
+ if (mutex->mutex_type != 1) {
+ if (mutex->count_using > 0) {
+ buf1len= my_snprintf(buf1, sizeof(buf1),
+ "%s:%s",
+ mutex->cmutex_name, mutex->cfile_name);
+ buf2len= my_snprintf(buf2, sizeof(buf2),
+ "count=%lu, spin_waits=%lu,"
+ " spin_rounds=%lu, "
+ "os_waits=%lu, os_yields=%lu,"
+ " os_wait_times=%lu",
+ mutex->count_using,
+ mutex->count_spin_loop,
+ mutex->count_spin_rounds,
+ mutex->count_os_wait,
+ mutex->count_os_yield,
+ mutex->lspent_time/1000);
+
+ if (stat_print(thd, innobase_hton.name,
+ hton_name_len, buf1, buf1len,
+ buf2, buf2len)) {
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
- mutex_exit(&mutex_list_mutex);
+ mutex_exit(&mutex_list_mutex);
#endif
- DBUG_RETURN(1);
- }
- }
- }
- else
- {
- rw_lock_count += mutex->count_using;
- rw_lock_count_spin_loop += mutex->count_spin_loop;
- rw_lock_count_spin_rounds += mutex->count_spin_rounds;
- rw_lock_count_os_wait += mutex->count_os_wait;
- rw_lock_count_os_yield += mutex->count_os_yield;
- rw_lock_wait_time += mutex->lspent_time;
- }
+ DBUG_RETURN(1);
+ }
+ }
+ }
+ else {
+ rw_lock_count += mutex->count_using;
+ rw_lock_count_spin_loop += mutex->count_spin_loop;
+ rw_lock_count_spin_rounds += mutex->count_spin_rounds;
+ rw_lock_count_os_wait += mutex->count_os_wait;
+ rw_lock_count_os_yield += mutex->count_os_yield;
+ rw_lock_wait_time += mutex->lspent_time;
+ }
- mutex = UT_LIST_GET_NEXT(list, mutex);
- }
+ mutex = UT_LIST_GET_NEXT(list, mutex);
+ }
- buf2len= my_snprintf(buf2, sizeof(buf2),
- "count=%lu, spin_waits=%lu, spin_rounds=%lu, "
- "os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
- rw_lock_count, rw_lock_count_spin_loop,
- rw_lock_count_spin_rounds,
- rw_lock_count_os_wait, rw_lock_count_os_yield,
- rw_lock_wait_time/1000);
-
- if (stat_print(thd, innobase_hton.name, hton_name_len,
- STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len))
- {
- DBUG_RETURN(1);
- }
+ buf2len= my_snprintf(buf2, sizeof(buf2),
+ "count=%lu, spin_waits=%lu, spin_rounds=%lu, "
+ "os_waits=%lu, os_yields=%lu, os_wait_times=%lu",
+ rw_lock_count, rw_lock_count_spin_loop,
+ rw_lock_count_spin_rounds,
+ rw_lock_count_os_wait, rw_lock_count_os_yield,
+ rw_lock_wait_time/1000);
+
+ if (stat_print(thd, innobase_hton.name, hton_name_len,
+ STRING_WITH_LEN("rw_lock_mutexes"), buf2, buf2len)) {
+ DBUG_RETURN(1);
+ }
#ifdef MUTEX_PROTECT_TO_BE_ADDED_LATER
- mutex_exit(&mutex_list_mutex);
+ mutex_exit(&mutex_list_mutex);
#endif
- DBUG_RETURN(FALSE);
+
+ DBUG_RETURN(FALSE);
}
bool innobase_show_status(THD* thd, stat_print_fn* stat_print,
- enum ha_stat_type stat_type)
+ enum ha_stat_type stat_type)
{
- switch (stat_type) {
- case HA_ENGINE_STATUS:
- return innodb_show_status(thd, stat_print);
- case HA_ENGINE_MUTEX:
- return innodb_mutex_show_status(thd, stat_print);
- default:
- return FALSE;
- }
+ switch (stat_type) {
+ case HA_ENGINE_STATUS:
+ return innodb_show_status(thd, stat_print);
+ case HA_ENGINE_MUTEX:
+ return innodb_mutex_show_status(thd, stat_print);
+ default:
+ return FALSE;
+ }
}
@@ -6744,54 +6779,61 @@
locking.
****************************************************************************/
-static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length,
- my_bool not_used __attribute__((unused)))
+static mysql_byte* innobase_get_key(INNOBASE_SHARE* share, uint* length,
+ my_bool not_used __attribute__((unused)))
{
- *length=share->table_name_length;
- return (mysql_byte*) share->table_name;
+ *length=share->table_name_length;
+
+ return (mysql_byte*) share->table_name;
}
-static INNOBASE_SHARE *get_share(const char *table_name)
+static INNOBASE_SHARE* get_share(const char* table_name)
{
- INNOBASE_SHARE *share;
- pthread_mutex_lock(&innobase_share_mutex);
- uint length=(uint) strlen(table_name);
- if (!(share=(INNOBASE_SHARE*) hash_search(&innobase_open_tables,
- (mysql_byte*) table_name,
- length)))
- {
- if ((share=(INNOBASE_SHARE *) my_malloc(sizeof(*share)+length+1,
- MYF(MY_WME | MY_ZEROFILL))))
- {
- share->table_name_length=length;
- share->table_name=(char*) (share+1);
- strmov(share->table_name,table_name);
- if (my_hash_insert(&innobase_open_tables, (mysql_byte*) share))
- {
- pthread_mutex_unlock(&innobase_share_mutex);
- my_free((gptr) share,0);
- return 0;
- }
- thr_lock_init(&share->lock);
- pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
- }
- }
- share->use_count++;
- pthread_mutex_unlock(&innobase_share_mutex);
- return share;
+ INNOBASE_SHARE *share;
+ pthread_mutex_lock(&innobase_share_mutex);
+ uint length=(uint) strlen(table_name);
+
+ if (!(share=(INNOBASE_SHARE*) hash_search(&innobase_open_tables,
+ (mysql_byte*) table_name,
+ length))) {
+
+ share = (INNOBASE_SHARE *) my_malloc(sizeof(*share)+length+1,
+ MYF(MY_FAE | MY_ZEROFILL));
+
+ share->table_name_length=length;
+ share->table_name=(char*) (share+1);
+ strmov(share->table_name,table_name);
+
+ if (my_hash_insert(&innobase_open_tables,
+ (mysql_byte*) share)) {
+ pthread_mutex_unlock(&innobase_share_mutex);
+ my_free((gptr) share,0);
+
+ return 0;
+ }
+
+ thr_lock_init(&share->lock);
+ pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
+ }
+
+ share->use_count++;
+ pthread_mutex_unlock(&innobase_share_mutex);
+
+ return share;
}
-static void free_share(INNOBASE_SHARE *share)
-{
- pthread_mutex_lock(&innobase_share_mutex);
- if (!--share->use_count)
- {
- hash_delete(&innobase_open_tables, (mysql_byte*) share);
- thr_lock_delete(&share->lock);
- pthread_mutex_destroy(&share->mutex);
- my_free((gptr) share, MYF(0));
- }
- pthread_mutex_unlock(&innobase_share_mutex);
+static void free_share(INNOBASE_SHARE* share)
+{
+ pthread_mutex_lock(&innobase_share_mutex);
+
+ if (!--share->use_count) {
+ hash_delete(&innobase_open_tables, (mysql_byte*) share);
+ thr_lock_delete(&share->lock);
+ pthread_mutex_destroy(&share->mutex);
+ my_free((gptr) share, MYF(0));
+ }
+
+ pthread_mutex_unlock(&innobase_share_mutex);
}
/*********************************************************************
@@ -6814,22 +6856,22 @@
pointer to the 'lock' field
of current handle is stored
next to this array */
- enum thr_lock_type lock_type) /* in: lock type to store in
+ enum thr_lock_type lock_type) /* in: lock type to store in
'lock'; this may also be
TL_IGNORE */
{
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE!
+ /* NOTE: MySQL can call this function with lock 'type' TL_IGNORE!
Be careful to ignore TL_IGNORE if we are going to do something with
only 'real' locks! */
- if ((lock_type == TL_READ && thd->in_lock_tables) ||
- (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) ||
- lock_type == TL_READ_WITH_SHARED_LOCKS ||
- lock_type == TL_READ_NO_INSERT ||
- (thd->lex->sql_command != SQLCOM_SELECT
- && lock_type != TL_IGNORE)) {
+ if ((lock_type == TL_READ && thd->in_lock_tables) ||
+ (lock_type == TL_READ_HIGH_PRIORITY && thd->in_lock_tables) ||
+ lock_type == TL_READ_WITH_SHARED_LOCKS ||
+ lock_type == TL_READ_NO_INSERT ||
+ (thd->lex->sql_command != SQLCOM_SELECT
+ && lock_type != TL_IGNORE)) {
/* The OR cases above are in this order:
1) MySQL is doing LOCK TABLES ... READ LOCAL, or
@@ -6849,10 +6891,10 @@
used. */
if (srv_locks_unsafe_for_binlog &&
- prebuilt->trx->isolation_level != TRX_ISO_SERIALIZABLE &&
- (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) &&
- (thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
- thd->lex->sql_command == SQLCOM_UPDATE)) {
+ prebuilt->trx->isolation_level != TRX_ISO_SERIALIZABLE &&
+ (lock_type == TL_READ || lock_type == TL_READ_NO_INSERT) &&
+ (thd->lex->sql_command == SQLCOM_INSERT_SELECT ||
+ thd->lex->sql_command == SQLCOM_UPDATE)) {
/* In case we have innobase_locks_unsafe_for_binlog
option set and isolation level of the transaction
@@ -6875,7 +6917,7 @@
} else if (lock_type != TL_IGNORE) {
- /* We set possible LOCK_X value in external_lock, not yet
+ /* We set possible LOCK_X value in external_lock, not yet
here even if this would be SELECT ... FOR UPDATE */
prebuilt->select_lock_type = LOCK_NONE;
@@ -6884,7 +6926,7 @@
if (lock_type != TL_IGNORE && lock.type == TL_UNLOCK) {
- /* Starting from 5.0.7, we weaken also the table locks
+ /* Starting from 5.0.7, we weaken also the table locks
set at the start of a MySQL stored procedure call, just like
we weaken the locks set at the start of an SQL statement.
MySQL does set thd->in_lock_tables TRUE there, but in reality
@@ -6907,38 +6949,48 @@
lock_type = TL_READ_NO_INSERT;
}
- /* If we are not doing a LOCK TABLE or DISCARD/IMPORT
- TABLESPACE or TRUNCATE TABLE, then allow multiple writers */
+ /* If we are not doing a LOCK TABLE, DISCARD/IMPORT
+ TABLESPACE or TRUNCATE TABLE then allow multiple
+ writers. Note that ALTER TABLE uses a TL_WRITE_ALLOW_READ
+ < TL_WRITE_CONCURRENT_INSERT.
- if ((lock_type >= TL_WRITE_CONCURRENT_INSERT &&
- lock_type <= TL_WRITE)
- && (!thd->in_lock_tables
- || thd->lex->sql_command == SQLCOM_CALL)
- && !thd->tablespace_op
- && thd->lex->sql_command != SQLCOM_TRUNCATE
- && thd->lex->sql_command != SQLCOM_OPTIMIZE
- && thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
+ We especially allow multiple writers if MySQL is at the
+ start of a stored procedure call (SQLCOM_CALL)
+ (MySQL does have thd->in_lock_tables TRUE there). */
- lock_type = TL_WRITE_ALLOW_WRITE;
- }
+ if ((lock_type >= TL_WRITE_CONCURRENT_INSERT
+ && lock_type <= TL_WRITE)
+ && (!thd->in_lock_tables
+ || thd->lex->sql_command == SQLCOM_CALL)
+ && !thd->tablespace_op
+ && thd->lex->sql_command != SQLCOM_TRUNCATE
+ && thd->lex->sql_command != SQLCOM_OPTIMIZE
+ && thd->lex->sql_command != SQLCOM_CREATE_TABLE) {
+
+ lock_type = TL_WRITE_ALLOW_WRITE;
+ }
/* In queries of type INSERT INTO t1 SELECT ... FROM t2 ...
MySQL would use the lock TL_READ_NO_INSERT on t2, and that
would conflict with TL_WRITE_ALLOW_WRITE, blocking all inserts
to t2. Convert the lock to a normal read lock to allow
- concurrent inserts to t2. */
-
+ concurrent inserts to t2.
+
+ We especially allow concurrent inserts if MySQL is at the
+ start of a stored procedure call (SQLCOM_CALL)
+ (MySQL does have thd->in_lock_tables TRUE there). */
+
if (lock_type == TL_READ_NO_INSERT
- && (!thd->in_lock_tables
- || thd->lex->sql_command == SQLCOM_CALL)) {
+ && (!thd->in_lock_tables
+ || thd->lex->sql_command == SQLCOM_CALL)) {
lock_type = TL_READ;
}
-
- lock.type = lock_type;
- }
- *to++= &lock;
+ lock.type = lock_type;
+ }
+
+ *to++= &lock;
return(to);
}
@@ -6956,17 +7008,17 @@
timeout */
longlong* ret) /* out: auto-inc value */
{
- row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- longlong auto_inc;
+ row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
+ longlong auto_inc;
ulint old_select_lock_type;
ibool trx_was_not_started = FALSE;
- int error;
+ int error;
- ut_a(prebuilt);
+ ut_a(prebuilt);
ut_a(prebuilt->trx ==
- (trx_t*) current_thd->ha_data[innobase_hton.slot]);
+ (trx_t*) current_thd->ha_data[innobase_hton.slot]);
ut_a(prebuilt->table);
-
+
if (prebuilt->trx->conc_state == TRX_NOT_STARTED) {
trx_was_not_started = TRUE;
}
@@ -6981,7 +7033,7 @@
if (auto_inc != 0) {
/* Already initialized */
*ret = auto_inc;
-
+
error = 0;
goto func_exit_early;
@@ -6993,21 +7045,21 @@
error = convert_error_code_to_mysql(error, user_thd);
goto func_exit_early;
- }
+ }
/* Check again if someone has initialized the counter meanwhile */
auto_inc = dict_table_autoinc_read(prebuilt->table);
if (auto_inc != 0) {
*ret = auto_inc;
-
+
error = 0;
goto func_exit_early;
}
- (void) extra(HA_EXTRA_KEYREAD);
- index_init(table->s->next_number_index, 1);
+ (void) extra(HA_EXTRA_KEYREAD);
+ index_init(table->s->next_number_index, 1);
/* Starting from 5.0.9, we use a consistent read to read the auto-inc
column maximum value. This eliminates the spurious deadlocks caused
@@ -7016,12 +7068,12 @@
column, our consistent read will not return the largest value. We
accept this flaw, since the deadlocks were a bigger trouble. */
- /* Fetch all the columns in the key */
-
+ /* Fetch all the columns in the key */
+
prebuilt->hint_need_to_fetch_extra_cols = ROW_RETRIEVE_ALL_COLS;
old_select_lock_type = prebuilt->select_lock_type;
- prebuilt->select_lock_type = LOCK_NONE;
+ prebuilt->select_lock_type = LOCK_NONE;
/* Eliminate an InnoDB error print that happens when we try to SELECT
from a table when no table has been locked in ::external_lock(). */
@@ -7030,9 +7082,9 @@
error = index_last(table->record[1]);
prebuilt->trx->n_mysql_tables_in_use--;
- prebuilt->select_lock_type = old_select_lock_type;
+ prebuilt->select_lock_type = old_select_lock_type;
- if (error) {
+ if (error) {
if (error == HA_ERR_END_OF_FILE) {
/* The table was empty, initialize to 1 */
auto_inc = 1;
@@ -7042,25 +7094,25 @@
/* This should not happen in a consistent read */
sql_print_error("Consistent read of auto-inc column "
"returned %lu", (ulong) error);
- auto_inc = -1;
+ auto_inc = -1;
- goto func_exit;
- }
- } else {
+ goto func_exit;
+ }
+ } else {
/* Initialize to max(col) + 1; we use
'found_next_number_field' below because MySQL in SHOW TABLE
STATUS does not seem to set 'next_number_field'. The comment
in table.h says that 'next_number_field' is set when it is
'active'. */
- auto_inc = (longlong) table->found_next_number_field->
- val_int_offset(table->s->rec_buff_length) + 1;
- }
+ auto_inc = (longlong) table->found_next_number_field->
+ val_int_offset(table->s->rec_buff_length) + 1;
+ }
dict_table_autoinc_initialize(prebuilt->table, auto_inc);
func_exit:
- (void) extra(HA_EXTRA_NO_KEYREAD);
+ (void) extra(HA_EXTRA_NO_KEYREAD);
index_end();
@@ -7079,7 +7131,7 @@
innobase_commit_low(prebuilt->trx);
}
- return(error);
+ return(error);
}
/***********************************************************************
@@ -7091,23 +7143,23 @@
ulonglong
ha_innobase::get_auto_increment()
/*=============================*/
- /* out: auto-increment column value, -1 if error
- (deadlock or lock wait timeout) */
+ /* out: auto-increment column value, -1 if error
+ (deadlock or lock wait timeout) */
{
- longlong nr;
- int error;
-
+ longlong nr;
+ int error;
+
error = innobase_read_and_init_auto_inc(&nr);
if (error) {
/* This should never happen in the current (5.0.6) code, since
we call this function only after the counter has been
initialized. */
-
+
ut_print_timestamp(stderr);
sql_print_error("Error %lu in ::get_auto_increment()",
(ulong) error);
- return(~(ulonglong) 0);
+ return(~(ulonglong) 0);
}
return((ulonglong) nr);
@@ -7120,7 +7172,7 @@
DBUG_ENTER("ha_innobase::reset_auto_increment");
row_prebuilt_t* prebuilt = (row_prebuilt_t*) innobase_prebuilt;
- int error;
+ int error;
error = row_lock_table_autoinc_for_mysql(prebuilt);
@@ -7128,7 +7180,7 @@
error = convert_error_code_to_mysql(error, user_thd);
DBUG_RETURN(error);
- }
+ }
dict_table_autoinc_initialize(prebuilt->table, value);
@@ -7139,7 +7191,7 @@
bool
ha_innobase::get_error_message(int error, String *buf)
{
- trx_t* trx = check_trx_exists(current_thd);
+ trx_t* trx = check_trx_exists(current_thd);
buf->copy(trx->detailed_error, strlen(trx->detailed_error),
system_charset_info);
@@ -7169,7 +7221,7 @@
KEY_PART_INFO* key_part_end;
uint len1;
uint len2;
- int result;
+ int result;
if (prebuilt->clust_index_was_generated) {
/* The 'ref' is an InnoDB row id */
@@ -7190,10 +7242,10 @@
mysql_type = field->type();
if (mysql_type == FIELD_TYPE_TINY_BLOB
- || mysql_type == FIELD_TYPE_MEDIUM_BLOB
- || mysql_type == FIELD_TYPE_BLOB
- || mysql_type == FIELD_TYPE_LONG_BLOB) {
-
+ || mysql_type == FIELD_TYPE_MEDIUM_BLOB
+ || mysql_type == FIELD_TYPE_BLOB
+ || mysql_type == FIELD_TYPE_LONG_BLOB) {
+
/* In the MySQL key value format, a column prefix of
a BLOB is preceded by a 2-byte length field */
@@ -7203,8 +7255,8 @@
ref1 += 2;
ref2 += 2;
result = ((Field_blob*)field)->cmp(
- (const char*)ref1, len1,
- (const char*)ref2, len2);
+ (const char*)ref1, len1,
+ (const char*)ref2, len2);
} else {
result = field->key_cmp(ref1, ref2);
}
@@ -7230,10 +7282,10 @@
ulonglong
ha_innobase::get_mysql_bin_log_pos()
{
- /* trx... is ib_longlong, which is a typedef for a 64-bit integer
+ /* trx... is ib_longlong, which is a typedef for a 64-bit integer
(__int64 or longlong) so it's ok to cast it to ulonglong. */
- return(trx_sys_mysql_bin_log_pos);
+ return(trx_sys_mysql_bin_log_pos);
}
extern "C" {
@@ -7255,7 +7307,7 @@
ulint prefix_len, /* in: prefix length in bytes of the index
(this has to be divided by mbmaxlen to get the
number of CHARACTERS n in the prefix) */
- ulint data_len, /* in: length of the string in bytes */
+ ulint data_len, /* in: length of the string in bytes */
const char* str) /* in: character string */
{
ulint char_length; /* character length in bytes */
@@ -7299,7 +7351,7 @@
str + data_len, (int) n_chars);
if (char_length > data_len) {
char_length = data_len;
- }
+ }
} else {
if (data_len < prefix_len) {
char_length = data_len;
@@ -7314,15 +7366,15 @@
extern "C" {
/**********************************************************************
-This function returns true if
+This function returns true if
1) SQL-query in the current thread
-is either REPLACE or LOAD DATA INFILE REPLACE.
+is either REPLACE or LOAD DATA INFILE REPLACE.
2) SQL-query in the current thread
is INSERT ON DUPLICATE KEY UPDATE.
-NOTE that /mysql/innobase/row/row0ins.c must contain the
+NOTE that /mysql/innobase/row/row0ins.c must contain the
prototype for this function ! */
ibool
@@ -7330,19 +7382,19 @@
/*==========================*/
{
THD* thd;
-
+
thd = (THD *)innobase_current_thd();
-
+
if (thd->lex->sql_command == SQLCOM_REPLACE ||
- thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
- (thd->lex->sql_command == SQLCOM_LOAD &&
- thd->lex->duplicates == DUP_REPLACE)) {
+ thd->lex->sql_command == SQLCOM_REPLACE_SELECT ||
+ (thd->lex->sql_command == SQLCOM_LOAD &&
+ thd->lex->duplicates == DUP_REPLACE)) {
return(1);
}
if (thd->lex->sql_command == SQLCOM_INSERT &&
- thd->lex->duplicates == DUP_UPDATE) {
+ thd->lex->duplicates == DUP_UPDATE) {
return(1);
}
@@ -7354,7 +7406,7 @@
/***********************************************************************
This function is used to prepare X/Open XA distributed transaction */
-int
+int
innobase_xa_prepare(
/*================*/
/* out: 0 or error number */
@@ -7364,39 +7416,39 @@
FALSE - the current SQL statement ended */
{
int error = 0;
- trx_t* trx = check_trx_exists(thd);
+ trx_t* trx = check_trx_exists(thd);
- if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
+ if (thd->lex->sql_command != SQLCOM_XA_PREPARE) {
- /* For ibbackup to work the order of transactions in binlog
- and InnoDB must be the same. Consider the situation
+ /* For ibbackup to work the order of transactions in binlog
+ and InnoDB must be the same. Consider the situation
- thread1> prepare; write to binlog; ...
- <context switch>
- thread2> prepare; write to binlog; commit
- thread1> ... commit
-
- To ensure this will not happen we're taking the mutex on
- prepare, and releasing it on commit.
-
- Note: only do it for normal commits, done via ha_commit_trans.
- If 2pc protocol is executed by external transaction
- coordinator, it will be just a regular MySQL client
- executing XA PREPARE and XA COMMIT commands.
- In this case we cannot know how many minutes or hours
- will be between XA PREPARE and XA COMMIT, and we don't want
- to block for undefined period of time.
- */
- pthread_mutex_lock(&prepare_commit_mutex);
- trx->active_trans = 2;
- }
+ thread1> prepare; write to binlog; ...
+ <context switch>
+ thread2> prepare; write to binlog; commit
+ thread1> ... commit
+
+ To ensure this will not happen we're taking the mutex on
+ prepare, and releasing it on commit.
+
+ Note: only do it for normal commits, done via ha_commit_trans.
+ If 2pc protocol is executed by external transaction
+ coordinator, it will be just a regular MySQL client
+ executing XA PREPARE and XA COMMIT commands.
+ In this case we cannot know how many minutes or hours
+ will be between XA PREPARE and XA COMMIT, and we don't want
+ to block for undefined period of time.
+ */
+ pthread_mutex_lock(&prepare_commit_mutex);
+ trx->active_trans = 2;
+ }
if (!thd->variables.innodb_support_xa) {
return(0);
}
- trx->xid=thd->transaction.xid_state.xid;
+ trx->xid=thd->transaction.xid_state.xid;
/* Release a possible FIFO ticket and search latch. Since we will
reserve the kernel mutex, we have to release the search system latch
@@ -7411,16 +7463,16 @@
}
if (all
- || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
+ || (!(thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)))) {
- /* We were instructed to prepare the whole transaction, or
- this is an SQL statement end and autocommit is on */
+ /* We were instructed to prepare the whole transaction, or
+ this is an SQL statement end and autocommit is on */
- ut_ad(trx->active_trans);
+ ut_ad(trx->active_trans);
error = (int) trx_prepare_for_mysql(trx);
} else {
- /* We just mark the SQL statement ended and do not do a
+ /* We just mark the SQL statement ended and do not do a
transaction prepare */
if (trx->auto_inc_lock) {
@@ -7441,18 +7493,18 @@
srv_active_wake_master_thread();
- return error;
+ return error;
}
/***********************************************************************
This function is used to recover X/Open XA distributed transactions */
-int
+int
innobase_xa_recover(
/*================*/
- /* out: number of prepared transactions
+ /* out: number of prepared transactions
stored in xid_list */
- XID* xid_list, /* in/out: prepared transactions */
+ XID* xid_list, /* in/out: prepared transactions */
uint len) /* in: number of slots in xid_list */
{
if (len == 0 || xid_list == NULL) {
@@ -7467,7 +7519,7 @@
This function is used to commit one X/Open XA distributed transaction
which is in the prepared state */
-int
+int
innobase_commit_by_xid(
/*===================*/
/* out: 0 or error number */
@@ -7479,7 +7531,7 @@
if (trx) {
innobase_commit_low(trx);
-
+
return(XA_OK);
} else {
return(XAER_NOTA);
@@ -7490,7 +7542,7 @@
This function is used to rollback one X/Open XA distributed transaction
which is in the prepared state */
-int
+int
innobase_rollback_by_xid(
/*=====================*/
/* out: 0 or error number */
@@ -7510,7 +7562,7 @@
/***********************************************************************
Create a consistent view for a cursor based on current transaction
which is created if the corresponding MySQL thread still lacks one.
-This consistent view is then used inside of MySQL when accessing records
+This consistent view is then used inside of MySQL when accessing records
using a cursor. */
void*
@@ -7524,7 +7576,7 @@
/***********************************************************************
Close the given consistent cursor view of a transaction and restore
-global read view to a transaction read view. Transaction is created if the
+global read view to a transaction read view. Transaction is created if the
corresponding MySQL thread still lacks one. */
void
@@ -7537,8 +7589,8 @@
}
/***********************************************************************
-Set the given consistent cursor view to a transaction which is created
-if the corresponding MySQL thread still lacks one. If the given
+Set the given consistent cursor view to a transaction which is created
+if the corresponding MySQL thread still lacks one. If the given
consistent cursor view is NULL global read view of a transaction is
restored to a transaction read view. */
@@ -7547,27 +7599,33 @@
/*=====================*/
void* curview)/* in: Consistent cursor view to be set */
{
- read_cursor_set_for_mysql(check_trx_exists(current_thd),
+ read_cursor_set_for_mysql(check_trx_exists(current_thd),
(cursor_view_t*) curview);
}
-bool ha_innobase::check_if_incompatible_data(HA_CREATE_INFO *info,
- uint table_changes)
+bool ha_innobase::check_if_incompatible_data(
+ HA_CREATE_INFO* info,
+ uint table_changes)
{
- if (table_changes != IS_EQUAL_YES)
- return COMPATIBLE_DATA_NO;
-
- /* Check that auto_increment value was not changed */
- if ((info->used_fields & HA_CREATE_USED_AUTO) &&
- info->auto_increment_value != 0)
- return COMPATIBLE_DATA_NO;
-
- /* Check that row format didn't change */
- if ((info->used_fields & HA_CREATE_USED_AUTO) &&
- get_row_type() != info->row_type)
- return COMPATIBLE_DATA_NO;
+ if (table_changes != IS_EQUAL_YES) {
- return COMPATIBLE_DATA_YES;
-}
+ return COMPATIBLE_DATA_NO;
+ }
+
+ /* Check that auto_increment value was not changed */
+ if ((info->used_fields & HA_CREATE_USED_AUTO) &&
+ info->auto_increment_value != 0) {
+ return COMPATIBLE_DATA_NO;
+ }
+
+ /* Check that row format didn't change */
+ if ((info->used_fields & HA_CREATE_USED_AUTO) &&
+ get_row_type() != info->row_type) {
+
+ return COMPATIBLE_DATA_NO;
+ }
+
+ return COMPATIBLE_DATA_YES;
+}
| Thread |
|---|
| • bk commit into 5.2 tree (elliot:1.2161) | Elliot Murphy | 16 Mar |