@@ -143,6 +143,7 @@ static void dumpNamespace(Archive *fout, NamespaceInfo *nspinfo);
143
143
static void dumpType (Archive * fout , TypeInfo * tyinfo );
144
144
static void dumpBaseType (Archive * fout , TypeInfo * tyinfo );
145
145
static void dumpEnumType (Archive * fout , TypeInfo * tyinfo );
146
+ static void dumpUndefinedType (Archive * fout , TypeInfo * tyinfo );
146
147
static void dumpDomain (Archive * fout , TypeInfo * tyinfo );
147
148
static void dumpCompositeType (Archive * fout , TypeInfo * tyinfo );
148
149
static void dumpCompositeTypeColComments (Archive * fout , TypeInfo * tyinfo );
@@ -1056,11 +1057,6 @@ selectDumpableType(TypeInfo *tyinfo)
1056
1057
/* dump only types in dumpable namespaces */
1057
1058
if (!tyinfo -> dobj .namespace -> dobj .dump )
1058
1059
tyinfo -> dobj .dump = false;
1059
-
1060
- /* skip undefined placeholder types */
1061
- else if (!tyinfo -> isDefined )
1062
- tyinfo -> dobj .dump = false;
1063
-
1064
1060
else
1065
1061
tyinfo -> dobj .dump = true;
1066
1062
}
@@ -2760,7 +2756,7 @@ getTypes(int *numTypes)
2760
2756
}
2761
2757
}
2762
2758
2763
- if (strlen (tyinfo [i ].rolname ) == 0 && tyinfo [ i ]. isDefined )
2759
+ if (strlen (tyinfo [i ].rolname ) == 0 )
2764
2760
write_msg (NULL , "WARNING: owner of data type \"%s\" appears to be invalid\n" ,
2765
2761
tyinfo [i ].dobj .name );
2766
2762
}
@@ -6711,6 +6707,11 @@ dumpType(Archive *fout, TypeInfo *tyinfo)
6711
6707
dumpCompositeType (fout , tyinfo );
6712
6708
else if (tyinfo -> typtype == TYPTYPE_ENUM )
6713
6709
dumpEnumType (fout , tyinfo );
6710
+ else if (tyinfo -> typtype == TYPTYPE_PSEUDO && !tyinfo -> isDefined )
6711
+ dumpUndefinedType (fout , tyinfo );
6712
+ else
6713
+ write_msg (NULL , "WARNING: typtype of data type \"%s\" appears to be invalid\n" ,
6714
+ tyinfo -> dobj .name );
6714
6715
}
6715
6716
6716
6717
/*
@@ -6818,6 +6819,61 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
6818
6819
destroyPQExpBuffer (query );
6819
6820
}
6820
6821
6822
+ /*
6823
+ * dumpUndefinedType
6824
+ * writes out to fout the queries to recreate a !typisdefined type
6825
+ *
6826
+ * This is a shell type, but we use different terminology to distinguish
6827
+ * this case from where we have to emit a shell type definition to break
6828
+ * circular dependencies. An undefined type shouldn't ever have anything
6829
+ * depending on it.
6830
+ */
6831
+ static void
6832
+ dumpUndefinedType (Archive * fout , TypeInfo * tyinfo )
6833
+ {
6834
+ PQExpBuffer q = createPQExpBuffer ();
6835
+ PQExpBuffer delq = createPQExpBuffer ();
6836
+ PQExpBuffer labelq = createPQExpBuffer ();
6837
+ char * qtypname ;
6838
+
6839
+ qtypname = pg_strdup (fmtId (tyinfo -> dobj .name ));
6840
+
6841
+ /*
6842
+ * DROP must be fully qualified in case same name appears in pg_catalog.
6843
+ */
6844
+ appendPQExpBuffer (delq , "DROP TYPE %s." ,
6845
+ fmtId (tyinfo -> dobj .namespace -> dobj .name ));
6846
+ appendPQExpBuffer (delq , "%s;\n" ,
6847
+ qtypname );
6848
+
6849
+ if (binary_upgrade )
6850
+ binary_upgrade_set_type_oids_by_type_oid (q , tyinfo -> dobj .catId .oid );
6851
+
6852
+ appendPQExpBuffer (q , "CREATE TYPE %s;\n" ,
6853
+ qtypname );
6854
+
6855
+ appendPQExpBuffer (labelq , "TYPE %s" , qtypname );
6856
+
6857
+ ArchiveEntry (fout , tyinfo -> dobj .catId , tyinfo -> dobj .dumpId ,
6858
+ tyinfo -> dobj .name ,
6859
+ tyinfo -> dobj .namespace -> dobj .name ,
6860
+ NULL ,
6861
+ tyinfo -> rolname , false,
6862
+ "TYPE" , SECTION_PRE_DATA ,
6863
+ q -> data , delq -> data , NULL ,
6864
+ NULL , 0 ,
6865
+ NULL , NULL );
6866
+
6867
+ /* Dump Type Comments */
6868
+ dumpComment (fout , labelq -> data ,
6869
+ tyinfo -> dobj .namespace -> dobj .name , tyinfo -> rolname ,
6870
+ tyinfo -> dobj .catId , 0 , tyinfo -> dobj .dumpId );
6871
+
6872
+ destroyPQExpBuffer (q );
6873
+ destroyPQExpBuffer (delq );
6874
+ destroyPQExpBuffer (labelq );
6875
+ }
6876
+
6821
6877
/*
6822
6878
* dumpBaseType
6823
6879
* writes out to fout the queries to recreate a user-defined base type
0 commit comments