Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Aug 22, 2022
2 parents f02ca42 + 1d90d68 commit d65a2b7
Show file tree
Hide file tree
Showing 18 changed files with 253 additions and 97 deletions.
16 changes: 0 additions & 16 deletions cmake/os/Darwin.cmake

This file was deleted.

51 changes: 43 additions & 8 deletions extra/mariabackup/ds_compress.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ typedef struct {
pthread_t id;
uint num;
pthread_mutex_t data_mutex;
pthread_cond_t avail_cond;
pthread_cond_t data_cond;
pthread_cond_t done_cond;
my_bool data_avail;
pthread_t data_avail;
my_bool cancelled;
const char *from;
size_t from_len;
Expand Down Expand Up @@ -195,9 +196,13 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)
threads = comp_ctxt->threads;
nthreads = comp_ctxt->nthreads;

const pthread_t self = pthread_self();

ptr = (const char *) buf;
while (len > 0) {
uint max_thread;
bool wait = nthreads == 1;
retry:
bool submitted = false;

/* Send data to worker threads for compression */
for (i = 0; i < nthreads; i++) {
Expand All @@ -206,30 +211,54 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)
thd = threads + i;

pthread_mutex_lock(&thd->data_mutex);
if (thd->data_avail == pthread_t(~0UL)) {
} else if (!wait) {
skip:
pthread_mutex_unlock(&thd->data_mutex);
continue;
} else {
for (;;) {
pthread_cond_wait(&thd->avail_cond,
&thd->data_mutex);
if (thd->data_avail
== pthread_t(~0UL)) {
break;
}
goto skip;
}
}

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

thd->data_avail = TRUE;
thd->data_avail = self;
pthread_cond_signal(&thd->data_cond);
pthread_mutex_unlock(&thd->data_mutex);

submitted = true;
len -= chunk_len;
if (len == 0) {
break;
}
ptr += chunk_len;
}

max_thread = (i < nthreads) ? i : nthreads - 1;
if (!submitted) {
wait = true;
goto retry;
}

/* Reap and stream the compressed data */
for (i = 0; i <= max_thread; i++) {
for (i = 0; i < nthreads; i++) {
thd = threads + i;

pthread_mutex_lock(&thd->data_mutex);
if (thd->data_avail != self) {
pthread_mutex_unlock(&thd->data_mutex);
continue;
}

while (!thd->to_len) {
pthread_cond_wait(&thd->done_cond,
&thd->data_mutex);
Expand All @@ -247,6 +276,8 @@ compress_write(ds_file_t *file, const uchar *buf, size_t len)
}

thd->to_len = 0;
thd->data_avail = pthread_t(~0UL);
pthread_cond_signal(&thd->avail_cond);
pthread_mutex_unlock(&thd->data_mutex);

if (fail) {
Expand Down Expand Up @@ -334,6 +365,7 @@ destroy_worker_thread(comp_thread_ctxt_t *thd)

pthread_join(thd->id, NULL);

pthread_cond_destroy(&thd->avail_cond);
pthread_cond_destroy(&thd->data_cond);
pthread_cond_destroy(&thd->done_cond);
pthread_mutex_destroy(&thd->data_mutex);
Expand Down Expand Up @@ -364,11 +396,14 @@ create_worker_threads(uint n)

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

thd->data_avail = pthread_t(~0UL);

if (pthread_create(&thd->id, NULL, compress_worker_thread_func,
thd)) {
msg("compress: pthread_create() failed: "
Expand Down Expand Up @@ -410,13 +445,13 @@ compress_worker_thread_func(void *arg)
pthread_mutex_lock(&thd->data_mutex);

while (1) {
while (!thd->data_avail && !thd->cancelled) {
while (!thd->cancelled
&& (thd->to_len || thd->data_avail == pthread_t(~0UL))) {
pthread_cond_wait(&thd->data_cond, &thd->data_mutex);
}

if (thd->cancelled)
break;
thd->data_avail = FALSE;
thd->to_len = qlz_compress(thd->from, thd->to, thd->from_len,
&thd->state);

Expand Down
27 changes: 27 additions & 0 deletions mysql-test/main/func_json.result
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,33 @@ j
{"ID": "4", "Name": "Betty", "Age": 19}
drop table t1;
#
# MDEV-27151: JSON_VALUE() does not parse NULL properties properly
#
#
# It is correct for JSON_EXTRACT() to give null instead of "NULL" because
# it returns the json literal that is put inside json.
# Hence it should return null as in 'null' string and not SQL NULL.
# JSON_VALUE() returns the "VALUE" so it is correct for it to return SQl NULL
#
SELECT NULL;
NULL
NULL
SELECT JSON_VALUE('{"nulltest": null}', '$.nulltest');
JSON_VALUE('{"nulltest": null}', '$.nulltest')
NULL
SELECT 1 + NULL;
1 + NULL
NULL
SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest');
1 + JSON_VALUE('{"nulltest": null}', '$.nulltest')
NULL
SELECT NULL;
NULL
NULL
SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a');
JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a')
null
#
# End of 10.3 tests
#
#
Expand Down
19 changes: 19 additions & 0 deletions mysql-test/main/func_json.test
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,25 @@ SELECT * FROM t1 WHERE JSON_EXTRACT(j, '$.Age')=19;

drop table t1;

--echo #
--echo # MDEV-27151: JSON_VALUE() does not parse NULL properties properly
--echo #
--echo #
--echo # It is correct for JSON_EXTRACT() to give null instead of "NULL" because
--echo # it returns the json literal that is put inside json.
--echo # Hence it should return null as in 'null' string and not SQL NULL.
--echo # JSON_VALUE() returns the "VALUE" so it is correct for it to return SQl NULL
--echo #

SELECT NULL;
SELECT JSON_VALUE('{"nulltest": null}', '$.nulltest');
SELECT 1 + NULL;
SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest');


SELECT NULL;
SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a');

--echo #
--echo # End of 10.3 tests
--echo #
Expand Down
12 changes: 6 additions & 6 deletions mysql-test/suite/innodb/r/check_ibd_filesize,32k.rdiff
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
--- check_ibd_filesize.result
+++ check_ibd_filesize.result,32k
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:29:25.129637040 +0530
@@ -3,18 +3,12 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 196608
-# bytes: 65536
+# bytes: 131072
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
-# bytes: 9437184
+# bytes: 786432
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 196608
-# bytes: 65536
+# bytes: 131072
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
-# bytes: 4194304
-DROP TABLE t1;
Expand Down
12 changes: 6 additions & 6 deletions mysql-test/suite/innodb/r/check_ibd_filesize,4k.rdiff
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
--- check_ibd_filesize.result
+++ check_ibd_filesize.result,4k
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:39.288769153 +0530
@@ -3,18 +3,18 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 24576
-# bytes: 65536
+# bytes: 16384
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
# bytes: 9437184
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 24576
-# bytes: 65536
+# bytes: 16384
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
# bytes: 4194304
DROP TABLE t1;
Expand Down
12 changes: 6 additions & 6 deletions mysql-test/suite/innodb/r/check_ibd_filesize,64k.rdiff
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
--- check_ibd_filesize.result
+++ check_ibd_filesize.result,64k
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:30:28.957174270 +0530
@@ -3,18 +3,12 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 393216
-# bytes: 65536
+# bytes: 262144
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
-# bytes: 9437184
+# bytes: 983040
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 393216
-# bytes: 65536
+# bytes: 262144
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
-# bytes: 4194304
-DROP TABLE t1;
Expand Down
12 changes: 6 additions & 6 deletions mysql-test/suite/innodb/r/check_ibd_filesize,8k.rdiff
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
--- check_ibd_filesize.result
+++ check_ibd_filesize.result,8k
--- mysql-test/suite/innodb/r/check_ibd_filesize.result 2022-08-16 17:28:06.462350465 +0530
+++ mysql-test/suite/innodb/r/check_ibd_filesize.reject 2022-08-16 17:31:03.516962339 +0530
@@ -3,18 +3,18 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 49152
-# bytes: 65536
+# bytes: 32768
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
# bytes: 9437184
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
-# bytes: 98304
+# bytes: 49152
-# bytes: 65536
+# bytes: 32768
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
# bytes: 4194304
DROP TABLE t1;
Expand Down
4 changes: 2 additions & 2 deletions mysql-test/suite/innodb/r/check_ibd_filesize.result
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# SPACE IN 5.7 THAN IN 5.6
#
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
# bytes: 98304
# bytes: 65536
INSERT INTO t1 SELECT * FROM seq_1_to_25000;
# bytes: 9437184
DROP TABLE t1;
CREATE TABLE t1 (a INT PRIMARY KEY, b BLOB) ENGINE=InnoDB;
# bytes: 98304
# bytes: 65536
INSERT INTO t1 SELECT seq,REPEAT('a',30000) FROM seq_1_to_20;
# bytes: 4194304
DROP TABLE t1;
Expand Down
1 change: 1 addition & 0 deletions mysql-test/suite/innodb/t/temporary_table.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#

--source include/have_innodb.inc
--source include/innodb_page_size.inc
# Embedded server does not restart of server
--source include/not_embedded.inc
--source include/no_valgrind_without_big.inc
Expand Down
Loading

0 comments on commit d65a2b7

Please sign in to comment.