This is an automated email from the ASF dual-hosted git repository. yjhjstz pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit bb5d05287fa82f5b9e7a90e27ccaf634eea202ab Author: Haotian Chen <[email protected]> AuthorDate: Wed Oct 12 17:49:11 2022 +0800 fix crash on get_ao_compression_ratio of heap table (#14205) Co-authored-by: CharlieTT <[email protected]> Fix crash of PG_TRY which caused by return branch in PG_TRY block. When we return value in PG_TRY, some setjump/longjump context has been messed up so that we cannot longjump to right address once ereport(ERROR) exists later, so crash will happen. --- src/backend/access/appendonly/aosegfiles.c | 14 +++++++++----- src/test/regress/expected/AORO_Compression.out | 12 ++++++++++++ src/test/regress/sql/AORO_Compression.sql | 11 +++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/backend/access/appendonly/aosegfiles.c b/src/backend/access/appendonly/aosegfiles.c index 1eb78db3f2..4c21354b36 100644 --- a/src/backend/access/appendonly/aosegfiles.c +++ b/src/backend/access/appendonly/aosegfiles.c @@ -1624,12 +1624,10 @@ aorow_compression_ratio_internal(Relation parentrel) if (NULL == attr1 || NULL == attr2) { - SPI_finish(); - return 1; + compress_ratio = 1; } - - if (scanint8(attr1, true, &eof) && - scanint8(attr2, true, &eof_uncomp)) + else if (scanint8(attr1, true, &eof) && + scanint8(attr2, true, &eof_uncomp)) { /* guard against division by zero */ if (eof > 0) @@ -1641,6 +1639,12 @@ aorow_compression_ratio_internal(Relation parentrel) compress_ratio = round(compress_ratio * 100.0) / 100.0; } } + else + { + ereport(ERROR, + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("unable to parse aorow compress_ratio string to int8."))); + } } connected = false; diff --git a/src/test/regress/expected/AORO_Compression.out b/src/test/regress/expected/AORO_Compression.out index 3ed0de2e84..25e4861d60 100644 --- a/src/test/regress/expected/AORO_Compression.out +++ b/src/test/regress/expected/AORO_Compression.out @@ -25,3 +25,15 @@ CREATE TABLE a_aoro_table_with_rle_type_compression(col int) WITH (APPENDONLY=tr NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col' as the Cloudberry Database data distribution key for this table. HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. ERROR: rle_type cannot be used with Append Only relations row orientation +-- Test get_ao_compression_ratio +CREATE TABLE test_table (date date) +PARTITION BY RANGE(date) +( +PARTITION test_cmp_02 START ('2022-02-01'::date) END ('2022-03-01'::date) EVERY ('1 mon'::interval) WITH (tablename='test_table_1_prt_cmp_202202', appendonly='true', orientation='row', compresstype=zlib), +START ('2022-03-01'::date) END ('2022-04-01'::date) EVERY ('1 mon'::interval) WITH (tablename='test_table_1_prt_123', appendonly='false') +); +NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'date' as the Greenplum Database data distribution key for this table. +HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew. +select get_ao_compression_ratio('test_table_1_prt_123'); +ERROR: 'test_table_1_prt_123' is not an append-only relation +drop table test_table; diff --git a/src/test/regress/sql/AORO_Compression.sql b/src/test/regress/sql/AORO_Compression.sql index 06d350c6cd..d0ac30d748 100644 --- a/src/test/regress/sql/AORO_Compression.sql +++ b/src/test/regress/sql/AORO_Compression.sql @@ -11,3 +11,14 @@ SELECT pg_size_pretty(pg_relation_size('a_aoro_table_with_zlib_compression')), -- Test basic create table for AO/RO table fails for rle compression. rle is only supported for columnar tables. CREATE TABLE a_aoro_table_with_rle_type_compression(col int) WITH (APPENDONLY=true, COMPRESSTYPE=rle_type, COMPRESSLEVEL=1, ORIENTATION=row); + +-- Test get_ao_compression_ratio +CREATE TABLE test_table (date date) +PARTITION BY RANGE(date) +( +PARTITION test_cmp_02 START ('2022-02-01'::date) END ('2022-03-01'::date) EVERY ('1 mon'::interval) WITH (tablename='test_table_1_prt_cmp_202202', appendonly='true', orientation='row', compresstype=zlib), +START ('2022-03-01'::date) END ('2022-04-01'::date) EVERY ('1 mon'::interval) WITH (tablename='test_table_1_prt_123', appendonly='false') +); + +select get_ao_compression_ratio('test_table_1_prt_123'); +drop table test_table; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
