Merge branch '10.6' into 10.11

This commit is contained in:
Oleksandr Byelkin 2025-09-12 13:08:40 +02:00
commit 0707dac202
22 changed files with 204 additions and 46 deletions

View file

@ -1870,6 +1870,26 @@ static char *cover_definer_clause(const char *stmt_str,
return query_str;
}
static const char* build_path_for_table(char *to, const char *dir,
const char *table, const char *ext)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path, path, NULL);
my_load_path(tmp_path, tmp_path, NULL);
if (check_if_legal_tablename(table))
strxnmov(filename, sizeof(filename) - 1, table, "@@@", NULL);
else
{
uint errors, len;
len= my_convert(filename, sizeof(filename) - 1, &my_charset_filename,
table, (uint32)strlen(table), charset_info, &errors);
filename[len]= 0;
}
return fn_format(to, filename, tmp_path, ext, MYF(MY_UNPACK_FILENAME));
}
/*
Open a new .sql file to dump the table or view into
@ -1884,12 +1904,9 @@ static char *cover_definer_clause(const char *stmt_str,
*/
static FILE* open_sql_file_for_table(const char* table, int flags)
{
FILE* res;
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
convert_dirname(tmp_path,path,NullS);
res= my_fopen(fn_format(filename, table, tmp_path, ".sql", 4),
char filename[FN_REFLEN];
return my_fopen(build_path_for_table(filename, path, table, ".sql"),
flags, MYF(MY_WME));
return res;
}
@ -4135,14 +4152,9 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
if (path)
{
char filename[FN_REFLEN], tmp_path[FN_REFLEN];
/*
Convert the path to native os format
and resolve to the full filepath.
*/
convert_dirname(tmp_path,path,NullS);
my_load_path(tmp_path, tmp_path, NULL);
fn_format(filename, table, tmp_path, ".txt", MYF(MY_UNPACK_FILENAME));
char filename[FN_REFLEN];
build_path_for_table(filename, path, table, ".txt");
/* Must delete the file that 'INTO OUTFILE' will write to */
my_delete(filename, MYF(0));
@ -4151,7 +4163,6 @@ static void dump_table(const char *table, const char *db, const uchar *hash_key,
to_unix_path(filename);
/* now build the query string */
dynstr_append_checked(&query_string, "SELECT /*!40001 SQL_NO_CACHE */ ");
dynstr_append_checked(&query_string, select_field_names.str);
dynstr_append_checked(&query_string, " INTO OUTFILE '");

View file

@ -339,7 +339,17 @@ static int write_to_table(char *filename, MYSQL *mysql)
DBUG_ENTER("write_to_table");
DBUG_PRINT("enter",("filename: %s",filename));
fn_format(tablename, filename, "", "", 1 | 2); /* removes path & ext. */
fn_format(tablename, filename, "", "", MYF(MY_REPLACE_DIR | MY_REPLACE_EXT));
if (strchr(tablename, '@'))
{
uint errors, len;
CHARSET_INFO *cs=
get_charset_by_csname(default_charset, MY_CS_PRIMARY, MYF(0));
len= my_convert(escaped_name, sizeof(escaped_name) - 1, cs, tablename,
(uint32)strlen(tablename), &my_charset_filename, &errors);
if (!errors)
strmake(tablename, escaped_name, len);
}
if (!opt_local_file)
strmov(hard_path,filename);
else
@ -489,7 +499,7 @@ static MYSQL *db_connect(char *host, char *database,
if (!strcmp(default_charset,MYSQL_AUTODETECT_CHARSET_NAME))
default_charset= (char *)my_default_csname();
my_set_console_cp(default_charset);
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, my_default_csname());
mysql_options(mysql, MYSQL_SET_CHARSET_NAME, default_charset);
mysql_options(mysql, MYSQL_OPT_CONNECT_ATTR_RESET, 0);
mysql_options4(mysql, MYSQL_OPT_CONNECT_ATTR_ADD,
"program_name", "mysqlimport");

View file

@ -5969,3 +5969,10 @@ b rank() over (order by c)
drop view v1;
drop table t1;
# End of 10.4 tests
#
# MDEV-32308: Server crash on cleanup of
# non-fully-constructed-due-to-an-error CTE
#
SELECT ( WITH RECURSIVE x AS ( WITH x AS ( SELECT 1 FROM t14 ) SELECT x ) , t14 AS ( SELECT 1 UNION SELECT 'x' FROM x ) SELECT x FROM x WHERE ( SELECT x FROM x ) ) ;
ERROR 42S22: Unknown column 'x' in 'SELECT'
# End of 10.6 tests

View file

@ -4056,3 +4056,12 @@ drop view v1;
drop table t1;
--echo # End of 10.4 tests
--echo #
--echo # MDEV-32308: Server crash on cleanup of
--echo # non-fully-constructed-due-to-an-error CTE
--echo #
--error ER_BAD_FIELD_ERROR
SELECT ( WITH RECURSIVE x AS ( WITH x AS ( SELECT 1 FROM t14 ) SELECT x ) , t14 AS ( SELECT 1 UNION SELECT 'x' FROM x ) SELECT x FROM x WHERE ( SELECT x FROM x ) ) ;
--echo # End of 10.6 tests

View file

@ -6781,6 +6781,52 @@ drop view `v'1"2`;
drop table t1;
# End of 10.5 tests
#
# MDEV-37483 mariadb-dump -T doesn't convert table names
#
create database foo;
use foo;
create table `con_schöne_grüße` (a int) select 1 as a;
create table `con` (b int) select 2 as b;
create table `con/bar` (c int) select 3 as c;
create table `con@fame` (d int) select 4 as d;
drop database foo;
use test;
con@002fbar.sql
con@002fbar.txt
con@@@.sql
con@@@.txt
con@fame.sql
con@fame.txt
con_sch@1ine_gr@1o@1je.sql
con_sch@1ine_gr@1o@1je.txt
show tables;
Tables_in_test
con
con/bar
con@fame
con_schöne_grüße
test.con: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
test.con/bar: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
test.con_schöne_grüße: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
test.con@fame: Records: 1 Deleted: 0 Skipped: 0 Warnings: 0
select * from `con_schöne_grüße`;
a
1
select * from `con`;
b
2
select * from `con/bar`;
c
3
select * from `con@fame`;
d
4
drop table `con_schöne_grüße`;
drop table `con`;
drop table `con/bar`;
drop table `con@fame`;
# End of 10.6 tests
#
# MDEV-16733 mysqldump --tab and --xml options are conflicting
#
mariadb-dump: --xml can't be used with --tab.

View file

@ -3040,6 +3040,42 @@ drop table t1;
--echo # End of 10.5 tests
--echo #
--echo # MDEV-37483 mariadb-dump -T doesn't convert table names
--echo #
create database foo;
use foo;
create table `con_schöne_grüße` (a int) select 1 as a;
create table `con` (b int) select 2 as b;
create table `con/bar` (c int) select 3 as c;
create table `con@fame` (d int) select 4 as d;
exec $MYSQL_DUMP foo --tab $MYSQLTEST_VARDIR/tmp;
drop database foo;
use test;
move_file $MYSQLTEST_VARDIR/tmp/con@0040fame.sql $MYSQLTEST_VARDIR/tmp/con@fame.sql;
move_file $MYSQLTEST_VARDIR/tmp/con@0040fame.txt $MYSQLTEST_VARDIR/tmp/con@fame.txt;
list_files $MYSQLTEST_VARDIR/tmp con*;
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/con@@@.sql;
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/con@002fbar.sql;
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/con_sch@1ine_gr@1o@1je.sql;
exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/con@fame.sql;
show tables;
exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/con@@@.txt;
exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/con@002fbar.txt;
exec $MYSQL_IMPORT --default-character-set=utf8mb4 test $MYSQLTEST_VARDIR/tmp/con_sch@1ine_gr@1o@1je.txt;
exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/con@fame.txt;
select * from `con_schöne_grüße`;
select * from `con`;
select * from `con/bar`;
select * from `con@fame`;
drop table `con_schöne_grüße`;
drop table `con`;
drop table `con/bar`;
drop table `con@fame`;
--echo # End of 10.6 tests
--echo #
--echo # MDEV-16733 mysqldump --tab and --xml options are conflicting
--echo #

View file

@ -10,6 +10,7 @@
#
--source include/galera_cluster.inc
--source include/no_protocol.inc
--source include/have_innodb.inc
--source include/force_restart.inc

View file

@ -4,6 +4,15 @@ INSERT INTO t1 VALUES(1, 'sql'), (2, 'server'), (3, 'mariadb'),
(4, 'mariadb'), (5, 'test1'), (6, 'test2'), (7, 'test3'),
(8, 'test4'), (9, 'test5'), (10, 'test6'), (11, 'test7'),
(12, 'test8');
call mtr.add_suppression("InnoDB: Cannot apply log to \\[page id: space=[1-9], page number=0\\] of corrupted file '.*mdev_37412\\.ibd'");
SET GLOBAL innodb_log_checkpoint_now=ON;
CREATE TABLE mdev_37412(id INT AUTO_INCREMENT, PRIMARY KEY(id))
STATS_PERSISTENT=0 ENGINE=InnoDB;
# Kill the server
# restart: --debug_dbug=+d,recv_corrupt
SELECT * FROM mdev_37412;
id
DROP TABLE mdev_37412;
SELECT COUNT(*) FROM t1;
COUNT(*)
12

View file

@ -21,8 +21,23 @@ INSERT INTO t1 VALUES(1, 'sql'), (2, 'server'), (3, 'mariadb'),
(8, 'test4'), (9, 'test5'), (10, 'test6'), (11, 'test7'),
(12, 'test8');
call mtr.add_suppression("InnoDB: Cannot apply log to \\[page id: space=[1-9], page number=0\\] of corrupted file '.*mdev_37412\\.ibd'");
SET GLOBAL innodb_log_checkpoint_now=ON;
--source ../include/no_checkpoint_start.inc
CREATE TABLE mdev_37412(id INT AUTO_INCREMENT, PRIMARY KEY(id))
STATS_PERSISTENT=0 ENGINE=InnoDB;
--let CLEANUP_IF_CHECKPOINT=DROP TABLE t1,mdev_37412;
--source ../include/no_checkpoint_end.inc
--let $restart_parameters=--debug_dbug=+d,recv_corrupt
--source include/start_mysqld.inc
let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
let SEARCH_PATTERN= InnoDB: Cannot apply log to \\[page id: space=[1-9], page number=0\\] of corrupted file '.*mdev_37412\\.ibd';
--let $restart_parameters=
let $restart_noprint=2;
--source include/restart_mysqld.inc
SELECT * FROM mdev_37412;
DROP TABLE mdev_37412;
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
let MYSQLD_DATADIR=`select @@datadir`;

View file

@ -1,6 +1,9 @@
create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1;
insert into t1 values (1000,1000,1000);
insert into t1 select seq,seq+100, seq+200 from seq_1_to_10;
select sum(a),sum(b),sum(c) from t1;
sum(a) sum(b) sum(c)
1055 2055 3055
SET GLOBAL debug_dbug="+d,crash_end_bulk_insert";
REPLACE into t1 select seq+20,seq+95, seq + 300 from seq_1_to_10;
ERROR HY000: Lost connection to server during query

View file

@ -18,6 +18,8 @@ create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=
insert into t1 values (1000,1000,1000);
insert into t1 select seq,seq+100, seq+200 from seq_1_to_10;
select sum(a),sum(b),sum(c) from t1;
# Insert into t1 with batch insert where we get a rows replaced after
# a few sucessful inserts

View file

@ -31,4 +31,10 @@ set transaction isolation level read committed;
update t1 for portion of p from '1980-01-01' to '1980-01-02' set a = 1;
ERROR 23000: Duplicate entry 'foo' for key 'f'
drop table t1;
#
# MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
#
create table t (f int,s date,e date,period for p (s,e),unique (f,p without overlaps)) with system versioning partition by system_time limit+1 (partition p history,partition pn current);
delete from t;
drop table t;
# End of 10.6 tests

View file

@ -41,4 +41,11 @@ set transaction isolation level read committed;
update t1 for portion of p from '1980-01-01' to '1980-01-02' set a = 1;
drop table t1;
--echo #
--echo # MDEV-37397 Assertion `bitmap_is_set(&read_partitions, next->id)' failed in int partition_info::vers_set_hist_part(THD *)
--echo #
create table t (f int,s date,e date,period for p (s,e),unique (f,p without overlaps)) with system versioning partition by system_time limit+1 (partition p history,partition pn current);
delete from t;
drop table t;
--echo # End of 10.6 tests

View file

@ -578,6 +578,9 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
}
}
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
table->file->prepare_for_insert(1);
#ifdef WITH_PARTITION_STORAGE_ENGINE
if (prune_partitions(thd, table, conds))
{
@ -888,8 +891,6 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
&& !table->versioned()
&& table->file->has_transactions();
if (table->versioned(VERS_TIMESTAMP) || (table_list->has_period()))
table->file->prepare_for_insert(1);
DBUG_ASSERT(table->file->inited != handler::NONE);
THD_STAGE_INFO(thd, stage_updating);

View file

@ -2624,6 +2624,7 @@ bool st_select_lex_unit::cleanup()
With_element *with_elem= with_element;
while ((with_elem= with_elem->get_next_mutually_recursive()) !=
with_element)
if (with_elem->rec_result)
with_elem->rec_result->cleanup_count++;
DBUG_RETURN(FALSE);
}

View file

@ -563,6 +563,7 @@ int mysql_update(THD *thd,
// Don't count on usage of 'only index' when calculating which key to use
table->covering_keys.clear_all();
table->file->prepare_for_insert(1);
transactional_table= table->file->has_transactions_and_rollback();
#ifdef WITH_PARTITION_STORAGE_ENGINE
@ -1031,7 +1032,6 @@ update_begin:
can_compare_record= records_are_comparable(table);
explain->tracker.on_scan_init();
table->file->prepare_for_insert(1);
DBUG_ASSERT(table->file->inited != handler::NONE);
THD_STAGE_INFO(thd, stage_updating);

View file

@ -3448,6 +3448,10 @@ static buf_block_t *recv_recover_page(buf_block_t *block, mtr_t &mtr,
block->page.id().page_no()));
log_phys_t::apply_status a= l->apply(*block, recs.last_offset);
DBUG_EXECUTE_IF("recv_corrupt",
if (init && init->created &&
(!space || space->id != 0))
a= log_phys_t::APPLIED_CORRUPTED;);
switch (a) {
case log_phys_t::APPLIED_NO:
@ -3519,17 +3523,9 @@ set_start_lsn:
mtr.discard_modifications();
mtr.commit();
fil_space_t* s = space
? space
: fil_space_t::get(block->page.id().space());
buf_pool.corrupted_evict(&block->page,
block->page.state() &
buf_page_t::LRU_MASK);
if (!space) {
s->release();
}
return nullptr;
}
@ -3926,7 +3922,6 @@ inline buf_block_t *recv_sys_t::recover_low(const map::iterator &p, mtr_t &mtr,
DBUG_LOG("ib_log", "skip log for page " << p->first
<< " LSN " << end_lsn << " < " << init.lsn);
fil_space_t *space= fil_space_t::get(p->first.space());
mtr.start();
mtr.set_log_mode(MTR_LOG_NO_REDO);
@ -3946,7 +3941,6 @@ inline buf_block_t *recv_sys_t::recover_low(const map::iterator &p, mtr_t &mtr,
zip_size= fil_space_t::zip_size(flags);
block= buf_page_create_deferred(p->first.space(), zip_size, &mtr, b);
ut_ad(block == b);
block->page.lock.x_lock_recursive();
}
else
{
@ -3965,6 +3959,8 @@ inline buf_block_t *recv_sys_t::recover_low(const map::iterator &p, mtr_t &mtr,
}
}
/* Released in buf_pool_t::corrupted_evict(), recover_deferred() or below */
block->page.lock.x_lock_recursive();
ut_d(mysql_mutex_lock(&mutex));
ut_ad(&recs == &pages.find(p->first)->second);
ut_d(mysql_mutex_unlock(&mutex));
@ -3973,8 +3969,11 @@ inline buf_block_t *recv_sys_t::recover_low(const map::iterator &p, mtr_t &mtr,
ut_ad(mtr.has_committed());
if (space)
{
space->release();
if (block)
block->page.lock.x_unlock();
}
return block ? block : reinterpret_cast<buf_block_t*>(-1);
}

View file

@ -199,6 +199,7 @@ err:
/* don't touch anything more, in case we hit a bug */
fprintf(stderr, "%s: FAILED\n", my_progname_short);
free_tmpdir(&maria_chk_tmpdir);
my_hash_free(&tables_to_redo);
free_defaults(default_argv);
exit(1);
}

View file

@ -953,14 +953,13 @@ void copy_not_changed_fields(MARIA_HA *info, MY_BITMAP *changed_fields,
uchar *to, uchar *from)
{
MARIA_COLUMNDEF *column, *end_column;
uchar *bitmap= (uchar*) changed_fields->bitmap;
MARIA_SHARE *share= info->s;
uint bit= 1;
uint bit= 0;
for (column= share->columndef, end_column= column+ share->base.fields;
column < end_column; column++)
column < end_column; column++, bit++)
{
if (!(*bitmap & bit))
if (!bitmap_is_set(changed_fields, bit))
{
uint field_length= column->length;
if (column->type == FIELD_VARCHAR)
@ -972,11 +971,6 @@ void copy_not_changed_fields(MARIA_HA *info, MY_BITMAP *changed_fields,
}
memcpy(to + column->offset, from + column->offset, field_length);
}
if ((bit= (bit << 1)) == 256)
{
bitmap++;
bit= 1;
}
}
}

View file

@ -739,8 +739,6 @@ get_one_option(const struct my_option *opt,
break;
case 'V':
print_version();
free_defaults(default_argv);
my_end(MY_CHECK_ERROR);
my_exit(0);
case OPT_CORRECT_CHECKSUM:
if (argument == disabled_my_option)

View file

@ -6915,7 +6915,7 @@ int ha_spider::create(
SPIDER_ALTER_PARTITION_COALESCE | SPIDER_ALTER_PARTITION_REORGANIZE |
SPIDER_ALTER_PARTITION_TABLE_REORG | SPIDER_ALTER_PARTITION_REBUILD
)
) &&
) && /* Does not support PART_CHANGED */
memcmp(name + strlen(name) - 5, "#TMP#", 5)
) {
need_lock = TRUE;

View file

@ -6750,7 +6750,8 @@ void spider_get_partition_info(
DBUG_VOID_RETURN;
}
DBUG_PRINT("info",("spider tmp_name=%s", tmp_name));
if (!memcmp(table_name, tmp_name, table_name_length + 1))
if (table_name_length == strlen(tmp_name) &&
!strncmp(table_name, tmp_name, table_name_length))
DBUG_VOID_RETURN;
if (
tmp_flg &&
@ -6771,7 +6772,8 @@ void spider_get_partition_info(
DBUG_VOID_RETURN;
}
DBUG_PRINT("info",("spider tmp_name=%s", tmp_name));
if (!memcmp(table_name, tmp_name, table_name_length + 1))
if (table_name_length == strlen(tmp_name) &&
!strncmp(table_name, tmp_name, table_name_length))
DBUG_VOID_RETURN;
if (
tmp_flg &&