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

Commit38458e4

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 parenteb821b9 commit38458e4

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
@@ -256,7 +256,8 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
256256
i_nspname,
257257
i_relname,
258258
i_oid,
259-
i_relfilenode;
259+
i_relfilenode,
260+
i_reltablespace;
260261
charquery[QUERY_ALLOC];
261262

262263
/*
@@ -269,7 +270,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
269270

270271
snprintf(query,sizeof(query),
271272
"SELECT c.oid, n.nspname, c.relname, "
272-
"c.relfilenode, %s "
273+
"c.relfilenode,c.reltablespace,%s "
273274
"FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
274275
" ON c.relnamespace = n.oid "
275276
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
@@ -306,6 +307,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
306307
i_nspname=PQfnumber(res,"nspname");
307308
i_relname=PQfnumber(res,"relname");
308309
i_relfilenode=PQfnumber(res,"relfilenode");
310+
i_reltablespace=PQfnumber(res,"reltablespace");
309311
i_spclocation=PQfnumber(res,"spclocation");
310312

311313
for (relnum=0;relnum<ntups;relnum++)
@@ -323,10 +325,13 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
323325

324326
curr->relfilenode=atooid(PQgetvalue(res,relnum,i_relfilenode));
325327

326-
tblspace=PQgetvalue(res,relnum,i_spclocation);
327-
/* if no table tablespace, use the database tablespace */
328-
if (strlen(tblspace)==0)
328+
if (atooid(PQgetvalue(res,relnum,i_reltablespace))!=0)
329+
/* Might be "", meaning the cluster default location. */
330+
tblspace=PQgetvalue(res,relnum,i_spclocation);
331+
else
332+
/* A zero reltablespace indicates the database tablespace. */
329333
tblspace=dbinfo->db_tblspace;
334+
330335
strlcpy(curr->tablespace,tblspace,sizeof(curr->tablespace));
331336
}
332337
PQclear(res);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ typedef struct
109109
charrelname[NAMEDATALEN];/* relation name */
110110
Oidreloid;/* relation oid */
111111
Oidrelfilenode;/* relation relfile node */
112-
chartablespace[MAXPGPATH];/* relations tablespace path */
112+
/* relation tablespace path, or "" for the cluster default */
113+
chartablespace[MAXPGPATH];
113114
}RelInfo;
114115

115116
typedefstruct

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp