From 1adb137f27300e19d41808e6478d0d5f9cfddb25 Mon Sep 17 00:00:00 2001 From: leipeng Date: Fri, 3 Feb 2023 08:59:57 -0800 Subject: [PATCH] Fix rdb_i_s_sst_props_fields_info (#1267) Upstream commit ID: https://github.com/facebook/mysql-5.6/commit/8fae2bbdcf49b875aefaf90d3c4e7677ed028961 PS-8755: Merge percona-202301 (https://jira.percona.com/browse/PS-8755) Summary: In `rdb_i_s_sst_props_fields_info` definition, flag `MY_I_S_MAYBE_NULL` is missing for fields `COMPRESSION_ALGO`, `FILTER_POLICY`, `COMPRESSION_OPTIONS`, causing the `set_null` does not take effect, these 3 fields will keep last SST's value. This PR fixed this issue. Pull Request resolved: https://github.com/facebook/mysql-5.6/pull/1267 Reviewed By: lth Differential Revision: D42928109 Pulled By: hermanlee fbshipit-source-id: 662dc11e7c9a8f8c0758006e20ccc739ebe09f40 --- mysql-test/suite/rocksdb/r/i_s_sst_props.result | 6 +++--- storage/rocksdb/rdb_i_s.cc | 11 ++++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mysql-test/suite/rocksdb/r/i_s_sst_props.result b/mysql-test/suite/rocksdb/r/i_s_sst_props.result index cb566209b457..5179eb5a20db 100644 --- a/mysql-test/suite/rocksdb/r/i_s_sst_props.result +++ b/mysql-test/suite/rocksdb/r/i_s_sst_props.result @@ -12,12 +12,12 @@ ROCKSDB_SST_PROPS CREATE TEMPORARY TABLE `ROCKSDB_SST_PROPS` ( `INDEX_PARTITIONS` int NOT NULL DEFAULT '0', `TOP_LEVEL_INDEX_SIZE` bigint NOT NULL DEFAULT '0', `FILTER_BLOCK_SIZE` bigint NOT NULL DEFAULT '0', - `COMPRESSION_ALGO` varchar(193) NOT NULL DEFAULT '', + `COMPRESSION_ALGO` varchar(193) DEFAULT NULL, `CREATION_TIME` bigint NOT NULL DEFAULT '0', `FILE_CREATION_TIME` bigint NOT NULL DEFAULT '0', `OLDEST_KEY_TIME` bigint NOT NULL DEFAULT '0', - `FILTER_POLICY` varchar(193) NOT NULL DEFAULT '', - `COMPRESSION_OPTIONS` varchar(193) NOT NULL DEFAULT '' + `FILTER_POLICY` varchar(193) DEFAULT NULL, + `COMPRESSION_OPTIONS` varchar(193) DEFAULT NULL ) ENGINE=MEMORY DEFAULT CHARSET=utf8mb3 uninstall plugin rocksdb; select * from information_schema.rocksdb_sst_props; diff --git a/storage/rocksdb/rdb_i_s.cc b/storage/rocksdb/rdb_i_s.cc index fdb78ca19b1f..c0b22a7ded5c 100644 --- a/storage/rocksdb/rdb_i_s.cc +++ b/storage/rocksdb/rdb_i_s.cc @@ -1670,16 +1670,18 @@ static ST_FIELD_INFO rdb_i_s_sst_props_fields_info[] = { MYSQL_TYPE_LONGLONG, 0), ROCKSDB_FIELD_INFO("FILTER_BLOCK_SIZE", sizeof(int64_t), MYSQL_TYPE_LONGLONG, 0), - ROCKSDB_FIELD_INFO("COMPRESSION_ALGO", NAME_LEN + 1, MYSQL_TYPE_STRING, 0), + ROCKSDB_FIELD_INFO("COMPRESSION_ALGO", NAME_LEN + 1, MYSQL_TYPE_STRING, + MY_I_S_MAYBE_NULL), ROCKSDB_FIELD_INFO("CREATION_TIME", sizeof(int64_t), MYSQL_TYPE_LONGLONG, 0), ROCKSDB_FIELD_INFO("FILE_CREATION_TIME", sizeof(int64_t), MYSQL_TYPE_LONGLONG, 0), ROCKSDB_FIELD_INFO("OLDEST_KEY_TIME", sizeof(int64_t), MYSQL_TYPE_LONGLONG, 0), - ROCKSDB_FIELD_INFO("FILTER_POLICY", NAME_LEN + 1, MYSQL_TYPE_STRING, 0), + ROCKSDB_FIELD_INFO("FILTER_POLICY", NAME_LEN + 1, MYSQL_TYPE_STRING, + MY_I_S_MAYBE_NULL), ROCKSDB_FIELD_INFO("COMPRESSION_OPTIONS", NAME_LEN + 1, MYSQL_TYPE_STRING, - 0), + MY_I_S_MAYBE_NULL), ROCKSDB_FIELD_INFO_END}; static int rdb_i_s_sst_props_fill_table( @@ -1756,6 +1758,7 @@ static int rdb_i_s_sst_props_fill_table( if (props.second->compression_name.empty()) { field[RDB_SST_PROPS_FIELD::COMPRESSION_ALGO]->set_null(); } else { + field[RDB_SST_PROPS_FIELD::COMPRESSION_ALGO]->set_notnull(); field[RDB_SST_PROPS_FIELD::COMPRESSION_ALGO]->store( props.second->compression_name.c_str(), props.second->compression_name.size(), system_charset_info); @@ -1769,6 +1772,7 @@ static int rdb_i_s_sst_props_fill_table( if (props.second->filter_policy_name.empty()) { field[RDB_SST_PROPS_FIELD::FILTER_POLICY]->set_null(); } else { + field[RDB_SST_PROPS_FIELD::FILTER_POLICY]->set_notnull(); field[RDB_SST_PROPS_FIELD::FILTER_POLICY]->store( props.second->filter_policy_name.c_str(), props.second->filter_policy_name.size(), system_charset_info); @@ -1776,6 +1780,7 @@ static int rdb_i_s_sst_props_fill_table( if (props.second->compression_options.empty()) { field[RDB_SST_PROPS_FIELD::COMPRESSION_OPTIONS]->set_null(); } else { + field[RDB_SST_PROPS_FIELD::COMPRESSION_OPTIONS]->set_notnull(); field[RDB_SST_PROPS_FIELD::COMPRESSION_OPTIONS]->store( props.second->compression_options.c_str(), props.second->compression_options.size(), system_charset_info);