@@ -175,6 +175,7 @@ static void dumpType(Archive *fout, TypeInfo *tyinfo);
175
175
static void dumpBaseType (Archive * fout , TypeInfo * tyinfo );
176
176
static void dumpEnumType (Archive * fout , TypeInfo * tyinfo );
177
177
static void dumpRangeType (Archive * fout , TypeInfo * tyinfo );
178
+ static void dumpUndefinedType (Archive * fout , TypeInfo * tyinfo );
178
179
static void dumpDomain (Archive * fout , TypeInfo * tyinfo );
179
180
static void dumpCompositeType (Archive * fout , TypeInfo * tyinfo );
180
181
static void dumpCompositeTypeColComments (Archive * fout , TypeInfo * tyinfo );
@@ -1311,11 +1312,6 @@ selectDumpableType(TypeInfo *tyinfo)
1311
1312
/* dump only types in dumpable namespaces */
1312
1313
if (!tyinfo -> dobj .namespace -> dobj .dump )
1313
1314
tyinfo -> dobj .dump = false;
1314
-
1315
- /* skip undefined placeholder types */
1316
- else if (!tyinfo -> isDefined )
1317
- tyinfo -> dobj .dump = false;
1318
-
1319
1315
else
1320
1316
tyinfo -> dobj .dump = true;
1321
1317
}
@@ -3425,7 +3421,7 @@ getTypes(Archive *fout, int *numTypes)
3425
3421
}
3426
3422
}
3427
3423
3428
- if (strlen (tyinfo [i ].rolname ) == 0 && tyinfo [ i ]. isDefined )
3424
+ if (strlen (tyinfo [i ].rolname ) == 0 )
3429
3425
write_msg (NULL , "WARNING: owner of data type \"%s\" appears to be invalid\n" ,
3430
3426
tyinfo [i ].dobj .name );
3431
3427
}
@@ -8008,6 +8004,8 @@ dumpType(Archive *fout, TypeInfo *tyinfo)
8008
8004
dumpEnumType (fout , tyinfo );
8009
8005
else if (tyinfo -> typtype == TYPTYPE_RANGE )
8010
8006
dumpRangeType (fout , tyinfo );
8007
+ else if (tyinfo -> typtype == TYPTYPE_PSEUDO && !tyinfo -> isDefined )
8008
+ dumpUndefinedType (fout , tyinfo );
8011
8009
else
8012
8010
write_msg (NULL , "WARNING: typtype of data type \"%s\" appears to be invalid\n" ,
8013
8011
tyinfo -> dobj .name );
@@ -8275,6 +8273,73 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
8275
8273
destroyPQExpBuffer (query );
8276
8274
}
8277
8275
8276
+ /*
8277
+ * dumpUndefinedType
8278
+ * writes out to fout the queries to recreate a !typisdefined type
8279
+ *
8280
+ * This is a shell type, but we use different terminology to distinguish
8281
+ * this case from where we have to emit a shell type definition to break
8282
+ * circular dependencies. An undefined type shouldn't ever have anything
8283
+ * depending on it.
8284
+ */
8285
+ static void
8286
+ dumpUndefinedType (Archive * fout , TypeInfo * tyinfo )
8287
+ {
8288
+ PQExpBuffer q = createPQExpBuffer ();
8289
+ PQExpBuffer delq = createPQExpBuffer ();
8290
+ PQExpBuffer labelq = createPQExpBuffer ();
8291
+ char * qtypname ;
8292
+
8293
+ qtypname = pg_strdup (fmtId (tyinfo -> dobj .name ));
8294
+
8295
+ /*
8296
+ * DROP must be fully qualified in case same name appears in pg_catalog.
8297
+ */
8298
+ appendPQExpBuffer (delq , "DROP TYPE %s." ,
8299
+ fmtId (tyinfo -> dobj .namespace -> dobj .name ));
8300
+ appendPQExpBuffer (delq , "%s;\n" ,
8301
+ qtypname );
8302
+
8303
+ if (binary_upgrade )
8304
+ binary_upgrade_set_type_oids_by_type_oid (fout ,
8305
+ q , tyinfo -> dobj .catId .oid );
8306
+
8307
+ appendPQExpBuffer (q , "CREATE TYPE %s;\n" ,
8308
+ qtypname );
8309
+
8310
+ appendPQExpBuffer (labelq , "TYPE %s" , qtypname );
8311
+
8312
+ if (binary_upgrade )
8313
+ binary_upgrade_extension_member (q , & tyinfo -> dobj , labelq -> data );
8314
+
8315
+ ArchiveEntry (fout , tyinfo -> dobj .catId , tyinfo -> dobj .dumpId ,
8316
+ tyinfo -> dobj .name ,
8317
+ tyinfo -> dobj .namespace -> dobj .name ,
8318
+ NULL ,
8319
+ tyinfo -> rolname , false,
8320
+ "TYPE" , SECTION_PRE_DATA ,
8321
+ q -> data , delq -> data , NULL ,
8322
+ NULL , 0 ,
8323
+ NULL , NULL );
8324
+
8325
+ /* Dump Type Comments and Security Labels */
8326
+ dumpComment (fout , labelq -> data ,
8327
+ tyinfo -> dobj .namespace -> dobj .name , tyinfo -> rolname ,
8328
+ tyinfo -> dobj .catId , 0 , tyinfo -> dobj .dumpId );
8329
+ dumpSecLabel (fout , labelq -> data ,
8330
+ tyinfo -> dobj .namespace -> dobj .name , tyinfo -> rolname ,
8331
+ tyinfo -> dobj .catId , 0 , tyinfo -> dobj .dumpId );
8332
+
8333
+ dumpACL (fout , tyinfo -> dobj .catId , tyinfo -> dobj .dumpId , "TYPE" ,
8334
+ qtypname , NULL , tyinfo -> dobj .name ,
8335
+ tyinfo -> dobj .namespace -> dobj .name ,
8336
+ tyinfo -> rolname , tyinfo -> typacl );
8337
+
8338
+ destroyPQExpBuffer (q );
8339
+ destroyPQExpBuffer (delq );
8340
+ destroyPQExpBuffer (labelq );
8341
+ }
8342
+
8278
8343
/*
8279
8344
* dumpBaseType
8280
8345
* writes out to fout the queries to recreate a user-defined base type
0 commit comments