Commit 37b8691c authored by Sergei Golubchik's avatar Sergei Golubchik

fix the fix and update test results for MDEV-4439

parent bf050b1d
......@@ -51,4 +51,4 @@ RUNNING 4 0 0 7 1 0 REPEATABLE READ 1 1
trx_isolation_level trx_unique_checks trx_foreign_key_checks
SERIALIZABLE 0 0
trx_state trx_isolation_level trx_last_foreign_key_error
RUNNING REPEATABLE READ `test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`)
RUNNING REPEATABLE READ `test`.`t2`, CONSTRAINT `fk1` FOREIGN KEY (`c02`) REFERENCES `t1` (`c01`)
......@@ -315,7 +315,7 @@ CREATE TABLE `t``1` ( `a``` INT PRIMARY KEY) ENGINE=innodb;
CREATE TABLE `t``2` ( `b``` INT PRIMARY KEY, `c``` INT NOT NULL,
FOREIGN KEY fk (`c```) REFERENCES `t``1`(`a```)) ENGINE=innodb;
TRUNCATE `t``1`;
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; select 'oops!'`.`t``2`, CONSTRAINT `t``2_ibfk_1` FOREIGN KEY (`c```) REFERENCES `db1``; select 'oops!'`.`t``1` (`a```))
ERROR 42000: Cannot truncate a table referenced in a foreign key constraint (`db1``; select 'oops!'`.`t``2`, CONSTRAINT `fk` FOREIGN KEY (`c```) REFERENCES `db1``; select 'oops!'`.`t``1` (`a```))
DROP TABLE `t``2`;
DROP TABLE `t``1`;
*** Test correct quoting of DELETE FROM statement binlogged for HEAP table that is emptied due to server restart
......
......@@ -5476,7 +5476,7 @@ handle_if_exists_options(THD *thd, TABLE *table, Alter_info *alter_info)
if (remove_key)
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_KEYNAME, ER(ER_DUP_KEYNAME), key->name.str);
ER_DUP_KEYNAME, ER(ER_DUP_KEYNAME), keyname);
key_it.remove();
if (key->type == Key::FOREIGN_KEY)
{
......
......@@ -4242,18 +4242,45 @@ loop:
goto loop;
}
if (my_isspace(cs, *ptr)) {
ptr1 = dict_accept(cs, ptr, "IF", &success);
if (success) {
if (!my_isspace(cs, *ptr1)) {
goto loop;
}
ptr1 = dict_accept(cs, ptr1, "NOT", &success);
if (!success) {
goto loop;
}
ptr1 = dict_accept(cs, ptr1, "EXISTS", &success);
if (!success) {
goto loop;
}
ptr = ptr1;
}
}
ptr = dict_accept(cs, ptr, "(", &success);
if (!success) {
/* MySQL allows also an index id before the '('; we
skip it */
ptr = dict_skip_word(cs, ptr, &success);
if (!success) {
dict_foreign_report_syntax_err(
name, start_of_latest_foreign, ptr);
if (constraint_name) {
/* MySQL allows also an index id before the '('; we
skip it */
ptr = dict_skip_word(cs, ptr, &success);
if (!success) {
dict_foreign_report_syntax_err(
name, start_of_latest_foreign, ptr);
return(DB_CANNOT_ADD_CONSTRAINT);
}
}
else {
while (my_isspace(cs, *ptr)) {
ptr++;
}
return(DB_CANNOT_ADD_CONSTRAINT);
ptr = dict_scan_id(cs, ptr, heap,
&constraint_name, FALSE, FALSE);
}
ptr = dict_accept(cs, ptr, "(", &success);
......@@ -4727,6 +4754,7 @@ dict_foreign_parse_drop_constraints(
char* str;
size_t len;
const char* ptr;
const char* ptr1;
const char* id;
struct charset_info_st* cs;
......@@ -4777,6 +4805,16 @@ loop:
goto syntax_error;
}
ptr1 = dict_accept(cs, ptr, "IF", &success);
if (success && my_isspace(cs, *ptr1)) {
ptr1 = dict_accept(cs, ptr1, "EXISTS", &success);
if (success) {
ptr = ptr1;
}
}
ptr = dict_scan_id(cs, ptr, heap, &id, FALSE, TRUE);
if (id == NULL) {
......
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