Commit e3f6ea50 authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.1 into 10.2

parents 3a42926c 98e185ee
...@@ -249,6 +249,19 @@ Warnings: ...@@ -249,6 +249,19 @@ Warnings:
Warning 1088 failed to load FOREIGN KEY constraints Warning 1088 failed to load FOREIGN KEY constraints
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f); ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
DROP TABLE t1; DROP TABLE t1;
#
# MDEV-18630 Conditional jump or move depends on uninitialised value
# in ib_push_warning / dict_create_foreign_constraints_low
#
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
ALTER IGNORE TABLE t1 ADD FOREIGN KEY (a) REFERENCES t2 (b);
ERROR HY000: Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
SHOW WARNINGS;
Level Code Message
Warning 150 Alter table test/#sql-temporary with foreign key constraint failed. Referenced table `test`.`t2` not found in the data dictionary near 'FOREIGN KEY (a) REFERENCES t2 (b)'.
Error 1005 Can't create table `test`.`t1` (errno: 150 "Foreign key constraint is incorrectly formed")
Warning 1215 Cannot add foreign key constraint
DROP TABLE t1;
# Start of 10.2 tests # Start of 10.2 tests
# #
# MDEV-13246 Stale rows despite ON DELETE CASCADE constraint # MDEV-13246 Stale rows despite ON DELETE CASCADE constraint
......
...@@ -230,6 +230,17 @@ ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f); ...@@ -230,6 +230,17 @@ ALTER TABLE t1 ADD FULLTEXT INDEX ft1 (f);
ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f); ALTER TABLE t1 ADD FULLTEXT INDEX ft2 (f);
DROP TABLE t1; DROP TABLE t1;
--echo #
--echo # MDEV-18630 Conditional jump or move depends on uninitialised value
--echo # in ib_push_warning / dict_create_foreign_constraints_low
--echo #
CREATE TABLE t1 (a INT) ENGINE=InnoDB;
--error ER_CANT_CREATE_TABLE
ALTER IGNORE TABLE t1 ADD FOREIGN KEY (a) REFERENCES t2 (b);
--replace_regex /#sql-[0-9_a-f-]*/#sql-temporary/
SHOW WARNINGS;
DROP TABLE t1;
--echo # Start of 10.2 tests --echo # Start of 10.2 tests
--echo # --echo #
......
...@@ -4386,7 +4386,6 @@ dict_create_foreign_constraints_low( ...@@ -4386,7 +4386,6 @@ dict_create_foreign_constraints_low(
const char* create_table_name; const char* create_table_name;
const char* orig; const char* orig;
char create_name[MAX_TABLE_NAME_LEN + 1]; char create_name[MAX_TABLE_NAME_LEN + 1];
char operation[8];
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(mutex_own(&dict_sys->mutex)); ut_ad(mutex_own(&dict_sys->mutex));
...@@ -4397,41 +4396,33 @@ dict_create_foreign_constraints_low( ...@@ -4397,41 +4396,33 @@ dict_create_foreign_constraints_low(
orig = ptr; orig = ptr;
ptr = dict_accept(cs, ptr, "ALTER", &success); ptr = dict_accept(cs, ptr, "ALTER", &success);
strcpy((char *)operation, success ? "Alter " : "Create "); const char* const operation = success ? "Alter " : "Create ";
if (!success) { if (!success) {
orig = ptr; orig = ptr;
ptr = dict_scan_to(ptr, "CREATE"); ptr = dict_scan_to(ptr, "CREATE");
ptr = dict_scan_to(ptr, "TABLE"); ptr = dict_scan_to(ptr, "TABLE");
ptr = dict_accept(cs, ptr, "TABLE", &success); ptr = dict_accept(cs, ptr, "TABLE", &success);
create_table_name = NULL;
if (success) { if (success) {
ptr = dict_scan_table_name(cs, ptr, &table_to_create, name, ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
&success, heap, &create_table_name); &success, heap, &create_table_name);
} }
if (success) { ptr = orig;
char *bufend; const char* n = create_table_name ? create_table_name : name;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, char *bufend = innobase_convert_name(create_name, MAX_TABLE_NAME_LEN,
create_table_name, strlen(create_table_name), n, strlen(n), trx->mysql_thd);
trx->mysql_thd); create_name[bufend-create_name] = '\0';
create_name[bufend-create_name]='\0'; } else {
ptr = orig; strncpy(create_name, name, sizeof create_name);
} else { create_name[(sizeof create_name) - 1] = '\0';
char *bufend;
ptr = orig;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
name, strlen(name), trx->mysql_thd);
create_name[bufend-create_name]='\0';
}
goto loop;
} }
if (table == NULL) { if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, create_name); dict_foreign_error_report_low(ef, create_name);
dict_foreign_error_report_low(ef, create_name);
fprintf(ef, "%s table %s with foreign key constraint" fprintf(ef, "%s table %s with foreign key constraint"
" failed. Table %s not found from data dictionary." " failed. Table %s not found from data dictionary."
" Error close to %s.\n", " Error close to %s.\n",
...@@ -4466,19 +4457,13 @@ dict_create_foreign_constraints_low( ...@@ -4466,19 +4457,13 @@ dict_create_foreign_constraints_low(
ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name, ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
&success, heap, &referenced_table_name); &success, heap, &referenced_table_name);
if (table_to_alter) { {
char *bufend; const char* n = table_to_alter
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, ? table_to_alter->name.m_name : referenced_table_name;
table_to_alter->name.m_name, strlen(table_to_alter->name.m_name), char* bufend = innobase_convert_name(
trx->mysql_thd); create_name, MAX_TABLE_NAME_LEN, n, strlen(n),
create_name[bufend-create_name]='\0'; trx->mysql_thd);
} else {
char *bufend;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
referenced_table_name, strlen(referenced_table_name),
trx->mysql_thd);
create_name[bufend-create_name]='\0'; create_name[bufend-create_name]='\0';
} }
if (!success) { if (!success) {
......
...@@ -4405,7 +4405,6 @@ dict_create_foreign_constraints_low( ...@@ -4405,7 +4405,6 @@ dict_create_foreign_constraints_low(
const char* create_table_name; const char* create_table_name;
const char* orig; const char* orig;
char create_name[MAX_TABLE_NAME_LEN + 1]; char create_name[MAX_TABLE_NAME_LEN + 1];
char operation[8];
ut_ad(!srv_read_only_mode); ut_ad(!srv_read_only_mode);
ut_ad(mutex_own(&(dict_sys->mutex))); ut_ad(mutex_own(&(dict_sys->mutex)));
...@@ -4416,41 +4415,33 @@ dict_create_foreign_constraints_low( ...@@ -4416,41 +4415,33 @@ dict_create_foreign_constraints_low(
orig = ptr; orig = ptr;
ptr = dict_accept(cs, ptr, "ALTER", &success); ptr = dict_accept(cs, ptr, "ALTER", &success);
strcpy((char *)operation, success ? "Alter " : "Create "); const char* const operation = success ? "Alter " : "Create ";
if (!success) { if (!success) {
orig = ptr; orig = ptr;
ptr = dict_scan_to(ptr, "CREATE"); ptr = dict_scan_to(ptr, "CREATE");
ptr = dict_scan_to(ptr, "TABLE"); ptr = dict_scan_to(ptr, "TABLE");
ptr = dict_accept(cs, ptr, "TABLE", &success); ptr = dict_accept(cs, ptr, "TABLE", &success);
create_table_name = NULL;
if (success) { if (success) {
ptr = dict_scan_table_name(cs, ptr, &table_to_create, name, ptr = dict_scan_table_name(cs, ptr, &table_to_create, name,
&success, heap, &create_table_name); &success, heap, &create_table_name);
} }
if (success) { ptr = orig;
char *bufend; const char* n = create_table_name ? create_table_name : name;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, char *bufend = innobase_convert_name(create_name, MAX_TABLE_NAME_LEN,
create_table_name, strlen(create_table_name), n, strlen(n), trx->mysql_thd, TRUE);
trx->mysql_thd, TRUE); create_name[bufend-create_name] = '\0';
create_name[bufend-create_name]='\0'; } else {
ptr = orig; strncpy(create_name, name, sizeof create_name);
} else { create_name[(sizeof create_name) - 1] = '\0';
char *bufend;
ptr = orig;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
name, strlen(name), trx->mysql_thd, TRUE);
create_name[bufend-create_name]='\0';
}
goto loop;
} }
if (table == NULL) { if (table == NULL) {
mutex_enter(&dict_foreign_err_mutex); mutex_enter(&dict_foreign_err_mutex);
dict_foreign_error_report_low(ef, create_name); dict_foreign_error_report_low(ef, create_name);
dict_foreign_error_report_low(ef, create_name);
fprintf(ef, "%s table %s with foreign key constraint" fprintf(ef, "%s table %s with foreign key constraint"
" failed. Table %s not found from data dictionary." " failed. Table %s not found from data dictionary."
" Error close to %s.\n", " Error close to %s.\n",
...@@ -4485,19 +4476,13 @@ dict_create_foreign_constraints_low( ...@@ -4485,19 +4476,13 @@ dict_create_foreign_constraints_low(
ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name, ptr = dict_scan_table_name(cs, ptr, &table_to_alter, name,
&success, heap, &referenced_table_name); &success, heap, &referenced_table_name);
if (table_to_alter) { {
char *bufend; const char* n = table_to_alter
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN, ? table_to_alter->name : referenced_table_name;
table_to_alter->name, strlen(table_to_alter->name), char* bufend = innobase_convert_name(
trx->mysql_thd, TRUE); create_name, MAX_TABLE_NAME_LEN, n, strlen(n),
create_name[bufend-create_name]='\0'; trx->mysql_thd, TRUE);
} else {
char *bufend;
bufend = innobase_convert_name((char *)create_name, MAX_TABLE_NAME_LEN,
referenced_table_name, strlen(referenced_table_name),
trx->mysql_thd, TRUE);
create_name[bufend-create_name]='\0'; create_name[bufend-create_name]='\0';
} }
if (!success) { if (!success) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment