Skip to content

Commit 1286c92

Browse files
authored
Fix: Core happend when calling pg_relation_size on root partitioned table with PAX AM (#1128)
In the `calculate_relation_size` method, whether to directly callback the table AM(access method) is determined by `RelationIsNonblockRelation`. However, for root partitioned tables, the table AM is always be NULL. When the AM of a root partitioned table is PAX, `RelationIsNonblockRelation` always returns TRUE. But for AO tables, `RelationIsNonblockRelation` will returns FALSE. It because AO table are determined directly through `rel->rd_amhandler` (PAX as a plugin, cannot register its `amhandler` in the CBDB kernel).
1 parent 1149568 commit 1286c92

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

contrib/pax_storage/expected/ddl.out

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,21 @@ drop table pax_test.t3;
7171
create table pax_test.t4 (v1 text) with(compresstype=zstd, compresslevel=1);
7272
alter table pax_test.t4 add column v2 text;
7373
drop table pax_test.t4;
74+
-- test pg_relation_size
75+
CREATE TABLE pt_pax (id int, date date) using pax DISTRIBUTED BY (id)
76+
PARTITION BY RANGE (date)
77+
( PARTITION subpt1 START (date '2016-01-01') INCLUSIVE ,
78+
PARTITION subpt2 START (date '2016-02-01') INCLUSIVE);
79+
SELECT pg_catalog.pg_relation_size('pt_pax'::regclass);
80+
pg_relation_size
81+
------------------
82+
0
83+
(1 row)
84+
85+
select 1 from (select count(*) from gp_toolkit.gp_size_of_schema_disk) empty_out;
86+
?column?
87+
----------
88+
1
89+
(1 row)
90+
91+
drop table pt_pax;

contrib/pax_storage/sql/ddl.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,13 @@ drop table pax_test.t3;
4848
create table pax_test.t4 (v1 text) with(compresstype=zstd, compresslevel=1);
4949
alter table pax_test.t4 add column v2 text;
5050
drop table pax_test.t4;
51+
52+
-- test pg_relation_size
53+
CREATE TABLE pt_pax (id int, date date) using pax DISTRIBUTED BY (id)
54+
PARTITION BY RANGE (date)
55+
( PARTITION subpt1 START (date '2016-01-01') INCLUSIVE ,
56+
PARTITION subpt2 START (date '2016-02-01') INCLUSIVE);
57+
58+
SELECT pg_catalog.pg_relation_size('pt_pax'::regclass);
59+
select 1 from (select count(*) from gp_toolkit.gp_size_of_schema_disk) empty_out;
60+
drop table pt_pax;

src/include/utils/rel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,9 @@ typedef struct ViewOptions
563563
* True iff relation(table) should run the code path as AO/CO
564564
*/
565565
#define RelationIsNonblockRelation(relation) \
566+
((relation)->rd_tableam && \
566567
(RelationIsAppendOptimized(relation) || \
567-
RelationIsPax(relation))
568+
RelationIsPax(relation)))
568569

569570
/*
570571
* RelationIsBitmapIndex

0 commit comments

Comments
 (0)