20 #include "catalog/pg_class_d.h"
21 #include "catalog/pg_collation_d.h"
22 #include "catalog/pg_extension_d.h"
23 #include "catalog/pg_namespace_d.h"
24 #include "catalog/pg_operator_d.h"
25 #include "catalog/pg_proc_d.h"
26 #include "catalog/pg_publication_d.h"
27 #include "catalog/pg_subscription_d.h"
28 #include "catalog/pg_type_d.h"
67 #define SH_PREFIX catalogid
68 #define SH_ELEMENT_TYPE CatalogIdMapEntry
69 #define SH_KEY_TYPE CatalogId
71 #define SH_HASH_KEY(tb, key) hash_bytes((const unsigned char *) &(key), sizeof(CatalogId))
72 #define SH_EQUAL(tb, a, b) ((a).oid == (b).oid && (a).tableoid == (b).tableoid)
74 #define SH_GET_HASH(tb, a) (a)->hashval
75 #define SH_SCOPE static inline
76 #define SH_RAW_ALLOCATOR pg_malloc0
81 #define CATALOGIDHASH_INITIAL_SIZE 10000
86 InhInfo *inhinfo,
int numInherits);
89 static int strInArray(
const char *pattern,
char **arr,
int arr_size);
143 pg_log_info(
"reading user-defined aggregate functions");
149 pg_log_info(
"reading user-defined access methods");
152 pg_log_info(
"reading user-defined operator classes");
155 pg_log_info(
"reading user-defined operator families");
158 pg_log_info(
"reading user-defined text search parsers");
161 pg_log_info(
"reading user-defined text search templates");
164 pg_log_info(
"reading user-defined text search dictionaries");
167 pg_log_info(
"reading user-defined text search configurations");
170 pg_log_info(
"reading user-defined foreign-data wrappers");
173 pg_log_info(
"reading user-defined foreign servers");
191 pg_log_info(
"reading table inheritance information");
203 flagInhTables(fout, tblinfo, numTables, inhinfo, numInherits);
205 pg_log_info(
"reading column info for interesting tables");
208 pg_log_info(
"flagging inherited columns in subtables");
217 pg_log_info(
"flagging indexes in partitioned tables");
238 pg_log_info(
"reading publication membership of tables");
241 pg_log_info(
"reading publication membership of schemas");
247 pg_log_info(
"reading subscription membership of tables");
252 *numTablesPtr = numTables;
270 InhInfo *inhinfo,
int numInherits)
285 for (
i = 0;
i < numInherits;
i++)
305 if (parent == NULL ||
310 pg_fatal(
"failed sanity check, parent OID %u of table \"%s\" (OID %u) not found",
311 inhinfo[
i].inhparent,
328 for (
i = 0;
i < numTables;
i++)
335 if (tblinfo[
i].dobj.dump)
340 for (
j = 0;
j < numParents;
j++)
341 parents[
j]->interesting =
true;
351 if (tblinfo[
i].numParents != 1)
352 pg_fatal(
"invalid number of parents %d for table \"%s\"",
353 tblinfo[
i].numParents,
354 tblinfo[
i].dobj.name);
362 attachinfo->
dobj.namespace = tblinfo[
i].
dobj.namespace;
392 for (
i = 0;
i < numTables;
i++)
394 if (!tblinfo[
i].ispartition || tblinfo[
i].numParents == 0)
397 Assert(tblinfo[
i].numParents == 1);
405 if (
index->parentidx == 0)
409 if (parentidx == NULL)
419 attachinfo->
dobj.namespace =
index->indextable->dobj.namespace;
441 index->indextable->dobj.dumpId);
491 for (
i = 0;
i < numTables;
i++)
498 if (tbinfo->
relkind == RELKIND_SEQUENCE ||
499 tbinfo->
relkind == RELKIND_VIEW ||
500 tbinfo->
relkind == RELKIND_MATVIEW)
518 bool foundSameGenerated;
519 bool foundDiffGenerated;
525 foundNotNull =
false;
526 foundDefault =
false;
527 foundSameGenerated =
false;
528 foundDiffGenerated =
false;
529 for (k = 0; k < numParents; k++)
541 foundNotNull |= parent->
notnull[inhAttrInd];
542 foundDefault |= (parentDef != NULL &&
543 strcmp(parentDef->
adef_expr,
"NULL") != 0 &&
548 if (parentDef != NULL &&
552 foundSameGenerated =
true;
554 foundDiffGenerated =
true;
570 if (foundDefault && tbinfo->
attrdefs[
j] == NULL)
580 attrDef->
dobj.namespace = tbinfo->
dobj.namespace;
606 if (foundSameGenerated && !foundDiffGenerated &&
626 dobj->namespace = NULL;
833 catId.
tableoid = RelationRelationId;
851 catId.
tableoid = RelationRelationId;
888 catId.
tableoid = ProcedureRelationId;
906 catId.
tableoid = OperatorRelationId;
924 catId.
tableoid = CollationRelationId;
942 catId.
tableoid = NamespaceRelationId;
960 catId.
tableoid = ExtensionRelationId;
978 catId.
tableoid = PublicationRelationId;
996 catId.
tableoid = SubscriptionRelationId;
1070 if (s ==
' ' || s ==
'\0')
1074 if (argNum >= arraysize)
1075 pg_fatal(
"could not parse numeric array \"%s\": too many numbers",
str);
1077 array[argNum++] =
atooid(temp);
1085 if (!(isdigit((
unsigned char) s) || s ==
'-') ||
1086 j >=
sizeof(temp) - 1)
1087 pg_fatal(
"could not parse numeric array \"%s\": invalid character in number",
str);
1092 while (argNum < arraysize)
1109 for (
i = 0;
i < arr_size;
i++)
1111 if (strcmp(pattern, arr[
i]) == 0)
void recordAdditionalCatalogID(CatalogId catId, DumpableObject *dobj)
void recordExtensionMembership(CatalogId catId, ExtensionInfo *ext)
FuncInfo * findFuncByOid(Oid oid)
static void flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, InhInfo *inhinfo, int numInherits)
static void flagInhIndexes(Archive *fout, TableInfo *tblinfo, int numTables)
NamespaceInfo * findNamespaceByOid(Oid oid)
SubscriptionInfo * findSubscriptionByOid(Oid oid)
ExtensionInfo * findOwningExtension(CatalogId catalogId)
TableInfo * getSchemaData(Archive *fout, int *numTablesPtr)
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
static void flagInhAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
void addObjectDependency(DumpableObject *dobj, DumpId refId)
static int allocedDumpIds
DumpableObject * findObjectByDumpId(DumpId dumpId)
void parseOidArray(const char *str, Oid *array, int arraysize)
TableInfo * findTableByOid(Oid oid)
static IndxInfo * findIndexByOid(Oid oid)
DumpId createDumpId(void)
ExtensionInfo * findExtensionByOid(Oid oid)
void AssignDumpId(DumpableObject *dobj)
DumpId getMaxDumpId(void)
static DumpableObject ** dumpIdMap
#define CATALOGIDHASH_INITIAL_SIZE
static int strInArray(const char *pattern, char **arr, int arr_size)
void getDumpableObjects(DumpableObject ***objs, int *numObjs)
CollInfo * findCollationByOid(Oid oid)
static catalogid_hash * catalogIdHash
TypeInfo * findTypeByOid(Oid oid)
OprInfo * findOprByOid(Oid oid)
struct _catalogIdMapEntry CatalogIdMapEntry
void removeObjectDependency(DumpableObject *dobj, DumpId refId)
PublicationInfo * findPublicationByOid(Oid oid)
#define Assert(condition)
#define OidIsValid(objectId)
char * pg_strdup(const char *in)
#define pg_realloc_array(pointer, type, count)
#define pg_malloc_array(type, count)
#define pg_malloc_object(type)
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
void getPublicationNamespaces(Archive *fout)
void getPartitioningInfo(Archive *fout)
void getForeignDataWrappers(Archive *fout)
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
void getTypes(Archive *fout)
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
void getOpclasses(Archive *fout)
void getForeignServers(Archive *fout)
void getFuncs(Archive *fout)
void getTSDictionaries(Archive *fout)
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
void getCasts(Archive *fout)
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
void getTSConfigurations(Archive *fout)
void getAccessMethods(Archive *fout)
void getConversions(Archive *fout)
void getRules(Archive *fout)
InhInfo * getInherits(Archive *fout, int *numInherits)
void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
void getSubscriptionTables(Archive *fout)
void getCollations(Archive *fout)
void getAggregates(Archive *fout)
void getNamespaces(Archive *fout)
void getPublications(Archive *fout)
void getTSParsers(Archive *fout)
void getExtendedStatistics(Archive *fout)
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
void getDefaultACLs(Archive *fout)
void getSubscriptions(Archive *fout)
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
void getTransforms(Archive *fout)
void getEventTriggers(Archive *fout)
TableInfo * getTables(Archive *fout, int *numTables)
void getTSTemplates(Archive *fout)
void getProcLangs(Archive *fout)
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
void getOperators(Archive *fout)
void getOpfamilies(Archive *fout)
#define DUMP_COMPONENT_ALL
#define DUMP_COMPONENT_NONE
#define DUMP_COMPONENT_DEFINITION
void simple_ptr_list_append(SimplePtrList *list, void *ptr)
DumpComponents components
DumpableObjectType objType
DumpComponents dump_contains
SimplePtrList partattaches
struct _indxInfo * indexes
struct _tableInfo ** parents
struct _attrDefInfo ** attrdefs