@@ -12004,7 +12004,11 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1200412004"UNLOGGED " :"" ,
1200512005reltypename ,
1200612006fmtId (tbinfo -> dobj .name ));
12007- if (tbinfo -> reloftype )
12007+ /*
12008+ * In case of a binary upgrade, we dump the table normally and attach
12009+ * it to the type afterward.
12010+ */
12011+ if (tbinfo -> reloftype && !binary_upgrade )
1200812012appendPQExpBuffer (q ," OF %s" ,tbinfo -> reloftype );
1200912013actual_atts = 0 ;
1201012014for (j = 0 ;j < tbinfo -> numatts ;j ++ )
@@ -12032,7 +12036,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1203212036bool has_notnull = (tbinfo -> notnull [j ]
1203312037&& (!tbinfo -> inhNotNull [j ]|| binary_upgrade ));
1203412038
12035- if (tbinfo -> reloftype && !has_default && !has_notnull )
12039+ if (tbinfo -> reloftype && !has_default && !has_notnull && ! binary_upgrade )
1203612040continue ;
1203712041
1203812042/* Format properly if not first attr */
@@ -12060,7 +12064,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1206012064}
1206112065
1206212066/* Attribute type */
12063- if (tbinfo -> reloftype )
12067+ if (tbinfo -> reloftype && ! binary_upgrade )
1206412068{
1206512069appendPQExpBuffer (q ,"WITH OPTIONS" );
1206612070}
@@ -12126,7 +12130,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1212612130
1212712131if (actual_atts )
1212812132appendPQExpBuffer (q ,"\n)" );
12129- else if (!tbinfo -> reloftype )
12133+ else if (!( tbinfo -> reloftype && ! binary_upgrade ) )
1213012134{
1213112135/*
1213212136 * We must have a parenthesized attribute list, even though empty,
@@ -12192,6 +12196,7 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1219212196 * an INHERITS clause --- the latter would possibly mess up the column
1219312197 * order. That also means we have to take care about setting
1219412198 * attislocal correctly, plus fix up any inherited CHECK constraints.
12199+ * Analogously, we set up typed tables using ALTER TABLE / OF here.
1219512200 */
1219612201if (binary_upgrade && tbinfo -> relkind == RELKIND_RELATION )
1219712202{
@@ -12268,6 +12273,14 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1226812273}
1226912274}
1227012275
12276+ if (tbinfo -> reloftype )
12277+ {
12278+ appendPQExpBuffer (q ,"\n-- For binary upgrade, set up typed tables this way.\n" );
12279+ appendPQExpBuffer (q ,"ALTER TABLE ONLY %s OF %s;\n" ,
12280+ fmtId (tbinfo -> dobj .name ),
12281+ tbinfo -> reloftype );
12282+ }
12283+
1227112284appendPQExpBuffer (q ,"\n-- For binary upgrade, set heap's relfrozenxid\n" );
1227212285appendPQExpBuffer (q ,"UPDATE pg_catalog.pg_class\n"
1227312286"SET relfrozenxid = '%u'\n"