mariadb/mysql-test/suite/sys_vars/t/concurrent_insert_func.test
Michael Widenius e63b5546c5 Implementation of MWL#172: Add support for prepared statements to HANDLER READ
It includes speed optimizations for HANDLER READ by caching as much as possible in HANDLER OPEN
Other things:
- Added mysqld option --disable-thr-alarm to be able to benchmark things without thr_alarm
- Changed 'Locked' state to 'System lock' and 'Table lock' (these where used in the code but never shown to end user)
- Better error message if mysql_install_db.sh fails
- Moved handler function prototypes to sql_handler.h
- Remove not anymore used 'thd->locked' member


include/thr_alarm.h:
  Added my_disable_thr_alarm
include/thr_lock.h:
  Add new member to THR_LOCK_DATA to remember original lock type state. This is needed as thr_unlock() resets type to TL_UNLOCK.
mysql-test/include/check_no_concurrent_insert.inc:
  Locked -> Table lock
mysql-test/include/handler.inc:
  Locked -> Table lock
mysql-test/r/handler_innodb.result:
  Updated results for new tests
mysql-test/r/handler_myisam.result:
  Updated results for new tests
mysql-test/r/sp-threads.result:
  Locked -> Table lock
mysql-test/suite/binlog/t/binlog_stm_row.test:
  Locked -> Table lock
mysql-test/suite/funcs_1/datadict/processlist_val.inc:
  Locked -> Table lock
mysql-test/suite/pbxt/t/lock_multi.test:
  Locked -> Table lock
mysql-test/suite/sys_vars/r/concurrent_insert_func.result:
  Locked -> Table lock
mysql-test/suite/sys_vars/t/concurrent_insert_func.test:
  Locked -> Table lock
mysql-test/suite/sys_vars/t/delayed_insert_limit_func.test:
  Locked -> Table lock
mysql-test/suite/sys_vars/t/query_cache_wlock_invalidate_func.test:
  Locked -> Table lock
mysql-test/suite/sys_vars/t/sql_low_priority_updates_func.test:
  Locked -> Table lock
mysql-test/t/insert_notembedded.test:
  Locked -> Table lock
mysql-test/t/lock_multi.test:
  Locked -> Table lock
mysql-test/t/merge-big.test:
  Locked -> Table lock
mysql-test/t/multi_update.test:
  Locked -> Table lock
mysql-test/t/query_cache_28249.test:
  Locked -> Table lock
mysql-test/t/sp_notembedded.test:
  Locked -> Table lock
mysql-test/t/sp_sync.test:
  Locked -> Table lock
mysql-test/t/status.test:
  Locked -> Table lock
mysql-test/t/trigger_notembedded.test:
  Locked -> Table lock
mysys/thr_alarm.c:
  Added option to disable thr_alarm
mysys/thr_lock.c:
  Detect loops
scripts/mysql_install_db.sh:
  Give better error message if something goes wrong
sql/Makefile.am:
  Added sql_handler.h
sql/lock.cc:
  Split functions to allow one to cache value if store_lock() (for HANDLER functions).
  - Split mysql_lock_tables() into two functions, where first one allocates MYSQL_LOCK and other other one uses it.
  - Made get_lock_data() an external function.
  - Added argument to mysql_unlock_tables() to not free sql_lock.
  - Added argument to reset_lock_data() to reset lock structure to initial state (as after get_lock_data())
sql/mysql_priv.h:
  Moved handler function prototypes to sql_handler.h
  Added new lock functions.
sql/mysqld.cc:
  Added --thread-alarm startup option
sql/net_serv.cc:
  Don't call vio_blocking() if not needed
sql/sql_base.cc:
  include sql_handler.h
sql/sql_class.cc:
  include sql_handler.h
  Remove not anymore used 'thd->locked' member
sql/sql_class.h:
  Remove not anymore used 'thd->locked' member
sql/sql_db.cc:
  include sql_handler.h
sql/sql_delete.cc:
  include sql_handler.h
sql/sql_handler.cc:
  Rewrote all code to use SQL_HANDLER instead of TABLE_LIST (original interface)
  Rewrote mysql_ha_open() to cache all things from TABLE_LIST and items for field list, where etc.
  In mysql_ha_open() also cache MYSQL_LOCK structure from get_lock_data().
  Split functions into smaller sub functions (needed to be able to implement mysql_ha_read_prepare())
  Added mysql_ha_read_prepare() to allow one to prepare HANDLER READ.
sql/sql_handler.h:
  Interface to sql_handler.cc
sql/sql_parse.cc:
  include sql_handler.h
sql/sql_prepare.cc:
  Added mysql_test_handler_read(), prepare for HANDLER READ
sql/sql_rename.cc:
  include sql_handler.h
sql/sql_show.cc:
  Removed usage of thd->locked
sql/sql_table.cc:
  include sql_handler.h
sql/sql_trigger.cc:
  include sql_handler.h
2011-01-04 00:55:41 +02:00

168 lines
6.2 KiB
Text

############## mysql-test\t\concurrent_insert_basic.test #######################
# #
# Variable Name: concurrent_insert #
# Scope: GLOBAL #
# Access Type: Dynamic #
# Data Type: Boolean & Numeric #
# Default Value: 1 #
# Valid Values: 0,1 & 2 #
# #
# #
# Creation Date: 2008-03-07 #
# Author: Salman Rawala #
# #
# Modified: HHunger 2009-02-23 Inserted a wait condition right after the #
# "INSERT ..record_6" to wait for the end of #
# the insert. #
# mleich This test needs some inporovements #
# #
# Description: Test Cases of Dynamic System Variable "concurrent_insert" #
# that checks functionality of this variable #
# #
# Reference: #
# http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html #
# #
################################################################################
--source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
#########################
# Creating new table #
#########################
--echo ## Creating new table ##
CREATE TABLE t1
(
name VARCHAR(30)
);
--echo '#--------------------FN_DYNVARS_018_01-------------------------#'
####################################################################
# Setting initial value of concurrent_insert to 1
# concurrent_insert = 1 means Enables concurrent insert
# for MyISAM tables that don't have holes
####################################################################
SET @start_value= @@global.concurrent_insert;
--echo ## Setting initial value of variable to 1 ##
SET @@global.concurrent_insert = 1;
INSERT INTO t1(name) VALUES('Record_1');
INSERT INTO t1(name) VALUES('Record_2');
INSERT INTO t1(name) VALUES('Record_3');
--echo ## locking table ##
LOCK TABLE t1 READ LOCAL;
--echo ## Creating new connection to insert some rows in table ##
connect (test_con1,localhost,root,,);
--echo connection test_con1;
connection test_con1;
--echo ## New records should come at the end of all rows ##
INSERT INTO t1(name) VALUES('Record_4');
SELECT * FROM t1;
--echo ## unlocking tables ##
--echo connection default;
connection default;
UNLOCK TABLES;
--echo ## deleting record to create hole in table ##
DELETE FROM t1 WHERE name ='Record_2';
--echo '#--------------------FN_DYNVARS_018_02-------------------------#'
####################################################################
# Setting initial value of concurrent_insert to 1
# concurrent_insert = 1 and trying to insert some values
# in MyISAM tables that have holes
####################################################################
# lock table and connect with connection1
LOCK TABLE t1 READ LOCAL;
--echo connection test_con1;
connection test_con1;
# setting value of concurrent_insert to 1
SET @@global.concurrent_insert=1;
--echo ## send INSERT which should be blocked until unlock of the table ##
send
INSERT INTO t1(name) VALUES('Record_7');
--echo connection default;
connection default;
# wait until INSERT will be locked (low performance)
let $wait_condition= SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Table Lock" AND info LIKE "INSERT INTO t1%";
--source include/wait_condition.inc
--echo ## show processlist info and state ##
SELECT state,info FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE state= "Table Lock" AND info LIKE "INSERT INTO t1%";
--echo ## table contents befor UNLOCK ##
SELECT * FROM t1;
UNLOCK TABLES;
--echo ## table contens after UNLOCK ##
SELECT * FROM t1;
INSERT INTO t1(name) VALUES('Record_6');
let $wait_condition= SELECT COUNT(*) = 5 FROM t1;
--source include/wait_condition.inc
--echo connection test_con1;
connection test_con1;
# to complete the send above^
reap;
SELECT * FROM t1;
--echo connection default;
connection default;
--echo '#--------------------FN_DYNVARS_018_03-------------------------#'
################################################################################
# Setting value of concurrent_insert to 2 to verify values after inserting
# it into table with holes
# concurrent_insert = 2 means Enables concurrent insert
# for MyISAM tables that have holes but inserts values at the end of all rows
################################################################################
--echo ## lock table and connect with connection1 ##
LOCK TABLE t1 READ LOCAL;
--echo connection test_con1;
connection test_con1;
--echo ## setting value of concurrent_insert to 2 ##
SET @@global.concurrent_insert=2;
--echo ## Inserting record in table, record should go at the end of the table ##
INSERT INTO t1(name) VALUES('Record_5');
SELECT * FROM t1;
SELECT @@concurrent_insert;
--echo connection default;
connection default;
--echo ## Unlocking table ##
UNLOCK TABLES;
SELECT * FROM t1;
--echo ## Inserting new row, this should go in the hole ##
INSERT INTO t1(name) VALUES('Record_6');
SELECT * FROM t1;
--echo ## connection test_con1 ##
DELETE FROM t1 WHERE name ='Record_3';
SELECT * FROM t1;
--echo ## Dropping table ##
DROP TABLE t1;
--echo ## Disconnecting connection ##
disconnect test_con1;
SET @@global.concurrent_insert= @start_value;