Skip to content

Commit b4e8798

Browse files
author
Marko Mäkelä
committed
Merge mysql-trunk to mysql-trunk-wl5545.
2 parents a1e4913 + 716bbeb commit b4e8798

File tree

148 files changed

+6428
-1737
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+6428
-1737
lines changed

libmysqld/lib_sql.cc

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,35 @@
1919
The following is needed to not cause conflicts when we include mysqld.cc
2020
*/
2121

22-
#define main main1
23-
#define mysql_unix_port mysql_inix_port1
24-
#define mysql_port mysql_port1
25-
2622
extern "C"
2723
{
2824
extern unsigned long max_allowed_packet, net_buffer_length;
2925
}
3026

3127
#include "../sql/mysqld.cc"
3228

33-
C_MODE_START
29+
extern "C" {
3430

3531
#include <mysql.h>
3632
#undef ER
3733
#include "errmsg.h"
3834
#include "embedded_priv.h"
3935

36+
} // extern "C"
37+
4038
#include <algorithm>
4139

4240
using std::min;
4341
using std::max;
4442

43+
extern "C" {
44+
4545
extern unsigned int mysql_server_last_errno;
4646
extern char mysql_server_last_error[MYSQL_ERRMSG_SIZE];
4747
static my_bool emb_read_query_result(MYSQL *mysql);
4848

4949

50-
extern "C" void unireg_clear(int exit_code)
50+
void unireg_clear(int exit_code)
5151
{
5252
DBUG_ENTER("unireg_clear");
5353
clean_up(!opt_help && (exit_code || !opt_bootstrap)); /* purecov: inspected */
@@ -422,9 +422,12 @@ static void emb_free_embedded_thd(MYSQL *mysql)
422422
{
423423
THD *thd= (THD*)mysql->thd;
424424
thd->clear_data_list();
425-
thread_count--;
426425
thd->store_globals();
427-
thd->unlink();
426+
427+
mysql_mutex_lock(&LOCK_thread_count);
428+
remove_global_thread(thd);
429+
mysql_mutex_unlock(&LOCK_thread_count);
430+
428431
delete thd;
429432
my_pthread_setspecific_ptr(THR_THD, 0);
430433
mysql->thd=0;
@@ -720,8 +723,9 @@ void *create_embedded_thd(int client_flag)
720723
thd->data_tail= &thd->first_data;
721724
memset(&thd->net, 0, sizeof(thd->net));
722725

723-
thread_count++;
724-
threads.push_front(thd);
726+
mysql_mutex_lock(&LOCK_thread_count);
727+
add_global_thread(thd);
728+
mysql_mutex_unlock(&LOCK_thread_count);
725729
thd->mysys_var= 0;
726730
return thd;
727731
err:
@@ -815,7 +819,8 @@ int check_embedded_connection(MYSQL *mysql, const char *db)
815819
}
816820
#endif
817821

818-
C_MODE_END
822+
} // extern "C"
823+
819824

820825
void THD::clear_data_list()
821826
{

mysql-test/extra/rpl_tests/rpl_loaddata.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ if (`SELECT @@global.binlog_format != 'ROW'`)
160160
{
161161
# Query causes error on master but not on slave. This causes the slave to
162162
# stop with error code 0 (which is wrong: see BUG#57287)
163-
--let $slave_sql_errno= 0,1754
163+
# ER_MTS_INCONSISTENT_DATA
164+
--let $slave_sql_errno= 0,1755
164165
--source include/wait_for_slave_sql_error.inc
165166
drop table t1, t2;
166167
}

mysql-test/extra/rpl_tests/rpl_mts_crash_safe.inc

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,39 @@ if ($commands == recovery)
9898

9999
#### Crashing server after assigning and processing jobs ######
100100
--connection slave
101+
102+
--let $mts_run=`select @@global.slave_parallel_workers > 0`
101103
eval SET @@global.slave_checkpoint_group= $count_debug_groups;
102104
SET GLOBAL debug="d,check_slave_debug_group";
103105
SET GLOBAL debug="+d,mts_distribute_round_robin";
104106
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
105107
--error 0, 2013
106108
START SLAVE SQL_THREAD;
107109
--source include/wait_until_disconnected.inc
108-
--exec echo "restart --skip-slave-start --slave-transaction-retries=0 --relay-log-info-repository=TABLE --master-info-repository=TABLE --sync-master-info=1" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
110+
111+
#### MTS can not relay-log-recover in presense of gaps that the test creates
112+
#### The server has to be restarted with --relay-log-recovery = 0 followed by
113+
#### START SLAVE UNTIL SQL_AFTER_MTS_GAPS.
114+
115+
if ($mts_run)
116+
{
117+
--echo ** fixing gaps **
118+
--let $rpl_server_number= 2
119+
--let $rpl_server_parameters= --skip-slave-start --relay-log-recovery=0 --slave-parallel-workers=0
120+
--source include/rpl_start_server.inc
121+
122+
START SLAVE UNTIL SQL_AFTER_MTS_GAPS;
123+
--let $slave_param= Until_Condition
124+
--let $slave_param_value= DONE
125+
--source include/wait_for_slave_param.inc
126+
# there's a chance it will hang at this point (thanks to pre-exec UNTIL check)
127+
--source include/wait_for_slave_sql_to_stop.inc
128+
}
129+
130+
--echo ** regular restart **
109131
--let $rpl_server_number= 2
110-
--source include/rpl_reconnect.inc
132+
--let $rpl_server_parameters= --skip-slave-start --slave-transaction-retries=0 --relay-log-info-repository=TABLE --master-info-repository=TABLE --sync-master-info=1
133+
--source include/rpl_restart_server.inc
111134

112135
#### Checking if the recovery worked and the coordinator has an updated state. ####
113136
--connection slave

mysql-test/extra/rpl_tests/rpl_row_basic.test

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
# First we test tables with only an index.
77
#
88

9+
#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
10+
#Testing command counters -BEFORE
11+
#Storing the before counts of Slave
12+
connection slave;
13+
let $slave_com_commit_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
14+
let $slave_com_insert_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
15+
let $slave_com_delete_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
16+
let $slave_com_update_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
17+
918
connection master;
1019
eval CREATE TABLE t1 (C1 CHAR(1), C2 CHAR(1), INDEX (C1)$extra_index_t1) ENGINE = $type ;
1120
SELECT * FROM t1;
@@ -40,6 +49,32 @@ SELECT * FROM t1 ORDER BY C1,C2;
4049
sync_slave_with_master;
4150
SELECT * FROM t1 ORDER BY C1,C2;
4251

52+
#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
53+
#Testing command counters -AFTER
54+
#Storing the after counts of Slave
55+
connection slave;
56+
let $slave_com_commit_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
57+
let $slave_com_insert_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
58+
let $slave_com_delete_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
59+
let $slave_com_update_after= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
60+
61+
#Commit count check
62+
--let $assert_text= Counter for COM_COMMIT is consistent with the number of actual commits
63+
--let $assert_cond= $slave_com_commit_after - $slave_com_commit_before = 4
64+
--source include/assert.inc
65+
#Insert count check
66+
--let $assert_text= Counter for COM_INSERT is consistent with the number of actual inserts
67+
--let $assert_cond= $slave_com_insert_after - $slave_com_insert_before = 2
68+
--source include/assert.inc
69+
#Delete count check
70+
--let $assert_text= Counter for COM_DELETE is consistent with the number of actual deletes
71+
--let $assert_cond= $slave_com_delete_after - $slave_com_delete_before = 1
72+
--source include/assert.inc
73+
#Update count check
74+
--let $assert_text= Counter for COM_UPDATE is consistent with the number of actual updates
75+
--let $assert_cond= $slave_com_update_after - $slave_com_update_before = 1
76+
--source include/assert.inc
77+
4378
# Testing update with a condition that does not match any rows, but
4479
# which has a match for the index.
4580
connection master;

mysql-test/extra/rpl_tests/rpl_stm_EE_err2.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ call mtr.add_suppression("Slave SQL.*Query caused different errors on master and
2828
call mtr.add_suppression("The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
2929

3030
--echo (expect different error codes on master and slave)
31-
--let $slave_sql_errno= 0,1754
31+
# ER_MTS_INCONSISTENT_DATA
32+
--let $slave_sql_errno= 0,1755
3233
# can't print error text. MTS reports a separate error in this case.
3334
# Todo: to fix single-threaded-slave BUG#57287.
3435
--let $show_slave_sql_error= 0

mysql-test/include/function_defaults.inc

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,3 +1107,60 @@ WHERE t1.a = 1 AND t1.ts >= '2000-09-28 00:00:00';
11071107
SELECT b FROM t1;
11081108

11091109
DROP TABLE t1, t2;
1110+
1111+
--echo #
1112+
--echo # Bug#11745578: 17392: ALTER TABLE ADD COLUMN TIMESTAMP DEFAULT
1113+
--echo # CURRENT_TIMESTAMP INSERTS ZERO
1114+
--echo #
1115+
SET timestamp = 1000;
1116+
1117+
CREATE TABLE t1 ( b INT );
1118+
INSERT INTO t1 VALUES (1);
1119+
1120+
eval ALTER TABLE t1 ADD COLUMN a6 $datetime DEFAULT $now ON UPDATE $now FIRST;
1121+
eval ALTER TABLE t1 ADD COLUMN a5 $datetime DEFAULT $now FIRST;
1122+
eval ALTER TABLE t1 ADD COLUMN a4 $datetime ON UPDATE $now FIRST;
1123+
1124+
eval ALTER TABLE t1 ADD COLUMN a3 $timestamp DEFAULT $now ON UPDATE $now FIRST;
1125+
eval ALTER TABLE t1 ADD COLUMN a2 $timestamp DEFAULT $now FIRST;
1126+
eval ALTER TABLE t1 ADD COLUMN a1 $timestamp ON UPDATE $now FIRST;
1127+
1128+
eval ALTER TABLE t1 ADD COLUMN c1 $timestamp ON UPDATE $now AFTER b;
1129+
eval ALTER TABLE t1 ADD COLUMN c2 $timestamp DEFAULT $now AFTER c1;
1130+
eval ALTER TABLE t1 ADD COLUMN c3 $timestamp DEFAULT $now ON UPDATE $now AFTER c2;
1131+
1132+
eval ALTER TABLE t1 ADD COLUMN c4 $datetime ON UPDATE $now AFTER c3;
1133+
eval ALTER TABLE t1 ADD COLUMN c5 $datetime DEFAULT $now AFTER c4;
1134+
eval ALTER TABLE t1 ADD COLUMN c6 $datetime DEFAULT $now ON UPDATE $now AFTER c5;
1135+
1136+
SELECT * FROM t1;
1137+
1138+
DROP TABLE t1;
1139+
1140+
1141+
eval CREATE TABLE t1 ( a $timestamp DEFAULT $now, b $datetime DEFAULT $now );
1142+
INSERT INTO t1 VALUES ();
1143+
1144+
SET timestamp = 1000000000;
1145+
1146+
ALTER TABLE t1 MODIFY COLUMN a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3);
1147+
ALTER TABLE t1 MODIFY COLUMN b DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3);
1148+
1149+
SELECT * FROM t1;
1150+
1151+
DROP TABLE t1;
1152+
1153+
1154+
eval CREATE TABLE t1 (
1155+
a $timestamp DEFAULT '1999-12-01 11:22:33',
1156+
b $datetime DEFAULT '1999-12-01 11:22:33'
1157+
);
1158+
INSERT INTO t1 VALUES ();
1159+
1160+
eval ALTER TABLE t1 MODIFY COLUMN a $timestamp DEFAULT $now;
1161+
eval ALTER TABLE t1 MODIFY COLUMN b $datetime DEFAULT $now;
1162+
INSERT INTO t1 VALUES ();
1163+
1164+
SELECT * FROM t1;
1165+
1166+
DROP TABLE t1;

mysql-test/r/alter_table.result

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,3 +1898,58 @@ DROP TABLE ti3;
18981898
CREATE TABLE tm1(i INT DEFAULT 1) engine=MyISAM;
18991899
ALTER TABLE tm1 ADD INDEX ii1(i), ALTER COLUMN i DROP DEFAULT;
19001900
DROP TABLE tm1;
1901+
#
1902+
# Bug#11815557 60269: MYSQL SHOULD REJECT ATTEMPTS TO CREATE SYSTEM
1903+
# TABLES IN INCORRECT ENGINE
1904+
#
1905+
# Note: This test assumes that only MyISAM supports system tables.
1906+
# If other engines are made to support system tables,
1907+
# then this test needs to be updated
1908+
#
1909+
use mysql;
1910+
ALTER TABLE db ENGINE=innodb;
1911+
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.db]
1912+
ALTER TABLE user ENGINE=memory;
1913+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.user]
1914+
ALTER TABLE proc ENGINE=heap;
1915+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.proc]
1916+
ALTER TABLE func ENGINE=csv;
1917+
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.func]
1918+
ALTER TABLE event ENGINE=merge;
1919+
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.event]
1920+
ALTER TABLE servers ENGINE=innodb;
1921+
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.servers]
1922+
ALTER TABLE procs_priv ENGINE=memory;
1923+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.procs_priv]
1924+
ALTER TABLE tables_priv ENGINE=heap;
1925+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.tables_priv]
1926+
ALTER TABLE columns_priv ENGINE=csv;
1927+
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.columns_priv]
1928+
ALTER TABLE time_zone ENGINE=merge;
1929+
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.time_zone]
1930+
ALTER TABLE help_topic ENGINE=innodb;
1931+
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.help_topic]
1932+
CREATE TABLE db (dummy int) ENGINE=innodb;
1933+
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.db]
1934+
CREATE TABLE user (dummy int) ENGINE=memory;
1935+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.user]
1936+
CREATE TABLE proc (dummy int) ENGINE=heap;
1937+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.proc]
1938+
CREATE TABLE func (dummy int) ENGINE=csv;
1939+
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.func]
1940+
CREATE TABLE event (dummy int) ENGINE=merge;
1941+
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.event]
1942+
CREATE TABLE servers (dummy int) ENGINE=innodb;
1943+
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.servers]
1944+
CREATE TABLE procs_priv (dummy int) ENGINE=memory;
1945+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.procs_priv]
1946+
CREATE TABLE tables_priv (dummy int) ENGINE=heap;
1947+
ERROR HY000: Storage engine 'MEMORY' does not support system tables. [mysql.tables_priv]
1948+
CREATE TABLE columns_priv (dummy int) ENGINE=csv;
1949+
ERROR HY000: Storage engine 'CSV' does not support system tables. [mysql.columns_priv]
1950+
CREATE TABLE time_zone (dummy int) ENGINE=merge;
1951+
ERROR HY000: Storage engine 'MRG_MYISAM' does not support system tables. [mysql.time_zone]
1952+
CREATE TABLE help_topic (dummy int) ENGINE=innodb;
1953+
ERROR HY000: Storage engine 'InnoDB' does not support system tables. [mysql.help_topic]
1954+
use test;
1955+
# End of Bug#11815557

mysql-test/r/explain.result

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE url=1;
414414
id select_type table type possible_keys key key_len ref rows filtered Extra
415415
1 SIMPLE t1 index PRIMARY PRIMARY 1 NULL 5 100.00 Using where; Using index
416416
Warnings:
417-
Warning 1737 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'url'
418-
Warning 1737 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
417+
Warning 1738 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'url'
418+
Warning 1738 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
419419
Note 1003 /* select#1 */ select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` = 1)
420420

421421
# Test that index can't be used for lookup due to collation mismatch
@@ -426,8 +426,8 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE url='1' collate latin1_german2_ci;
426426
id select_type table type possible_keys key key_len ref rows filtered Extra
427427
1 SIMPLE t1 index PRIMARY PRIMARY 1 NULL 5 100.00 Using where; Using index
428428
Warnings:
429-
Warning 1737 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'url'
430-
Warning 1737 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
429+
Warning 1738 Cannot use ref access on index 'PRIMARY' due to type or collation conversion on field 'url'
430+
Warning 1738 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
431431
Note 1003 /* select#1 */ select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` = <cache>(('1' collate latin1_german2_ci)))
432432

433433
# Normally, range access on primary key is done
@@ -447,7 +447,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>3;
447447
id select_type table type possible_keys key key_len ref rows filtered Extra
448448
1 SIMPLE t1 index PRIMARY PRIMARY 1 NULL 5 100.00 Using where; Using index
449449
Warnings:
450-
Warning 1737 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
450+
Warning 1738 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
451451
Note 1003 /* select#1 */ select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` > 3)
452452

453453
# Test that range access on index can't be done due to collation mismatch
@@ -459,7 +459,7 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE url>'3' collate latin1_german2_ci;
459459
id select_type table type possible_keys key key_len ref rows filtered Extra
460460
1 SIMPLE t1 index PRIMARY PRIMARY 1 NULL 5 100.00 Using where; Using index
461461
Warnings:
462-
Warning 1737 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
462+
Warning 1738 Cannot use range access on index 'PRIMARY' due to type or collation conversion on field 'url'
463463
Note 1003 /* select#1 */ select `test`.`t1`.`url` AS `url` from `test`.`t1` where (`test`.`t1`.`url` > <cache>(('3' collate latin1_german2_ci)))
464464

465465
DROP TABLE t1;

0 commit comments

Comments
 (0)