You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudberry.apache.org by re...@apache.org on 2025/01/23 14:13:21 UTC

(cloudberry) 01/16: Fix gp_toolkit.__gp_aocsseg_history crash on non-aocs tables.

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

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

commit d2863e47e7d2aec3b092cbf2d56fa354a34a55a1
Author: Zhang Mingli <av...@gmail.com>
AuthorDate: Mon Mar 4 14:53:51 2024 +0800

    Fix gp_toolkit.__gp_aocsseg_history crash on non-aocs tables.
    
    We try to use macro to fetch relation'name after closing the
    relation in error message, which causes a crash.
    We do have heap_close in later lines, don't need to close here.
    
    Authored-by: Zhang Mingli avamingli@gmail.com
---
 gpcontrib/gp_toolkit/.gitignore                       | 1 +
 gpcontrib/gp_toolkit/expected/gp_toolkit_ao_funcs.out | 4 ++++
 gpcontrib/gp_toolkit/sql/gp_toolkit_ao_funcs.sql      | 4 ++++
 src/backend/access/aocs/aocssegfiles.c                | 1 -
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/gpcontrib/gp_toolkit/.gitignore b/gpcontrib/gp_toolkit/.gitignore
new file mode 100644
index 0000000000..6628455c0a
--- /dev/null
+++ b/gpcontrib/gp_toolkit/.gitignore
@@ -0,0 +1 @@
+/results/
diff --git a/gpcontrib/gp_toolkit/expected/gp_toolkit_ao_funcs.out b/gpcontrib/gp_toolkit/expected/gp_toolkit_ao_funcs.out
index 91ca518204..afb2aba8fc 100644
--- a/gpcontrib/gp_toolkit/expected/gp_toolkit_ao_funcs.out
+++ b/gpcontrib/gp_toolkit/expected/gp_toolkit_ao_funcs.out
@@ -78,6 +78,10 @@ SELECT * FROM gp_toolkit.__gp_aoblkdir('toolkit_aocs_test');
 ---------+-------+----------------+----------+--------------+-------------+-----------
 (0 rows)
 
+CREATE TABLE toolkit_heap_test (a INT) DISTRIBUTED BY (a);
+SELECT count(*) FROM gp_toolkit.__gp_aocsseg_history('toolkit_heap_test');
+ERROR:  Relation 'toolkit_heap_test' does not have append-optimized column-oriented storage  (seg0 slice1 127.0.1.1:7002 pid=1226082)
+DROP TABLE toolkit_heap_test;
 -- The same, but on the segments.
 SELECT (t).* FROM (
   SELECT gp_toolkit.__gp_aovisimap('toolkit_ao_test') AS t FROM gp_dist_random('gp_id')
diff --git a/gpcontrib/gp_toolkit/sql/gp_toolkit_ao_funcs.sql b/gpcontrib/gp_toolkit/sql/gp_toolkit_ao_funcs.sql
index 0df9943ef4..8b2c599088 100644
--- a/gpcontrib/gp_toolkit/sql/gp_toolkit_ao_funcs.sql
+++ b/gpcontrib/gp_toolkit/sql/gp_toolkit_ao_funcs.sql
@@ -37,6 +37,10 @@ SELECT count(*) FROM gp_toolkit.__gp_aoseg('toolkit_ao_test');
 SELECT * FROM gp_toolkit.__gp_aoblkdir('toolkit_ao_test');
 SELECT * FROM gp_toolkit.__gp_aoblkdir('toolkit_aocs_test');
 
+CREATE TABLE toolkit_heap_test (a INT) DISTRIBUTED BY (a);
+SELECT count(*) FROM gp_toolkit.__gp_aocsseg_history('toolkit_heap_test');
+DROP TABLE toolkit_heap_test;
+
 -- The same, but on the segments.
 SELECT (t).* FROM (
   SELECT gp_toolkit.__gp_aovisimap('toolkit_ao_test') AS t FROM gp_dist_random('gp_id')
diff --git a/src/backend/access/aocs/aocssegfiles.c b/src/backend/access/aocs/aocssegfiles.c
index 88a4756cb9..451eff3cf9 100644
--- a/src/backend/access/aocs/aocssegfiles.c
+++ b/src/backend/access/aocs/aocssegfiles.c
@@ -1466,7 +1466,6 @@ gp_aocsseg_history(PG_FUNCTION_ARGS)
 		aocsRel = heap_open(aocsRelOid, AccessShareLock);
 		if (!RelationIsAoCols(aocsRel))
 		{
-			heap_close(aocsRel, AccessShareLock);
 			ereport(ERROR,
 			        (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				        errmsg("'%s' is not an append-only columnar relation",


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cloudberry.apache.org
For additional commands, e-mail: commits-help@cloudberry.apache.org