@@ -172,6 +172,7 @@ static void dumpType(Archive *fout, TypeInfo *tyinfo);
172
172
static void dumpBaseType (Archive * fout , TypeInfo * tyinfo );
173
173
static void dumpEnumType (Archive * fout , TypeInfo * tyinfo );
174
174
static void dumpRangeType (Archive * fout , TypeInfo * tyinfo );
175
+ static void dumpUndefinedType (Archive * fout , TypeInfo * tyinfo );
175
176
static void dumpDomain (Archive * fout , TypeInfo * tyinfo );
176
177
static void dumpCompositeType (Archive * fout , TypeInfo * tyinfo );
177
178
static void dumpCompositeTypeColComments (Archive * fout , TypeInfo * tyinfo );
@@ -1321,11 +1322,6 @@ selectDumpableType(TypeInfo *tyinfo)
1321
1322
/* dump only types in dumpable namespaces */
1322
1323
if (!tyinfo -> dobj .namespace -> dobj .dump )
1323
1324
tyinfo -> dobj .dump = false;
1324
-
1325
- /* skip undefined placeholder types */
1326
- else if (!tyinfo -> isDefined )
1327
- tyinfo -> dobj .dump = false;
1328
-
1329
1325
else
1330
1326
tyinfo -> dobj .dump = true;
1331
1327
}
@@ -3462,7 +3458,7 @@ getTypes(Archive *fout, int *numTypes)
3462
3458
}
3463
3459
}
3464
3460
3465
- if (strlen (tyinfo [i ].rolname ) == 0 && tyinfo [ i ]. isDefined )
3461
+ if (strlen (tyinfo [i ].rolname ) == 0 )
3466
3462
write_msg (NULL , "WARNING: owner of data type \"%s\" appears to be invalid\n" ,
3467
3463
tyinfo [i ].dobj .name );
3468
3464
}
@@ -8135,6 +8131,8 @@ dumpType(Archive *fout, TypeInfo *tyinfo)
8135
8131
dumpEnumType (fout , tyinfo );
8136
8132
else if (tyinfo -> typtype == TYPTYPE_RANGE )
8137
8133
dumpRangeType (fout , tyinfo );
8134
+ else if (tyinfo -> typtype == TYPTYPE_PSEUDO && !tyinfo -> isDefined )
8135
+ dumpUndefinedType (fout , tyinfo );
8138
8136
else
8139
8137
write_msg (NULL , "WARNING: typtype of data type \"%s\" appears to be invalid\n" ,
8140
8138
tyinfo -> dobj .name );
@@ -8401,6 +8399,73 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
8401
8399
destroyPQExpBuffer (query );
8402
8400
}
8403
8401
8402
+ /*
8403
+ * dumpUndefinedType
8404
+ * writes out to fout the queries to recreate a !typisdefined type
8405
+ *
8406
+ * This is a shell type, but we use different terminology to distinguish
8407
+ * this case from where we have to emit a shell type definition to break
8408
+ * circular dependencies. An undefined type shouldn't ever have anything
8409
+ * depending on it.
8410
+ */
8411
+ static void
8412
+ dumpUndefinedType (Archive * fout , TypeInfo * tyinfo )
8413
+ {
8414
+ PQExpBuffer q = createPQExpBuffer ();
8415
+ PQExpBuffer delq = createPQExpBuffer ();
8416
+ PQExpBuffer labelq = createPQExpBuffer ();
8417
+ char * qtypname ;
8418
+
8419
+ qtypname = pg_strdup (fmtId (tyinfo -> dobj .name ));
8420
+
8421
+ /*
8422
+ * DROP must be fully qualified in case same name appears in pg_catalog.
8423
+ */
8424
+ appendPQExpBuffer (delq , "DROP TYPE %s." ,
8425
+ fmtId (tyinfo -> dobj .namespace -> dobj .name ));
8426
+ appendPQExpBuffer (delq , "%s;\n" ,
8427
+ qtypname );
8428
+
8429
+ if (binary_upgrade )
8430
+ binary_upgrade_set_type_oids_by_type_oid (fout ,
8431
+ q , tyinfo -> dobj .catId .oid );
8432
+
8433
+ appendPQExpBuffer (q , "CREATE TYPE %s;\n" ,
8434
+ qtypname );
8435
+
8436
+ appendPQExpBuffer (labelq , "TYPE %s" , qtypname );
8437
+
8438
+ if (binary_upgrade )
8439
+ binary_upgrade_extension_member (q , & tyinfo -> dobj , labelq -> data );
8440
+
8441
+ ArchiveEntry (fout , tyinfo -> dobj .catId , tyinfo -> dobj .dumpId ,
8442
+ tyinfo -> dobj .name ,
8443
+ tyinfo -> dobj .namespace -> dobj .name ,
8444
+ NULL ,
8445
+ tyinfo -> rolname , false,
8446
+ "TYPE" , SECTION_PRE_DATA ,
8447
+ q -> data , delq -> data , NULL ,
8448
+ NULL , 0 ,
8449
+ NULL , NULL );
8450
+
8451
+ /* Dump Type Comments and Security Labels */
8452
+ dumpComment (fout , labelq -> data ,
8453
+ tyinfo -> dobj .namespace -> dobj .name , tyinfo -> rolname ,
8454
+ tyinfo -> dobj .catId , 0 , tyinfo -> dobj .dumpId );
8455
+ dumpSecLabel (fout , labelq -> data ,
8456
+ tyinfo -> dobj .namespace -> dobj .name , tyinfo -> rolname ,
8457
+ tyinfo -> dobj .catId , 0 , tyinfo -> dobj .dumpId );
8458
+
8459
+ dumpACL (fout , tyinfo -> dobj .catId , tyinfo -> dobj .dumpId , "TYPE" ,
8460
+ qtypname , NULL , tyinfo -> dobj .name ,
8461
+ tyinfo -> dobj .namespace -> dobj .name ,
8462
+ tyinfo -> rolname , tyinfo -> typacl );
8463
+
8464
+ destroyPQExpBuffer (q );
8465
+ destroyPQExpBuffer (delq );
8466
+ destroyPQExpBuffer (labelq );
8467
+ }
8468
+
8404
8469
/*
8405
8470
* dumpBaseType
8406
8471
* writes out to fout the queries to recreate a user-defined base type
0 commit comments