This is an automated email from the ASF dual-hosted git repository.

gfphoenix78 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/main by this push:
     new 1286c92b07 Fix: Core happend when calling pg_relation_size on root 
partitioned table with PAX AM (#1128)
1286c92b07 is described below

commit 1286c92b076b4a7357bd92d52168b94c9b0663ed
Author: jiaqizho <[email protected]>
AuthorDate: Thu May 29 15:33:13 2025 +0800

    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).
---
 contrib/pax_storage/expected/ddl.out | 18 ++++++++++++++++++
 contrib/pax_storage/sql/ddl.sql      | 10 ++++++++++
 src/include/utils/rel.h              |  3 ++-
 3 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/contrib/pax_storage/expected/ddl.out 
b/contrib/pax_storage/expected/ddl.out
index f939be2a2a..b3889bc8a2 100644
--- a/contrib/pax_storage/expected/ddl.out
+++ b/contrib/pax_storage/expected/ddl.out
@@ -71,3 +71,21 @@ drop table pax_test.t3;
 create table pax_test.t4 (v1 text) with(compresstype=zstd, compresslevel=1);
 alter table pax_test.t4 add column v2 text;
 drop table pax_test.t4;
+-- test pg_relation_size
+CREATE TABLE pt_pax (id int, date date) using pax DISTRIBUTED BY (id)
+PARTITION BY RANGE (date)
+( PARTITION subpt1 START (date '2016-01-01') INCLUSIVE ,
+  PARTITION subpt2 START (date '2016-02-01') INCLUSIVE);
+SELECT pg_catalog.pg_relation_size('pt_pax'::regclass);
+ pg_relation_size 
+------------------
+                0
+(1 row)
+
+select 1 from (select count(*) from gp_toolkit.gp_size_of_schema_disk) 
empty_out;
+ ?column? 
+----------
+        1
+(1 row)
+
+drop table pt_pax;
diff --git a/contrib/pax_storage/sql/ddl.sql b/contrib/pax_storage/sql/ddl.sql
index 6238b6cd1c..55824cf318 100644
--- a/contrib/pax_storage/sql/ddl.sql
+++ b/contrib/pax_storage/sql/ddl.sql
@@ -48,3 +48,13 @@ drop table pax_test.t3;
 create table pax_test.t4 (v1 text) with(compresstype=zstd, compresslevel=1);
 alter table pax_test.t4 add column v2 text;
 drop table pax_test.t4;
+
+-- test pg_relation_size
+CREATE TABLE pt_pax (id int, date date) using pax DISTRIBUTED BY (id)
+PARTITION BY RANGE (date)
+( PARTITION subpt1 START (date '2016-01-01') INCLUSIVE ,
+  PARTITION subpt2 START (date '2016-02-01') INCLUSIVE);
+
+SELECT pg_catalog.pg_relation_size('pt_pax'::regclass);
+select 1 from (select count(*) from gp_toolkit.gp_size_of_schema_disk) 
empty_out;
+drop table pt_pax;
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index d0b8c5cb47..b2192ab877 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -563,8 +563,9 @@ typedef struct ViewOptions
  *      True iff relation(table) should run the code path as AO/CO
  */
 #define RelationIsNonblockRelation(relation) \
+       ((relation)->rd_tableam && \
        (RelationIsAppendOptimized(relation) || \
-        RelationIsPax(relation))
+        RelationIsPax(relation)))
 
 /*
  * RelationIsBitmapIndex


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to