diff options
author | heikki@hundin.mysql.fi <> | 2004-02-09 23:57:29 +0200 |
---|---|---|
committer | heikki@hundin.mysql.fi <> | 2004-02-09 23:57:29 +0200 |
commit | d9790a406c69a46eb197cea725c1e7c7e480ac41 (patch) | |
tree | 4b1a405fb8e787dcba8a5a3f77ac537aa6b874fe /sql/sql_insert.cc | |
parent | d2d1e6f7261846c34a93fe17c1c10a3a0be2e3ca (diff) | |
download | mariadb-git-d9790a406c69a46eb197cea725c1e7c7e480ac41.tar.gz |
row0mysql.c:
Allow always DROPping of a table which is only referenced by FOREIGN KEY constraints from the same table
Many files:
Do not let REPLACE to perform internally an UPDATE if the table is referenced by a FOREIGN KEY: the manual says that REPLACE must resolve a duplicate key error semantically with DELETE(s) + INSERT, and not by an UPDATE; the internal update caused foreign key checks and cascaded operations to behave in a semantically wrong way
Diffstat (limited to 'sql/sql_insert.cc')
-rw-r--r-- | sql/sql_insert.cc | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 97b7c1db03d..4d7a9f7e508 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -442,7 +442,15 @@ int write_record(TABLE *table,COPY_INFO *info) HA_READ_KEY_EXACT)))) goto err; } - if (last_uniq_key(table,key_nr)) + /* + The manual defines the REPLACE semantics that it is either an INSERT or + DELETE(s) + INSERT; FOREIGN KEY checks do not function in the defined + way if we allow MySQL to convert the latter operation internally to an + UPDATE. + */ + + if (last_uniq_key(table,key_nr) + && !table->file->referenced_by_foreign_key()) { if ((error=table->file->update_row(table->record[1],table->record[0]))) goto err; |