Description:
If a table contains a UNIQUE constraint that contains a mix of functional and non-functional parts where any non-functional part is declared after any functional part, dumpInstance will segfault.
I've marked the severity of this bug as S2 because there are no error messages aside from the segfault, which makes tracking down the source of the error difficult and will likely break people's production processes.
How to repeat:
CREATE DATABASE testdb;
USE testdb;
CREATE TABLE test (
test_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
col1 CHAR(1),
col2 CHAR(1),
col3 CHAR(1),
UNIQUE ((UPPER(col1)), col2)
);
mysqlsh -- util dumpInstance ./dump --includeSchemas=testdb --includeTables=testdb.test
Acquiring global read lock
Global read lock acquired
Initializing - done
Segmentation fault (core dumped)
The following example UNIQUE patterns will result in a segfault:
UNIQUE ((UPPER(col1)), col2)
UNIQUE (col1, (UPPER(col2)), col3)
UNIQUE ((UPPER(col1)), (UPPER(col2)), col3)
Note that these examples show a non-functional key part after a functional key part, which seems to be the cause of the segfault.
The following example UNIQUE patterns will NOT result in a segfault:
UNIQUE (col1, (UPPER(col2)))
UNIQUE (col1, col2, (UPPER(col3)))
UNIQUE (col1, (UPPER(col2)), (UPPER(col3)))
A hacky workaround exists that requires all trailing non-functional key parts to be wrapped inside an identity-returning function, like COALESCE, which makes that key part functional and should retain uniqueness logic. For example:
UNIQUE(col1, (CONCAT(col1, col2)), (COALESCE(col3)))
Description: If a table contains a UNIQUE constraint that contains a mix of functional and non-functional parts where any non-functional part is declared after any functional part, dumpInstance will segfault. I've marked the severity of this bug as S2 because there are no error messages aside from the segfault, which makes tracking down the source of the error difficult and will likely break people's production processes. How to repeat: CREATE DATABASE testdb; USE testdb; CREATE TABLE test ( test_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, col1 CHAR(1), col2 CHAR(1), col3 CHAR(1), UNIQUE ((UPPER(col1)), col2) ); mysqlsh -- util dumpInstance ./dump --includeSchemas=testdb --includeTables=testdb.test Acquiring global read lock Global read lock acquired Initializing - done Segmentation fault (core dumped) The following example UNIQUE patterns will result in a segfault: UNIQUE ((UPPER(col1)), col2) UNIQUE (col1, (UPPER(col2)), col3) UNIQUE ((UPPER(col1)), (UPPER(col2)), col3) Note that these examples show a non-functional key part after a functional key part, which seems to be the cause of the segfault. The following example UNIQUE patterns will NOT result in a segfault: UNIQUE (col1, (UPPER(col2))) UNIQUE (col1, col2, (UPPER(col3))) UNIQUE (col1, (UPPER(col2)), (UPPER(col3))) A hacky workaround exists that requires all trailing non-functional key parts to be wrapped inside an identity-returning function, like COALESCE, which makes that key part functional and should retain uniqueness logic. For example: UNIQUE(col1, (CONCAT(col1, col2)), (COALESCE(col3)))