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

chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git


The following commit(s) were added to refs/heads/cbdb-postgres-merge by this 
push:
     new f29a62b9171 Fix some sql on gp_tablespace
f29a62b9171 is described below

commit f29a62b91712a2c2f7657ed6dd08b3497b7a2013
Author: Jinbao Chen <[email protected]>
AuthorDate: Sun Dec 14 23:05:49 2025 +0800

    Fix some sql on gp_tablespace
---
 src/backend/storage/smgr/md.c          |  2 +-
 src/test/regress/sql/gp_tablespace.sql | 22 +++++++++++++---------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
index 6df0dc63779..7c62e43dffd 100644
--- a/src/backend/storage/smgr/md.c
+++ b/src/backend/storage/smgr/md.c
@@ -1652,7 +1652,7 @@ _mdnblocks(SMgrRelation reln, ForkNumber forknum, MdfdVec 
*seg)
 int
 mdsyncfiletag(const FileTag *ftag, char *path)
 {
-       SMgrRelation reln = smgropen(ftag->rlocator, InvalidBackendId, 0, NULL);
+       SMgrRelation reln = smgropen(ftag->rlocator, InvalidBackendId, SMGR_MD, 
NULL);
        File            file;
        instr_time      io_start;
        bool            need_to_close;
diff --git a/src/test/regress/sql/gp_tablespace.sql 
b/src/test/regress/sql/gp_tablespace.sql
index 66046363bb4..ee8817516f2 100644
--- a/src/test/regress/sql/gp_tablespace.sql
+++ b/src/test/regress/sql/gp_tablespace.sql
@@ -38,8 +38,9 @@ END;
 $$ language plpgsql;
 
 -- create tablespaces we can use
+\set testtablespace_unlogged :testtablespace '_unlogged'
 CREATE TABLESPACE testspace LOCATION :'testtablespace';
-CREATE TABLESPACE ul_testspace LOCATION :'testtablespace' '_unlogged';
+CREATE TABLESPACE ul_testspace LOCATION :'testtablespace_unlogged';
 SELECT gp_segment_id,
        CASE tblspc_loc
             WHEN :'testtablespace' THEN 'testtablespace'
@@ -48,7 +49,7 @@ SELECT gp_segment_id,
 FROM gp_tablespace_location((SELECT oid FROM pg_tablespace WHERE 
spcname='testspace'));
 SELECT gp_segment_id,
        CASE tblspc_loc
-            WHEN :'testtablespace' '_unlogged' THEN 'testtablespace_unlogged'
+            WHEN :'testtablespace_unlogged' THEN 'testtablespace_unlogged'
             ELSE 'testtablespace_unknown'
        END AS tblspc_loc
 FROM gp_tablespace_location((SELECT oid FROM pg_tablespace WHERE 
spcname='ul_testspace'));
@@ -61,7 +62,7 @@ FROM pg_tablespace WHERE spcname = 'testspace';
 
 -- Ensure mirrors have applied filesystem changes
 SELECT force_mirrors_to_catch_up();
-\! ls :'testtablespace';
+\! ls :testtablespace;
 
 -- Test moving AO/AOCO tables from one tablespace to another.
 CREATE TABLE ao_ts_table (id int4, t text) with (appendonly=true, 
orientation=row) distributed by (id);
@@ -190,19 +191,21 @@ drop table aoco_ul_ctas;
 drop tablespace ul_testspace;
 
 -- Cloudberry tablespaces have the option to define tablespace location for 
specific segments
-CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH 
(content9999=:'testtablespace' '_otherloc'); -- should fail
-CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH 
(content1=:'testtablespace' '_otherloc');
+\set testtablespace_otherloc :testtablespace '_otherloc'
+CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH 
(content9999=:'testtablespace_otherloc'); -- should fail
+CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH 
(content1=:'testtablespace_otherloc');
 SELECT gp_segment_id,
        CASE tblspc_loc
             WHEN :'testtablespace' THEN 'testtablespace'
-            WHEN :'testtablespace' '_otherloc' THEN 'testtablespace_otherloc'
+            WHEN :'testtablespace_otherloc' THEN 'testtablespace_otherloc'
             ELSE 'testtablespace_unknown'
        END AS tblspc_loc
 FROM gp_tablespace_location((SELECT oid FROM pg_tablespace WHERE 
spcname='testspace_otherloc'));
 
 -- Create a tablespace with an existing GP_TABLESPACE_VERSION_DIRECTORY for
 -- another version of GPDB.
-CREATE TABLESPACE testspace_existing_version_dir LOCATION 
'@testtablespace@_existing_version_dir';
+\set testtablespace_existing_version_dir :testtablespace 
'_existing_version_dir'
+CREATE TABLESPACE testspace_existing_version_dir LOCATION 
:'testtablespace_existing_version_dir';
 
 SELECT * FROM
   (SELECT pg_ls_dir('pg_tblspc/' || oid) AS versiondirs
@@ -224,7 +227,8 @@ DROP TABLESPACE testspace_existing_version_dir;
 
 -- Ensure mirrors have applied filesystem changes
 SELECT force_mirrors_to_catch_up();
-\! ls :'testtablespace'_existing_version_dir/*;
+\set testtablespace_existing_version_dir :testtablespace 
'_existing_version_dir'
+\! ls testtablespace_existing_version_dir/*;
 
 -- Test alter tablespace: PG does not seem to test these.
 
@@ -253,7 +257,7 @@ SELECT COUNT(*) FROM tblspc_otherloc_heap;
 DROP TABLE tblspc_otherloc_heap;
 DROP TABLESPACE testspace_otherloc;
 
-CREATE TABLESPACE testspace_dir_empty LOCATION '@testtablespace@';
+CREATE TABLESPACE testspace_dir_empty LOCATION :'testtablespace';
 CREATE TABLE t_dir_empty(a int);
 \! rm -rf @testtablespace@/*;
 DROP TABLE IF EXISTS t_dir_empty;


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

Reply via email to