summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mysql.com>2004-10-20 11:25:46 +0300
committerunknown <monty@mysql.com>2004-10-20 11:25:46 +0300
commit95f0e39a38435e0451e77c919ce21697eaccd334 (patch)
treec21f43f19b7e410011d90316a1266b6e5fd80efb
parent0e0c9af593367797d844058bfff0534b53c7fe12 (diff)
parented8ec2cf1613e1bb57705698b8962e767fd89320 (diff)
downloadmariadb-git-95f0e39a38435e0451e77c919ce21697eaccd334.tar.gz
Merge bk-internal.mysql.com:/home/bk/mysql-4.0
into mysql.com:/home/my/mysql-4.0 libmysql/libmysql.c: Auto merged
-rw-r--r--libmysql/libmysql.c10
-rw-r--r--myisam/myisampack.c12
-rw-r--r--mysql-test/r/innodb-lock.result26
-rw-r--r--mysql-test/t/innodb-lock.test46
-rw-r--r--sql/ha_innodb.cc2
-rw-r--r--sql/mysqld.cc10
-rw-r--r--sql/set_var.cc8
-rw-r--r--sql/sql_class.h2
8 files changed, 91 insertions, 25 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 73f8f8f8b0b..2250111f5a0 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3173,20 +3173,18 @@ void my_net_local_init(NET *net)
trailing '. The caller must supply whichever of those is desired.
*/
-unsigned long
-mysql_hex_string(char *to, const char *from, unsigned long length)
+ulong mysql_hex_string(char *to, const char *from, ulong length)
{
char *to0= to;
const char *end;
- static char hex[]= "0123456789ABCDEF";
for (end= from + length; from < end; from++)
{
- *to++= hex[((unsigned char) *from) >> 4];
- *to++= hex[((unsigned char) *from) & 0x0F];
+ *to++= _dig_vec[((unsigned char) *from) >> 4];
+ *to++= _dig_vec[((unsigned char) *from) & 0x0F];
}
*to= '\0';
- return to-to0;
+ return (ulong) (to-to0);
}
/*
diff --git a/myisam/myisampack.c b/myisam/myisampack.c
index 5efd6b3a7fd..0dde1916f03 100644
--- a/myisam/myisampack.c
+++ b/myisam/myisampack.c
@@ -418,14 +418,12 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count)
mrg->src_file_has_indexes_disabled= 0;
for (i=0; i < count ; i++)
{
- if ((mrg->file[i]=open_isam_file(names[i],O_RDONLY)))
- {
- mrg->src_file_has_indexes_disabled |=
- (mrg->file[i]->s->state.key_map !=
- (1ULL << mrg->file[i]->s->base.keys) - 1);
- }
- else
+ if (!(mrg->file[i]=open_isam_file(names[i],O_RDONLY)))
goto error;
+
+ mrg->src_file_has_indexes_disabled|= ((mrg->file[i]->s->state.key_map !=
+ (((ulonglong) 1) <<
+ mrg->file[i]->s->base. keys) - 1));
}
/* Check that files are identical */
for (j=0 ; j < count-1 ; j++)
diff --git a/mysql-test/r/innodb-lock.result b/mysql-test/r/innodb-lock.result
index cf00adb30ae..f87f221ea66 100644
--- a/mysql-test/r/innodb-lock.result
+++ b/mysql-test/r/innodb-lock.result
@@ -1,4 +1,30 @@
drop table if exists t1;
+select @@innodb_table_locks;
+@@innodb_table_locks
+0
+set @@innodb_table_locks=1;
+create table t1 (id integer, x integer) engine=INNODB;
+insert into t1 values(0, 0);
+set autocommit=0;
+SELECT * from t1 where id = 0 FOR UPDATE;
+id x
+0 0
+set autocommit=0;
+lock table t1 write;
+update t1 set x=1 where id = 0;
+select * from t1;
+id x
+0 1
+commit;
+update t1 set x=2 where id = 0;
+commit;
+unlock tables;
+select * from t1;
+id x
+0 2
+commit;
+drop table t1;
+set @@innodb_table_locks=0;
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
set autocommit=0;
diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test
index 43a175508b4..11395b301c4 100644
--- a/mysql-test/t/innodb-lock.test
+++ b/mysql-test/t/innodb-lock.test
@@ -5,10 +5,54 @@ connect (con2,localhost,root,,);
drop table if exists t1;
#
-# Testing of explicit table locks
+# Check and select innodb lock type
#
+select @@innodb_table_locks;
+
+#
+# Testing of explicit table locks with enforced table locks
+#
+
+set @@innodb_table_locks=1;
+
+connection con1;
+create table t1 (id integer, x integer) engine=INNODB;
+insert into t1 values(0, 0);
+set autocommit=0;
+SELECT * from t1 where id = 0 FOR UPDATE;
+
+connection con2;
+set autocommit=0;
+
+# The following statement should hang because con1 is locking the page
+--send
+lock table t1 write;
+--sleep 2;
+
connection con1;
+update t1 set x=1 where id = 0;
+select * from t1;
+commit;
+
+connection con2;
+reap;
+update t1 set x=2 where id = 0;
+commit;
+unlock tables;
+
+connection con1;
+select * from t1;
+commit;
+
+drop table t1;
+
+#
+# Try with old lock method (where LOCK TABLE is ignored)
+#
+
+set @@innodb_table_locks=0;
+
create table t1 (id integer, x integer) engine=INNODB;
insert into t1 values(0, 0);
set autocommit=0;
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 44d050d14aa..e747ff3210c 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -4694,7 +4694,7 @@ ha_innobase::external_lock(
if (prebuilt->select_lock_type != LOCK_NONE) {
if (thd->in_lock_tables &&
- !thd->variables.innodb_table_locks_old_behavior) {
+ thd->variables.innodb_table_locks) {
ulint error;
error = row_lock_table_for_mysql(prebuilt);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 226d4c113a5..b7eafcbcc14 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3526,7 +3526,7 @@ enum options_mysqld {
OPT_INNODB_FORCE_RECOVERY,
OPT_INNODB_STATUS_FILE,
OPT_INNODB_MAX_DIRTY_PAGES_PCT,
- OPT_INNODB_TABLE_LOCKS_OLD_BEHAVIOR,
+ OPT_INNODB_TABLE_LOCKS,
OPT_BDB_CACHE_SIZE,
OPT_BDB_LOG_BUFFER_SIZE,
OPT_BDB_MAX_LOCK,
@@ -3700,10 +3700,10 @@ struct my_option my_long_options[] =
{"innodb_max_dirty_pages_pct", OPT_INNODB_MAX_DIRTY_PAGES_PCT,
"Percentage of dirty pages allowed in bufferpool", (gptr*) &srv_max_buf_pool_modified_pct,
(gptr*) &srv_max_buf_pool_modified_pct, 0, GET_ULONG, REQUIRED_ARG, 90, 0, 100, 0, 0, 0},
- {"innodb_table_locks_old_behavior", OPT_INNODB_TABLE_LOCKS_OLD_BEHAVIOR,
- "Disable InnoDB locking in LOCK TABLES",
- (gptr*) &global_system_variables.innodb_table_locks_old_behavior,
- (gptr*) &global_system_variables.innodb_table_locks_old_behavior,
+ {"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, 0, 0, 0, 0, 0, 0},
#endif /* End HAVE_INNOBASE_DB */
{"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 9b2db7a0802..a6a5ea72c71 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -263,8 +263,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_old_behavior("innodb_table_locks_old_behavior",
- &SV::innodb_table_locks_old_behavior);
+sys_var_thd_bool sys_innodb_table_locks("innodb_table_locks",
+ &SV::innodb_table_locks);
#endif
@@ -451,7 +451,7 @@ sys_var *sys_variables[]=
&sys_os,
#ifdef HAVE_INNOBASE_DB
&sys_innodb_max_dirty_pages_pct,
- &sys_innodb_table_locks_old_behavior,
+ &sys_innodb_table_locks,
#endif
&sys_unique_checks
};
@@ -523,7 +523,7 @@ struct show_var_st init_vars[]= {
{"innodb_log_group_home_dir", (char*) &innobase_log_group_home_dir, SHOW_CHAR_PTR},
{"innodb_mirrored_log_groups", (char*) &innobase_mirrored_log_groups, SHOW_LONG},
{sys_innodb_max_dirty_pages_pct.name, (char*) &sys_innodb_max_dirty_pages_pct, SHOW_SYS},
- {sys_innodb_table_locks_old_behavior.name, (char*) &sys_innodb_table_locks_old_behavior, SHOW_SYS},
+ {sys_innodb_table_locks.name, (char*) &sys_innodb_table_locks, SHOW_SYS},
#endif
{sys_interactive_timeout.name,(char*) &sys_interactive_timeout, SHOW_SYS},
{sys_join_buffer_size.name, (char*) &sys_join_buffer_size, SHOW_SYS},
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 8c383d5848d..4250ebdd568 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -339,7 +339,7 @@ struct system_variables
my_bool new_mode;
my_bool query_cache_wlock_invalidate;
#ifdef HAVE_INNOBASE_DB
- my_bool innodb_table_locks_old_behavior;
+ my_bool innodb_table_locks;
#endif /* HAVE_INNOBASE_DB */
CONVERT *convert_set;