Skip to content

Commit

Permalink
Merge branch 'mysql/5.5' into 5.5
Browse files Browse the repository at this point in the history
without a fix for Bug#12818255 (MDEV-6581)
  • Loading branch information
vuvova committed Aug 3, 2016
2 parents 511313b + 7d57772 commit a350e53
Show file tree
Hide file tree
Showing 13 changed files with 373 additions and 41 deletions.
58 changes: 48 additions & 10 deletions client/mysqlimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

/* Global Thread counter */
uint counter= 0;
pthread_mutex_t init_mutex;
pthread_mutex_t counter_mutex;
pthread_cond_t count_threshhold;

Expand Down Expand Up @@ -421,8 +422,19 @@ static MYSQL *db_connect(char *host, char *database,
MYSQL *mysql;
if (verbose)
fprintf(stdout, "Connecting to %s\n", host ? host : "localhost");
if (!(mysql= mysql_init(NULL)))
return 0;
if (opt_use_threads && !lock_tables)
{
pthread_mutex_lock(&init_mutex);
if (!(mysql= mysql_init(NULL)))
{
pthread_mutex_unlock(&init_mutex);
return 0;
}
pthread_mutex_unlock(&init_mutex);
}
else
if (!(mysql= mysql_init(NULL)))
return 0;
if (opt_compress)
mysql_options(mysql,MYSQL_OPT_COMPRESS,NullS);
if (opt_local_file)
Expand Down Expand Up @@ -605,7 +617,7 @@ pthread_handler_t worker_thread(void *arg)
pthread_cond_signal(&count_threshhold);
pthread_mutex_unlock(&counter_mutex);
mysql_thread_end();

pthread_exit(0);
return 0;
}

Expand All @@ -629,15 +641,31 @@ int main(int argc, char **argv)

if (opt_use_threads && !lock_tables)
{
pthread_t mainthread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
char **save_argv;
uint worker_thread_count= 0, table_count= 0, i= 0;
pthread_t *worker_threads; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,
PTHREAD_CREATE_DETACHED);
PTHREAD_CREATE_JOINABLE);

pthread_mutex_init(&init_mutex, NULL);
pthread_mutex_init(&counter_mutex, NULL);
pthread_cond_init(&count_threshhold, NULL);

/* Count the number of tables. This number denotes the total number
of threads spawn.
*/
save_argv= argv;
for (table_count= 0; *argv != NULL; argv++)
table_count++;
argv= save_argv;

if (!(worker_threads= (pthread_t*) my_malloc(table_count *
sizeof(*worker_threads),
MYF(0))))
return -2;

for (counter= 0; *argv != NULL; argv++) /* Loop through tables */
{
pthread_mutex_lock(&counter_mutex);
Expand All @@ -652,15 +680,16 @@ int main(int argc, char **argv)
counter++;
pthread_mutex_unlock(&counter_mutex);
/* now create the thread */
if (pthread_create(&mainthread, &attr, worker_thread,
(void *)*argv) != 0)
if (pthread_create(&worker_threads[worker_thread_count], &attr,
worker_thread, (void *)*argv) != 0)
{
pthread_mutex_lock(&counter_mutex);
counter--;
pthread_mutex_unlock(&counter_mutex);
fprintf(stderr,"%s: Could not create thread\n",
my_progname);
fprintf(stderr,"%s: Could not create thread\n", my_progname);
continue;
}
worker_thread_count++;
}

/*
Expand All @@ -675,9 +704,18 @@ int main(int argc, char **argv)
pthread_cond_timedwait(&count_threshhold, &counter_mutex, &abstime);
}
pthread_mutex_unlock(&counter_mutex);
pthread_mutex_destroy(&init_mutex);
pthread_mutex_destroy(&counter_mutex);
pthread_cond_destroy(&count_threshhold);
pthread_attr_destroy(&attr);

for(i= 0; i < worker_thread_count; i++)
{
if (pthread_join(worker_threads[i], NULL))
fprintf(stderr,"%s: Could not join worker thread.\n", my_progname);
}

my_free(worker_threads);
}
else
{
Expand Down
7 changes: 7 additions & 0 deletions mysql-test/r/func_misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -574,3 +574,10 @@ drop table t1;
#
# End of 5.5 tests
#
SELECT NAME_CONST('a', -(1 OR 2)) OR 1;
ERROR HY000: Incorrect arguments to NAME_CONST
SELECT NAME_CONST('a', -(1 AND 2)) OR 1;
ERROR HY000: Incorrect arguments to NAME_CONST
SELECT NAME_CONST('a', -(1)) OR 1;
NAME_CONST('a', -(1)) OR 1
1
26 changes: 25 additions & 1 deletion mysql-test/r/loaddata.result
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ DROP TABLE t1;
# Bug#11765139 58069: LOAD DATA INFILE: VALGRIND REPORTS INVALID MEMORY READS AND WRITES WITH U
#
CREATE TABLE t1(f1 INT);
SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
SELECT 0xE1C330 INTO OUTFILE 't1.dat';
LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
DROP TABLE t1;
#
Expand All @@ -532,3 +532,27 @@ FIELDS TERMINATED BY 't' LINES TERMINATED BY '';
Got one of the listed errors
SET @@sql_mode= @old_mode;
DROP TABLE t1;

#
# Bug#23080148 - Backport of Bug#20683959.
# Bug#20683959 LOAD DATA INFILE IGNORES A SPECIFIC ROW SILENTLY
# UNDER DB CHARSET IS UTF8.
#
CREATE DATABASE d1 CHARSET latin1;
USE d1;
CREATE TABLE t1 (val TEXT);
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
SELECT COUNT(*) FROM t1;
COUNT(*)
1
SELECT HEX(val) FROM t1;
HEX(val)
C38322525420406E696F757A656368756E3A20E98198E2889AF58081AEE7B99DE4B88AE383A3E7B99DE69690F58087B3E7B9A7EFBDA8E7B99DEFBDB3E7B99DE78999E880B3E7B8BAEFBDAAE7B9A7E89699E296A1E7B8BAE4BBA3EFBD8CE7B8BAEFBDA9E7B8B2E2889AE38184E7B99DEFBDB3E7B99DE4B88AE383A3E7B99DE69690F58087B3E7B9A7EFBDA8E7B99DEFBDB3E7B99DE5B3A8EFBD84E8ABA0EFBDA8E89C89F580948EE599AAE7B8BAEFBDAAE7B8BAE9A198EFBDA9EFBDB1E7B9A7E581B5E289A0E7B8BAEFBDBEE7B9A7E9A194EFBDA9E882B4EFBDA5EFBDB5E980A7F5808B96E28693E99EABE38287E58F99E7B8BAE58AB1E28691E7B8BAF5808B9AE7828AE98095EFBDB1E7B8BAEFBDAFE7B8B2E288ABE6A89FE89EB3E6BA98F58081ADE88EA0EFBDBAE98095E6BA98F58081AEE89D93EFBDBAE8AD9BEFBDACE980A7F5808B96E28693E7B8BAF580918EE288AAE7B8BAE4B88AEFBC9EE7B8BAE4B99DE28691E7B8BAF5808B96EFBCA0E88DB3E6A68AEFBDB9EFBDB3E981B2E5B3A8E296A1E7B8BAE7A4BCE7828AE88DB3E6A68AEFBDB0EFBDBDE7B8BAA0E7B8BAE88B93EFBDBEE5B899EFBC9E
CREATE DATABASE d2 CHARSET utf8;
USE d2;
CREATE TABLE t1 (val TEXT);
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
ERROR HY000: Invalid utf8 character string: '�"RT @niouzechun: \9058\221A'
DROP TABLE d1.t1, d2.t1;
DROP DATABASE d1;
DROP DATABASE d2;
20 changes: 20 additions & 0 deletions mysql-test/r/sp-prelocking.result
Original file line number Diff line number Diff line change
Expand Up @@ -320,3 +320,23 @@ c2
DROP TRIGGER t1_ai;
DROP TABLE t1, t2;
End of 5.0 tests
#
# Bug#21142859: FUNCTION UPDATING A VIEW FAILS TO FIND TABLE THAT ACTUALLY EXISTS
#
CREATE TABLE t1 SELECT 1 AS fld1, 'A' AS fld2;
CREATE TABLE t2 (fld3 INT, fld4 CHAR(1));
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TRIGGER t1_au AFTER UPDATE ON t1
FOR EACH ROW INSERT INTO t2 VALUES (new.fld1, new.fld2);
CREATE FUNCTION f1() RETURNS INT
BEGIN
UPDATE v1 SET fld2='B' WHERE fld1=1;
RETURN row_count();
END !
# Without the patch, an error was getting reported.
SELECT f1();
f1()
1
DROP FUNCTION f1;
DROP VIEW v1;
DROP TABLE t1,t2;
1 change: 1 addition & 0 deletions mysql-test/std_data/bug20683959loaddata.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Ã"RT @niouzechun: 遘√����繝上ャ繝斐����繧ィ繝ウ繝牙耳縺ェ繧薙□縺代l縺ゥ縲√い繝ウ繝上ャ繝斐����繧ィ繝ウ繝峨d諠ィ蜉����噪縺ェ縺願ゥア繧偵≠縺セ繧顔ゥ肴・オ逧����↓鞫ょ叙縺励↑縺����炊逕ア縺ッ縲∫樟螳溘����莠コ逕溘����蝓コ譛ャ逧����↓縺����∪縺上>縺九↑縺����@荳榊ケウ遲峨□縺礼炊荳榊ース縺�縺苓セ帙>
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
DROP TABLE IF EXISTS t1 ;
# READ_ONLY does nothing to SUPER users
# so we use a non-SUPER one:
GRANT CREATE, SELECT, DROP ON *.* TO test@localhost;
connect con1,localhost,test,,test;
connection default;
SET GLOBAL READ_ONLY=1;
connection con1;
CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB;
# Test INSERTS with autocommit being off and on.
BEGIN;
INSERT INTO t1 VALUES (10);
COMMIT;
INSERT INTO t1 VALUES (20);
# Test UPDATES with autocommit being off and on.
BEGIN;
UPDATE t1 SET a=30 WHERE a=10;
COMMIT;
UPDATE t1 SET a=40 WHERE a=20;
connection default;
SET GLOBAL READ_ONLY=0;
# Test scenario where global read_only is enabled in the middle of transaction.
# Test INSERT operations on temporary tables, INSERTs should be successful even
# when global read_only is enabled.
connection con1;
BEGIN;
INSERT INTO t1 VALUES(50);
connection default;
SET GLOBAL READ_ONLY=1;
connection con1;
SELECT @@GLOBAL.READ_ONLY;
@@GLOBAL.READ_ONLY
1
COMMIT;
connection default;
SET GLOBAL READ_ONLY=0;
# Test UPDATE operations on temporary tables, UPDATEs should be successful even
# when global read_only is enabled.
connection con1;
BEGIN;
UPDATE t1 SET a=60 WHERE a=50;
connection default;
SET GLOBAL READ_ONLY=1;
connection con1;
SELECT @@GLOBAL.READ_ONLY;
@@GLOBAL.READ_ONLY
1
COMMIT;
SELECT * FROM t1;
a
30
40
60
# Clean up
connection default;
SET GLOBAL READ_ONLY=0;
disconnect con1;
DROP USER test@localhost;
91 changes: 91 additions & 0 deletions mysql-test/suite/binlog/t/binlog_dmls_on_tmp_tables_readonly.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# ==== Purpose ====
#
# Check that DMLs are allowed on temporary tables, when server is in read only
# mode and binary log is enabled with binlog-format being stmt/mixed mode.
#
# ==== Implementation ====
#
# Start the server with binary log being enabled. Mark the server as read only.
# Create a non-SUPER user and let the user to create a temporary table and
# perform DML operations on that temporary table. DMLs should not be blocked
# with a 'server read-only mode' error.
#
# ==== References ====
#
# Bug#12818255: READ-ONLY OPTION DOES NOT ALLOW INSERTS/UPDATES ON TEMPORARY
# TABLES
# Bug#14294223: CHANGES NOT ALLOWED TO TEMPORARY TABLES ON READ-ONLY SERVERS
###############################################################################
--source include/have_log_bin.inc
--source include/have_innodb.inc
--disable_warnings
DROP TABLE IF EXISTS t1 ;
--enable_warnings

--enable_connect_log
--echo # READ_ONLY does nothing to SUPER users
--echo # so we use a non-SUPER one:
GRANT CREATE, SELECT, DROP ON *.* TO test@localhost;

connect (con1,localhost,test,,test);

connection default;
SET GLOBAL READ_ONLY=1;

connection con1;
CREATE TEMPORARY TABLE t1 (a INT) ENGINE=INNODB;

--echo # Test INSERTS with autocommit being off and on.
BEGIN;
INSERT INTO t1 VALUES (10);
COMMIT;
INSERT INTO t1 VALUES (20);

--echo # Test UPDATES with autocommit being off and on.
BEGIN;
UPDATE t1 SET a=30 WHERE a=10;
COMMIT;
UPDATE t1 SET a=40 WHERE a=20;

connection default;
SET GLOBAL READ_ONLY=0;

--echo # Test scenario where global read_only is enabled in the middle of transaction.
--echo # Test INSERT operations on temporary tables, INSERTs should be successful even
--echo # when global read_only is enabled.
connection con1;
BEGIN;
INSERT INTO t1 VALUES(50);

connection default;
SET GLOBAL READ_ONLY=1;

connection con1;
SELECT @@GLOBAL.READ_ONLY;
COMMIT;

connection default;
SET GLOBAL READ_ONLY=0;

--echo # Test UPDATE operations on temporary tables, UPDATEs should be successful even
--echo # when global read_only is enabled.
connection con1;
BEGIN;
UPDATE t1 SET a=60 WHERE a=50;

connection default;
SET GLOBAL READ_ONLY=1;

connection con1;
SELECT @@GLOBAL.READ_ONLY;
COMMIT;

SELECT * FROM t1;

--echo # Clean up
connection default;
SET GLOBAL READ_ONLY=0;

disconnect con1;
DROP USER test@localhost;
--disable_connect_log
10 changes: 10 additions & 0 deletions mysql-test/t/func_misc.test
Original file line number Diff line number Diff line change
Expand Up @@ -599,3 +599,13 @@ drop table t1;
--echo #
--echo # End of 5.5 tests
--echo #

#
# Bug#12735545 - PARSER STACK OVERFLOW WITH NAME_CONST
# CONTAINING OR EXPRESSION
#
--error ER_WRONG_ARGUMENTS
SELECT NAME_CONST('a', -(1 OR 2)) OR 1;
--error ER_WRONG_ARGUMENTS
SELECT NAME_CONST('a', -(1 AND 2)) OR 1;
SELECT NAME_CONST('a', -(1)) OR 1;
25 changes: 24 additions & 1 deletion mysql-test/t/loaddata.test
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ disconnect con1;
--echo #

CREATE TABLE t1(f1 INT);
EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat';
EVAL SELECT 0xE1C330 INTO OUTFILE 't1.dat';
--disable_warnings
LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8;
--enable_warnings
Expand Down Expand Up @@ -658,3 +658,26 @@ SET @@sql_mode= @old_mode;
--remove_file $MYSQLTEST_VARDIR/mysql
DROP TABLE t1;

--echo
--echo #
--echo # Bug#23080148 - Backport of Bug#20683959.
--echo # Bug#20683959 LOAD DATA INFILE IGNORES A SPECIFIC ROW SILENTLY
--echo # UNDER DB CHARSET IS UTF8.
--echo #

CREATE DATABASE d1 CHARSET latin1;
USE d1;
CREATE TABLE t1 (val TEXT);
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;
SELECT COUNT(*) FROM t1;
SELECT HEX(val) FROM t1;

CREATE DATABASE d2 CHARSET utf8;
USE d2;
CREATE TABLE t1 (val TEXT);
--error ER_INVALID_CHARACTER_STRING
LOAD DATA INFILE '../../std_data/bug20683959loaddata.txt' INTO TABLE t1;

DROP TABLE d1.t1, d2.t1;
DROP DATABASE d1;
DROP DATABASE d2;
Loading

0 comments on commit a350e53

Please sign in to comment.