mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Merge branch '10.11' into 11.2
This commit is contained in:
commit
cfa9784edb
42 changed files with 284 additions and 573 deletions
19
cmake/os/FreeBSD.cmake
Normal file
19
cmake/os/FreeBSD.cmake
Normal file
|
@ -0,0 +1,19 @@
|
|||
# Copyright (C) 2024 MariaDB Foundation
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; version 2 of the License.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA
|
||||
|
||||
# This file includes FreeBSD specific options and quirks, related to system checks
|
||||
|
||||
# For all userspace dependencies
|
||||
LINK_DIRECTORIES(/usr/local/lib)
|
|
@ -1353,9 +1353,6 @@ out:
|
|||
return(ret);
|
||||
}
|
||||
|
||||
lsn_t server_lsn_after_lock;
|
||||
extern void backup_wait_for_lsn(lsn_t lsn);
|
||||
|
||||
/** Release resources after backup_files() */
|
||||
void backup_release()
|
||||
{
|
||||
|
|
|
@ -3503,35 +3503,70 @@ static bool xtrabackup_copy_logfile()
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
Wait until redo log copying thread processes given lsn
|
||||
*/
|
||||
void backup_wait_for_lsn(lsn_t lsn)
|
||||
static bool backup_wait_timeout(lsn_t lsn, lsn_t last_lsn)
|
||||
{
|
||||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
for (lsn_t last_lsn{recv_sys.lsn}; last_lsn < lsn; )
|
||||
if (last_lsn >= lsn)
|
||||
return true;
|
||||
msg("Was only able to copy log from " LSN_PF " to " LSN_PF
|
||||
", not " LSN_PF "; try increasing innodb_log_file_size",
|
||||
log_sys.next_checkpoint_lsn, last_lsn, lsn);
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
Wait for enough log to be copied.
|
||||
@param lsn log sequence number target
|
||||
@return the reached log sequence number (may be less or more than lsn)
|
||||
*/
|
||||
static lsn_t backup_wait_for_lsn_low(lsn_t lsn)
|
||||
{
|
||||
mysql_mutex_assert_owner(&recv_sys.mutex);
|
||||
|
||||
lsn_t last_lsn{recv_sys.lsn};
|
||||
|
||||
if (last_lsn >= lsn)
|
||||
return last_lsn;
|
||||
|
||||
msg("Waiting for log copy thread to read lsn " LSN_PF, lsn);
|
||||
|
||||
while (log_copying_running && last_lsn < lsn)
|
||||
{
|
||||
timespec abstime;
|
||||
set_timespec(abstime, 5);
|
||||
if (my_cond_timedwait(&scanned_lsn_cond, &recv_sys.mutex.m_mutex,
|
||||
&abstime) &&
|
||||
last_lsn == recv_sys.lsn)
|
||||
die("Was only able to copy log from " LSN_PF " to " LSN_PF
|
||||
", not " LSN_PF "; try increasing innodb_log_file_size",
|
||||
log_sys.next_checkpoint_lsn, last_lsn, lsn);
|
||||
break;
|
||||
last_lsn= recv_sys.lsn;
|
||||
}
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
|
||||
return last_lsn;
|
||||
}
|
||||
|
||||
/**
|
||||
Wait for enough log to be copied after BACKUP STAGE BLOCK_DDL.
|
||||
@param lsn log sequence number target
|
||||
@return whether log_copying_thread() copied everything until the target lsn
|
||||
*/
|
||||
static bool backup_wait_for_lsn(lsn_t lsn)
|
||||
{
|
||||
if (!lsn)
|
||||
return true;
|
||||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
ut_ad(!metadata_to_lsn);
|
||||
ut_ad(!metadata_last_lsn);
|
||||
lsn_t last_lsn{backup_wait_for_lsn_low(lsn)};
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
return backup_wait_timeout(lsn, last_lsn);
|
||||
}
|
||||
|
||||
extern lsn_t server_lsn_after_lock;
|
||||
|
||||
static void log_copying_thread()
|
||||
{
|
||||
my_thread_init();
|
||||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
while (!xtrabackup_copy_logfile() &&
|
||||
(!metadata_to_lsn || metadata_to_lsn > recv_sys.lsn))
|
||||
(!metadata_last_lsn || metadata_last_lsn > recv_sys.lsn))
|
||||
{
|
||||
timespec abstime;
|
||||
set_timespec_nsec(abstime, 1000000ULL * xtrabackup_log_copy_interval);
|
||||
|
@ -3555,7 +3590,7 @@ static void io_watching_thread()
|
|||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
ut_ad(have_io_watching_thread);
|
||||
|
||||
while (log_copying_running && !metadata_to_lsn)
|
||||
while (log_copying_running && !metadata_last_lsn)
|
||||
{
|
||||
timespec abstime;
|
||||
set_timespec(abstime, 1);
|
||||
|
@ -4706,6 +4741,7 @@ end:
|
|||
|
||||
static void stop_backup_threads()
|
||||
{
|
||||
ut_ad(metadata_last_lsn);
|
||||
mysql_cond_broadcast(&log_copying_stop);
|
||||
|
||||
if (log_copying_running || have_io_watching_thread)
|
||||
|
@ -4729,38 +4765,58 @@ static void stop_backup_threads()
|
|||
mysql_cond_destroy(&log_copying_stop);
|
||||
}
|
||||
|
||||
/**
|
||||
Wait for enough log to be copied.
|
||||
@return whether log_copying_thread() copied everything until the target lsn
|
||||
*/
|
||||
static bool backup_wait_for_commit_lsn()
|
||||
{
|
||||
lsn_t lsn= get_current_lsn(mysql_connection);
|
||||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
ut_ad(!metadata_to_lsn);
|
||||
ut_ad(!metadata_last_lsn);
|
||||
|
||||
lsn_t last_lsn= recv_sys.lsn;
|
||||
|
||||
/* read the latest checkpoint lsn */
|
||||
if (recv_sys.find_checkpoint() == DB_SUCCESS && log_sys.is_latest())
|
||||
{
|
||||
if (log_sys.next_checkpoint_lsn > lsn)
|
||||
lsn= log_sys.next_checkpoint_lsn;
|
||||
metadata_to_lsn= log_sys.next_checkpoint_lsn;
|
||||
msg("mariabackup: The latest check point (for incremental): '"
|
||||
LSN_PF "'", metadata_to_lsn);
|
||||
}
|
||||
else
|
||||
{
|
||||
msg("Error: recv_sys.find_checkpoint() failed.");
|
||||
metadata_last_lsn= 1;
|
||||
stop_backup_threads();
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
return false;
|
||||
}
|
||||
|
||||
recv_sys.lsn= last_lsn;
|
||||
ut_ad(metadata_to_lsn);
|
||||
metadata_last_lsn= lsn;
|
||||
|
||||
last_lsn= backup_wait_for_lsn_low(LSN_MAX);
|
||||
|
||||
metadata_last_lsn= last_lsn;
|
||||
stop_backup_threads();
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
return backup_wait_timeout(lsn, last_lsn);
|
||||
}
|
||||
|
||||
/** Implement the core of --backup
|
||||
@return whether the operation succeeded */
|
||||
bool Backup_datasinks::backup_low()
|
||||
{
|
||||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
ut_ad(!metadata_to_lsn);
|
||||
|
||||
/* read the latest checkpoint lsn */
|
||||
{
|
||||
const lsn_t lsn = recv_sys.lsn;
|
||||
if (recv_sys.find_checkpoint() == DB_SUCCESS
|
||||
&& log_sys.is_latest()) {
|
||||
metadata_to_lsn = log_sys.next_checkpoint_lsn;
|
||||
msg("mariabackup: The latest check point"
|
||||
" (for incremental): '" LSN_PF "'",
|
||||
metadata_to_lsn);
|
||||
} else {
|
||||
msg("Error: recv_sys.find_checkpoint() failed.");
|
||||
}
|
||||
|
||||
recv_sys.lsn = lsn;
|
||||
stop_backup_threads();
|
||||
}
|
||||
|
||||
if (metadata_to_lsn && xtrabackup_copy_logfile()) {
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
ds_close(dst_log_file);
|
||||
dst_log_file = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
ut_d(mysql_mutex_lock(&recv_sys.mutex));
|
||||
ut_ad(metadata_last_lsn);
|
||||
ut_ad(metadata_to_lsn);
|
||||
ut_ad(!log_copying_running);
|
||||
ut_d(mysql_mutex_unlock(&recv_sys.mutex));
|
||||
|
||||
if (ds_close(dst_log_file) || !metadata_to_lsn) {
|
||||
dst_log_file = NULL;
|
||||
|
@ -4777,7 +4833,7 @@ bool Backup_datasinks::backup_low()
|
|||
|
||||
for (uint32_t id : failed_ids) {
|
||||
msg("mariabackup: Failed to read undo log "
|
||||
"tablespace space id %d and there is no undo "
|
||||
"tablespace space id " UINT32PF " and there is no undo "
|
||||
"tablespace truncation redo record.",
|
||||
id);
|
||||
}
|
||||
|
@ -4864,17 +4920,17 @@ private:
|
|||
// TODO: this came from the old code, where it was not thread-safe
|
||||
// too, use separate mysql connection per thread here
|
||||
DBUG_MARIABACKUP_EVENT("before_copy", node->space->name());
|
||||
DBUG_EXECUTE_FOR_KEY("wait_innodb_redo_before_copy",
|
||||
node->space->name(),
|
||||
backup_wait_for_lsn(
|
||||
get_current_lsn(mysql_connection)););
|
||||
DBUG_EXECUTE_FOR_KEY("wait_innodb_redo_before_copy",
|
||||
node->space->name(),
|
||||
backup_wait_for_lsn(
|
||||
get_current_lsn(mysql_connection)););
|
||||
/* copy the datafile */
|
||||
if(xtrabackup_copy_datafile(m_backup_datasinks.m_data,
|
||||
m_backup_datasinks.m_meta,
|
||||
node, thread_num, NULL,
|
||||
xtrabackup_incremental
|
||||
? wf_incremental : wf_write_through,
|
||||
m_corrupted_pages))
|
||||
m_backup_datasinks.m_meta,
|
||||
node, thread_num, NULL,
|
||||
xtrabackup_incremental
|
||||
? wf_incremental : wf_write_through,
|
||||
m_corrupted_pages))
|
||||
die("mariabackup: Error: failed to copy datafile.");
|
||||
// TODO: this came from the old code, where it was not thread-safe
|
||||
// too, use separate mysql connection per thread here
|
||||
|
@ -4882,8 +4938,8 @@ private:
|
|||
m_tasks.finish_task(1);
|
||||
}
|
||||
|
||||
Backup_datasinks &m_backup_datasinks;
|
||||
CorruptedPages &m_corrupted_pages;
|
||||
Backup_datasinks &m_backup_datasinks;
|
||||
CorruptedPages &m_corrupted_pages;
|
||||
TasksGroup m_tasks;
|
||||
};
|
||||
|
||||
|
@ -5084,9 +5140,9 @@ class BackupStages {
|
|||
return false;
|
||||
}
|
||||
|
||||
msg("Waiting for log copy thread to read lsn %llu",
|
||||
server_lsn_after_lock);
|
||||
backup_wait_for_lsn(server_lsn_after_lock);
|
||||
if (!backup_wait_for_lsn(server_lsn_after_lock)) {
|
||||
return false;
|
||||
}
|
||||
corrupted_pages.backup_fix_ddl(backup_datasinks.m_data,
|
||||
backup_datasinks.m_meta);
|
||||
|
||||
|
@ -5122,11 +5178,28 @@ class BackupStages {
|
|||
}
|
||||
|
||||
// Copy log tables tail
|
||||
if (!m_common_backup.copy_log_tables(true)) {
|
||||
if (!m_common_backup.copy_log_tables(true) ||
|
||||
!m_common_backup.close_log_tables()) {
|
||||
msg("Error on copy log tables");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy just enough log to cover the latest commit.
|
||||
// Meanwhile, there could be some active transactions
|
||||
// that are modifying the database and writing more
|
||||
// log. Not copying log for them will save busy work
|
||||
// and avoid some rollback of the incomplete
|
||||
// transactions after the backup has been restored.
|
||||
//
|
||||
// We find the current InnoDB LSN by executing
|
||||
// SHOW ENGINE INNODB STATUS, which in the case of
|
||||
// general_log=1, log_output='TABLES'
|
||||
// would be written to the table mysql.general_log
|
||||
// that we just finished copying above.
|
||||
if (!backup_wait_for_commit_lsn()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Copy stats tables
|
||||
if (!m_common_backup.copy_stats_tables()) {
|
||||
msg("Error on copy stats tables");
|
||||
|
@ -5144,11 +5217,6 @@ class BackupStages {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!m_common_backup.close_log_tables()) {
|
||||
msg("Error on close log tables");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!backup_files_from_datadir(backup_datasinks.m_data,
|
||||
fil_path_to_mysql_datadir,
|
||||
"aws-kms-key")) {
|
||||
|
@ -5290,13 +5358,14 @@ static bool xtrabackup_backup_func()
|
|||
undo_space_trunc = backup_undo_trunc;
|
||||
first_page_init = backup_first_page_op;
|
||||
metadata_to_lsn = 0;
|
||||
metadata_last_lsn = 0;
|
||||
|
||||
/* initialize components */
|
||||
if(innodb_init_param()) {
|
||||
fail:
|
||||
if (log_copying_running) {
|
||||
mysql_mutex_lock(&recv_sys.mutex);
|
||||
metadata_to_lsn = 1;
|
||||
metadata_last_lsn = 1;
|
||||
stop_backup_threads();
|
||||
mysql_mutex_unlock(&recv_sys.mutex);
|
||||
}
|
||||
|
@ -5481,14 +5550,9 @@ fail:
|
|||
|
||||
xb_data_files_close();
|
||||
|
||||
/* Make sure that the latest checkpoint was included */
|
||||
if (metadata_to_lsn > recv_sys.lsn) {
|
||||
msg("Error: failed to copy enough redo log ("
|
||||
"LSN=" LSN_PF "; checkpoint LSN=" LSN_PF ").",
|
||||
recv_sys.lsn, metadata_to_lsn);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ut_ad(!log_copying_running);
|
||||
ut_ad(metadata_to_lsn <= recv_sys.lsn);
|
||||
ut_ad(metadata_last_lsn == recv_sys.lsn);
|
||||
innodb_shutdown();
|
||||
log_file_op = NULL;
|
||||
undo_space_trunc = NULL;
|
||||
|
|
|
@ -10,11 +10,11 @@ ssl-ca=@ENV.MYSQL_TEST_DIR/std_data/cacert.pem
|
|||
|
||||
[mysqld.1]
|
||||
wsrep_provider_options='base_port=@mysqld.1.#galera_port;pc.ignore_sb=true'
|
||||
innodb-log-file-buffering
|
||||
loose-innodb-log-file-buffering
|
||||
|
||||
[mysqld.2]
|
||||
wsrep_provider_options='base_port=@mysqld.2.#galera_port;pc.ignore_sb=true'
|
||||
innodb-log-file-buffering
|
||||
loose-innodb-log-file-buffering
|
||||
|
||||
[sst]
|
||||
ssl-mode=VERIFY_CA
|
||||
|
|
|
@ -16,7 +16,7 @@ CONSTRAINT test FOREIGN KEY (b) REFERENCES t2 (id)
|
|||
ERROR HY000: Can't create table `test`.`t2` (errno: 121 "Duplicate key on write or update")
|
||||
show warnings;
|
||||
Level Code Message
|
||||
Warning 121 Create or Alter table `test`.`t2` with foreign key constraint failed. Foreign key constraint `test`.`test` already exists on data dictionary. Foreign key constraint names need to be unique in database. Error in foreign key definition: CONSTRAINT `test` FOREIGN KEY (`b`) REFERENCES `test`.`t2` (`id`).
|
||||
Warning 121 CREATE or ALTER TABLE `test`.`t2` failed: duplicate name, CONSTRAINT `test` FOREIGN KEY (`b`) REFERENCES `t2` (`id`)
|
||||
Error 1005 Can't create table `test`.`t2` (errno: 121 "Duplicate key on write or update")
|
||||
Warning 1022 Can't write; duplicate key in table 't2'
|
||||
drop table t1;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
CREATE TABLE t(i INT)
|
||||
ENGINE ARIA TRANSACTIONAL=1 ROW_FORMAT=PAGE PAGE_CHECKSUM=1;
|
||||
SET GLOBAL general_log = 0;
|
||||
TRUNCATE mysql.general_log;
|
||||
SET GLOBAL general_log = 1;
|
||||
SET GLOBAL log_output = 'TABLE';
|
||||
INSERT INTO t VALUES (1);
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
CREATE TABLE t(i INT)
|
||||
ENGINE ARIA TRANSACTIONAL=1 ROW_FORMAT=PAGE PAGE_CHECKSUM=1;
|
||||
|
||||
--let $general_log_old = `SELECT @@global.general_log`
|
||||
--let $log_output_old = `SELECT @@global.log_output`
|
||||
|
||||
# Truncate the log in order to make the test ./mtr --repeat proof
|
||||
SET GLOBAL general_log = 0;
|
||||
TRUNCATE mysql.general_log;
|
||||
SET GLOBAL general_log = 1;
|
||||
SET GLOBAL log_output = 'TABLE';
|
||||
|
||||
|
@ -43,7 +43,3 @@ SELECT * FROM mysql.general_log
|
|||
|
||||
--rmdir $targetdir
|
||||
DROP TABLE t;
|
||||
--disable_query_log
|
||||
--eval SET GLOBAL general_log = $general_log_old
|
||||
--eval SET GLOBAL log_output = $log_output_old
|
||||
--enable_query_log
|
||||
|
|
|
@ -1293,7 +1293,7 @@ Item *Item::multiple_equality_transformer(THD *thd, uchar *arg)
|
|||
This flag will be removed at the end of the pushdown optimization by
|
||||
remove_immutable_flag_processor processor.
|
||||
*/
|
||||
int new_flag= MARKER_IMMUTABLE;
|
||||
int16 new_flag= MARKER_IMMUTABLE;
|
||||
this->walk(&Item::set_extraction_flag_processor, false,
|
||||
(void*)&new_flag);
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ bool Sql_cmd_delete::delete_from_single_table(THD *thd)
|
|||
query_plan.set_no_partitions();
|
||||
if (thd->lex->describe || thd->lex->analyze_stmt)
|
||||
goto produce_explain_and_leave;
|
||||
|
||||
|
||||
if (thd->binlog_for_noop_dml(transactional_table))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
|
|
|
@ -195,15 +195,13 @@ bool btr_root_fseg_validate(ulint offset, const buf_block_t &block,
|
|||
return false;
|
||||
}
|
||||
|
||||
/** Report a decryption failure. */
|
||||
ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index)
|
||||
/** Report a read failure if it is a decryption failure.
|
||||
@param err error code
|
||||
@param index the index that is being accessed */
|
||||
ATTRIBUTE_COLD void btr_read_failed(dberr_t err, const dict_index_t &index)
|
||||
{
|
||||
ib_push_warning(static_cast<void*>(nullptr), DB_DECRYPTION_FAILED,
|
||||
"Table %s is encrypted but encryption service or"
|
||||
" used key_id is not available. "
|
||||
" Can't continue reading table.",
|
||||
index.table->name.m_name);
|
||||
index.table->file_unreadable= true;
|
||||
if (err == DB_DECRYPTION_FAILED)
|
||||
innodb_decryption_failed(nullptr, index.table);
|
||||
}
|
||||
|
||||
/** Get an index page and declare its latching order level.
|
||||
|
@ -242,8 +240,8 @@ buf_block_t *btr_block_get(const dict_index_t &index,
|
|||
else if (!buf_page_make_young_if_needed(&block->page) && first)
|
||||
*first= true;
|
||||
}
|
||||
else if (*err == DB_DECRYPTION_FAILED)
|
||||
btr_decryption_failed(index);
|
||||
else
|
||||
btr_read_failed(*err, index);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
@ -304,8 +302,8 @@ btr_root_block_get(
|
|||
else
|
||||
buf_page_make_young_if_needed(&block->page);
|
||||
}
|
||||
else if (*err == DB_DECRYPTION_FAILED)
|
||||
btr_decryption_failed(*index);
|
||||
else
|
||||
btr_read_failed(*err, *index);
|
||||
|
||||
return block;
|
||||
}
|
||||
|
|
|
@ -1196,8 +1196,8 @@ dberr_t btr_cur_t::search_leaf(const dtuple_t *tuple, page_cur_mode_t mode,
|
|||
buf_page_get_gen(page_id, zip_size, rw_latch, guess, BUF_GET, mtr, &err);
|
||||
if (!block)
|
||||
{
|
||||
if (err == DB_DECRYPTION_FAILED)
|
||||
btr_decryption_failed(*index());
|
||||
if (err != DB_SUCCESS)
|
||||
btr_read_failed(err, *index());
|
||||
goto func_exit;
|
||||
}
|
||||
|
||||
|
@ -1669,8 +1669,7 @@ dberr_t btr_cur_t::pessimistic_search_leaf(const dtuple_t *tuple,
|
|||
|
||||
if (!block)
|
||||
{
|
||||
if (err == DB_DECRYPTION_FAILED)
|
||||
btr_decryption_failed(*index());
|
||||
btr_read_failed(err, *index());
|
||||
goto func_exit;
|
||||
}
|
||||
|
||||
|
@ -1778,8 +1777,7 @@ search_loop:
|
|||
else if (!(block= buf_page_get_gen(page_id, zip_size, rw_latch,
|
||||
block, BUF_GET, mtr, &err)))
|
||||
{
|
||||
if (err == DB_DECRYPTION_FAILED)
|
||||
btr_decryption_failed(*index);
|
||||
btr_read_failed(err, *index);
|
||||
goto func_exit;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1597,104 +1597,6 @@ dict_create_add_foreign_field_to_dictionary(
|
|||
table_name, foreign->id, trx));
|
||||
}
|
||||
|
||||
/********************************************************************//**
|
||||
Construct foreign key constraint defintion from data dictionary information.
|
||||
*/
|
||||
static
|
||||
char*
|
||||
dict_foreign_def_get(
|
||||
/*=================*/
|
||||
dict_foreign_t* foreign,/*!< in: foreign */
|
||||
trx_t* trx) /*!< in: trx */
|
||||
{
|
||||
char* fk_def = (char *)mem_heap_alloc(foreign->heap, 4*1024);
|
||||
const char* tbname;
|
||||
char tablebuf[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
unsigned i;
|
||||
char* bufend;
|
||||
|
||||
tbname = dict_remove_db_name(foreign->id);
|
||||
bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN,
|
||||
tbname, strlen(tbname), trx->mysql_thd);
|
||||
tablebuf[bufend - tablebuf] = '\0';
|
||||
|
||||
sprintf(fk_def,
|
||||
(char *)"CONSTRAINT %s FOREIGN KEY (", (char *)tablebuf);
|
||||
|
||||
for(i = 0; i < foreign->n_fields; i++) {
|
||||
char buf[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
|
||||
foreign->foreign_col_names[i],
|
||||
strlen(foreign->foreign_col_names[i]),
|
||||
trx->mysql_thd);
|
||||
strcat(fk_def, buf);
|
||||
if (i < static_cast<unsigned>(foreign->n_fields-1)) {
|
||||
strcat(fk_def, (char *)",");
|
||||
}
|
||||
}
|
||||
|
||||
strcat(fk_def,(char *)") REFERENCES ");
|
||||
|
||||
bufend = innobase_convert_name(tablebuf, MAX_TABLE_NAME_LEN,
|
||||
foreign->referenced_table_name,
|
||||
strlen(foreign->referenced_table_name),
|
||||
trx->mysql_thd);
|
||||
tablebuf[bufend - tablebuf] = '\0';
|
||||
|
||||
strcat(fk_def, tablebuf);
|
||||
strcat(fk_def, " (");
|
||||
|
||||
for(i = 0; i < foreign->n_fields; i++) {
|
||||
char buf[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
bufend = innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
|
||||
foreign->referenced_col_names[i],
|
||||
strlen(foreign->referenced_col_names[i]),
|
||||
trx->mysql_thd);
|
||||
buf[bufend - buf] = '\0';
|
||||
strcat(fk_def, buf);
|
||||
if (i < (uint)foreign->n_fields-1) {
|
||||
strcat(fk_def, (char *)",");
|
||||
}
|
||||
}
|
||||
strcat(fk_def, (char *)")");
|
||||
|
||||
return fk_def;
|
||||
}
|
||||
|
||||
/********************************************************************//**
|
||||
Convert foreign key column names from data dictionary to SQL-layer.
|
||||
*/
|
||||
static
|
||||
void
|
||||
dict_foreign_def_get_fields(
|
||||
/*========================*/
|
||||
dict_foreign_t* foreign,/*!< in: foreign */
|
||||
trx_t* trx, /*!< in: trx */
|
||||
char** field, /*!< out: foreign column */
|
||||
char** field2, /*!< out: referenced column */
|
||||
ulint col_no) /*!< in: column number */
|
||||
{
|
||||
char* bufend;
|
||||
char* fieldbuf = (char *)mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1);
|
||||
char* fieldbuf2 = (char *)mem_heap_alloc(foreign->heap, MAX_TABLE_NAME_LEN+1);
|
||||
|
||||
bufend = innobase_convert_name(fieldbuf, MAX_TABLE_NAME_LEN,
|
||||
foreign->foreign_col_names[col_no],
|
||||
strlen(foreign->foreign_col_names[col_no]),
|
||||
trx->mysql_thd);
|
||||
|
||||
fieldbuf[bufend - fieldbuf] = '\0';
|
||||
|
||||
bufend = innobase_convert_name(fieldbuf2, MAX_TABLE_NAME_LEN,
|
||||
foreign->referenced_col_names[col_no],
|
||||
strlen(foreign->referenced_col_names[col_no]),
|
||||
trx->mysql_thd);
|
||||
|
||||
fieldbuf2[bufend - fieldbuf2] = '\0';
|
||||
*field = fieldbuf;
|
||||
*field2 = fieldbuf2;
|
||||
}
|
||||
|
||||
/********************************************************************//**
|
||||
Add a foreign key definition to the data dictionary tables.
|
||||
@return error code or DB_SUCCESS */
|
||||
|
@ -1736,29 +1638,8 @@ dict_create_add_foreign_to_dictionary(
|
|||
, name, foreign->id, trx);
|
||||
|
||||
if (error != DB_SUCCESS) {
|
||||
|
||||
if (error == DB_DUPLICATE_KEY) {
|
||||
char buf[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
char tablename[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
char* fk_def;
|
||||
|
||||
innobase_convert_name(tablename, MAX_TABLE_NAME_LEN,
|
||||
name, strlen(name), trx->mysql_thd);
|
||||
|
||||
innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
|
||||
foreign->id, strlen(foreign->id), trx->mysql_thd);
|
||||
|
||||
fk_def = dict_foreign_def_get((dict_foreign_t*)foreign, trx);
|
||||
|
||||
ib_push_warning(trx, error,
|
||||
"Create or Alter table %s with foreign key constraint"
|
||||
" failed. Foreign key constraint %s"
|
||||
" already exists on data dictionary."
|
||||
" Foreign key constraint names need to be unique in database."
|
||||
" Error in foreign key definition: %s.",
|
||||
tablename, buf, fk_def);
|
||||
}
|
||||
|
||||
err_exit:
|
||||
innodb_fk_error(trx, error, name, *foreign);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
@ -1767,27 +1648,7 @@ dict_create_add_foreign_to_dictionary(
|
|||
i, name, foreign, trx);
|
||||
|
||||
if (error != DB_SUCCESS) {
|
||||
char buf[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
char tablename[MAX_TABLE_NAME_LEN + 1] = "";
|
||||
char* field=NULL;
|
||||
char* field2=NULL;
|
||||
char* fk_def;
|
||||
|
||||
innobase_convert_name(tablename, MAX_TABLE_NAME_LEN,
|
||||
name, strlen(name), trx->mysql_thd);
|
||||
innobase_convert_name(buf, MAX_TABLE_NAME_LEN,
|
||||
foreign->id, strlen(foreign->id), trx->mysql_thd);
|
||||
fk_def = dict_foreign_def_get((dict_foreign_t*)foreign, trx);
|
||||
dict_foreign_def_get_fields((dict_foreign_t*)foreign, trx, &field, &field2, i);
|
||||
|
||||
ib_push_warning(trx, error,
|
||||
"Create or Alter table %s with foreign key constraint"
|
||||
" failed. Error adding foreign key constraint name %s"
|
||||
" fields %s or %s to the dictionary."
|
||||
" Error in foreign key definition: %s.",
|
||||
tablename, buf, i+1, fk_def);
|
||||
|
||||
DBUG_RETURN(error);
|
||||
goto err_exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -195,21 +195,6 @@ dict_tables_have_same_db(
|
|||
return(FALSE);
|
||||
}
|
||||
|
||||
/********************************************************************//**
|
||||
Return the end of table name where we have removed dbname and '/'.
|
||||
@return table name */
|
||||
const char*
|
||||
dict_remove_db_name(
|
||||
/*================*/
|
||||
const char* name) /*!< in: table name in the form
|
||||
dbname '/' tablename */
|
||||
{
|
||||
const char* s = strchr(name, '/');
|
||||
ut_a(s);
|
||||
|
||||
return(s + 1);
|
||||
}
|
||||
|
||||
/** Decrement the count of open handles */
|
||||
void dict_table_close(dict_table_t *table)
|
||||
{
|
||||
|
@ -3844,15 +3829,10 @@ dict_index_calc_min_rec_len(
|
|||
return(sum);
|
||||
}
|
||||
|
||||
/**********************************************************************//**
|
||||
Outputs info on a foreign key of a table in a format suitable for
|
||||
CREATE TABLE. */
|
||||
std::string
|
||||
dict_print_info_on_foreign_key_in_create_format(
|
||||
/*============================================*/
|
||||
trx_t* trx, /*!< in: transaction */
|
||||
dict_foreign_t* foreign, /*!< in: foreign key constraint */
|
||||
ibool add_newline) /*!< in: whether to add a newline */
|
||||
dict_print_info_on_foreign_key_in_create_format(const trx_t *trx,
|
||||
const dict_foreign_t *foreign,
|
||||
bool add_newline)
|
||||
{
|
||||
const char* stripped_id;
|
||||
ulint i;
|
||||
|
|
|
@ -669,8 +669,7 @@ dberr_t rtr_search_to_nth_level(btr_cur_t *cur, que_thr_t *thr,
|
|||
if (err)
|
||||
{
|
||||
err_exit:
|
||||
if (err == DB_DECRYPTION_FAILED)
|
||||
btr_decryption_failed(*index);
|
||||
btr_read_failed(err, *index);
|
||||
mtr->rollback_to_savepoint(savepoint);
|
||||
}
|
||||
func_exit:
|
||||
|
|
|
@ -3335,7 +3335,7 @@ innobase_invalidate_query_cache(
|
|||
void
|
||||
innobase_quote_identifier(
|
||||
FILE* file,
|
||||
trx_t* trx,
|
||||
const trx_t* trx,
|
||||
const char* id)
|
||||
{
|
||||
const int q = trx != NULL && trx->mysql_thd != NULL
|
||||
|
@ -3365,7 +3365,7 @@ innobase_quote_identifier(
|
|||
std::string
|
||||
innobase_quote_identifier(
|
||||
/*======================*/
|
||||
trx_t* trx,
|
||||
const trx_t* trx,
|
||||
const char* id)
|
||||
{
|
||||
std::string quoted_identifier;
|
||||
|
@ -21047,64 +21047,46 @@ static void innodb_remember_check_sysvar_funcs()
|
|||
check_sysvar_int = MYSQL_SYSVAR_NAME(flush_log_at_timeout).check;
|
||||
}
|
||||
|
||||
static const size_t MAX_BUF_SIZE = 4 * 1024;
|
||||
|
||||
/********************************************************************//**
|
||||
Helper function to push warnings from InnoDB internals to SQL-layer. */
|
||||
void
|
||||
ib_push_warning(
|
||||
trx_t* trx, /*!< in: trx */
|
||||
dberr_t error, /*!< in: error code to push as warning */
|
||||
const char *format,/*!< in: warning message */
|
||||
...)
|
||||
/** Report that a table cannot be decrypted.
|
||||
@param thd connection context
|
||||
@param table table that cannot be decrypted
|
||||
@retval DB_DECRYPTION_FAILED (always) */
|
||||
ATTRIBUTE_COLD
|
||||
dberr_t innodb_decryption_failed(THD *thd, dict_table_t *table)
|
||||
{
|
||||
if (trx && trx->mysql_thd) {
|
||||
THD *thd = (THD *)trx->mysql_thd;
|
||||
va_list args;
|
||||
char *buf;
|
||||
|
||||
va_start(args, format);
|
||||
buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME));
|
||||
buf[MAX_BUF_SIZE - 1] = 0;
|
||||
vsnprintf(buf, MAX_BUF_SIZE - 1, format, args);
|
||||
|
||||
push_warning_printf(
|
||||
thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
uint(convert_error_code_to_mysql(error, 0, thd)), buf);
|
||||
my_free(buf);
|
||||
va_end(args);
|
||||
}
|
||||
table->file_unreadable= true;
|
||||
if (!thd)
|
||||
thd= current_thd;
|
||||
const int dblen= int(table->name.dblen());
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
HA_ERR_DECRYPTION_FAILED,
|
||||
"Table %`.*s.%`s in tablespace " UINT32PF
|
||||
" (file %s) cannot be decrypted.",
|
||||
dblen, table->name.m_name,
|
||||
table->name.m_name + dblen + 1,
|
||||
uint32_t(table->space_id),
|
||||
UT_LIST_GET_FIRST(table->space->chain)->name);
|
||||
return DB_DECRYPTION_FAILED;
|
||||
}
|
||||
|
||||
/********************************************************************//**
|
||||
Helper function to push warnings from InnoDB internals to SQL-layer. */
|
||||
void
|
||||
ib_push_warning(
|
||||
void* ithd, /*!< in: thd */
|
||||
dberr_t error, /*!< in: error code to push as warning */
|
||||
const char *format,/*!< in: warning message */
|
||||
...)
|
||||
/** Report a foreign key error.
|
||||
@param error error to report
|
||||
@param name table name
|
||||
@param foreign constraint */
|
||||
ATTRIBUTE_COLD
|
||||
void innodb_fk_error(const trx_t *trx, dberr_t err, const char *name,
|
||||
const dict_foreign_t& foreign)
|
||||
{
|
||||
va_list args;
|
||||
THD *thd = (THD *)ithd;
|
||||
char *buf;
|
||||
|
||||
if (ithd == NULL) {
|
||||
thd = current_thd;
|
||||
}
|
||||
|
||||
if (thd) {
|
||||
va_start(args, format);
|
||||
buf = (char *)my_malloc(PSI_INSTRUMENT_ME, MAX_BUF_SIZE, MYF(MY_WME));
|
||||
buf[MAX_BUF_SIZE - 1] = 0;
|
||||
vsnprintf(buf, MAX_BUF_SIZE - 1, format, args);
|
||||
|
||||
push_warning_printf(
|
||||
thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
uint(convert_error_code_to_mysql(error, 0, thd)), buf);
|
||||
my_free(buf);
|
||||
va_end(args);
|
||||
}
|
||||
const int dblen= int(table_name_t(const_cast<char*>(name)).dblen());
|
||||
std::string fk= dict_print_info_on_foreign_key_in_create_format
|
||||
(trx, &foreign, false);
|
||||
push_warning_printf(trx->mysql_thd, Sql_condition::WARN_LEVEL_WARN,
|
||||
convert_error_code_to_mysql(err, 0, nullptr),
|
||||
"CREATE or ALTER TABLE %`.*s.%`s failed%s%.*s",
|
||||
dblen, name, name + dblen + 1,
|
||||
err == DB_DUPLICATE_KEY
|
||||
? ": duplicate name" : "",
|
||||
int(fk.length()), fk.data());
|
||||
}
|
||||
|
||||
/** Helper function to push warnings from InnoDB internals to SQL-layer.
|
||||
|
|
|
@ -83,8 +83,10 @@ btr_root_adjust_on_import(
|
|||
bool btr_root_fseg_validate(ulint offset, const buf_block_t &block,
|
||||
const fil_space_t &space);
|
||||
|
||||
/** Report a decryption failure. */
|
||||
ATTRIBUTE_COLD void btr_decryption_failed(const dict_index_t &index);
|
||||
/** Report a read failure if it is a decryption failure.
|
||||
@param err error code
|
||||
@param index the index that is being accessed */
|
||||
ATTRIBUTE_COLD void btr_read_failed(dberr_t err, const dict_index_t &index);
|
||||
|
||||
/** Get an index page and declare its latching order level.
|
||||
@param[in] index index tree
|
||||
|
|
|
@ -102,15 +102,9 @@ dict_table_is_partition(const dict_table_t* table)
|
|||
return (strstr(table->name.m_name, "#p#")
|
||||
|| strstr(table->name.m_name, "#P#"));
|
||||
}
|
||||
/********************************************************************//**
|
||||
Return the end of table name where we have removed dbname and '/'.
|
||||
@return table name */
|
||||
const char*
|
||||
dict_remove_db_name(
|
||||
/*================*/
|
||||
const char* name) /*!< in: table name in the form
|
||||
dbname '/' tablename */
|
||||
MY_ATTRIBUTE((nonnull, warn_unused_result));
|
||||
|
||||
#define dict_remove_db_name(name) \
|
||||
(table_name_t{const_cast<char*>(name)}.dbend() + 1)
|
||||
|
||||
/** Operation to perform when opening a table */
|
||||
enum dict_table_op_t {
|
||||
|
@ -566,15 +560,15 @@ dict_print_info_on_foreign_keys(
|
|||
trx_t* trx, /*!< in: transaction */
|
||||
dict_table_t* table); /*!< in: table */
|
||||
|
||||
/**********************************************************************//**
|
||||
Outputs info on a foreign key of a table in a format suitable for
|
||||
CREATE TABLE. */
|
||||
/** Output info on a foreign key of a table in a format suitable for
|
||||
CREATE TABLE.
|
||||
@param trx transaction
|
||||
@param foreign constraint
|
||||
@param add_newline whether to add a newline */
|
||||
std::string
|
||||
dict_print_info_on_foreign_key_in_create_format(
|
||||
/*============================================*/
|
||||
trx_t* trx, /*!< in: transaction */
|
||||
dict_foreign_t* foreign, /*!< in: foreign key constraint */
|
||||
ibool add_newline); /*!< in: whether to add a newline */
|
||||
dict_print_info_on_foreign_key_in_create_format(const trx_t *trx,
|
||||
const dict_foreign_t *foreign,
|
||||
bool add_newline);
|
||||
|
||||
/*********************************************************************//**
|
||||
Tries to find an index whose first fields are the columns in the array,
|
||||
|
|
|
@ -37,6 +37,9 @@ simple headers.
|
|||
/* Forward declarations */
|
||||
class THD;
|
||||
class Field;
|
||||
struct dict_table_t;
|
||||
struct dict_foreign_t;
|
||||
struct table_name_t;
|
||||
|
||||
// JAN: TODO missing features:
|
||||
#undef MYSQL_FT_INIT_EXT
|
||||
|
@ -83,7 +86,7 @@ innobase_invalidate_query_cache(
|
|||
void
|
||||
innobase_quote_identifier(
|
||||
FILE* file,
|
||||
trx_t* trx,
|
||||
const trx_t* trx,
|
||||
const char* id);
|
||||
|
||||
/** Quote an standard SQL identifier like tablespace, index or column name.
|
||||
|
@ -93,7 +96,7 @@ Return the string as an std:string object.
|
|||
@return a std::string with id properly quoted. */
|
||||
std::string
|
||||
innobase_quote_identifier(
|
||||
trx_t* trx,
|
||||
const trx_t* trx,
|
||||
const char* id);
|
||||
|
||||
/*****************************************************************//**
|
||||
|
@ -406,23 +409,20 @@ innobase_convert_to_filename_charset(
|
|||
const char* from, /* in: identifier to convert */
|
||||
ulint len); /* in: length of 'to', in bytes */
|
||||
|
||||
/********************************************************************//**
|
||||
Helper function to push warnings from InnoDB internals to SQL-layer. */
|
||||
void
|
||||
ib_push_warning(
|
||||
trx_t* trx, /*!< in: trx */
|
||||
dberr_t error, /*!< in: error code to push as warning */
|
||||
const char *format,/*!< in: warning message */
|
||||
...);
|
||||
/** Report that a table cannot be decrypted.
|
||||
@param thd connection context
|
||||
@param table table that cannot be decrypted
|
||||
@retval DB_DECRYPTION_FAILED (always) */
|
||||
ATTRIBUTE_COLD
|
||||
dberr_t innodb_decryption_failed(THD *thd, dict_table_t *table);
|
||||
|
||||
/********************************************************************//**
|
||||
Helper function to push warnings from InnoDB internals to SQL-layer. */
|
||||
void
|
||||
ib_push_warning(
|
||||
void* ithd, /*!< in: thd */
|
||||
dberr_t error, /*!< in: error code to push as warning */
|
||||
const char *format,/*!< in: warning message */
|
||||
...);
|
||||
/** Report a foreign key error.
|
||||
@param error error to report
|
||||
@param name table name
|
||||
@param foreign constraint */
|
||||
ATTRIBUTE_COLD
|
||||
void innodb_fk_error(const trx_t *trx, dberr_t err, const char *name,
|
||||
const dict_foreign_t& foreign);
|
||||
|
||||
/********************************************************************//**
|
||||
Helper function to push warnings from InnoDB internals to SQL-layer. */
|
||||
|
|
|
@ -1088,13 +1088,11 @@ static ATTRIBUTE_COLD void os_file_log_buffered()
|
|||
log_sys.log_maybe_unbuffered= false;
|
||||
log_sys.log_buffered= true;
|
||||
}
|
||||
# endif
|
||||
|
||||
/** @return whether the log file may work with unbuffered I/O. */
|
||||
static ATTRIBUTE_COLD bool os_file_log_maybe_unbuffered(const struct stat &st)
|
||||
{
|
||||
MSAN_STAT_WORKAROUND(&st);
|
||||
# ifdef __linux__
|
||||
char b[20 + sizeof "/sys/dev/block/" ":" "/../queue/physical_block_size"];
|
||||
if (snprintf(b, sizeof b, "/sys/dev/block/%u:%u/queue/physical_block_size",
|
||||
major(st.st_dev), minor(st.st_dev)) >=
|
||||
|
@ -1126,13 +1124,11 @@ static ATTRIBUTE_COLD bool os_file_log_maybe_unbuffered(const struct stat &st)
|
|||
if (s > 4096 || s < 64 || !ut_is_2pow(s))
|
||||
return false;
|
||||
log_sys.set_block_size(uint32_t(s));
|
||||
# else
|
||||
constexpr unsigned long s= 4096;
|
||||
# endif
|
||||
|
||||
return !(st.st_size & (s - 1));
|
||||
}
|
||||
#endif
|
||||
# endif /* __linux__ */
|
||||
#endif /* O_DIRECT */
|
||||
|
||||
/** NOTE! Use the corresponding macro os_file_create(), not directly
|
||||
this function!
|
||||
|
@ -1187,7 +1183,9 @@ os_file_create_func(
|
|||
ut_a(purpose == OS_FILE_AIO || purpose == OS_FILE_NORMAL);
|
||||
|
||||
#ifdef O_DIRECT
|
||||
# ifdef __linux__
|
||||
struct stat st;
|
||||
# endif
|
||||
ut_a(type == OS_LOG_FILE
|
||||
|| type == OS_DATA_FILE || type == OS_DATA_FILE_NO_O_DIRECT);
|
||||
int direct_flag = 0;
|
||||
|
|
|
@ -3051,7 +3051,8 @@ row_ins_sec_index_entry_low(
|
|||
|
||||
if (err != DB_SUCCESS) {
|
||||
if (err == DB_DECRYPTION_FAILED) {
|
||||
btr_decryption_failed(*index);
|
||||
innodb_decryption_failed(thr_get_trx(thr)->mysql_thd,
|
||||
index->table);
|
||||
}
|
||||
goto func_exit;
|
||||
}
|
||||
|
|
|
@ -4730,13 +4730,9 @@ row_merge_build_indexes(
|
|||
/* Do not continue if we can't encrypt table pages */
|
||||
if (!old_table->is_readable() ||
|
||||
!new_table->is_readable()) {
|
||||
error = DB_DECRYPTION_FAILED;
|
||||
ib_push_warning(trx->mysql_thd, DB_DECRYPTION_FAILED,
|
||||
"Table %s is encrypted but encryption service or"
|
||||
" used key_id is not available. "
|
||||
" Can't continue reading table.",
|
||||
!old_table->is_readable() ? old_table->name.m_name :
|
||||
new_table->name.m_name);
|
||||
error = innodb_decryption_failed(trx->mysql_thd,
|
||||
!old_table->is_readable()
|
||||
? old_table : new_table);
|
||||
goto func_exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -1185,51 +1185,26 @@ row_lock_table(row_prebuilt_t* prebuilt)
|
|||
return(err);
|
||||
}
|
||||
|
||||
/** Determine is tablespace encrypted but decryption failed, is table corrupted
|
||||
or is tablespace .ibd file missing.
|
||||
@param[in] table Table
|
||||
@param[in] trx Transaction
|
||||
@param[in] push_warning true if we should push warning to user
|
||||
/** Report an error for a failure to access a table.
|
||||
@param table unreadable table
|
||||
@param trx transaction
|
||||
@retval DB_DECRYPTION_FAILED table is encrypted but decryption failed
|
||||
@retval DB_CORRUPTION table is corrupted
|
||||
@retval DB_TABLESPACE_NOT_FOUND tablespace .ibd file not found */
|
||||
static
|
||||
dberr_t
|
||||
row_mysql_get_table_status(
|
||||
const dict_table_t* table,
|
||||
trx_t* trx,
|
||||
bool push_warning = true)
|
||||
ATTRIBUTE_COLD
|
||||
static dberr_t row_mysql_get_table_error(trx_t *trx, dict_table_t *table)
|
||||
{
|
||||
dberr_t err;
|
||||
if (const fil_space_t* space = table->space) {
|
||||
if (space->crypt_data && space->crypt_data->is_encrypted()) {
|
||||
// maybe we cannot access the table due to failing
|
||||
// to decrypt
|
||||
if (push_warning) {
|
||||
ib_push_warning(trx, DB_DECRYPTION_FAILED,
|
||||
"Table %s is encrypted."
|
||||
"However key management plugin or used key_id is not found or"
|
||||
" used encryption algorithm or method does not match.",
|
||||
table->name.m_name);
|
||||
}
|
||||
if (const fil_space_t *space= table->space)
|
||||
{
|
||||
if (space->crypt_data && space->crypt_data->is_encrypted())
|
||||
return innodb_decryption_failed(trx->mysql_thd, table);
|
||||
return DB_CORRUPTION;
|
||||
}
|
||||
|
||||
err = DB_DECRYPTION_FAILED;
|
||||
} else {
|
||||
if (push_warning) {
|
||||
ib_push_warning(trx, DB_CORRUPTION,
|
||||
"Table %s in tablespace %lu corrupted.",
|
||||
table->name.m_name, table->space);
|
||||
}
|
||||
|
||||
err = DB_CORRUPTION;
|
||||
}
|
||||
} else {
|
||||
ib::error() << ".ibd file is missing for table "
|
||||
<< table->name;
|
||||
err = DB_TABLESPACE_NOT_FOUND;
|
||||
}
|
||||
|
||||
return(err);
|
||||
const int dblen= int(table->name.dblen());
|
||||
sql_print_error("InnoDB .ibd file is missing for table %`.*s.%`s",
|
||||
dblen, table->name.m_name, table->name.m_name + dblen + 1);
|
||||
return DB_TABLESPACE_NOT_FOUND;
|
||||
}
|
||||
|
||||
/** Does an insert for MySQL.
|
||||
|
@ -1265,7 +1240,7 @@ row_insert_for_mysql(
|
|||
|
||||
return(DB_TABLESPACE_DELETED);
|
||||
} else if (!table->is_readable()) {
|
||||
return row_mysql_get_table_status(table, trx, true);
|
||||
return row_mysql_get_table_error(trx, table);
|
||||
} else if (high_level_read_only) {
|
||||
return(DB_READ_ONLY);
|
||||
} else if (UNIV_UNLIKELY(table->corrupted)
|
||||
|
@ -1622,7 +1597,7 @@ row_update_for_mysql(row_prebuilt_t* prebuilt)
|
|||
ut_ad(table->stat_initialized);
|
||||
|
||||
if (!table->is_readable()) {
|
||||
return(row_mysql_get_table_status(table, trx, true));
|
||||
return row_mysql_get_table_error(trx, table);
|
||||
}
|
||||
|
||||
if (high_level_read_only) {
|
||||
|
|
|
@ -4844,7 +4844,8 @@ page_corrupted:
|
|||
|
||||
if (err != DB_SUCCESS) {
|
||||
if (err == DB_DECRYPTION_FAILED) {
|
||||
btr_decryption_failed(*index);
|
||||
innodb_decryption_failed(trx->mysql_thd,
|
||||
index->table);
|
||||
}
|
||||
rec = NULL;
|
||||
goto page_read_error;
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
@ -1164,13 +1163,7 @@ int ha_spider::extra(
|
|||
if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num)))
|
||||
DBUG_RETURN(error_num);
|
||||
break;
|
||||
#if defined(HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN) || defined(HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF)
|
||||
#ifdef HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
|
||||
case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN:
|
||||
#endif
|
||||
#ifdef HA_EXTRA_HAS_HA_EXTRA_USE_CMP_REF
|
||||
case HA_EXTRA_USE_CMP_REF:
|
||||
#endif
|
||||
DBUG_PRINT("info",("spider HA_EXTRA_STARTING_ORDERED_INDEX_SCAN"));
|
||||
if (table_share->primary_key != MAX_KEY)
|
||||
{
|
||||
|
@ -1198,7 +1191,6 @@ int ha_spider::extra(
|
|||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -6447,9 +6439,7 @@ int ha_spider::info(
|
|||
DBUG_ENTER("ha_spider::info");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
DBUG_PRINT("info",("spider flag=%x", flag));
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
auto_inc_temporary = FALSE;
|
||||
#endif
|
||||
wide_handler->sql_command = thd_sql_command(thd);
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
{
|
||||
|
@ -6458,9 +6448,7 @@ int ha_spider::info(
|
|||
share->lgtm_tblhnd_share->auto_increment_value;
|
||||
else {
|
||||
stats.auto_increment_value = 1;
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
auto_inc_temporary = TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (
|
||||
|
@ -6715,9 +6703,7 @@ int ha_spider::info(
|
|||
}
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
{
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
auto_inc_temporary = FALSE;
|
||||
#endif
|
||||
if (share->wide_share && table->next_number_field)
|
||||
{
|
||||
ulonglong first_value, nb_reserved_values;
|
||||
|
@ -7550,7 +7536,6 @@ bool ha_spider::need_info_for_auto_inc()
|
|||
));
|
||||
}
|
||||
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
bool ha_spider::can_use_for_auto_inc_init()
|
||||
{
|
||||
DBUG_ENTER("ha_spider::can_use_for_auto_inc_init");
|
||||
|
@ -7562,7 +7547,6 @@ bool ha_spider::can_use_for_auto_inc_init()
|
|||
!auto_inc_temporary
|
||||
));
|
||||
}
|
||||
#endif
|
||||
|
||||
int ha_spider::update_auto_increment()
|
||||
{
|
||||
|
@ -7890,19 +7874,11 @@ int ha_spider::end_bulk_update(
|
|||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA
|
||||
int ha_spider::bulk_update_row(
|
||||
const uchar *old_data,
|
||||
const uchar *new_data,
|
||||
ha_rows *dup_key_found
|
||||
)
|
||||
#else
|
||||
int ha_spider::bulk_update_row(
|
||||
const uchar *old_data,
|
||||
uchar *new_data,
|
||||
ha_rows *dup_key_found
|
||||
)
|
||||
#endif
|
||||
{
|
||||
DBUG_ENTER("ha_spider::bulk_update_row");
|
||||
DBUG_PRINT("info",("spider this=%p", this));
|
||||
|
@ -7910,17 +7886,10 @@ int ha_spider::bulk_update_row(
|
|||
DBUG_RETURN(update_row(old_data, new_data));
|
||||
}
|
||||
|
||||
#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA
|
||||
int ha_spider::update_row(
|
||||
const uchar *old_data,
|
||||
const uchar *new_data
|
||||
)
|
||||
#else
|
||||
int ha_spider::update_row(
|
||||
const uchar *old_data,
|
||||
uchar *new_data
|
||||
)
|
||||
#endif
|
||||
{
|
||||
int error_num;
|
||||
THD *thd = ha_thd();
|
||||
|
|
|
@ -121,9 +121,7 @@ public:
|
|||
bool pre_bitmap_checked;
|
||||
bool bulk_insert;
|
||||
bool info_auto_called;
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
bool auto_inc_temporary;
|
||||
#endif
|
||||
int bulk_size= 0;
|
||||
int direct_dup_insert;
|
||||
int store_error_num;
|
||||
|
@ -353,9 +351,7 @@ public:
|
|||
uint max_supported_key_part_length() const override;
|
||||
uint8 table_cache_type() override;
|
||||
bool need_info_for_auto_inc() override;
|
||||
#ifdef HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
bool can_use_for_auto_inc_init() override;
|
||||
#endif
|
||||
int update_auto_increment();
|
||||
void get_auto_increment(
|
||||
ulonglong offset,
|
||||
|
@ -376,7 +372,6 @@ public:
|
|||
bool start_bulk_update() override;
|
||||
int exec_bulk_update(ha_rows *dup_key_found) override;
|
||||
int end_bulk_update() override;
|
||||
#ifdef SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA
|
||||
int bulk_update_row(
|
||||
const uchar *old_data,
|
||||
const uchar *new_data,
|
||||
|
@ -386,17 +381,6 @@ public:
|
|||
const uchar *old_data,
|
||||
const uchar *new_data
|
||||
) override;
|
||||
#else
|
||||
int bulk_update_row(
|
||||
const uchar *old_data,
|
||||
uchar *new_data,
|
||||
ha_rows *dup_key_found
|
||||
);
|
||||
int update_row(
|
||||
const uchar *old_data,
|
||||
uchar *new_data
|
||||
);
|
||||
#endif
|
||||
bool check_direct_update_sql_part(
|
||||
st_select_lex *select_lex,
|
||||
longlong select_limit,
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
@ -3279,32 +3278,6 @@ void *spider_bg_crd_action(
|
|||
share->conn_keys[spider.search_link_idx], trx,
|
||||
&spider, FALSE, FALSE, &error_num);
|
||||
conns[spider.search_link_idx]->error_mode = 0;
|
||||
/*
|
||||
if (
|
||||
error_num &&
|
||||
share->monitoring_kind[spider.search_link_idx] &&
|
||||
need_mons[spider.search_link_idx]
|
||||
) {
|
||||
lex_start(thd);
|
||||
error_num = spider_ping_table_mon_from_table(
|
||||
trx,
|
||||
thd,
|
||||
share,
|
||||
spider.search_link_idx,
|
||||
(uint32) share->monitoring_sid[spider.search_link_idx],
|
||||
share->table_name,
|
||||
share->table_name_length,
|
||||
spider.conn_link_idx[spider.search_link_idx],
|
||||
NULL,
|
||||
0,
|
||||
share->monitoring_kind[spider.search_link_idx],
|
||||
share->monitoring_limit[spider.search_link_idx],
|
||||
share->monitoring_flag[spider.search_link_idx],
|
||||
TRUE
|
||||
);
|
||||
lex_end(thd->lex);
|
||||
}
|
||||
*/
|
||||
spider.search_link_idx = -1;
|
||||
}
|
||||
if (spider.search_link_idx != -1 && conns[spider.search_link_idx])
|
||||
|
@ -3315,31 +3288,6 @@ void *spider_bg_crd_action(
|
|||
share->bg_crd_sync,
|
||||
2))
|
||||
{
|
||||
/*
|
||||
if (
|
||||
share->monitoring_kind[spider.search_link_idx] &&
|
||||
need_mons[spider.search_link_idx]
|
||||
) {
|
||||
lex_start(thd);
|
||||
error_num = spider_ping_table_mon_from_table(
|
||||
trx,
|
||||
thd,
|
||||
share,
|
||||
spider.search_link_idx,
|
||||
(uint32) share->monitoring_sid[spider.search_link_idx],
|
||||
share->table_name,
|
||||
share->table_name_length,
|
||||
spider.conn_link_idx[spider.search_link_idx],
|
||||
NULL,
|
||||
0,
|
||||
share->monitoring_kind[spider.search_link_idx],
|
||||
share->monitoring_limit[spider.search_link_idx],
|
||||
share->monitoring_flag[spider.search_link_idx],
|
||||
TRUE
|
||||
);
|
||||
lex_end(thd->lex);
|
||||
}
|
||||
*/
|
||||
spider.search_link_idx = -1;
|
||||
}
|
||||
}
|
||||
|
@ -3644,17 +3592,11 @@ void *spider_bg_mon_action(
|
|||
share->monitoring_bg_interval[link_idx] * 1000);
|
||||
pthread_cond_timedwait(&share->bg_mon_sleep_conds[link_idx],
|
||||
&share->bg_mon_mutexes[link_idx], &abstime);
|
||||
/*
|
||||
my_sleep((ulong) share->monitoring_bg_interval[link_idx]);
|
||||
*/
|
||||
}
|
||||
DBUG_PRINT("info",("spider bg mon roop start"));
|
||||
if (share->bg_mon_kill)
|
||||
{
|
||||
DBUG_PRINT("info",("spider bg mon kill start"));
|
||||
/*
|
||||
pthread_mutex_lock(&share->bg_mon_mutexes[link_idx]);
|
||||
*/
|
||||
pthread_cond_signal(&share->bg_mon_conds[link_idx]);
|
||||
pthread_mutex_unlock(&share->bg_mon_mutexes[link_idx]);
|
||||
spider_free_trx(trx, TRUE);
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
@ -2007,9 +2006,7 @@ int spider_db_mbase::connect(
|
|||
connect_retry_count--;
|
||||
my_sleep((ulong) connect_retry_interval);
|
||||
} else {
|
||||
#ifdef SPIDER_NET_HAS_THD
|
||||
db_conn->net.thd = NULL;
|
||||
#endif
|
||||
if (connect_mutex)
|
||||
pthread_mutex_unlock(&spider_open_conn_mutex);
|
||||
break;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
/* Copyright (C) 2008-2020 Kentoku Shiba
|
||||
Copyright (C) 2017-2020 MariaDB corp
|
||||
|
||||
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
|
||||
the Free Software Foundation; version 2 of the License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */
|
||||
|
||||
/*
|
||||
Define functionality offered by MySQL or MariaDB
|
||||
*/
|
||||
|
||||
#ifndef SPD_ENVIRON_INCLUDED
|
||||
|
||||
#define SPIDER_NET_HAS_THD
|
||||
#define HANDLER_HAS_TOP_TABLE_FIELDS
|
||||
#define PARTITION_HAS_GET_PART_SPEC
|
||||
#define HA_EXTRA_HAS_STARTING_ORDERED_INDEX_SCAN
|
||||
#define HANDLER_HAS_CAN_USE_FOR_AUTO_INC_INIT
|
||||
#define SPIDER_UPDATE_ROW_HAS_CONST_NEW_DATA
|
||||
#endif /* SPD_ENVIRON_INCLUDED */
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -87,8 +87,6 @@
|
|||
|
||||
#define SPIDER_ENGINE_CONDITION_PUSHDOWN_IS_ALWAYS_ON
|
||||
|
||||
#define SPIDER_Item_args_arg_count_IS_PROTECTED
|
||||
|
||||
#define SPIDER_Item_func_conv_charset_conv_charset collation.collation
|
||||
|
||||
#define SPIDER_WITHOUT_HA_STATISTIC_INCREMENT
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "my_getopt.h"
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "mysql_version.h"
|
||||
#include "spd_environ.h"
|
||||
#include "sql_priv.h"
|
||||
#include "probes_mysql.h"
|
||||
#include "sql_class.h"
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
#define MYSQL_SERVER 1
|
||||
#include <my_global.h>
|
||||
#include "spd_environ.h"
|
||||
#include "mysql.h"
|
||||
#include "spd_udf.h"
|
||||
|
||||
|
|
Loading…
Reference in a new issue