Skip to content

Commit f29a62b

Browse files
committed
Fix some sql on gp_tablespace
1 parent ef0c7c4 commit f29a62b

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/backend/storage/smgr/md.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1652,7 +1652,7 @@ _mdnblocks(SMgrRelation reln, ForkNumber forknum, MdfdVec *seg)
16521652
int
16531653
mdsyncfiletag(const FileTag *ftag, char *path)
16541654
{
1655-
SMgrRelation reln = smgropen(ftag->rlocator, InvalidBackendId, 0, NULL);
1655+
SMgrRelation reln = smgropen(ftag->rlocator, InvalidBackendId, SMGR_MD, NULL);
16561656
File file;
16571657
instr_time io_start;
16581658
bool need_to_close;

src/test/regress/sql/gp_tablespace.sql

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ END;
3838
$$ language plpgsql;
3939

4040
-- create tablespaces we can use
41+
\set testtablespace_unlogged :testtablespace '_unlogged'
4142
CREATE TABLESPACE testspace LOCATION :'testtablespace';
42-
CREATE TABLESPACE ul_testspace LOCATION :'testtablespace' '_unlogged';
43+
CREATE TABLESPACE ul_testspace LOCATION :'testtablespace_unlogged';
4344
SELECT gp_segment_id,
4445
CASE tblspc_loc
4546
WHEN :'testtablespace' THEN 'testtablespace'
@@ -48,7 +49,7 @@ SELECT gp_segment_id,
4849
FROM gp_tablespace_location((SELECT oid FROM pg_tablespace WHERE spcname='testspace'));
4950
SELECT gp_segment_id,
5051
CASE tblspc_loc
51-
WHEN :'testtablespace' '_unlogged' THEN 'testtablespace_unlogged'
52+
WHEN :'testtablespace_unlogged' THEN 'testtablespace_unlogged'
5253
ELSE 'testtablespace_unknown'
5354
END AS tblspc_loc
5455
FROM gp_tablespace_location((SELECT oid FROM pg_tablespace WHERE spcname='ul_testspace'));
@@ -61,7 +62,7 @@ FROM pg_tablespace WHERE spcname = 'testspace';
6162

6263
-- Ensure mirrors have applied filesystem changes
6364
SELECT force_mirrors_to_catch_up();
64-
\! ls :'testtablespace';
65+
\! ls :testtablespace;
6566

6667
-- Test moving AO/AOCO tables from one tablespace to another.
6768
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;
190191
drop tablespace ul_testspace;
191192

192193
-- Cloudberry tablespaces have the option to define tablespace location for specific segments
193-
CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH (content9999=:'testtablespace' '_otherloc'); -- should fail
194-
CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH (content1=:'testtablespace' '_otherloc');
194+
\set testtablespace_otherloc :testtablespace '_otherloc'
195+
CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH (content9999=:'testtablespace_otherloc'); -- should fail
196+
CREATE TABLESPACE testspace_otherloc LOCATION :'testtablespace' WITH (content1=:'testtablespace_otherloc');
195197
SELECT gp_segment_id,
196198
CASE tblspc_loc
197199
WHEN :'testtablespace' THEN 'testtablespace'
198-
WHEN :'testtablespace' '_otherloc' THEN 'testtablespace_otherloc'
200+
WHEN :'testtablespace_otherloc' THEN 'testtablespace_otherloc'
199201
ELSE 'testtablespace_unknown'
200202
END AS tblspc_loc
201203
FROM gp_tablespace_location((SELECT oid FROM pg_tablespace WHERE spcname='testspace_otherloc'));
202204

203205
-- Create a tablespace with an existing GP_TABLESPACE_VERSION_DIRECTORY for
204206
-- another version of GPDB.
205-
CREATE TABLESPACE testspace_existing_version_dir LOCATION '@testtablespace@_existing_version_dir';
207+
\set testtablespace_existing_version_dir :testtablespace '_existing_version_dir'
208+
CREATE TABLESPACE testspace_existing_version_dir LOCATION :'testtablespace_existing_version_dir';
206209

207210
SELECT * FROM
208211
(SELECT pg_ls_dir('pg_tblspc/' || oid) AS versiondirs
@@ -224,7 +227,8 @@ DROP TABLESPACE testspace_existing_version_dir;
224227

225228
-- Ensure mirrors have applied filesystem changes
226229
SELECT force_mirrors_to_catch_up();
227-
\! ls :'testtablespace'_existing_version_dir/*;
230+
\set testtablespace_existing_version_dir :testtablespace '_existing_version_dir'
231+
\! ls testtablespace_existing_version_dir/*;
228232
229233
-- Test alter tablespace: PG does not seem to test these.
230234
@@ -253,7 +257,7 @@ SELECT COUNT(*) FROM tblspc_otherloc_heap;
253257
DROP TABLE tblspc_otherloc_heap;
254258
DROP TABLESPACE testspace_otherloc;
255259
256-
CREATE TABLESPACE testspace_dir_empty LOCATION '@testtablespace@';
260+
CREATE TABLESPACE testspace_dir_empty LOCATION :'testtablespace';
257261
CREATE TABLE t_dir_empty(a int);
258262
\! rm -rf @testtablespace@/*;
259263
DROP TABLE IF EXISTS t_dir_empty;

0 commit comments

Comments
 (0)