Skip to content

Commit

Permalink
feat(tianmu):Optimize code with ternary expression(stoneatom#1325)
Browse files Browse the repository at this point in the history
  • Loading branch information
konghaiya authored and mergify[bot] committed Feb 28, 2023
1 parent 2321f0a commit f8df638
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
3 changes: 1 addition & 2 deletions sql/auth/sql_authorization.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4389,8 +4389,7 @@ bool check_fk_parent_table_access(THD *thd,

// Return if engine does not support Foreign key Constraint.
if (!ha_check_storage_engine_flag(db_type, HTON_SUPPORTS_FOREIGN_KEYS)) {
sql_mode_t sql_mode = thd->variables.sql_mode;
if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
if (db_type == tianmu_hton &&
(alter_info->flags & Alter_info::ADD_FOREIGN_KEY) &&
(!(sql_mode & MODE_NO_KEY_ERROR))) {
Expand Down
12 changes: 4 additions & 8 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3934,8 +3934,7 @@ mysql_prepare_create_table(THD *thd, const char *error_schema_name,
(*key_count)++;
tmp=file->max_key_parts();

sql_mode_t sql_mode = thd->variables.sql_mode;
if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
if ((create_info->db_type->db_type == DB_TYPE_TIANMU)) {
if ((file->ha_table_flags() & HA_NON_SECONDARY_KEY) &&
(key->type == KEYTYPE_MULTIPLE) &&
Expand Down Expand Up @@ -4083,8 +4082,7 @@ mysql_prepare_create_table(THD *thd, const char *error_schema_name,
DBUG_RETURN(TRUE);
}
if (create_info->db_type->db_type == DB_TYPE_TIANMU){
sql_mode_t sql_mode = thd->variables.sql_mode;
if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
if(!(sql_mode & MODE_NO_KEY_ERROR)) {
my_message(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX,
ER(ER_TIANMU_NOT_SUPPORTED_FULLTEXT_INDEX), MYF(0));
Expand Down Expand Up @@ -8499,8 +8497,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
// Now this contains only DROP for foreign keys and not-found objects
Alter_drop *drop;
drop_it.rewind();
sql_mode_t sql_mode = thd->variables.sql_mode;
if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
while ((drop=drop_it++)) {
switch (drop->type) {
case Alter_drop::KEY:
Expand Down Expand Up @@ -8531,8 +8528,7 @@ mysql_prepare_alter_table(THD *thd, TABLE *table,
if (rename_key_list.elements)
{
if (create_info->db_type->db_type == DB_TYPE_TIANMU){
sql_mode_t sql_mode = thd->variables.sql_mode;
if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
if(!(sql_mode & MODE_NO_KEY_ERROR)){
my_error(ER_TIANMU_NOT_FOUND_INDEX, MYF(0));
goto err;
Expand Down
3 changes: 1 addition & 2 deletions sql/sql_trigger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
table= tables->table;
table->pos_in_table_list= tables;
if ((table->file && table->file->ht == tianmu_hton)){
sql_mode_t sql_mode = thd->variables.sql_mode;
if(thd->slave_thread) sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = thd->slave_thread ? global_system_variables.sql_mode : thd->variables.sql_mode;
if(!(sql_mode & MODE_NO_KEY_ERROR)) {
my_error(ER_TIANMU_NOT_SUPPORTED_TRIGGER, MYF(0));
goto end;
Expand Down
4 changes: 1 addition & 3 deletions storage/tianmu/handler/ha_tianmu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,9 +1683,7 @@ enum_alter_inplace_result ha_tianmu::check_if_supported_inplace_alter([[maybe_un
ha_alter_info->handler_flags & Alter_inplace_info::DROP_PK_INDEX)
DBUG_RETURN(HA_ALTER_INPLACE_NOT_SUPPORTED);
// support alter table: mix add/drop key
sql_mode_t sql_mode = ha_thd()->variables.sql_mode;
if (ha_thd()->slave_thread)
sql_mode = global_system_variables.sql_mode;
sql_mode_t sql_mode = ha_thd()->slave_thread ? global_system_variables.sql_mode : ha_thd()->variables.sql_mode;
if ((ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX ||
ha_alter_info->handler_flags & Alter_inplace_info::DROP_INDEX ||
ha_alter_info->handler_flags & Alter_inplace_info::ADD_UNIQUE_INDEX ||
Expand Down

0 comments on commit f8df638

Please sign in to comment.