MDEV-15990 innodb: change DB_FOREIGN_DUPLICATE_KEY to DB_DUPLICATE_KEY

during row insert

DB_FOREIGN_DUPLICATE_KEY in row_ins_duplicate_error_in_clust was
motivated by handling the cascade changes during versioned operations.

It was found though, that certain row_update_for_mysql calls could
return DB_FOREIGN_DUPLICATE_KEY, even if there's no foreign relations.

Change DB_FOREIGN_DUPLICATE_KEY to DB_DUPLICATE_KEY in
row_ins_duplicate_error_in_clust.

It will be later converted to DB_FOREIGN_DUPLICATE_KEY in
row_ins_check_foreign_constraint if needed.

Additionally, ha_delete_row should return neither. Ensure it by an
assertion.
This commit is contained in:
Nikita Malyavin 2024-04-28 01:10:36 +02:00
commit c4b76b984f
2 changed files with 4 additions and 1 deletions

View file

@ -8748,6 +8748,9 @@ ha_innobase::delete_row(
ut_ad(!trx->is_bulk_insert());
error = row_update_for_mysql(m_prebuilt);
ut_ad(error != DB_DUPLICATE_KEY);
ut_ad(error != DB_FOREIGN_DUPLICATE_KEY);
#ifdef WITH_WSREP
if (error == DB_SUCCESS && trx->is_wsrep()
&& wsrep_thd_is_local(m_user_thd)

View file

@ -2412,7 +2412,7 @@ duplicate:
&trx_id_len);
ut_ad(trx_id_len == DATA_TRX_ID_LEN);
if (trx->id == trx_read_trx_id(trx_id)) {
err = DB_FOREIGN_DUPLICATE_KEY;
err = DB_DUPLICATE_KEY;
}
}
goto func_exit;