Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6cc2ed1

Browse files
committed
Fix pg_upgrade to properly upgrade a table that is stored in the cluster
default tablespace, but part of a database that is in a user-definedtablespace. Caused "file not found" error during upgrade.Per bug report from Ants Aasma.Backpatch to 9.1 and 9.0.
1 parent5cf6fdd commit6cc2ed1

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

‎contrib/pg_upgrade/info.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
250250
i_nspname,
251251
i_relname,
252252
i_oid,
253-
i_relfilenode;
253+
i_relfilenode,
254+
i_reltablespace;
254255
charquery[QUERY_ALLOC];
255256

256257
/*
@@ -263,7 +264,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
263264

264265
snprintf(query,sizeof(query),
265266
"SELECT c.oid, n.nspname, c.relname, "
266-
"c.relfilenode, t.spclocation "
267+
"c.relfilenode,c.reltablespace,t.spclocation "
267268
"FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
268269
" ON c.relnamespace = n.oid "
269270
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
@@ -297,6 +298,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
297298
i_nspname=PQfnumber(res,"nspname");
298299
i_relname=PQfnumber(res,"relname");
299300
i_relfilenode=PQfnumber(res,"relfilenode");
301+
i_reltablespace=PQfnumber(res,"reltablespace");
300302
i_spclocation=PQfnumber(res,"spclocation");
301303

302304
for (relnum=0;relnum<ntups;relnum++)
@@ -314,10 +316,13 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
314316

315317
curr->relfilenode=atooid(PQgetvalue(res,relnum,i_relfilenode));
316318

317-
tblspace=PQgetvalue(res,relnum,i_spclocation);
318-
/* if no table tablespace, use the database tablespace */
319-
if (strlen(tblspace)==0)
319+
if (atooid(PQgetvalue(res,relnum,i_reltablespace))!=0)
320+
/* Might be "", meaning the cluster default location. */
321+
tblspace=PQgetvalue(res,relnum,i_spclocation);
322+
else
323+
/* A zero reltablespace indicates the database tablespace. */
320324
tblspace=dbinfo->db_tblspace;
325+
321326
strlcpy(curr->tablespace,tblspace,sizeof(curr->tablespace));
322327
}
323328
PQclear(res);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ typedef struct
7171
charrelname[NAMEDATALEN];/* relation name */
7272
Oidreloid;/* relation oid */
7373
Oidrelfilenode;/* relation relfile node */
74-
chartablespace[MAXPGPATH];/* relations tablespace path */
74+
/* relation tablespace path, or "" for the cluster default */
75+
chartablespace[MAXPGPATH];
7576
}RelInfo;
7677

7778
typedefstruct

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp