summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormkaruza <mario.karuza@galeracluster.com>2021-03-31 11:29:51 +0200
committerJan Lindström <jan.lindstrom@mariadb.com>2021-03-31 13:30:09 +0300
commit71c08173fb2b366b236f9146503bd66934906386 (patch)
tree134c287afeb40802517de7b887614c70ad45649e
parent8341f582b2fe864027954282f96fb84e560cae72 (diff)
downloadmariadb-git-bb-10.4-MDEV-25047.tar.gz
MDEV-25047: SIGSEGV in mach_read_from_n_little_endianbb-10.4-MDEV-25047
Virtual column fields are not found in prebuilt data type, so we should match InnoDB fields with `get_innobase_type_from_mysql_type` method. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
-rw-r--r--mysql-test/suite/galera/r/galera_virtual_column.result19
-rw-r--r--mysql-test/suite/galera/t/galera_virtual_column.test13
-rw-r--r--storage/innobase/handler/ha_innodb.cc5
3 files changed, 36 insertions, 1 deletions
diff --git a/mysql-test/suite/galera/r/galera_virtual_column.result b/mysql-test/suite/galera/r/galera_virtual_column.result
index 71820ed8225..4e5d5097d9b 100644
--- a/mysql-test/suite/galera/r/galera_virtual_column.result
+++ b/mysql-test/suite/galera/r/galera_virtual_column.result
@@ -17,3 +17,22 @@ connection node_2;
connection node_1;
DROP TABLE c;
DROP TABLE p;
+CREATE TABLE t (a INT,b INT,c INT,d INT,e INT,f INT GENERATED ALWAYS AS (a+b)VIRTUAL,g INT,h BLOB,i INT,UNIQUE KEY(d,h));
+INSERT INTO t (a,b)VALUES(0,0), (0,0), (0,0), (0,0), (0,0);
+SELECT * FROM t;
+a b c d e f g h i
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+connection node_2;
+SELECT * FROM t;
+a b c d e f g h i
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+0 0 NULL NULL NULL 0 NULL NULL NULL
+connection node_1;
+DROP TABLE t;
diff --git a/mysql-test/suite/galera/t/galera_virtual_column.test b/mysql-test/suite/galera/t/galera_virtual_column.test
index 84e1da024f1..ed75a1e301b 100644
--- a/mysql-test/suite/galera/t/galera_virtual_column.test
+++ b/mysql-test/suite/galera/t/galera_virtual_column.test
@@ -40,3 +40,16 @@ SELECT * FROM c;
--connection node_1
DROP TABLE c;
DROP TABLE p;
+
+#
+# MDEV-25047: SIGSEGV in mach_read_from_n_little_endian
+#
+CREATE TABLE t (a INT,b INT,c INT,d INT,e INT,f INT GENERATED ALWAYS AS (a+b)VIRTUAL,g INT,h BLOB,i INT,UNIQUE KEY(d,h));
+INSERT INTO t (a,b)VALUES(0,0), (0,0), (0,0), (0,0), (0,0);
+SELECT * FROM t;
+
+--connection node_2
+SELECT * FROM t;
+
+--connection node_1
+DROP TABLE t;
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 8f6fe73a93c..4a298772f49 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -8735,6 +8735,8 @@ wsrep_calc_row_hash(
row_prebuilt_t* prebuilt) /*!< in: InnoDB prebuilt struct */
{
ulint len;
+ ulint col_type;
+ ulint is_unsigned;
const byte* ptr;
void *ctx = alloca(my_md5_context_size());
@@ -8751,8 +8753,9 @@ wsrep_calc_row_hash(
ptr = (const byte*) row + get_field_offset(table, field);
len = field->pack_length();
+ col_type = get_innobase_type_from_mysql_type(&is_unsigned, field);
- switch (prebuilt->table->cols[i].mtype) {
+ switch (col_type) {
case DATA_BLOB:
ptr = row_mysql_read_blob_ref(&len, ptr, len);