Skip to content

Commit

Permalink
Merge 10.5 into 10.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-m committed Sep 6, 2021
2 parents 4c1ed54 + 84c578c commit 7730dd3
Show file tree
Hide file tree
Showing 22 changed files with 256 additions and 91 deletions.
58 changes: 49 additions & 9 deletions mysql-test/suite/s3/basic.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,25 @@ drop table if exists t1;
#
# Test simple create of s3 table
#
create or replace table t1 (a int, b int, key (a)) engine=aria;
insert into t1 select seq,seq+10 from seq_1_to_10000;
create or replace table t1 (a int, b int, c varchar(1000), key (a), key(c)) engine=aria;
insert into t1 select seq, seq+10, repeat(char(65+ mod(seq, 20)),mod(seq,1000)) from seq_1_to_10000;
alter table t1 engine=s3;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `a` (`a`)
`c` varchar(1000) DEFAULT NULL,
KEY `a` (`a`),
KEY `c` (`c`)
) ENGINE=S3 DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from information_schema.tables where table_schema="database" and table_name="t1";;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME TABLE_TYPE ENGINE VERSION ROW_FORMAT TABLE_ROWS AVG_ROW_LENGTH DATA_LENGTH MAX_DATA_LENGTH INDEX_LENGTH DATA_FREE AUTO_INCREMENT CREATE_TIME UPDATE_TIME CHECK_TIME TABLE_COLLATION CHECKSUM CREATE_OPTIONS TABLE_COMMENT MAX_INDEX_LENGTH TEMPORARY
def # t1 BASE TABLE S3 10 Page 10000 33 335872 # 122880 0 NULL # # # latin1_swedish_ci NULL page_checksum=1 9007199254732800 #
def # t1 BASE TABLE S3 10 Page 10000 567 5677056 # 761856 0 NULL # # # latin1_swedish_ci NULL page_checksum=1 2305843009213685760 #
show table status like "t1";
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment Max_index_length Temporary
t1 S3 10 Page 10000 33 335872 # 122880 0 NULL # # # latin1_swedish_ci NULL page_checksum=1 # N
select * from t1 limit 10;
t1 S3 10 Page 10000 567 5677056 # 761856 0 NULL # # # latin1_swedish_ci NULL page_checksum=1 # N
select a,b from t1 limit 10;
a b
1 11
2 12
Expand All @@ -33,7 +35,7 @@ a b
select count(*) from t1;
count(*)
10000
select * from t1 where a between 10 and 20;
select a,b from t1 where a between 10 and 20;
a b
10 20
11 21
Expand All @@ -55,15 +57,53 @@ update t1 set b=100 where a=1;
ERROR HY000: Table 't1' is read only
delete from t1 where a>10;
ERROR HY000: Table 't1' is read only
#
# Analyze, repair, optimize and check table
#
set @@use_stat_tables='never';
truncate mysql.table_stats;
check table t1 fast;
Table Op Msg_type Msg_text
database.t1 check status Table is already up to date
check table t1 quick;
Table Op Msg_type Msg_text
database.t1 check status OK
check table t1 extended;
Table Op Msg_type Msg_text
database.t1 check status OK
analyze table t1;
Table Op Msg_type Msg_text
database.t1 analyze status Table 'database.t1' is read only
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
database.t1 analyze status Table 'database.t1' is read only
database.t1 analyze status Engine-independent statistics collected
database.t1 analyze status OK
repair table t1;
Table Op Msg_type Msg_text
database.t1 repair Error Table 't1' is read only
database.t1 repair status Operation failed
optimize table t1;
Table Op Msg_type Msg_text
database.t1 optimize Error Table 't1' is read only
database.t1 optimize status Operation failed
select * from mysql.table_stats;
db_name table_name cardinality
database t1 10000
#
# Converting table back to Aria
#
alter table t1 engine=aria;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
KEY `a` (`a`)
`c` varchar(1000) DEFAULT NULL,
KEY `a` (`a`),
KEY `c` (`c`)
) ENGINE=Aria DEFAULT CHARSET=latin1 PAGE_CHECKSUM=1
select * from t1 limit 10;
select a,b from t1 limit 10;
a b
1 11
2 12
Expand Down
39 changes: 34 additions & 5 deletions mysql-test/suite/s3/basic.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ drop table if exists t1;
--echo # Test simple create of s3 table
--echo #

create or replace table t1 (a int, b int, key (a)) engine=aria;
insert into t1 select seq,seq+10 from seq_1_to_10000;
create or replace table t1 (a int, b int, c varchar(1000), key (a), key(c)) engine=aria;
insert into t1 select seq, seq+10, repeat(char(65+ mod(seq, 20)),mod(seq,1000)) from seq_1_to_10000;
alter table t1 engine=s3;
show create table t1;

Expand All @@ -23,9 +23,9 @@ show create table t1;
--eval select * from information_schema.tables where table_schema="$database" and table_name="t1";
--replace_column 8 # 12 # 13 # 14 # 19 #
show table status like "t1";
select * from t1 limit 10;
select a,b from t1 limit 10;
select count(*) from t1;
select * from t1 where a between 10 and 20;
select a,b from t1 where a between 10 and 20;
--replace_column 9 #
explain select * from t1 where a between 10 and 20;
--error ER_OPEN_AS_READONLY
Expand All @@ -34,9 +34,38 @@ insert into t1 values (1,1);
update t1 set b=100 where a=1;
--error ER_OPEN_AS_READONLY
delete from t1 where a>10;


--echo #
--echo # Analyze, repair, optimize and check table
--echo #

set @@use_stat_tables='never';
truncate mysql.table_stats;
--replace_result $database database
check table t1 fast;
--replace_result $database database
check table t1 quick;
--replace_result $database database
check table t1 extended;
--replace_result $database database
analyze table t1;
--replace_result $database database
analyze table t1 persistent for all;
--replace_result $database database
repair table t1;
--replace_result $database database
optimize table t1;
--replace_result $database database
select * from mysql.table_stats;

--echo #
--echo # Converting table back to Aria
--echo #

alter table t1 engine=aria;
show create table t1;
select * from t1 limit 10;
select a,b from t1 limit 10;
select count(*) from t1;
delete from t1 where a=1;
drop table t1;
Expand Down
7 changes: 4 additions & 3 deletions mysql-test/suite/s3/partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@ ALTER TABLE t2 TRUNCATE PARTITION p3;
ERROR HY000: Table 't2' is read only
ALTER TABLE t2 ANALYZE PARTITION p3;
Table Op Msg_type Msg_text
s3.t2 analyze error Table 's3.t2' is read only
s3.t2 analyze status Table 's3.t2' is read only
s3.t2 analyze status Engine-independent statistics collected
s3.t2 analyze status OK
SELECT count(*) FROM t2;
count(*)
6
ALTER TABLE t2 CHECK PARTITION p3;
Table Op Msg_type Msg_text
s3.t2 check error Subpartition p3sp0 returned error
s3.t2 check error Unknown - internal error 165 during operation
s3.t2 check status OK
SELECT count(*) FROM t2;
count(*)
6
Expand Down
28 changes: 14 additions & 14 deletions mysys/mf_keycache.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,18 @@ typedef struct st_simple_key_cache_cb
size_t key_cache_mem_size; /* specified size of the cache memory */
size_t allocated_mem_size; /* size of the memory actually allocated */
uint key_cache_block_size; /* size of the page buffer of a cache block */
ulong min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */
size_t min_warm_blocks; /* min number of warm blocks; */
size_t age_threshold; /* age threshold for hot blocks */
ulonglong keycache_time; /* total number of block link operations */
uint hash_entries; /* max number of entries in the hash table */
uint changed_blocks_hash_size; /* Number of hash buckets for file blocks */
int hash_links; /* max number of hash links */
int hash_links_used; /* number of hash links currently used */
int disk_blocks; /* max number of blocks in the cache */
ulong blocks_used; /* maximum number of concurrently used blocks */
ulong blocks_unused; /* number of currently unused blocks */
ulong blocks_changed; /* number of currently dirty blocks */
ulong warm_blocks; /* number of blocks in warm sub-chain */
size_t blocks_used; /* maximum number of concurrently used blocks */
size_t blocks_unused; /* number of currently unused blocks */
size_t blocks_changed; /* number of currently dirty blocks */
size_t warm_blocks; /* number of blocks in warm sub-chain */
ulong cnt_for_resize_op; /* counter to block resize operation */
long blocks_available; /* number of blocks available in the LRU chain */
HASH_LINK **hash_root; /* arr. of entries into hash table buckets */
Expand Down Expand Up @@ -478,7 +478,7 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
size_t use_mem, uint division_limit,
uint age_threshold, uint changed_blocks_hash_size)
{
ulong blocks, hash_links;
size_t blocks, hash_links;
size_t length;
int error;
DBUG_ENTER("init_simple_key_cache");
Expand Down Expand Up @@ -519,8 +519,8 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
DBUG_PRINT("info", ("key_cache_block_size: %u",
key_cache_block_size));

blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
sizeof(HASH_LINK*) * 5/4 + key_cache_block_size));
blocks= use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) +
sizeof(HASH_LINK*) * 5/4 + key_cache_block_size);

/* Changed blocks hash needs to be a power of 2 */
changed_blocks_hash_size= my_round_up_to_next_power(MY_MAX(changed_blocks_hash_size,
Expand All @@ -532,7 +532,7 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
for ( ; ; )
{
/* Set my_hash_entries to the next bigger 2 power */
if ((keycache->hash_entries= next_power(blocks)) < blocks * 5/4)
if ((keycache->hash_entries= next_power((uint)blocks)) < blocks * 5/4)
keycache->hash_entries<<= 1;
hash_links= 2 * blocks;
#if defined(MAX_THREADS)
Expand All @@ -543,8 +543,8 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) +
ALIGN_SIZE(sizeof(HASH_LINK*) *
keycache->hash_entries) +
sizeof(BLOCK_LINK*)* (changed_blocks_hash_size*2))) +
((size_t) blocks * keycache->key_cache_block_size) > use_mem && blocks > 8)
sizeof(BLOCK_LINK*)* ((size_t)changed_blocks_hash_size*2))) +
(blocks * keycache->key_cache_block_size) > use_mem && blocks > 8)
blocks--;
keycache->allocated_mem_size= blocks * keycache->key_cache_block_size;
if ((keycache->block_mem= my_large_malloc(&keycache->allocated_mem_size,
Expand Down Expand Up @@ -584,7 +584,7 @@ int init_simple_key_cache(SIMPLE_KEY_CACHE_CB *keycache,
}
keycache->blocks_unused= blocks;
keycache->disk_blocks= (int) blocks;
keycache->hash_links= hash_links;
keycache->hash_links= (int)hash_links;
keycache->hash_links_used= 0;
keycache->free_hash_list= NULL;
keycache->blocks_used= keycache->blocks_changed= 0;
Expand Down Expand Up @@ -4854,7 +4854,7 @@ static int cache_empty(SIMPLE_KEY_CACHE_CB *keycache)
}
if (errcnt)
{
fprintf(stderr, "blocks: %d used: %lu\n",
fprintf(stderr, "blocks: %d used: %zu\n",
keycache->disk_blocks, keycache->blocks_used);
fprintf(stderr, "hash_links: %d used: %d\n",
keycache->hash_links, keycache->hash_links_used);
Expand Down
3 changes: 2 additions & 1 deletion sql/ha_partition.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,8 @@ int ha_partition::handle_opt_partitions(THD *thd, HA_CHECK_OPT *check_opt,
/* print a line which partition the error belongs to */
if (error != HA_ADMIN_NOT_IMPLEMENTED &&
error != HA_ADMIN_ALREADY_DONE &&
error != HA_ADMIN_TRY_ALTER)
error != HA_ADMIN_TRY_ALTER &&
error != HA_ERR_TABLE_READONLY)
{
print_admin_msg(thd, MYSQL_ERRMSG_SIZE, &msg_error,
table_share->db.str, table->alias,
Expand Down
23 changes: 11 additions & 12 deletions sql/signal_handler.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Copyright (c) 2011, 2012, Oracle and/or its affiliates.
Copyright (c) 2011, 2014, SkySQL Ab.
Copyright (c) 2011, 2021, 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
Expand Down Expand Up @@ -174,19 +174,19 @@ extern "C" sig_handler handle_fatal_signal(int sig)
my_safe_printf_stderr("Server version: %s\n", server_version);

if (dflt_key_cache)
my_safe_printf_stderr("key_buffer_size=%lu\n",
(ulong) dflt_key_cache->key_cache_mem_size);
my_safe_printf_stderr("key_buffer_size=%zu\n",
dflt_key_cache->key_cache_mem_size);

my_safe_printf_stderr("read_buffer_size=%ld\n",
(long) global_system_variables.read_buff_size);
my_safe_printf_stderr("read_buffer_size=%lu\n",
global_system_variables.read_buff_size);

my_safe_printf_stderr("max_used_connections=%lu\n",
(ulong) max_used_connections);
max_used_connections);

if (thread_scheduler)
my_safe_printf_stderr("max_threads=%u\n",
(uint) thread_scheduler->max_threads +
(uint) extra_max_connections);
my_safe_printf_stderr("max_threads=%lu\n",
thread_scheduler->max_threads +
extra_max_connections);

my_safe_printf_stderr("thread_count=%u\n", THD_count::value());

Expand All @@ -195,11 +195,10 @@ extern "C" sig_handler handle_fatal_signal(int sig)
my_safe_printf_stderr("It is possible that mysqld could use up to \n"
"key_buffer_size + "
"(read_buffer_size + sort_buffer_size)*max_threads = "
"%lu K bytes of memory\n",
(ulong)
"%zu K bytes of memory\n",
(dflt_key_cache->key_cache_mem_size +
(global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) *
(size_t)global_system_variables.sortbuff_size) *
(thread_scheduler->max_threads + extra_max_connections) +
(max_connections + extra_max_connections) *
sizeof(THD)) / 1024);
Expand Down
Loading

0 comments on commit 7730dd3

Please sign in to comment.