1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

BUG#22037930: INSERT IGNORE FAILS TO IGNORE FOREIGN KEY

CONSTRAINT.

Analysis
=======

INSERT and UPDATE operations using the IGNORE keyword which
causes FOREIGN KEY constraint violations reports an error
despite using the IGNORE keyword.

Foreign key violation errors were not ignored and reported
as errors instead of warnings even when IGNORE was set.

Fix
===
Added code to ignore the foreign key violation errors and
report them as warnings when the IGNORE keyword is used.
This commit is contained in:
Nisha Gopalakrishnan
2016-02-10 19:57:17 +05:30
parent 1fb6d4e6bf
commit d9c541cb1b
6 changed files with 141 additions and 13 deletions

View File

@ -2,7 +2,7 @@
#define HANDLER_INCLUDED
/*
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -303,6 +303,7 @@
/* Flags for method is_fatal_error */
#define HA_CHECK_DUP_KEY 1
#define HA_CHECK_DUP_UNIQUE 2
#define HA_CHECK_FK_ERROR 4
#define HA_CHECK_DUP (HA_CHECK_DUP_KEY + HA_CHECK_DUP_UNIQUE)
enum legacy_db_type
@ -1485,7 +1486,10 @@ public:
if (!error ||
((flags & HA_CHECK_DUP_KEY) &&
(error == HA_ERR_FOUND_DUPP_KEY ||
error == HA_ERR_FOUND_DUPP_UNIQUE)))
error == HA_ERR_FOUND_DUPP_UNIQUE)) ||
((flags & HA_CHECK_FK_ERROR) &&
(error == HA_ERR_ROW_IS_REFERENCED ||
error == HA_ERR_NO_REFERENCED_ROW)))
return FALSE;
return TRUE;
}
@ -2362,4 +2366,6 @@ inline const char *table_case_name(HA_CREATE_INFO *info, const char *name)
return ((lower_case_table_names == 2 && info->alias) ? info->alias : name);
}
void warn_fk_constraint_violation(THD *thd, TABLE *table, int error);
#endif /* HANDLER_INCLUDED */