summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authormonty@mysql.com <>2004-10-20 16:24:28 +0300
committermonty@mysql.com <>2004-10-20 16:24:28 +0300
commite1218474b87e1c28f080207558966fac6f4eb292 (patch)
treef3f6e81dac72352598beb9c21f116d2ef7f9c3ef /sql
parentf9cd4a60e466a211024e5efb6840b79a3066f3c8 (diff)
parentb32ffec8fdc9d05377e69c8b1abb92d562670324 (diff)
downloadmariadb-git-e1218474b87e1c28f080207558966fac6f4eb292.tar.gz
Merge with 4.0
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_innodb.cc5
-rw-r--r--sql/ha_myisam.cc18
-rw-r--r--sql/lock.cc10
-rw-r--r--sql/mysqld.cc8
-rw-r--r--sql/set_var.cc4
-rw-r--r--sql/sql_base.cc2
-rw-r--r--sql/sql_class.h3
7 files changed, 43 insertions, 7 deletions
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 133ea3c9c7c..04a1c6a9014 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -302,7 +302,7 @@ convert_error_code_to_mysql(
} else if (error == (int) DB_CANNOT_DROP_CONSTRAINT) {
- return(HA_ERR_CANNOT_ADD_FOREIGN); /* 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) {
@@ -4958,7 +4958,8 @@ ha_innobase::external_lock(
}
if (prebuilt->select_lock_type != LOCK_NONE) {
- if (thd->in_lock_tables) {
+ if (thd->in_lock_tables &&
+ thd->variables.innodb_table_locks) {
ulint error;
error = row_lock_table_for_mysql(prebuilt);
diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc
index 0b993ebe793..6504dd321a0 100644
--- a/sql/ha_myisam.cc
+++ b/sql/ha_myisam.cc
@@ -537,6 +537,7 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
{
+ int error;
if (!file) return HA_ADMIN_INTERNAL_ERROR;
MI_CHECK param;
@@ -546,7 +547,14 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
param.testflag = (check_opt->flags | T_SILENT | T_FORCE_CREATE |
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
param.sort_buffer_length= check_opt->sort_buffer_size;
- return repair(thd,param,1);
+ if ((error= repair(thd,param,1)) && param.retry_repair)
+ {
+ sql_print_warning("Warning: Optimize table got errno %d, retrying",
+ my_errno);
+ param.testflag&= ~T_REP_BY_SORT;
+ error= repair(thd,param,1);
+ }
+ return error;
}
@@ -913,7 +921,13 @@ int ha_myisam::enable_indexes(uint mode)
param.myf_rw&= ~MY_WAIT_IF_FULL;
param.sort_buffer_length= thd->variables.myisam_sort_buff_size;
param.tmpdir=&mysql_tmpdir_list;
- error=repair(thd,param,0) != HA_ADMIN_OK;
+ if ((error= (repair(thd,param,0) != HA_ADMIN_OK)) && param.retry_repair)
+ {
+ sql_print_warning("Warning: Enabling keys got errno %d, retrying",
+ my_errno);
+ param.testflag&= ~(T_REP_BY_SORT | T_QUICK);
+ error= (repair(thd,param,0) != HA_ADMIN_OK);
+ }
info(HA_STATUS_CONST);
thd->proc_info=save_proc_info;
}
diff --git a/sql/lock.cc b/sql/lock.cc
index 215059b8a46..646babea6a1 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -792,9 +792,15 @@ bool wait_if_global_read_lock(THD *thd, bool abort_on_refresh,
{
if (thd->global_read_lock) // This thread had the read locks
{
- my_error(ER_CANT_UPDATE_WITH_READLOCK,MYF(0));
+ if (is_not_commit)
+ my_error(ER_CANT_UPDATE_WITH_READLOCK,MYF(0));
(void) pthread_mutex_unlock(&LOCK_open);
- DBUG_RETURN(1);
+ /*
+ We allow FLUSHer to COMMIT; we assume FLUSHer knows what it does.
+ This allowance is needed to not break existing versions of innobackup
+ which do a BEGIN; INSERT; FLUSH TABLES WITH READ LOCK; COMMIT.
+ */
+ DBUG_RETURN(is_not_commit);
}
old_message=thd->enter_cond(&COND_refresh, &LOCK_open,
"Waiting for release of readlock");
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 878b7bf7e92..384f76029f9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4012,6 +4012,7 @@ enum options_mysqld
OPT_INNODB_FORCE_RECOVERY,
OPT_INNODB_STATUS_FILE,
OPT_INNODB_MAX_DIRTY_PAGES_PCT,
+ OPT_INNODB_TABLE_LOCKS,
OPT_INNODB_OPEN_FILES,
OPT_INNODB_AUTOEXTEND_INCREMENT,
OPT_BDB_CACHE_SIZE,
@@ -4250,6 +4251,11 @@ Disable with --skip-innodb (will save memory).",
"Enable SHOW INNODB STATUS output in the innodb_status.<pid> file",
(gptr*) &innobase_create_status_file, (gptr*) &innobase_create_status_file,
0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0},
+ {"innodb_table_locks", OPT_INNODB_TABLE_LOCKS,
+ "If Innodb should enforce LOCK TABLE",
+ (gptr*) &global_system_variables.innodb_table_locks,
+ (gptr*) &global_system_variables.innodb_table_locks,
+ 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},
#endif /* End HAVE_INNOBASE_DB */
{"isam", OPT_ISAM, "Enable ISAM (if this version of MySQL supports it). \
Disable with --skip-isam.",
@@ -4812,7 +4818,7 @@ replicating a LOAD DATA INFILE command.",
(gptr*) &dflt_key_cache_var.param_buff_size,
(gptr*) 0,
0, (GET_ULL | GET_ASK_ADDR),
- REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, (long) ~0, MALLOC_OVERHEAD,
+ REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, UINT_MAX32, MALLOC_OVERHEAD,
IO_SIZE, 0},
{"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD,
"This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache",
diff --git a/sql/set_var.cc b/sql/set_var.cc
index d661470576b..b5e479b9985 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -351,6 +351,8 @@ sys_var_thd_ulong sys_net_wait_timeout("wait_timeout",
#ifdef HAVE_INNOBASE_DB
sys_var_long_ptr sys_innodb_max_dirty_pages_pct("innodb_max_dirty_pages_pct",
&srv_max_buf_pool_modified_pct);
+sys_var_thd_bool sys_innodb_table_locks("innodb_table_locks",
+ &SV::innodb_table_locks);
sys_var_long_ptr sys_innodb_autoextend_increment("innodb_autoextend_increment",
&srv_auto_extend_increment);
sys_var_long_ptr sys_innodb_max_purge_lag("innodb_max_purge_lag",
@@ -605,6 +607,7 @@ sys_var *sys_variables[]=
&sys_os,
#ifdef HAVE_INNOBASE_DB
&sys_innodb_max_dirty_pages_pct,
+ &sys_innodb_table_locks,
&sys_innodb_max_purge_lag,
&sys_innodb_autoextend_increment,
#endif
@@ -700,6 +703,7 @@ struct show_var_st init_vars[]= {
{"innodb_log_files_in_group", (char*) &innobase_log_files_in_group, SHOW_LONG},
{"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
{sys_innodb_max_dirty_pages_pct.name, (char*) &sys_innodb_max_dirty_pages_pct, SHOW_SYS},
+ {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
{sys_innodb_max_purge_lag.name, (char*) &sys_innodb_max_purge_lag, SHOW_SYS},
{"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG},
{"innodb_open_files", (char*) &innobase_open_files, SHOW_LONG },
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 55e6a75b4b4..2fc0aa62f19 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -818,6 +818,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
table->query_id=thd->query_id;
table->clear_query_id=1;
thd->tmp_table_used= 1;
+ DBUG_PRINT("info",("Using temporary table"));
goto reset;
}
}
@@ -832,6 +833,7 @@ TABLE *open_table(THD *thd,const char *db,const char *table_name,
table->query_id != thd->query_id)
{
table->query_id=thd->query_id;
+ DBUG_PRINT("info",("Using locked table"));
goto reset;
}
}
diff --git a/sql/sql_class.h b/sql/sql_class.h
index aea31f7db54..c30e1c321b0 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -396,6 +396,9 @@ struct system_variables
my_bool low_priority_updates;
my_bool new_mode;
my_bool query_cache_wlock_invalidate;
+#ifdef HAVE_INNOBASE_DB
+ my_bool innodb_table_locks;
+#endif /* HAVE_INNOBASE_DB */
my_bool old_passwords;
/* Only charset part of these variables is sensible */