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-defined tablespace. Caused "file not found" error during upgrade. Per bug report from Ants Aasma. Backpatch to 9.1 and 9.0.
This commit is contained in:
parent
eb821b91c8
commit
38458e4573
@ -256,7 +256,8 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
||||
i_nspname,
|
||||
i_relname,
|
||||
i_oid,
|
||||
i_relfilenode;
|
||||
i_relfilenode,
|
||||
i_reltablespace;
|
||||
char query[QUERY_ALLOC];
|
||||
|
||||
/*
|
||||
@ -269,7 +270,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
||||
|
||||
snprintf(query, sizeof(query),
|
||||
"SELECT c.oid, n.nspname, c.relname, "
|
||||
" c.relfilenode, %s "
|
||||
" c.relfilenode, c.reltablespace, %s "
|
||||
"FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n "
|
||||
" ON c.relnamespace = n.oid "
|
||||
" LEFT OUTER JOIN pg_catalog.pg_tablespace t "
|
||||
@ -306,6 +307,7 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
||||
i_nspname = PQfnumber(res, "nspname");
|
||||
i_relname = PQfnumber(res, "relname");
|
||||
i_relfilenode = PQfnumber(res, "relfilenode");
|
||||
i_reltablespace = PQfnumber(res, "reltablespace");
|
||||
i_spclocation = PQfnumber(res, "spclocation");
|
||||
|
||||
for (relnum = 0; relnum < ntups; relnum++)
|
||||
@ -323,10 +325,13 @@ get_rel_infos(ClusterInfo *cluster, DbInfo *dbinfo)
|
||||
|
||||
curr->relfilenode = atooid(PQgetvalue(res, relnum, i_relfilenode));
|
||||
|
||||
tblspace = PQgetvalue(res, relnum, i_spclocation);
|
||||
/* if no table tablespace, use the database tablespace */
|
||||
if (strlen(tblspace) == 0)
|
||||
if (atooid(PQgetvalue(res, relnum, i_reltablespace)) != 0)
|
||||
/* Might be "", meaning the cluster default location. */
|
||||
tblspace = PQgetvalue(res, relnum, i_spclocation);
|
||||
else
|
||||
/* A zero reltablespace indicates the database tablespace. */
|
||||
tblspace = dbinfo->db_tblspace;
|
||||
|
||||
strlcpy(curr->tablespace, tblspace, sizeof(curr->tablespace));
|
||||
}
|
||||
PQclear(res);
|
||||
|
@ -109,7 +109,8 @@ typedef struct
|
||||
char relname[NAMEDATALEN]; /* relation name */
|
||||
Oid reloid; /* relation oid */
|
||||
Oid relfilenode; /* relation relfile node */
|
||||
char tablespace[MAXPGPATH]; /* relations tablespace path */
|
||||
/* relation tablespace path, or "" for the cluster default */
|
||||
char tablespace[MAXPGPATH];
|
||||
} RelInfo;
|
||||
|
||||
typedef struct
|
||||
|
Loading…
x
Reference in New Issue
Block a user