Commit 7b97020d authored by Marko Mäkelä's avatar Marko Mäkelä

Merge 10.3 into 10.4

parents 5172f132 02da00a9
source have_federatedx.inc;
source include/have_binlog_format_row.inc;
source include/master-slave.inc;
......
......@@ -25,3 +25,10 @@ f1
disconnect con1;
connection default;
drop table t1;
#
# MDEV-27993 Assertion failed in btr_page_reorganize_low()
#
CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
SET DEBUG_DBUG = '+d,do_page_reorganize';
INSERT INTO t1 VALUES(0,0);
DROP TABLE t1;
......@@ -53,4 +53,12 @@ connection default;
drop table t1;
--echo #
--echo # MDEV-27993 Assertion failed in btr_page_reorganize_low()
--echo #
CREATE TABLE t1(a INT PRIMARY KEY, b INT UNIQUE) ENGINE=InnoDB;
SET DEBUG_DBUG = '+d,do_page_reorganize';
INSERT INTO t1 VALUES(0,0);
DROP TABLE t1;
--source include/wait_until_count_sessions.inc
......@@ -289,3 +289,32 @@ ENGINE=InnoDB;
ALTER TABLE t1 ADD c SERIAL;
DROP TABLE t1;
# End of 10.3 tests
#
# MDEV-27582 Fulltext DDL decrements the FTS_DOC_ID value
#
CREATE TABLE t1 (
f1 INT NOT NULL PRIMARY KEY,
f2 VARCHAR(64), FULLTEXT ft(f2)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
connect con1,localhost,root,,,;
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
DELETE FROM t1 WHERE f1 = 2;
ALTER TABLE t1 DROP INDEX ft;
ALTER TABLE t1 ADD FULLTEXT INDEX ft (f2);
INSERT INTO t1 VALUES (3, 'innodb fts search');
SET GLOBAL innodb_optimize_fulltext_only=ON;
OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
SET GLOBAL innodb_ft_aux_table = 'test/t1';
SELECT max(DOC_ID) FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE;
max(DOC_ID)
3
SELECT * FROM t1 WHERE MATCH(f2) AGAINST("+innodb +search" IN BOOLEAN MODE);
f1 f2
3 innodb fts search
DROP TABLE t1;
disconnect con1;
SET GLOBAL innodb_optimize_fulltext_only=OFF;
SET GLOBAL innodb_ft_aux_table = default;
--enable-plugin-innodb-sys-tables
--innodb_ft_index_table
......@@ -357,3 +357,28 @@ ALTER TABLE t1 ADD c SERIAL;
DROP TABLE t1;
--echo # End of 10.3 tests
--echo #
--echo # MDEV-27582 Fulltext DDL decrements the FTS_DOC_ID value
--echo #
CREATE TABLE t1 (
f1 INT NOT NULL PRIMARY KEY,
f2 VARCHAR(64), FULLTEXT ft(f2)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
connect(con1,localhost,root,,,);
START TRANSACTION WITH CONSISTENT SNAPSHOT;
connection default;
DELETE FROM t1 WHERE f1 = 2;
ALTER TABLE t1 DROP INDEX ft;
ALTER TABLE t1 ADD FULLTEXT INDEX ft (f2);
INSERT INTO t1 VALUES (3, 'innodb fts search');
SET GLOBAL innodb_optimize_fulltext_only=ON;
OPTIMIZE TABLE t1;
SET GLOBAL innodb_ft_aux_table = 'test/t1';
SELECT max(DOC_ID) FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE;
SELECT * FROM t1 WHERE MATCH(f2) AGAINST("+innodb +search" IN BOOLEAN MODE);
DROP TABLE t1;
disconnect con1;
SET GLOBAL innodb_optimize_fulltext_only=OFF;
SET GLOBAL innodb_ft_aux_table = default;
......@@ -512,10 +512,11 @@ then
args="$args --user=$user"
fi
if test -n "$group"
then
args="$args --group=$group"
fi
#To be enabled if/when we enable --group as an option to mysqld
#if test -n "$group"
#then
# args="$args --group=$group"
#fi
if test -f "$ldata/mysql/user.frm"
then
......
......@@ -703,6 +703,7 @@ then
if test "$user" != "root" -o $SET_USER = 1
then
USER_OPTION="--user=$user"
# To be used if/when we enable --system-group as an option to mysqld
GROUP_OPTION="--group=$group"
fi
if test -n "$open_files"
......
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates.
Copyright (c) 2009, 2020, MariaDB
Copyright (c) 2009, 2022, MariaDB
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
......@@ -3406,6 +3406,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
thd->alloc(f_args.arg_count*sizeof(Item_result))))
{
err_exit:
free_udf(u_d);
DBUG_RETURN(TRUE);
}
......@@ -3445,7 +3446,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
func->used_tables_and_const_cache_join(item);
f_args.arg_type[i]=item->result_type();
}
if (!(buffers=new (thd->mem_root) String[arg_count]) ||
buffers=new (thd->mem_root) String[arg_count];
if (!buffers ||
!multi_alloc_root(thd->mem_root,
&f_args.args, arg_count * sizeof(char *),
&f_args.lengths, arg_count * sizeof(long),
......@@ -3454,10 +3456,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
&f_args.attributes, arg_count * sizeof(char *),
&f_args.attribute_lengths, arg_count * sizeof(long),
NullS))
{
free_udf(u_d);
DBUG_RETURN(TRUE);
}
goto err_exit;
}
if (func->fix_length_and_dec())
DBUG_RETURN(TRUE);
......@@ -3525,8 +3524,7 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func,
{
my_error(ER_CANT_INITIALIZE_UDF, MYF(0),
u_d->name.str, init_msg_buff);
free_udf(u_d);
DBUG_RETURN(TRUE);
goto err_exit;
}
func->max_length=MY_MIN(initid.max_length,MAX_BLOB_WIDTH);
func->maybe_null=initid.maybe_null;
......
......@@ -3,7 +3,7 @@
Copyright (c) 1994, 2019, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2012, Facebook Inc.
Copyright (c) 2015, 2021, MariaDB Corporation.
Copyright (c) 2015, 2022, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
......@@ -3565,6 +3565,7 @@ btr_cur_optimistic_insert(
<< ib::hex(thr ? thr->graph->trx->id : 0)
<< ' ' << rec_printer(entry).str());
DBUG_EXECUTE_IF("do_page_reorganize",
if (n_recs)
btr_page_reorganize(page_cursor, index, mtr););
/* Now, try the insert */
......
......@@ -231,18 +231,6 @@ fts_add_doc_by_id(
/*==============*/
fts_trx_table_t*ftt, /*!< in: FTS trx table */
doc_id_t doc_id); /*!< in: doc id */
/******************************************************************//**
Update the last document id. This function could create a new
transaction to update the last document id.
@return DB_SUCCESS if OK */
static
dberr_t
fts_update_sync_doc_id(
/*===================*/
const dict_table_t* table, /*!< in: table */
doc_id_t doc_id, /*!< in: last document id */
trx_t* trx) /*!< in: update trx, or NULL */
MY_ATTRIBUTE((nonnull(1)));
/** Tokenize a document.
@param[in,out] doc document to tokenize
......@@ -2540,27 +2528,6 @@ fts_get_max_cache_size(
}
#endif
/*********************************************************************//**
Update the next and last Doc ID in the CONFIG table to be the input
"doc_id" value (+ 1). We would do so after each FTS index build or
table truncate */
void
fts_update_next_doc_id(
/*===================*/
trx_t* trx, /*!< in/out: transaction */
const dict_table_t* table, /*!< in: table */
doc_id_t doc_id) /*!< in: DOC ID to set */
{
table->fts->cache->synced_doc_id = doc_id;
table->fts->cache->next_doc_id = doc_id + 1;
table->fts->cache->first_doc_id = table->fts->cache->next_doc_id;
fts_update_sync_doc_id(
table, table->fts->cache->synced_doc_id, trx);
}
/*********************************************************************//**
Get the next available document id.
@return DB_SUCCESS if OK */
......@@ -2719,17 +2686,17 @@ fts_cmp_set_sync_doc_id(
return(error);
}
/*********************************************************************//**
Update the last document id. This function could create a new
/** Update the last document id. This function could create a new
transaction to update the last document id.
@return DB_SUCCESS if OK */
static
@param table table to be updated
@param doc_id last document id
@param trx update trx or null
@retval DB_SUCCESS if OK */
dberr_t
fts_update_sync_doc_id(
/*===================*/
const dict_table_t* table, /*!< in: table */
doc_id_t doc_id, /*!< in: last document id */
trx_t* trx) /*!< in: update trx, or NULL */
const dict_table_t* table,
doc_id_t doc_id,
trx_t* trx)
{
byte id[FTS_MAX_ID_LEN];
pars_info_t* info;
......
......@@ -2678,63 +2678,6 @@ innobase_next_autoinc(
return(~(ulonglong) 0);
}
/********************************************************************//**
Reset the autoinc value in the table.
@return DB_SUCCESS if all went well else error code */
UNIV_INTERN
dberr_t
ha_innobase::innobase_reset_autoinc(
/*================================*/
ulonglong autoinc) /*!< in: value to store */
{
dberr_t error;
error = innobase_lock_autoinc();
if (error == DB_SUCCESS) {
dict_table_autoinc_initialize(m_prebuilt->table, autoinc);
m_prebuilt->table->autoinc_mutex.unlock();
}
return(error);
}
/*******************************************************************//**
Reset the auto-increment counter to the given value, i.e. the next row
inserted will get the given value. This is called e.g. after TRUNCATE
is emulated by doing a 'DELETE FROM t'. HA_ERR_WRONG_COMMAND is
returned by storage engines that don't support this operation.
@return 0 or error code */
UNIV_INTERN
int
ha_innobase::reset_auto_increment(
/*==============================*/
ulonglong value) /*!< in: new value for table autoinc */
{
DBUG_ENTER("ha_innobase::reset_auto_increment");
dberr_t error;
update_thd(ha_thd());
error = row_lock_table_autoinc_for_mysql(m_prebuilt);
if (error != DB_SUCCESS) {
DBUG_RETURN(convert_error_code_to_mysql(
error, m_prebuilt->table->flags, m_user_thd));
}
/* The next value can never be 0. */
if (value == 0) {
value = 1;
}
innobase_reset_autoinc(value);
DBUG_RETURN(0);
}
/*********************************************************************//**
Initializes some fields in an InnoDB transaction object. */
static
......@@ -9103,16 +9046,6 @@ ha_innobase::delete_row(
error, m_prebuilt->table->flags, m_user_thd));
}
/** Delete all rows from the table.
@return error number or 0 */
int
ha_innobase::delete_all_rows()
{
DBUG_ENTER("ha_innobase::delete_all_rows");
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
}
/**********************************************************************//**
Removes a new lock set on a row, if it was not read optimistically. This can
be called after a row has been read in the processing of an UPDATE or a DELETE
......
/*****************************************************************************
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2013, 2021, MariaDB Corporation.
Copyright (c) 2013, 2022, 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 the Free Software
......@@ -105,8 +105,6 @@ class ha_innobase final: public handler
double read_time(uint index, uint ranges, ha_rows rows) override;
int delete_all_rows() override;
int write_row(const uchar * buf) override;
int update_row(const uchar * old_data, const uchar * new_data) override;
......@@ -239,7 +237,6 @@ class ha_innobase final: public handler
ulonglong nb_desired_values,
ulonglong* first_value,
ulonglong* nb_reserved_values) override;
int reset_auto_increment(ulonglong value) override;
bool get_error_message(int error, String *buf) override;
......@@ -449,7 +446,6 @@ class ha_innobase final: public handler
dberr_t innobase_lock_autoinc();
ulonglong innobase_peek_autoinc();
dberr_t innobase_set_max_autoinc(ulonglong auto_inc);
dberr_t innobase_reset_autoinc(ulonglong auto_inc);
/** Resets a query execution 'template'.
@see build_template() */
......
......@@ -402,17 +402,6 @@ fts_get_next_doc_id(
/*================*/
const dict_table_t* table, /*!< in: table */
doc_id_t* doc_id);/*!< out: new document id */
/*********************************************************************//**
Update the next and last Doc ID in the CONFIG table to be the input
"doc_id" value (+ 1). We would do so after each FTS index build or
table truncate */
void
fts_update_next_doc_id(
/*===================*/
trx_t* trx, /*!< in/out: transaction */
const dict_table_t* table, /*!< in: table */
doc_id_t doc_id) /*!< in: DOC ID to set */
MY_ATTRIBUTE((nonnull(2)));
/******************************************************************//**
Create a new fts_doc_ids_t.
......@@ -964,4 +953,16 @@ bool fts_check_aux_table(const char *name,
table_id_t *table_id,
index_id_t *index_id);
/** Update the last document id. This function could create a new
transaction to update the last document id.
@param table table to be updated
@param doc_id last document id
@param trx update trx or null
@retval DB_SUCCESS if OK */
dberr_t
fts_update_sync_doc_id(const dict_table_t *table,
doc_id_t doc_id,
trx_t *trx)
MY_ATTRIBUTE((nonnull(1)));
#endif /*!< fts0fts.h */
......@@ -2861,7 +2861,21 @@ row_merge_read_clustered_index(
err = fts_sync_table(const_cast<dict_table_t*>(new_table));
if (err == DB_SUCCESS) {
fts_update_next_doc_id(NULL, new_table, max_doc_id);
new_table->fts->cache->synced_doc_id = max_doc_id;
/* Update the max value as next FTS_DOC_ID */
if (max_doc_id >= new_table->fts->cache->next_doc_id) {
new_table->fts->cache->next_doc_id =
max_doc_id + 1;
}
new_table->fts->cache->first_doc_id =
new_table->fts->cache->next_doc_id;
err= fts_update_sync_doc_id(
new_table,
new_table->fts->cache->synced_doc_id,
NULL);
}
}
......
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