Commit 81cdce4d authored by Marc Alff's avatar Marc Alff

local merge

parents 6d59a131 3509fecf
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
--source include/not_windows.inc --source include/not_windows.inc
--source include/not_embedded.inc --source include/not_embedded.inc
if ($MYSQLHOTCOPY) if (!$MYSQLHOTCOPY)
{ {
die due to missing mysqlhotcopy tool; die due to missing mysqlhotcopy tool;
} }
......
...@@ -2155,10 +2155,12 @@ sub environment_setup { ...@@ -2155,10 +2155,12 @@ sub environment_setup {
# mysqlhotcopy # mysqlhotcopy
# ---------------------------------------------------- # ----------------------------------------------------
my $mysqlhotcopy= my $mysqlhotcopy=
mtr_pl_maybe_exists("$bindir/scripts/mysqlhotcopy"); mtr_pl_maybe_exists("$bindir/scripts/mysqlhotcopy") ||
# Since mysqltest interprets the real path as "false" in an if, mtr_pl_maybe_exists("$path_client_bindir/mysqlhotcopy");
# use 1 ("true") to indicate "not exists" so it can be tested for if ($mysqlhotcopy)
$ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy || 1; {
$ENV{'MYSQLHOTCOPY'}= $mysqlhotcopy;
}
# ---------------------------------------------------- # ----------------------------------------------------
# perror # perror
......
...@@ -1114,5 +1114,18 @@ format(123,2,'no_NO') ...@@ -1114,5 +1114,18 @@ format(123,2,'no_NO')
123,00 123,00
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#42511 mysqld: ctype-ucs2.c:2044: my_strnncollsp_utf32: Assertion (tlen % 4) == 0' faied
#
CREATE TABLE t1 (
b char(250) CHARACTER SET utf32,
key (b)
) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('d'),('f');
SELECT * FROM t1 WHERE b BETWEEN 'a' AND 'z';
b
d
f
DROP TABLE t1;
#
# End of 5.5 tests # End of 5.5 tests
# #
...@@ -348,6 +348,8 @@ DROP TABLE t1; ...@@ -348,6 +348,8 @@ DROP TABLE t1;
# #
# Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
# #
# This test is not supposed to work under --ps-protocol since
# INSERT DELAYED doesn't work under LOCK TABLES with this protocol.
DROP TABLE IF EXISTS t1, t2; DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT); CREATE TABLE t1 (a INT);
CREATE TABLE t2 (a INT); CREATE TABLE t2 (a INT);
......
...@@ -1715,7 +1715,7 @@ drop table t1; ...@@ -1715,7 +1715,7 @@ drop table t1;
# #
End of 5.1 tests End of 5.1 tests
# #
# Bug#55648: Server crash on MIX/MAX on maximum time value # Bug#55648: Server crash on MIN/MAX on maximum time value
# #
CREATE TABLE t1(c1 TIME NOT NULL); CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('837:59:59'); INSERT INTO t1 VALUES('837:59:59');
...@@ -1725,3 +1725,13 @@ MAX(c1) ...@@ -1725,3 +1725,13 @@ MAX(c1)
838:59:59 838:59:59
DROP TABLE t1; DROP TABLE t1;
# End of the bug#55648 # End of the bug#55648
#
# Bug#56120: Failed assertion on MIN/MAX on negative time value
#
CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('-00:00:01');
SELECT MAX(c1),MIN(c1) FROM t1;
MAX(c1) MIN(c1)
-00:00:01 -00:00:01
DROP TABLE t1;
# End of the bug#56120
...@@ -44,7 +44,7 @@ a abmon mon ...@@ -44,7 +44,7 @@ a abmon mon
2006-12-01 Δεκ Δεκέμβριος 2006-12-01 Δεκ Δεκέμβριος
SELECT format(123456.789, 3, 'el_GR'); SELECT format(123456.789, 3, 'el_GR');
format(123456.789, 3, 'el_GR') format(123456.789, 3, 'el_GR')
123456.789 123456,789
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#46633 Obsolete Serbian locale name # Bug#46633 Obsolete Serbian locale name
......
...@@ -432,8 +432,5 @@ Bug #47147: mysql client option --skip-column-names does not apply to vertical o ...@@ -432,8 +432,5 @@ Bug #47147: mysql client option --skip-column-names does not apply to vertical o
*************************** 1. row *************************** *************************** 1. row ***************************
1 1
Bug #54466 client 5.5 built from source lacks "pager" support
a
1
End of tests End of tests
Bug #54466 client 5.5 built from source lacks "pager" support
a
1
End of tests
This diff is collapsed.
...@@ -193,4 +193,4 @@ mysqld-bin.000001 # Table_map 2 # table_id: # (mysql.ndb_apply_status) ...@@ -193,4 +193,4 @@ mysqld-bin.000001 # Table_map 2 # table_id: # (mysql.ndb_apply_status)
mysqld-bin.000001 # Write_rows 2 # table_id: # mysqld-bin.000001 # Write_rows 2 # table_id: #
mysqld-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F mysqld-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Query 2 # COMMIT mysqld-bin.000001 # Query 2 # COMMIT
mysqld-bin.000001 # Query 2 # use `test`; drop table t2 mysqld-bin.000001 # Query 2 # use `test`; DROP TABLE `t2` /* generated by server */
...@@ -7,5 +7,5 @@ create table t1 (a int primary key, b int) engine=ndb; ...@@ -7,5 +7,5 @@ create table t1 (a int primary key, b int) engine=ndb;
insert into t1 values (1, 1); insert into t1 values (1, 1);
show binlog events from <binlog_start>; show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
mysqld-bin.000001 # Query 1 # use `test`; drop table if exists t1 mysqld-bin.000001 # Query 1 # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */
drop database mysqltest; drop database mysqltest;
...@@ -47,8 +47,8 @@ mysqld-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) ...@@ -47,8 +47,8 @@ mysqld-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status)
mysqld-bin.000001 # Write_rows 1 # table_id: # mysqld-bin.000001 # Write_rows 1 # table_id: #
mysqld-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F mysqld-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Query 1 # COMMIT mysqld-bin.000001 # Query 1 # COMMIT
mysqld-bin.000001 # Query 1 # use `mysqltest`; drop table t1 mysqld-bin.000001 # Query 1 # use `mysqltest`; DROP TABLE `t1` /* generated by server */
mysqld-bin.000001 # Query 1 # use `mysqltest`; drop table t2 mysqld-bin.000001 # Query 1 # use `mysqltest`; DROP TABLE `t2` /* generated by server */
mysqld-bin.000001 # Query 1 # use `mysqltest`; create table t1 (d int key, e int) engine=ndb mysqld-bin.000001 # Query 1 # use `mysqltest`; create table t1 (d int key, e int) engine=ndb
mysqld-bin.000001 # Query 1 # use `mysqltest`; create table t2 (d int key, e int) engine=ndb mysqld-bin.000001 # Query 1 # use `mysqltest`; create table t2 (d int key, e int) engine=ndb
mysqld-bin.000001 # Query 1 # BEGIN mysqld-bin.000001 # Query 1 # BEGIN
......
...@@ -37,7 +37,7 @@ mysqld-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status) ...@@ -37,7 +37,7 @@ mysqld-bin.000001 # Table_map 1 # table_id: # (mysql.ndb_apply_status)
mysqld-bin.000001 # Write_rows 1 # table_id: # mysqld-bin.000001 # Write_rows 1 # table_id: #
mysqld-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F mysqld-bin.000001 # Write_rows 1 # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Query 1 # COMMIT mysqld-bin.000001 # Query 1 # COMMIT
mysqld-bin.000001 # Query 1 # use `test`; DROP TABLE t2 mysqld-bin.000001 # Query 1 # use `test`; DROP TABLE `t2` /* generated by server */
SELECT inserts,updates,deletes,schemaops FROM SELECT inserts,updates,deletes,schemaops FROM
mysql.ndb_binlog_index WHERE epoch=<the_epoch>; mysql.ndb_binlog_index WHERE epoch=<the_epoch>;
inserts updates deletes schemaops inserts updates deletes schemaops
...@@ -73,7 +73,7 @@ mysqld-bin.000001 # Table_map 2 # table_id: # (mysql.ndb_apply_status) ...@@ -73,7 +73,7 @@ mysqld-bin.000001 # Table_map 2 # table_id: # (mysql.ndb_apply_status)
mysqld-bin.000001 # Write_rows 2 # table_id: # mysqld-bin.000001 # Write_rows 2 # table_id: #
mysqld-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F mysqld-bin.000001 # Write_rows 2 # table_id: # flags: STMT_END_F
mysqld-bin.000001 # Query 2 # COMMIT mysqld-bin.000001 # Query 2 # COMMIT
mysqld-bin.000001 # Query 2 # use `test`; drop table t1 mysqld-bin.000001 # Query 2 # use `test`; DROP TABLE `t1` /* generated by server */
SELECT inserts,updates,deletes,schemaops FROM SELECT inserts,updates,deletes,schemaops FROM
mysql.ndb_binlog_index WHERE epoch > <the_epoch> AND epoch <= <the_epoch2>; mysql.ndb_binlog_index WHERE epoch > <the_epoch> AND epoch <= <the_epoch2>;
inserts updates deletes schemaops inserts updates deletes schemaops
......
...@@ -25,7 +25,7 @@ master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) ...@@ -25,7 +25,7 @@ master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
master-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=NDB master-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=NDB
master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t1)
...@@ -204,7 +204,7 @@ master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) ...@@ -204,7 +204,7 @@ master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; drop table t1 master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
master-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=NDB master-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=NDB
master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t1)
...@@ -240,7 +240,7 @@ slave-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) ...@@ -240,7 +240,7 @@ slave-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
slave-bin.000001 # Write_rows # # table_id: # slave-bin.000001 # Write_rows # # table_id: #
slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F slave-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
slave-bin.000001 # Query # # COMMIT slave-bin.000001 # Query # # COMMIT
slave-bin.000001 # Query # # use `test`; drop table t1 slave-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
slave-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=NDB slave-bin.000001 # Query # # use `test`; create table t1 (word char(20) not null)ENGINE=NDB
slave-bin.000001 # Query # # BEGIN slave-bin.000001 # Query # # BEGIN
slave-bin.000001 # Table_map # # table_id: # (test.t1) slave-bin.000001 # Table_map # # table_id: # (test.t1)
......
...@@ -37,7 +37,7 @@ master-bin.000001 # Write_rows # # table_id: # ...@@ -37,7 +37,7 @@ master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1 master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
master-bin.000001 # Query # # use `test`; DROP TABLE t1 master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
**** On Master **** **** On Master ****
CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB;
INSERT INTO t1 VALUES (1,1), (2,2); INSERT INTO t1 VALUES (1,1), (2,2);
...@@ -72,7 +72,7 @@ master-bin.000001 # Write_rows # # table_id: # ...@@ -72,7 +72,7 @@ master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Write_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1 master-bin.000001 # Query # # use `test`; TRUNCATE TABLE t1
master-bin.000001 # Query # # use `test`; DROP TABLE t1 master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT PRIMARY KEY, b LONG) ENGINE=NDB
master-bin.000001 # Query # # BEGIN master-bin.000001 # Query # # BEGIN
master-bin.000001 # Table_map # # table_id: # (test.t1) master-bin.000001 # Table_map # # table_id: # (test.t1)
...@@ -86,4 +86,4 @@ master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status) ...@@ -86,4 +86,4 @@ master-bin.000001 # Table_map # # table_id: # (mysql.ndb_apply_status)
master-bin.000001 # Write_rows # # table_id: # master-bin.000001 # Write_rows # # table_id: #
master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F master-bin.000001 # Delete_rows # # table_id: # flags: STMT_END_F
master-bin.000001 # Query # # COMMIT master-bin.000001 # Query # # COMMIT
master-bin.000001 # Query # # use `test`; DROP TABLE t1 master-bin.000001 # Query # # use `test`; DROP TABLE `t1` /* generated by server */
...@@ -818,6 +818,17 @@ SHOW CREATE TABLE t1; ...@@ -818,6 +818,17 @@ SHOW CREATE TABLE t1;
SELECT * FROM t1; SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # Bug#42511 mysqld: ctype-ucs2.c:2044: my_strnncollsp_utf32: Assertion (tlen % 4) == 0' faied
--echo #
CREATE TABLE t1 (
b char(250) CHARACTER SET utf32,
key (b)
) ENGINE=MYISAM;
INSERT INTO t1 VALUES ('d'),('f');
SELECT * FROM t1 WHERE b BETWEEN 'a' AND 'z';
DROP TABLE t1;
--echo # --echo #
--echo # End of 5.5 tests --echo # End of 5.5 tests
--echo # --echo #
...@@ -394,6 +394,10 @@ DROP TABLE t1; ...@@ -394,6 +394,10 @@ DROP TABLE t1;
--echo # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED --echo # Bug#54332 Deadlock with two connections doing LOCK TABLE+INSERT DELAYED
--echo # --echo #
--echo # This test is not supposed to work under --ps-protocol since
--echo # INSERT DELAYED doesn't work under LOCK TABLES with this protocol.
--disable_ps_protocol
--disable_warnings --disable_warnings
DROP TABLE IF EXISTS t1, t2; DROP TABLE IF EXISTS t1, t2;
--enable_warnings --enable_warnings
...@@ -547,3 +551,4 @@ disconnect con1; ...@@ -547,3 +551,4 @@ disconnect con1;
--echo # Connection default --echo # Connection default
connection default; connection default;
DROP TABLE t1, t2, t3; DROP TABLE t1, t2, t3;
--enable_ps_protocol
...@@ -1086,7 +1086,7 @@ drop table t1; ...@@ -1086,7 +1086,7 @@ drop table t1;
--echo End of 5.1 tests --echo End of 5.1 tests
--echo # --echo #
--echo # Bug#55648: Server crash on MIX/MAX on maximum time value --echo # Bug#55648: Server crash on MIN/MAX on maximum time value
--echo # --echo #
CREATE TABLE t1(c1 TIME NOT NULL); CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('837:59:59'); INSERT INTO t1 VALUES('837:59:59');
...@@ -1095,3 +1095,12 @@ SELECT MAX(c1) FROM t1; ...@@ -1095,3 +1095,12 @@ SELECT MAX(c1) FROM t1;
DROP TABLE t1; DROP TABLE t1;
--echo # End of the bug#55648 --echo # End of the bug#55648
--echo #
--echo # Bug#56120: Failed assertion on MIN/MAX on negative time value
--echo #
CREATE TABLE t1(c1 TIME NOT NULL);
INSERT INTO t1 VALUES('-00:00:01');
SELECT MAX(c1),MIN(c1) FROM t1;
DROP TABLE t1;
--echo # End of the bug#56120
...@@ -425,11 +425,5 @@ drop table t1; ...@@ -425,11 +425,5 @@ drop table t1;
--echo --echo
--exec $MYSQL --skip-column-names --vertical test -e "select 1 as a" --exec $MYSQL --skip-column-names --vertical test -e "select 1 as a"
#
# Bug #54466 client 5.5 built from source lacks "pager" support
#
--echo Bug #54466 client 5.5 built from source lacks "pager" support
--exec $MYSQL --pager test -e "select 1 as a"
--echo --echo
--echo End of tests --echo End of tests
-- source include/not_windows.inc
# This test should work in embedded server after we fix mysqltest
-- source include/not_embedded.inc
#
# Testing the MySQL command line client(mysql)
#
#
# Bug #54466 client 5.5 built from source lacks "pager" support
#
--echo Bug #54466 client 5.5 built from source lacks "pager" support
--exec $MYSQL --pager test -e "select 1 as a"
--echo
--echo End of tests
...@@ -7510,9 +7510,14 @@ String *Item_cache_datetime::val_str(String *str) ...@@ -7510,9 +7510,14 @@ String *Item_cache_datetime::val_str(String *str)
return NULL; return NULL;
if (cached_field_type == MYSQL_TYPE_TIME) if (cached_field_type == MYSQL_TYPE_TIME)
{ {
ulonglong time= int_value; longlong time= int_value;
DBUG_ASSERT(time <= TIME_MAX_VALUE);
set_zero_time(&ltime, MYSQL_TIMESTAMP_TIME); set_zero_time(&ltime, MYSQL_TIMESTAMP_TIME);
if (time < 0)
{
time= -time;
ltime.neg= TRUE;
}
DBUG_ASSERT(time <= TIME_MAX_VALUE);
ltime.second= time % 100; ltime.second= time % 100;
time/= 100; time/= 100;
ltime.minute= time % 100; ltime.minute= time % 100;
......
...@@ -674,7 +674,8 @@ const char* Log_event::get_type_str() ...@@ -674,7 +674,8 @@ const char* Log_event::get_type_str()
#ifndef MYSQL_CLIENT #ifndef MYSQL_CLIENT
Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans) Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans)
:log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg), thd(thd_arg) :log_pos(0), temp_buf(0), exec_time(0), flags(flags_arg),
cache_type(Log_event::EVENT_INVALID_CACHE), thd(thd_arg)
{ {
server_id= thd->server_id; server_id= thd->server_id;
when= thd->start_time; when= thd->start_time;
......
...@@ -563,15 +563,6 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list) ...@@ -563,15 +563,6 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list)
*/ */
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
/*
If a lock was acquired above, we should release it after delayed_get_table()
has cloned the ticket for the handler thread. Note that acquire_lock() can
succeed because of a lock already held by the connection. In this case we
should not release it here.
*/
MDL_ticket *table_ticket = mdl_savepoint == thd->mdl_context.mdl_savepoint() ?
NULL: thd->mdl_context.mdl_savepoint();
bool error= FALSE; bool error= FALSE;
if (delayed_get_table(thd, table_list)) if (delayed_get_table(thd, table_list))
error= TRUE; error= TRUE;
...@@ -597,12 +588,18 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list) ...@@ -597,12 +588,18 @@ bool open_and_lock_for_insert_delayed(THD *thd, TABLE_LIST *table_list)
} }
} }
if (table_ticket)
thd->mdl_context.release_lock(table_ticket);
/* /*
Clone_ticket() in delayed_get_table() causes TABLE_LIST::MDL_REQUEST::ticket If a lock was acquired above, we should release it after
to be overwritten with the cloned ticket. Reset the ticket here in case handle_delayed_insert() has cloned the ticket. Note that acquire_lock() can
we end up having to use normal insert. succeed because the connection already has the lock. In this case the ticket
will be before the mdl_savepoint and we should not release it here.
*/
if (!thd->mdl_context.has_lock(mdl_savepoint, table_list->mdl_request.ticket))
thd->mdl_context.release_lock(table_list->mdl_request.ticket);
/*
Reset the ticket in case we end up having to use normal insert and
therefore will reopen the table and reacquire the metadata lock.
*/ */
table_list->mdl_request.ticket= NULL; table_list->mdl_request.ticket= NULL;
...@@ -1839,14 +1836,25 @@ public: ...@@ -1839,14 +1836,25 @@ public:
mysql_cond_t cond, cond_client; mysql_cond_t cond, cond_client;
volatile uint tables_in_use,stacked_inserts; volatile uint tables_in_use,stacked_inserts;
volatile bool status; volatile bool status;
/*
When the handler thread starts, it clones a metadata lock ticket
for the table to be inserted. This is done to allow the deadlock
detector to detect deadlocks resulting from this lock.
Before this is done, the connection thread cannot safely exit
without causing problems for clone_ticket().
Once handler_thread_initialized has been set, it is safe for the
connection thread to exit.
Access to handler_thread_initialized is protected by di->mutex.
*/
bool handler_thread_initialized;
COPY_INFO info; COPY_INFO info;
I_List<delayed_row> rows; I_List<delayed_row> rows;
ulong group_count; ulong group_count;
TABLE_LIST table_list; // Argument TABLE_LIST table_list; // Argument
Delayed_insert() Delayed_insert()
:locks_in_memory(0), :locks_in_memory(0), table(0),tables_in_use(0),stacked_inserts(0),
table(0),tables_in_use(0),stacked_inserts(0), status(0), group_count(0) status(0), handler_thread_initialized(FALSE), group_count(0)
{ {
DBUG_ENTER("Delayed_insert constructor"); DBUG_ENTER("Delayed_insert constructor");
thd.security_ctx->user=thd.security_ctx->priv_user=(char*) delayed_user; thd.security_ctx->user=thd.security_ctx->priv_user=(char*) delayed_user;
...@@ -2063,19 +2071,9 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) ...@@ -2063,19 +2071,9 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
/* Replace volatile strings with local copies */ /* Replace volatile strings with local copies */
di->table_list.alias= di->table_list.table_name= di->thd.query(); di->table_list.alias= di->table_list.table_name= di->thd.query();
di->table_list.db= di->thd.db; di->table_list.db= di->thd.db;
/* We need the ticket so that it can be cloned in handle_delayed_insert */
/* init_mdl_requests(&di->table_list);
Clone the ticket representing the lock on the target table for di->table_list.mdl_request.ticket= table_list->mdl_request.ticket;
the insert and add it to the list of granted metadata locks held by
the handler thread. This is safe since the handler thread is
not holding nor waiting on any metadata locks.
*/
if (di->thd.mdl_context.clone_ticket(&table_list->mdl_request))
{
delete di;
my_error(ER_OUT_OF_RESOURCES, MYF(ME_FATALERROR));
goto end_create;
}
di->lock(); di->lock();
mysql_mutex_lock(&di->mutex); mysql_mutex_lock(&di->mutex);
...@@ -2088,15 +2086,20 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) ...@@ -2088,15 +2086,20 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list)
error)); error));
mysql_mutex_unlock(&di->mutex); mysql_mutex_unlock(&di->mutex);
di->unlock(); di->unlock();
di->thd.mdl_context.release_lock(table_list->mdl_request.ticket);
delete di; delete di;
my_error(ER_CANT_CREATE_THREAD, MYF(ME_FATALERROR), error); my_error(ER_CANT_CREATE_THREAD, MYF(ME_FATALERROR), error);
goto end_create; goto end_create;
} }
/* Wait until table is open */ /*
Wait until table is open unless the handler thread or the connection
thread has been killed. Note that we in all cases must wait until the
handler thread has been properly initialized before exiting. Otherwise
we risk doing clone_ticket() on a ticket that is no longer valid.
*/
thd_proc_info(thd, "waiting for handler open"); thd_proc_info(thd, "waiting for handler open");
while (!di->thd.killed && !di->table && !thd->killed) while (!di->handler_thread_initialized ||
(!di->thd.killed && !di->table && !thd->killed))
{ {
mysql_cond_wait(&di->cond_client, &di->mutex); mysql_cond_wait(&di->cond_client, &di->mutex);
} }
...@@ -2524,6 +2527,7 @@ pthread_handler_t handle_delayed_insert(void *arg) ...@@ -2524,6 +2527,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
/* Can't use my_error since store_globals has not yet been called */ /* Can't use my_error since store_globals has not yet been called */
thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES, thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES,
ER(ER_OUT_OF_RESOURCES), NULL); ER(ER_OUT_OF_RESOURCES), NULL);
di->handler_thread_initialized= TRUE;
} }
else else
{ {
...@@ -2534,6 +2538,7 @@ pthread_handler_t handle_delayed_insert(void *arg) ...@@ -2534,6 +2538,7 @@ pthread_handler_t handle_delayed_insert(void *arg)
/* Can't use my_error since store_globals has perhaps failed */ /* Can't use my_error since store_globals has perhaps failed */
thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES, thd->stmt_da->set_error_status(thd, ER_OUT_OF_RESOURCES,
ER(ER_OUT_OF_RESOURCES), NULL); ER(ER_OUT_OF_RESOURCES), NULL);
di->handler_thread_initialized= TRUE;
thd->fatal_error(); thd->fatal_error();
goto err; goto err;
} }
...@@ -2546,7 +2551,24 @@ pthread_handler_t handle_delayed_insert(void *arg) ...@@ -2546,7 +2551,24 @@ pthread_handler_t handle_delayed_insert(void *arg)
thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED); thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_INSERT_DELAYED);
thd->set_current_stmt_binlog_format_row_if_mixed(); thd->set_current_stmt_binlog_format_row_if_mixed();
init_mdl_requests(&di->table_list); /*
Clone the ticket representing the lock on the target table for
the insert and add it to the list of granted metadata locks held by
the handler thread. This is safe since the handler thread is
not holding nor waiting on any metadata locks.
*/
if (thd->mdl_context.clone_ticket(&di->table_list.mdl_request))
{
di->handler_thread_initialized= TRUE;
goto err;
}
/*
Now that the ticket has been cloned, it is safe for the connection
thread to exit.
*/
di->handler_thread_initialized= TRUE;
di->table_list.mdl_request.ticket= NULL;
if (di->open_and_lock_table()) if (di->open_and_lock_table())
goto err; goto err;
......
...@@ -4268,6 +4268,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, ...@@ -4268,6 +4268,7 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
Alter_info *alter_info) Alter_info *alter_info)
{ {
bool result; bool result;
bool is_trans= FALSE;
DBUG_ENTER("mysql_create_table"); DBUG_ENTER("mysql_create_table");
/* /*
...@@ -4282,7 +4283,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table, ...@@ -4282,7 +4283,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
/* Got lock. */ /* Got lock. */
DEBUG_SYNC(thd, "locked_table_name"); DEBUG_SYNC(thd, "locked_table_name");
bool is_trans;
result= mysql_create_table_no_lock(thd, create_table->db, result= mysql_create_table_no_lock(thd, create_table->db,
create_table->table_name, create_info, create_table->table_name, create_info,
alter_info, FALSE, 0, &is_trans); alter_info, FALSE, 0, &is_trans);
...@@ -4454,6 +4454,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, ...@@ -4454,6 +4454,7 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
HA_CREATE_INFO local_create_info; HA_CREATE_INFO local_create_info;
Alter_info local_alter_info; Alter_info local_alter_info;
bool res= TRUE; bool res= TRUE;
bool is_trans= FALSE;
uint not_used; uint not_used;
DBUG_ENTER("mysql_create_like_table"); DBUG_ENTER("mysql_create_like_table");
...@@ -4503,7 +4504,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table, ...@@ -4503,7 +4504,6 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table, TABLE_LIST* src_table,
/* Reset auto-increment counter for the new table. */ /* Reset auto-increment counter for the new table. */
local_create_info.auto_increment_value= 0; local_create_info.auto_increment_value= 0;
bool is_trans;
if ((res= mysql_create_table_no_lock(thd, table->db, table->table_name, if ((res= mysql_create_table_no_lock(thd, table->db, table->table_name,
&local_create_info, &local_alter_info, &local_create_info, &local_alter_info,
FALSE, 0, &is_trans))) FALSE, 0, &is_trans)))
......
...@@ -253,18 +253,17 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, ...@@ -253,18 +253,17 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
pos=old; pos=old;
if (keyseg->flag & HA_SPACE_PACK) if (keyseg->flag & HA_SPACE_PACK)
{ {
uchar *end=pos+length;
if (type == HA_KEYTYPE_NUM) if (type == HA_KEYTYPE_NUM)
{ {
while (pos < end && pos[0] == ' ') uchar *end= pos + length;
pos++; while (pos < end && pos[0] == ' ')
pos++;
length= (uint) (end - pos);
} }
else if (type != HA_KEYTYPE_BINARY) else if (type != HA_KEYTYPE_BINARY)
{ {
while (end > pos && end[-1] == ' ') length= cs->cset->lengthsp(cs, (char*) pos, length);
end--;
} }
length=(uint) (end-pos);
FIX_LENGTH(cs, pos, length, char_length); FIX_LENGTH(cs, pos, length, char_length);
store_key_length_inc(key,char_length); store_key_length_inc(key,char_length);
memcpy((uchar*) key,pos,(size_t) char_length); memcpy((uchar*) key,pos,(size_t) char_length);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment