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

Commit916eec2

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 parent8b67e3c commit916eec2

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
@@ -306,6 +306,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
306306
inti_relname=-1;
307307
inti_oid=-1;
308308
inti_relfilenode=-1;
309+
inti_reltablespace=-1;
309310
inti_reltoastrelid=-1;
310311
charquery[QUERY_ALLOC];
311312

@@ -320,7 +321,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
320321

321322
snprintf(query,sizeof(query),
322323
"SELECT DISTINCT c.oid, n.nspname, c.relname, "
323-
"c.relfilenode, c.reltoastrelid, t.spclocation "
324+
"c.relfilenode, c.reltoastrelid,c.reltablespace,t.spclocation "
324325
"FROM pg_catalog.pg_class c JOIN "
325326
"pg_catalog.pg_namespace n "
326327
"ON c.relnamespace = n.oid "
@@ -339,7 +340,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
339340
" ('pg_largeobject', 'pg_largeobject_loid_pn_index'%s) )) "
340341
"AND relkind IN ('r','t', 'i'%s)"
341342
"GROUP BY c.oid, n.nspname, c.relname, c.relfilenode,"
342-
"c.reltoastrelid, t.spclocation, "
343+
"c.reltoastrelid,c.reltablespace,t.spclocation, "
343344
"n.nspname "
344345
"ORDER BY n.nspname, c.relname;",
345346
FirstNormalObjectId,
@@ -361,6 +362,7 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
361362
i_relname=PQfnumber(res,"relname");
362363
i_relfilenode=PQfnumber(res,"relfilenode");
363364
i_reltoastrelid=PQfnumber(res,"reltoastrelid");
365+
i_reltablespace=PQfnumber(res,"reltablespace");
364366
i_spclocation=PQfnumber(res,"spclocation");
365367

366368
for (relnum=0;relnum<ntups;relnum++)
@@ -379,10 +381,13 @@ get_rel_infos(migratorContext *ctx, const DbInfo *dbinfo,
379381
curr->relfilenode=atooid(PQgetvalue(res,relnum,i_relfilenode));
380382
curr->toastrelid=atooid(PQgetvalue(res,relnum,i_reltoastrelid));
381383

382-
tblspace=PQgetvalue(res,relnum,i_spclocation);
383-
/* if no table tablespace, use the database tablespace */
384-
if (strlen(tblspace)==0)
384+
if (atooid(PQgetvalue(res,relnum,i_reltablespace))!=0)
385+
/* Might be "", meaning the cluster default location. */
386+
tblspace=PQgetvalue(res,relnum,i_spclocation);
387+
else
388+
/* A zero reltablespace indicates the database tablespace. */
385389
tblspace=dbinfo->db_tblspace;
390+
386391
strlcpy(curr->tablespace,tblspace,sizeof(curr->tablespace));
387392
}
388393
PQclear(res);

‎contrib/pg_upgrade/pg_upgrade.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ typedef struct
6969
Oidreloid;/* relation oid */
7070
Oidrelfilenode;/* relation relfile node */
7171
Oidtoastrelid;/* oid of the toast relation */
72-
chartablespace[MAXPGPATH];/* relations tablespace path */
72+
/* relation tablespace path, or "" for the cluster default */
73+
chartablespace[MAXPGPATH];
7374
}RelInfo;
7475

7576
typedefstruct

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp