Commit 45298b73 authored by Max Kellermann's avatar Max Kellermann Committed by Marko Mäkelä

sql/handler: referenced_by_foreign_key() returns bool

The method was declared to return an unsigned integer, but it is
really a boolean (and used as such by all callers).

A secondary change is the addition of "const" and "noexcept" to this
method.

In ha_mroonga.cpp, I also added "inline" to the two helper methods of
referenced_by_foreign_key().  This allows the compiler to flatten the
method.
parent b88f1267
...@@ -1464,7 +1464,7 @@ class ha_partition :public handler ...@@ -1464,7 +1464,7 @@ class ha_partition :public handler
virtual int get_foreign_key_list(THD *thd, virtual int get_foreign_key_list(THD *thd,
List<FOREIGN_KEY_INFO> *f_key_list) List<FOREIGN_KEY_INFO> *f_key_list)
virtual uint referenced_by_foreign_key() bool referenced_by_foreign_key() const noexcept override
*/ */
bool can_switch_engines() override; bool can_switch_engines() override;
/* /*
......
...@@ -4078,7 +4078,7 @@ class handler :public Sql_alloc ...@@ -4078,7 +4078,7 @@ class handler :public Sql_alloc
virtual int virtual int
get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list)
{ return 0; } { return 0; }
virtual uint referenced_by_foreign_key() { return 0;} virtual bool referenced_by_foreign_key() const noexcept { return false;}
virtual void init_table_handle_for_HANDLER() virtual void init_table_handle_for_HANDLER()
{ return; } /* prepare InnoDB for HANDLER */ { return; } /* prepare InnoDB for HANDLER */
virtual void free_foreign_key_create_info(char* str) {} virtual void free_foreign_key_create_info(char* str) {}
......
...@@ -10052,8 +10052,8 @@ wsrep_append_key( ...@@ -10052,8 +10052,8 @@ wsrep_append_key(
static bool static bool
referenced_by_foreign_key2( referenced_by_foreign_key2(
/*=======================*/ /*=======================*/
dict_table_t* table, const dict_table_t* table,
dict_index_t* index) const dict_index_t* index) noexcept
{ {
ut_ad(table != NULL); ut_ad(table != NULL);
ut_ad(index != NULL); ut_ad(index != NULL);
...@@ -15451,16 +15451,12 @@ ha_innobase::can_switch_engines(void) ...@@ -15451,16 +15451,12 @@ ha_innobase::can_switch_engines(void)
DBUG_RETURN(can_switch); DBUG_RETURN(can_switch);
} }
/*******************************************************************//** /** Checks if a table is referenced by a foreign key. The MySQL manual states
Checks if a table is referenced by a foreign key. The MySQL manual states that that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a
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 delete is then allowed internally to resolve a duplicate key conflict in
REPLACE, not an update. REPLACE, not an update.
@return > 0 if referenced by a FOREIGN KEY */ @return whether the table is referenced by a FOREIGN KEY */
bool ha_innobase::referenced_by_foreign_key() const noexcept
uint
ha_innobase::referenced_by_foreign_key(void)
/*========================================*/
{ {
if (dict_table_is_referenced_by_foreign_key(m_prebuilt->table)) { if (dict_table_is_referenced_by_foreign_key(m_prebuilt->table)) {
......
...@@ -222,7 +222,7 @@ class ha_innobase final : public handler ...@@ -222,7 +222,7 @@ class ha_innobase final : public handler
bool can_switch_engines() override; bool can_switch_engines() override;
uint referenced_by_foreign_key() override; bool referenced_by_foreign_key() const noexcept override;
void free_foreign_key_create_info(char* str) override; void free_foreign_key_create_info(char* str) override;
......
...@@ -16790,10 +16790,10 @@ int ha_mroonga::get_parent_foreign_key_list(THD *thd, ...@@ -16790,10 +16790,10 @@ int ha_mroonga::get_parent_foreign_key_list(THD *thd,
DBUG_RETURN(res); DBUG_RETURN(res);
} }
uint ha_mroonga::wrapper_referenced_by_foreign_key() inline bool ha_mroonga::wrapper_referenced_by_foreign_key() const noexcept
{ {
MRN_DBUG_ENTER_METHOD(); MRN_DBUG_ENTER_METHOD();
uint res; bool res;
MRN_SET_WRAP_SHARE_KEY(share, table->s); MRN_SET_WRAP_SHARE_KEY(share, table->s);
MRN_SET_WRAP_TABLE_KEY(this, table); MRN_SET_WRAP_TABLE_KEY(this, table);
res = wrap_handler->referenced_by_foreign_key(); res = wrap_handler->referenced_by_foreign_key();
...@@ -16802,17 +16802,17 @@ uint ha_mroonga::wrapper_referenced_by_foreign_key() ...@@ -16802,17 +16802,17 @@ uint ha_mroonga::wrapper_referenced_by_foreign_key()
DBUG_RETURN(res); DBUG_RETURN(res);
} }
uint ha_mroonga::storage_referenced_by_foreign_key() inline bool ha_mroonga::storage_referenced_by_foreign_key() const noexcept
{ {
MRN_DBUG_ENTER_METHOD(); MRN_DBUG_ENTER_METHOD();
uint res = handler::referenced_by_foreign_key(); bool res = handler::referenced_by_foreign_key();
DBUG_RETURN(res); DBUG_RETURN(res);
} }
uint ha_mroonga::referenced_by_foreign_key() bool ha_mroonga::referenced_by_foreign_key() const noexcept
{ {
MRN_DBUG_ENTER_METHOD(); MRN_DBUG_ENTER_METHOD();
uint res; bool res;
if (share->wrapper_mode) if (share->wrapper_mode)
{ {
res = wrapper_referenced_by_foreign_key(); res = wrapper_referenced_by_foreign_key();
......
...@@ -618,7 +618,7 @@ protected: ...@@ -618,7 +618,7 @@ protected:
bool can_switch_engines() mrn_override; bool can_switch_engines() mrn_override;
int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) mrn_override; int get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) mrn_override;
int get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) mrn_override; int get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) mrn_override;
uint referenced_by_foreign_key() mrn_override; bool referenced_by_foreign_key() const noexcept mrn_override;
void init_table_handle_for_HANDLER() mrn_override; void init_table_handle_for_HANDLER() mrn_override;
void free_foreign_key_create_info(char* str) mrn_override; void free_foreign_key_create_info(char* str) mrn_override;
#ifdef MRN_HAVE_HA_REBIND_PSI #ifdef MRN_HAVE_HA_REBIND_PSI
...@@ -1268,8 +1268,8 @@ private: ...@@ -1268,8 +1268,8 @@ private:
int storage_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int storage_get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
int wrapper_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int wrapper_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
int storage_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list); int storage_get_parent_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list);
uint wrapper_referenced_by_foreign_key(); bool wrapper_referenced_by_foreign_key() const noexcept;
uint storage_referenced_by_foreign_key(); bool storage_referenced_by_foreign_key() const noexcept;
void wrapper_init_table_handle_for_HANDLER(); void wrapper_init_table_handle_for_HANDLER();
void storage_init_table_handle_for_HANDLER(); void storage_init_table_handle_for_HANDLER();
void wrapper_free_foreign_key_create_info(char* str); void wrapper_free_foreign_key_create_info(char* str);
......
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