Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 28f6cab

Browse files
committed
binary upgrade:
Preserve relfilenodes for views and composite types --- even though we don't store data in, them, they do consume relfilenodes. Bump catalog version.
1 parent 6f8d200 commit 28f6cab

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

src/backend/catalog/heap.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.365 2010/01/06 03:03:58 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.366 2010/01/06 05:18:18 momjian Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -945,7 +945,8 @@ heap_create_with_catalog(const char *relname,
945945
errmsg("only shared relations can be placed in pg_global tablespace")));
946946
}
947947

948-
if ((relkind == RELKIND_RELATION || relkind == RELKIND_SEQUENCE) &&
948+
if ((relkind == RELKIND_RELATION || relkind == RELKIND_SEQUENCE ||
949+
relkind == RELKIND_VIEW || relkind == RELKIND_COMPOSITE_TYPE) &&
949950
OidIsValid(binary_upgrade_next_heap_relfilenode))
950951
{
951952
relid = binary_upgrade_next_heap_relfilenode;

src/bin/pg_dump/pg_dump.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* by PostgreSQL
1313
*
1414
* IDENTIFICATION
15-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.565 2010/01/06 03:04:02 momjian Exp $
15+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.c,v 1.566 2010/01/06 05:18:18 momjian Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -7192,6 +7192,7 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
71927192
int ntups;
71937193
int i_attname;
71947194
int i_atttypdefn;
7195+
int i_typrelid;
71957196
int i;
71967197

71977198
/* Set proper schema search path so type references list correctly */
@@ -7201,7 +7202,8 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
72017202
/* We assume here that remoteVersion must be at least 70300 */
72027203

72037204
appendPQExpBuffer(query, "SELECT a.attname, "
7204-
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn "
7205+
"pg_catalog.format_type(a.atttypid, a.atttypmod) AS atttypdefn, "
7206+
"typrelid "
72057207
"FROM pg_catalog.pg_type t, pg_catalog.pg_attribute a "
72067208
"WHERE t.oid = '%u'::pg_catalog.oid "
72077209
"AND a.attrelid = t.typrelid "
@@ -7222,9 +7224,15 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
72227224

72237225
i_attname = PQfnumber(res, "attname");
72247226
i_atttypdefn = PQfnumber(res, "atttypdefn");
7227+
i_typrelid = PQfnumber(res, "typrelid");
72257228

72267229
if (binary_upgrade)
7230+
{
7231+
Oid typrelid = atooid(PQgetvalue(res, 0, i_typrelid));
7232+
72277233
binary_upgrade_set_type_oids_by_type_oid(q, tyinfo->dobj.catId.oid);
7234+
binary_upgrade_set_relfilenodes(q, typrelid, false);
7235+
}
72287236

72297237
appendPQExpBuffer(q, "CREATE TYPE %s AS (",
72307238
fmtId(tyinfo->dobj.name));
@@ -10518,6 +10526,9 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1051810526
appendPQExpBuffer(delq, "%s;\n",
1051910527
fmtId(tbinfo->dobj.name));
1052010528

10529+
if (binary_upgrade)
10530+
binary_upgrade_set_relfilenodes(q, tbinfo->dobj.catId.oid, false);
10531+
1052110532
appendPQExpBuffer(q, "CREATE VIEW %s AS\n %s\n",
1052210533
fmtId(tbinfo->dobj.name), viewdef);
1052310534

src/include/catalog/catversion.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.568 2010/01/06 03:07:24 momjian Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.569 2010/01/06 05:18:18 momjian Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 201001052
56+
#define CATALOG_VERSION_NO 201001061
5757

5858
#endif

0 commit comments

Comments
 (0)