diff options
Diffstat (limited to 'sql/handler.cc')
-rw-r--r-- | sql/handler.cc | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index c683a94e292..3081d4b0d3c 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2009, 2022, MariaDB Corporation. + Copyright (c) 2009, 2023, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -581,6 +581,7 @@ static int hton_drop_table(handlerton *hton, const char *path) int ha_finalize_handlerton(st_plugin_int *plugin) { + int deinit_status= 0; handlerton *hton= (handlerton *)plugin->data; DBUG_ENTER("ha_finalize_handlerton"); @@ -595,18 +596,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin) hton->panic(hton, HA_PANIC_CLOSE); if (plugin->plugin->deinit) - { - /* - Today we have no defined/special behavior for uninstalling - engine plugins. - */ - DBUG_PRINT("info", ("Deinitializing plugin: '%s'", plugin->name.str)); - if (plugin->plugin->deinit(NULL)) - { - DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", - plugin->name.str)); - } - } + deinit_status= plugin->plugin->deinit(NULL); free_sysvar_table_options(hton); update_discovery_counters(hton, -1); @@ -627,7 +617,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin) my_free(hton); end: - DBUG_RETURN(0); + DBUG_RETURN(deinit_status); } @@ -1779,6 +1769,13 @@ int ha_commit_trans(THD *thd, bool all) if (ha_info->ht()->prepare_commit_versioned) { trx_end_id= ha_info->ht()->prepare_commit_versioned(thd, &trx_start_id); + + if (trx_end_id == ULONGLONG_MAX) + { + my_error(ER_ERROR_DURING_COMMIT, MYF(0), 1); + goto err; + } + if (trx_end_id) break; // FIXME: use a common ID for cross-engine transactions } @@ -4168,6 +4165,9 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment, int error; MY_BITMAP *old_read_set; bool rnd_inited= (inited == RND); + bool rev= table->key_info[table->s->next_number_index]. + key_part[table->s->next_number_keypart].key_part_flag & + HA_REVERSE_SORT; if (rnd_inited && ha_rnd_end()) return; @@ -4189,7 +4189,8 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment, if (table->s->next_number_keypart == 0) { // Autoincrement at key-start - error= ha_index_last(table->record[1]); + error= rev ? ha_index_first(table->record[1]) + : ha_index_last(table->record[1]); /* MySQL implicitly assumes such method does locking (as MySQL decides to use nr+increment without checking again with the handler, in @@ -4204,9 +4205,8 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment, table->key_info + table->s->next_number_index, table->s->next_number_key_offset); error= ha_index_read_map(table->record[1], key, - make_prev_keypart_map(table->s-> - next_number_keypart), - HA_READ_PREFIX_LAST); + make_prev_keypart_map(table->s->next_number_keypart), + rev ? HA_READ_KEY_EXACT : HA_READ_PREFIX_LAST); /* MySQL needs to call us for next row: assume we are inserting ("a",null) here, we return 3, and next this statement will want to insert @@ -8154,7 +8154,7 @@ static Create_field *vers_init_sys_field(THD *thd, const char *field_name, int f f->set_handler(&type_handler_timestamp2); f->length= MAX_DATETIME_PRECISION; } - f->invisible= DBUG_EVALUATE_IF("sysvers_show", VISIBLE, INVISIBLE_SYSTEM); + f->invisible= DBUG_IF("sysvers_show") ? VISIBLE : INVISIBLE_SYSTEM; if (f->check(thd)) return NULL; @@ -8167,8 +8167,8 @@ bool Vers_parse_info::create_sys_field(THD *thd, const char *field_name, { DBUG_ASSERT(can_native >= 0); /* Requires vers_check_native() called */ Create_field *f= vers_init_sys_field(thd, field_name, flags, - DBUG_EVALUATE_IF("sysvers_force_trx", - (bool) can_native, false)); + DBUG_IF("sysvers_force_trx") && + can_native); if (!f) return true; @@ -8214,8 +8214,7 @@ bool Table_scope_and_contents_source_st::vers_fix_system_fields( { DBUG_ASSERT(!(alter_info->flags & ALTER_DROP_SYSTEM_VERSIONING)); - if (DBUG_EVALUATE_IF("sysvers_force", true, false) || - DBUG_EVALUATE_IF("sysvers_force_trx", true, false)) + if (DBUG_IF("sysvers_force") || DBUG_IF("sysvers_force_trx")) { alter_info->flags|= ALTER_ADD_SYSTEM_VERSIONING; options|= HA_VERSIONED_TABLE; @@ -8318,8 +8317,8 @@ bool Vers_parse_info::fix_alter_info(THD *thd, Alter_info *alter_info, if (!need_check(alter_info) && !share->versioned) return false; - if (DBUG_EVALUATE_IF("sysvers_force", 0, share->tmp_table) || - DBUG_EVALUATE_IF("sysvers_force_trx", 0, share->tmp_table)) + if (share->tmp_table && + !DBUG_IF("sysvers_force") && !DBUG_IF("sysvers_force_trx")) { my_error(ER_VERS_NOT_SUPPORTED, MYF(0), "CREATE TEMPORARY TABLE"); return true; |