Merge 10.6 into 10.11

This commit is contained in:
Marko Mäkelä 2024-10-03 10:55:08 +03:00
commit 63913ce5af
519 changed files with 5112 additions and 995 deletions

View file

@ -10141,8 +10141,8 @@ wsrep_append_key(
static bool
referenced_by_foreign_key2(
/*=======================*/
dict_table_t* table,
dict_index_t* index)
const dict_table_t* table,
const dict_index_t* index) noexcept
{
ut_ad(table != NULL);
ut_ad(index != NULL);
@ -12615,13 +12615,13 @@ create_table_info_t::create_foreign_keys()
case FK_OPTION_RESTRICT:
break;
case FK_OPTION_CASCADE:
foreign->type |= DICT_FOREIGN_ON_DELETE_CASCADE;
foreign->type |= foreign->DELETE_CASCADE;
break;
case FK_OPTION_SET_NULL:
foreign->type |= DICT_FOREIGN_ON_DELETE_SET_NULL;
foreign->type |= foreign->DELETE_SET_NULL;
break;
case FK_OPTION_NO_ACTION:
foreign->type |= DICT_FOREIGN_ON_DELETE_NO_ACTION;
foreign->type |= foreign->DELETE_NO_ACTION;
break;
case FK_OPTION_SET_DEFAULT:
// TODO: MDEV-10393 Foreign keys SET DEFAULT action
@ -12636,13 +12636,13 @@ create_table_info_t::create_foreign_keys()
case FK_OPTION_RESTRICT:
break;
case FK_OPTION_CASCADE:
foreign->type |= DICT_FOREIGN_ON_UPDATE_CASCADE;
foreign->type |= foreign->UPDATE_CASCADE;
break;
case FK_OPTION_SET_NULL:
foreign->type |= DICT_FOREIGN_ON_UPDATE_SET_NULL;
foreign->type |= foreign->UPDATE_SET_NULL;
break;
case FK_OPTION_NO_ACTION:
foreign->type |= DICT_FOREIGN_ON_UPDATE_NO_ACTION;
foreign->type |= foreign->UPDATE_NO_ACTION;
break;
case FK_OPTION_SET_DEFAULT:
// TODO: MDEV-10393 Foreign keys SET DEFAULT action
@ -15527,28 +15527,43 @@ get_foreign_key_info(
name = thd_make_lex_string(thd, name, ptr,
strlen(ptr), 1);
f_key_info.foreign_fields.push_back(name);
if (dict_index_t* fidx = foreign->foreign_index) {
if (fidx->fields[i].col->is_nullable()) {
f_key_info.set_nullable(thd, false, i,
foreign->n_fields);
}
}
ptr = foreign->referenced_col_names[i];
name = thd_make_lex_string(thd, name, ptr,
strlen(ptr), 1);
f_key_info.referenced_fields.push_back(name);
if (dict_index_t* ref_idx = foreign->referenced_index) {
if (ref_idx->fields[i].col->is_nullable()) {
f_key_info.set_nullable(thd, true, i,
foreign->n_fields);
}
}
} while (++i < foreign->n_fields);
if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) {
if (foreign->type & foreign->DELETE_CASCADE) {
f_key_info.delete_method = FK_OPTION_CASCADE;
} else if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) {
} else if (foreign->type & foreign->DELETE_SET_NULL) {
f_key_info.delete_method = FK_OPTION_SET_NULL;
} else if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) {
} else if (foreign->type & foreign->DELETE_NO_ACTION) {
f_key_info.delete_method = FK_OPTION_NO_ACTION;
} else {
f_key_info.delete_method = FK_OPTION_RESTRICT;
}
if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) {
if (foreign->type & foreign->UPDATE_CASCADE) {
f_key_info.update_method = FK_OPTION_CASCADE;
} else if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) {
} else if (foreign->type & foreign->UPDATE_SET_NULL) {
f_key_info.update_method = FK_OPTION_SET_NULL;
} else if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) {
} else if (foreign->type & foreign->UPDATE_NO_ACTION) {
f_key_info.update_method = FK_OPTION_NO_ACTION;
} else {
f_key_info.update_method = FK_OPTION_RESTRICT;
@ -15689,14 +15704,12 @@ bool ha_innobase::can_switch_engines()
m_prebuilt->table->referenced_set.empty());
}
/*******************************************************************//**
Checks if a table is referenced by a foreign key. The MySQL manual states that
a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a
/** Checks if a table is referenced by a foreign key. The MySQL manual states
that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a
delete is then allowed internally to resolve a duplicate key conflict in
REPLACE, not an update.
@return > 0 if referenced by a FOREIGN KEY */
uint ha_innobase::referenced_by_foreign_key()
@return whether the table is referenced by a FOREIGN KEY */
bool ha_innobase::referenced_by_foreign_key() const noexcept
{
dict_sys.freeze(SRW_LOCK_CALL);
const bool empty= m_prebuilt->table->referenced_set.empty();
@ -16212,10 +16225,10 @@ ha_innobase::external_lock(
}
DBUG_RETURN(0);
} else {
DEBUG_SYNC_C("ha_innobase_end_statement");
}
DEBUG_SYNC_C("ha_innobase_end_statement");
/* MySQL is releasing a table lock */
trx->n_mysql_tables_in_use--;
@ -16242,14 +16255,6 @@ ha_innobase::external_lock(
}
}
if (!trx_is_started(trx)
&& lock_type != F_UNLCK
&& (m_prebuilt->select_lock_type != LOCK_NONE
|| m_prebuilt->stored_select_lock_type != LOCK_NONE)) {
trx->will_lock = true;
}
DBUG_RETURN(0);
}