Fix padding access invalid memory in default cg.

This commit is contained in:
XIAO-HOU 2024-06-24 12:45:21 +00:00 committed by ob-robot
parent 9c90276b13
commit 25073edf07
3 changed files with 52 additions and 4 deletions

View File

@ -314,6 +314,8 @@ int ObDefaultCGScanner::init_datum_infos_and_default_row(const ObTableIterParam
STORAGE_LOG(WARN, "unexpected null column_param", K(ret), K(iter_param));
} else if (OB_FAIL(default_row_.storage_datums_[0].from_obj_enhance(column_param->get_orig_default_value()))) {
STORAGE_LOG(WARN, "Failed to transefer obj to datum", K(ret));
} else if (OB_FAIL(pad_column(column_param->get_meta_type(), column_param->get_accuracy(), *access_ctx.stmt_allocator_, default_row_.storage_datums_[0]))) {
LOG_WARN("Failed to pad default column", K(ret), KPC(column_param), K_(default_row));
} else if (OB_FAIL(add_lob_header_if_need(*column_param, default_row_.local_allocator_, default_row_.storage_datums_[0]))) {
STORAGE_LOG(WARN, "Failed to add lob header to default value", K(ret));
} else if (iter_param.vectorized_enabled_ && !iter_param.enable_pd_aggregate()) {

View File

@ -1,5 +1,6 @@
create table t1(a int, b varchar(3048), primary key (a), c int) with column group (all columns, each column);
create table t2(pk int, c1 int, c2 int unsigned, c3 varchar(100)) block_size=2048 with column group (all columns, each column);
create table t3(c1 int) with column group (each column);
select count(*) from t1;
count(*)
150
@ -11,6 +12,7 @@ count(*) count(pk) min(pk) max(pk) sum(pk) min(c1) max(c1) sum(c1) min(c2) max(c
1500 1500 11 3000 2258250 11 3000 2258250 12 3001 2259750 abcdefg1 abcdefg99
alter system major freeze;
alter table t1 add column c1 int default 0, add column c2 varchar(100);
alter table t3 add column c2 char(60) default "中文";
alter system set _pushdown_storage_level = 0;
alter system set _rowsets_enabled = false;
alter system flush plan cache;
@ -179,6 +181,14 @@ count(*) count(a) min(a) max(a) sum(a) count(b) min(b) max(b) count(c) min(c) ma
select count(*),count(c1),min(c1),max(c1),sum(c1),count(c2),min(c2),max(c2) from t1;
count(*) count(c1) min(c1) max(c1) sum(c1) count(c2) min(c2) max(c2)
250 250 0 498 39900 100 300300300300300 498498498498498
select count(c2), min(c2), max(c2) from t3 where c1 < 256;
count(c2) min(c2) max(c2)
16384 中文 中文
alter system set _rowsets_enabled = false;
alter system flush plan cache;
select count(c2), min(c2), max(c2) from t3 where c1 < 256;
count(c2) min(c2) max(c2)
16384 中文 中文
alter system major freeze;
alter table t2 add column c4 bigint default 10, add column c5 bigint unsigned default 20;
alter table t2 add column c6 bigint default null;
@ -326,7 +336,7 @@ count(*) count(a) min(a) max(a) sum(a) count(b) min(b) max(b) count(c) min(c) ma
select count(*),count(c1),min(c1),max(c1),sum(c1),count(c2),min(c2),max(c2) from t1;
count(*) count(c1) min(c1) max(c1) sum(c1) count(c2) min(c2) max(c2)
250 250 0 498 39900 100 300300300300300 498498498498498
drop table t1,t2;
drop table t1,t2,t3;
alter system flush plan cache;
create table t1(a int, b varchar(3048), primary key (a), c int) with column group (each column);
create table t2(pk int, c1 int, c2 int unsigned, c3 varchar(100)) block_size=2048 with column group (each column);

View File

@ -4,14 +4,18 @@
--disable_query_log
--disable_warnings
connect (obsys,$OBMYSQL_MS0,admin,$OBMYSQL_PWD,test,$OBMYSQL_PORT);
connection obsys;
alter system set_tp tp_name = "EN_COMPACTION_DISABLE_ROW_COL_SWITCH", error_code = 4016, frequency = 1;
connection default;
set @@recyclebin = off;
drop table if exists t1,t2;
drop table if exists t1,t2,t3;
--enable_warnings
--enable_query_log
create table t1(a int, b varchar(3048), primary key (a), c int) with column group (all columns, each column);
create table t2(pk int, c1 int, c2 int unsigned, c3 varchar(100)) block_size=2048 with column group (all columns, each column);
create table t3(c1 int) with column group (each column);
sleep 10;
--disable_query_log
@ -31,9 +35,18 @@ while ($count < 300)
($count * 10 + 8,$count * 10 + 8, $count * 10 + 8 + 1, concat("abcdefg", $count)),
($count * 10 + 9,$count * 10 + 9, $count * 10 + 9 + 1, concat("abcdefg", $count)),
($count * 10 + 10,$count * 10 + 10, $count * 10 + 10+ 1, concat("abcdefg", $count));
eval insert into t3(c1) values ($count);
inc $count;
inc $count;
}
--let $count=1
while ($count < 8)
{
eval insert into t3 select * from t3;
inc $count;
}
--enable_warnings
--enable_query_log
select count(*) from t1;
@ -44,6 +57,7 @@ alter system major freeze;
--source mysql_test/include/wait_daily_merge.inc
alter table t1 add column c1 int default 0, add column c2 varchar(100);
alter table t3 add column c2 char(60) default "中文";
--disable_query_log
--disable_warnings
@ -117,6 +131,24 @@ select a, c1, count(c1) from t1 where a <20 and c1 != 80 and c1 != 6 and c1 < 30
select count(*),count(a),min(a),max(a),sum(a),count(b),min(b),max(b),count(c),min(c),max(c),sum(c) from t1;
select count(*),count(c1),min(c1),max(c1),sum(c1),count(c2),min(c2),max(c2) from t1;
--disable_query_log
SET sql_mode = 'PAD_CHAR_TO_FULL_LENGTH';
alter system flush plan cache;
sleep 1;
--enable_query_log
select count(c2), min(c2), max(c2) from t3 where c1 < 256;
alter system set _rowsets_enabled = false;
alter system flush plan cache;
select count(c2), min(c2), max(c2) from t3 where c1 < 256;
--disable_query_log
SET sql_mode = '';
alter system flush plan cache;
sleep 1;
--enable_query_log
alter system major freeze;
--source mysql_test/include/wait_daily_merge.inc
@ -183,7 +215,7 @@ select count(*) from t1;
select count(*),count(a),min(a),max(a),sum(a),count(b),min(b),max(b),count(c),min(c),max(c),sum(c) from t1;
select count(*),count(c1),min(c1),max(c1),sum(c1),count(c2),min(c2),max(c2) from t1;
drop table t1,t2;
drop table t1,t2,t3;
alter system flush plan cache;
@ -353,3 +385,7 @@ set @@recyclebin = on;
alter system set _pushdown_storage_level = 4;
alter system set _rowsets_enabled = true;
alter system flush plan cache;
connection obsys;
alter system set_tp tp_name = "EN_COMPACTION_DISABLE_ROW_COL_SWITCH", error_code = 4016, frequency = 0;
connection default;
--enable_query_log