Skip to content
Permalink
Browse files
Merge 10.4 into 10.5
  • Loading branch information
dr-m committed Jun 2, 2022
2 parents e7de50a + 96f4b4a commit 4b3c3e5
Show file tree
Hide file tree
Showing 36 changed files with 800 additions and 1,191 deletions.
@@ -1,6 +1,6 @@
/*
Copyright (c) 2001, 2012, Oracle and/or its affiliates.
Copyright (c) 2009, 2020, MariaDB
Copyright (c) 2009, 2022, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -102,6 +102,7 @@ enum options_client
OPT_IGNORE_DATA,
OPT_PRINT_ROW_COUNT, OPT_PRINT_ROW_EVENT_POSITIONS,
OPT_CHECK_IF_UPGRADE_NEEDED,
OPT_COMPATIBILTY_CLEARTEXT_PLUGIN,
OPT_SHUTDOWN_WAIT_FOR_SLAVES,
OPT_COPY_S3_TABLES,
OPT_PRINT_TABLE_METADATA,
@@ -1514,6 +1514,8 @@ static struct my_option my_long_options[] =
&delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"execute", 'e', "Execute command and quit. (Disables --force and history file.)", 0,
0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"enable-cleartext-plugin", OPT_COMPATIBILTY_CLEARTEXT_PLUGIN, "Obsolete option. Exists only for MySQL compatibility.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"vertical", 'E', "Print the output of a query (rows) vertically.",
&vertical, &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0,
0},
@@ -1812,6 +1814,14 @@ get_one_option(const struct my_option *opt, const char *argument, const char *)
printf("WARNING: --server-arg option not supported in this configuration.\n");
#endif
break;
case OPT_COMPATIBILTY_CLEARTEXT_PLUGIN:
/*
This option exists in MySQL client but not in MariaDB. Users switching from
MySQL might still have this option in their commands, and it will not work
in MariaDB unless it is handled. Therefore output a warning and continue.
*/
printf("WARNING: option '--enable-cleartext-plugin' is obsolete.\n");
break;
case 'A':
opt_rehash= 0;
break;
@@ -1,5 +1,6 @@
/******************************************************
Copyright (c) 2011-2013 Percona LLC and/or its affiliates.
Copyright (c) 2022, MariaDB Corporation.
Compressing datasink implementation for XtraBackup.
@@ -32,11 +33,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
typedef struct {
pthread_t id;
uint num;
pthread_mutex_t ctrl_mutex;
pthread_cond_t ctrl_cond;
pthread_mutex_t data_mutex;
pthread_cond_t data_cond;
my_bool started;
my_bool data_avail;
my_bool cancelled;
const char *from;
@@ -206,14 +204,13 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)

thd = threads + i;

pthread_mutex_lock(&thd->ctrl_mutex);
pthread_mutex_lock(&thd->data_mutex);

chunk_len = (len > COMPRESS_CHUNK_SIZE) ?
COMPRESS_CHUNK_SIZE : len;
thd->from = ptr;
thd->from_len = chunk_len;

pthread_mutex_lock(&thd->data_mutex);
thd->data_avail = TRUE;
pthread_cond_signal(&thd->data_cond);
pthread_mutex_unlock(&thd->data_mutex);
@@ -239,26 +236,24 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)

xb_a(threads[i].to_len > 0);

if (ds_write(dest_file, "NEWBNEWB", 8) ||
write_uint64_le(dest_file,
comp_file->bytes_processed)) {
msg("compress: write to the destination stream "
"failed.");
return 1;
bool fail = ds_write(dest_file, "NEWBNEWB", 8) ||
write_uint64_le(dest_file,
comp_file->bytes_processed);
comp_file->bytes_processed += threads[i].from_len;

if (!fail) {
fail = write_uint32_le(dest_file, threads[i].adler) ||
ds_write(dest_file, threads[i].to,
threads[i].to_len);
}

comp_file->bytes_processed += threads[i].from_len;
pthread_mutex_unlock(&threads[i].data_mutex);

if (write_uint32_le(dest_file, threads[i].adler) ||
ds_write(dest_file, threads[i].to,
threads[i].to_len)) {
if (fail) {
msg("compress: write to the destination stream "
"failed.");
return 1;
}

pthread_mutex_unlock(&threads[i].data_mutex);
pthread_mutex_unlock(&threads[i].ctrl_mutex);
}
}

@@ -328,6 +323,23 @@ write_uint64_le(ds_file_t *file, ulonglong n)
return ds_write(file, tmp, sizeof(tmp));
}

static
void
destroy_worker_thread(comp_thread_ctxt_t *thd)
{
pthread_mutex_lock(&thd->data_mutex);
thd->cancelled = TRUE;
pthread_cond_signal(&thd->data_cond);
pthread_mutex_unlock(&thd->data_mutex);

pthread_join(thd->id, NULL);

pthread_cond_destroy(&thd->data_cond);
pthread_mutex_destroy(&thd->data_mutex);

my_free(thd->to);
}

static
comp_thread_ctxt_t *
create_worker_threads(uint n)
@@ -342,53 +354,31 @@ create_worker_threads(uint n)
comp_thread_ctxt_t *thd = threads + i;

thd->num = i + 1;
thd->started = FALSE;
thd->cancelled = FALSE;
thd->data_avail = FALSE;

thd->to = (char *) my_malloc(PSI_NOT_INSTRUMENTED,
COMPRESS_CHUNK_SIZE + MY_QLZ_COMPRESS_OVERHEAD, MYF(MY_FAE));

/* Initialize the control mutex and condition var */
if (pthread_mutex_init(&thd->ctrl_mutex, NULL) ||
pthread_cond_init(&thd->ctrl_cond, NULL)) {
goto err;
}

/* Initialize and data mutex and condition var */
if (pthread_mutex_init(&thd->data_mutex, NULL) ||
pthread_cond_init(&thd->data_cond, NULL)) {
goto err;
}

pthread_mutex_lock(&thd->ctrl_mutex);

if (pthread_create(&thd->id, NULL, compress_worker_thread_func,
thd)) {
msg("compress: pthread_create() failed: "
"errno = %d", errno);
pthread_mutex_unlock(&thd->ctrl_mutex);
goto err;
}
}

/* Wait for the threads to start */
for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;

while (thd->started == FALSE)
pthread_cond_wait(&thd->ctrl_cond, &thd->ctrl_mutex);
pthread_mutex_unlock(&thd->ctrl_mutex);
}

return threads;

err:
while (i > 0) {
comp_thread_ctxt_t *thd;
i--;
thd = threads + i;
pthread_mutex_unlock(&thd->ctrl_mutex);
for (; i; i--) {
destroy_worker_thread(threads + i);
}

my_free(threads);
@@ -402,21 +392,7 @@ destroy_worker_threads(comp_thread_ctxt_t *threads, uint n)
uint i;

for (i = 0; i < n; i++) {
comp_thread_ctxt_t *thd = threads + i;

pthread_mutex_lock(&thd->data_mutex);
threads[i].cancelled = TRUE;
pthread_cond_signal(&thd->data_cond);
pthread_mutex_unlock(&thd->data_mutex);

pthread_join(thd->id, NULL);

pthread_cond_destroy(&thd->data_cond);
pthread_mutex_destroy(&thd->data_mutex);
pthread_cond_destroy(&thd->ctrl_cond);
pthread_mutex_destroy(&thd->ctrl_mutex);

my_free(thd->to);
destroy_worker_thread(threads + i);
}

my_free(threads);
@@ -428,19 +404,9 @@ compress_worker_thread_func(void *arg)
{
comp_thread_ctxt_t *thd = (comp_thread_ctxt_t *) arg;

pthread_mutex_lock(&thd->ctrl_mutex);

pthread_mutex_lock(&thd->data_mutex);

thd->started = TRUE;
pthread_cond_signal(&thd->ctrl_cond);

pthread_mutex_unlock(&thd->ctrl_mutex);

while (1) {
thd->data_avail = FALSE;
pthread_cond_signal(&thd->data_cond);

while (!thd->data_avail && !thd->cancelled) {
pthread_cond_wait(&thd->data_cond, &thd->data_mutex);
}
@@ -507,6 +507,21 @@ the section called \(lqMYSQL COMMANDS\(rq\&.
.sp -1
.IP \(bu 2.3
.\}
.\" mysql: enable cleartext plugin option
.\" enable cleartext plugin option: mysql
\fB\-\-enable\-cleartext\-plugin\fR
.sp
Obsolete option\&. Exists only for MySQL compatibility\&.
.RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
.\" mysql: execute option
.\" execute option: mysql
\fB\-\-execute=\fR\fB\fIstatement\fR\fR,
@@ -629,4 +629,7 @@ drop table t1;
#
# MDEV-15538 '-N' Produce html output wrong
#
<TABLE BORDER=1><TR><TD>1</TD></TR></TABLE>
<TABLE BORDER=1><TR><TD>1</TD></TR></TABLE>
WARNING: option '--enable-cleartext-plugin' is obsolete.
1
1
@@ -708,3 +708,11 @@ drop table t1;
--echo # MDEV-15538 '-N' Produce html output wrong
--echo #
--exec $MYSQL -NHe "select 1 as a"


#
# Test obsolete option --enable-cleartext-plugin
# This should proceed with a warning
#
--echo
--exec $MYSQL test --enable-cleartext-plugin -e "select 1"
@@ -6,7 +6,18 @@ drop table if exists t1, t2;
CREATE TABLE t1 (a int);
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
ERROR 42000: Can't open table
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
DROP VIEW v1;
DROP TABLE t1;
#
# MDEV-28599 EXCHANGE PARTITION on view causes ER_CHECK_NO_SUCH_TABLE instead of ER_WRONG_OBJECT
#
CREATE TABLE t1 (a int)
PARTITION BY HASH (a)
PARTITIONS 2;
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
ERROR HY000: 'test.v1' is not of type 'BASE TABLE'
DROP VIEW v1;
DROP TABLE t1;
#
@@ -16,7 +16,19 @@ let $MYSQLD_DATADIR= `SELECT @@datadir`;
--echo #
CREATE TABLE t1 (a int);
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
--error ER_CHECK_NO_SUCH_TABLE
--error ER_WRONG_OBJECT
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
DROP VIEW v1;
DROP TABLE t1;

--echo #
--echo # MDEV-28599 EXCHANGE PARTITION on view causes ER_CHECK_NO_SUCH_TABLE instead of ER_WRONG_OBJECT
--echo #
CREATE TABLE t1 (a int)
PARTITION BY HASH (a)
PARTITIONS 2;
CREATE OR REPLACE VIEW v1 AS SELECT * FROM t1;
--error ER_WRONG_OBJECT
ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE v1;
DROP VIEW v1;
DROP TABLE t1;
@@ -12,3 +12,6 @@ INSERT INTO t1 VALUES (NEXT VALUE FOR Seq1_1);
ERROR 23000: Duplicate entry '1' for key 'PRIMARY'
DROP SEQUENCE Seq1_1;
DROP TABLE t1;
CALL mtr.add_suppression("SEQUENCES declared without `NOCACHE` will not behave correctly in galera cluster.");
connection node_2;
CALL mtr.add_suppression("SEQUENCES declared without `NOCACHE` will not behave correctly in galera cluster.");
@@ -0,0 +1,54 @@
connection node_2;
connection node_1;
CREATE SEQUENCE seq_nocache ENGINE=InnoDB;
DROP SEQUENCE seq_nocache;
CALL mtr.add_suppression("SEQUENCES declared without `NOCACHE` will not behave correctly in galera cluster.");
connection node_2;
CALL mtr.add_suppression("SEQUENCES declared without `NOCACHE` will not behave correctly in galera cluster.");
connection node_1;
CREATE SEQUENCE seq NOCACHE ENGINE=InnoDB;
SELECT NEXTVAL(seq) = 1;
NEXTVAL(seq) = 1
1
connection node_2;
SELECT NEXTVAL(seq) = 2;
NEXTVAL(seq) = 2
1
connection node_1;
SELECT NEXTVAL(seq) = 3;
NEXTVAL(seq) = 3
1
SELECT SETVAL(seq, 100);
SETVAL(seq, 100)
100
connection node_2;
SELECT NEXTVAL(seq) = 101;
NEXTVAL(seq) = 101
1
connection node_1;
SELECT NEXTVAL(seq) = 102;
NEXTVAL(seq) = 102
1
DROP SEQUENCE seq;
CREATE TABLE t1(f1 INT);
CREATE SEQUENCE seq_transaction NOCACHE ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES (0);
SELECT NEXTVAL(seq_transaction);
NEXTVAL(seq_transaction)
1
INSERT INTO t1 VALUES (NEXTVAL(seq_transaction));
COMMIT;
connection node_2;
SELECT COUNT(*) = 2 FROM t1;
COUNT(*) = 2
1
SELECT NEXTVAL(seq_transaction) = 3;
NEXTVAL(seq_transaction) = 3
1
connection node_1;
SELECT NEXTVAL(seq_transaction) = 4;
NEXTVAL(seq_transaction) = 4
1
DROP SEQUENCE seq_transaction;
DROP TABLE t1;

0 comments on commit 4b3c3e5

Please sign in to comment.