PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
common.c File Reference
#include "postgres_fe.h"
#include <ctype.h>
#include "catalog/pg_am_d.h"
#include "catalog/pg_class_d.h"
#include "catalog/pg_collation_d.h"
#include "catalog/pg_extension_d.h"
#include "catalog/pg_namespace_d.h"
#include "catalog/pg_operator_d.h"
#include "catalog/pg_proc_d.h"
#include "catalog/pg_publication_d.h"
#include "catalog/pg_subscription_d.h"
#include "catalog/pg_type_d.h"
#include "common/hashfn.h"
#include "pg_backup_utils.h"
#include "pg_dump.h"
#include "lib/simplehash.h"
Include dependency graph for common.c:

Go to the source code of this file.

Data Structures

struct  _catalogIdMapEntry
 

Macros

#define SH_PREFIX   catalogid
 
#define SH_ELEMENT_TYPE   CatalogIdMapEntry
 
#define SH_KEY_TYPE   CatalogId
 
#define SH_KEY   catId
 
#define SH_HASH_KEY(tb, key)   hash_bytes((const unsigned char *) &(key), sizeof(CatalogId))
 
#define SH_EQUAL(tb, a, b)   ((a).oid == (b).oid && (a).tableoid == (b).tableoid)
 
#define SH_STORE_HASH
 
#define SH_GET_HASH(tb, a)   (a)->hashval
 
#define SH_SCOPE   static inline
 
#define SH_RAW_ALLOCATOR   pg_malloc0
 
#define SH_DECLARE
 
#define SH_DEFINE
 
#define CATALOGIDHASH_INITIAL_SIZE   10000
 

Typedefs

typedef struct _catalogIdMapEntry CatalogIdMapEntry
 

Functions

static void flagInhTables (Archive *fout, TableInfo *tblinfo, int numTables, InhInfo *inhinfo, int numInherits)
 
static void flagInhIndexes (Archive *fout, TableInfo *tblinfo, int numTables)
 
static void flagInhAttrs (Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables)
 
static int strInArray (const char *pattern, char **arr, int arr_size)
 
static IndxInfofindIndexByOid (Oid oid)
 
TableInfogetSchemaData (Archive *fout, int *numTablesPtr)
 
static void flagInhIndexes (Archive *fout, TableInfo tblinfo[], int numTables)
 
void AssignDumpId (DumpableObject *dobj)
 
void recordAdditionalCatalogID (CatalogId catId, DumpableObject *dobj)
 
DumpId createDumpId (void)
 
DumpId getMaxDumpId (void)
 
DumpableObjectfindObjectByDumpId (DumpId dumpId)
 
DumpableObjectfindObjectByCatalogId (CatalogId catalogId)
 
void getDumpableObjects (DumpableObject ***objs, int *numObjs)
 
void addObjectDependency (DumpableObject *dobj, DumpId refId)
 
void removeObjectDependency (DumpableObject *dobj, DumpId refId)
 
TableInfofindTableByOid (Oid oid)
 
TypeInfofindTypeByOid (Oid oid)
 
FuncInfofindFuncByOid (Oid oid)
 
OprInfofindOprByOid (Oid oid)
 
AccessMethodInfofindAccessMethodByOid (Oid oid)
 
CollInfofindCollationByOid (Oid oid)
 
NamespaceInfofindNamespaceByOid (Oid oid)
 
ExtensionInfofindExtensionByOid (Oid oid)
 
PublicationInfofindPublicationByOid (Oid oid)
 
SubscriptionInfofindSubscriptionByOid (Oid oid)
 
void recordExtensionMembership (CatalogId catId, ExtensionInfo *ext)
 
ExtensionInfofindOwningExtension (CatalogId catalogId)
 
void parseOidArray (const char *str, Oid *array, int arraysize)
 

Variables

static DumpableObject ** dumpIdMap = NULL
 
static int allocedDumpIds = 0
 
static DumpId lastDumpId = 0
 
static catalogid_hash * catalogIdHash = NULL
 

Macro Definition Documentation

◆ CATALOGIDHASH_INITIAL_SIZE

#define CATALOGIDHASH_INITIAL_SIZE   10000

Definition at line 80 of file common.c.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 76 of file common.c.

◆ SH_DEFINE

#define SH_DEFINE

Definition at line 77 of file common.c.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   CatalogIdMapEntry

Definition at line 67 of file common.c.

◆ SH_EQUAL

#define SH_EQUAL (   tb,
  a,
  b 
)    ((a).oid == (b).oid && (a).tableoid == (b).tableoid)

Definition at line 71 of file common.c.

◆ SH_GET_HASH

#define SH_GET_HASH (   tb,
  a 
)    (a)->hashval

Definition at line 73 of file common.c.

◆ SH_HASH_KEY

#define SH_HASH_KEY (   tb,
  key 
)    hash_bytes((const unsigned char *) &(key), sizeof(CatalogId))

Definition at line 70 of file common.c.

◆ SH_KEY

#define SH_KEY   catId

Definition at line 69 of file common.c.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   CatalogId

Definition at line 68 of file common.c.

◆ SH_PREFIX

#define SH_PREFIX   catalogid

Definition at line 66 of file common.c.

◆ SH_RAW_ALLOCATOR

#define SH_RAW_ALLOCATOR   pg_malloc0

Definition at line 75 of file common.c.

◆ SH_SCOPE

#define SH_SCOPE   static inline

Definition at line 74 of file common.c.

◆ SH_STORE_HASH

#define SH_STORE_HASH

Definition at line 72 of file common.c.

Typedef Documentation

◆ CatalogIdMapEntry

Function Documentation

◆ addObjectDependency()

void addObjectDependency ( DumpableObject dobj,
DumpId  refId 
)

◆ AssignDumpId()

void AssignDumpId ( DumpableObject dobj)

Definition at line 657 of file common.c.

658{
659 dobj->dumpId = ++lastDumpId;
660 dobj->name = NULL; /* must be set later */
661 dobj->namespace = NULL; /* may be set later */
662 dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
663 dobj->dump_contains = DUMP_COMPONENT_ALL; /* default assumption */
664 /* All objects have definitions; we may set more components bits later */
666 dobj->ext_member = false; /* default assumption */
667 dobj->depends_on_ext = false; /* default assumption */
668 dobj->dependencies = NULL;
669 dobj->nDeps = 0;
670 dobj->allocDeps = 0;
671
672 /* Add object to dumpIdMap[], enlarging that array if need be */
673 while (dobj->dumpId >= allocedDumpIds)
674 {
675 int newAlloc;
676
677 if (allocedDumpIds <= 0)
678 {
679 newAlloc = 256;
681 }
682 else
683 {
684 newAlloc = allocedDumpIds * 2;
686 }
687 memset(dumpIdMap + allocedDumpIds, 0,
688 (newAlloc - allocedDumpIds) * sizeof(DumpableObject *));
689 allocedDumpIds = newAlloc;
690 }
691 dumpIdMap[dobj->dumpId] = dobj;
692
693 /* If it has a valid CatalogId, enter it into the hash table */
694 if (OidIsValid(dobj->catId.tableoid))
695 {
696 CatalogIdMapEntry *entry;
697 bool found;
698
699 /* Initialize CatalogId hash table if not done yet */
700 if (catalogIdHash == NULL)
701 catalogIdHash = catalogid_create(CATALOGIDHASH_INITIAL_SIZE, NULL);
702
703 entry = catalogid_insert(catalogIdHash, dobj->catId, &found);
704 if (!found)
705 {
706 entry->dobj = NULL;
707 entry->ext = NULL;
708 }
709 Assert(entry->dobj == NULL);
710 entry->dobj = dobj;
711 }
712}
static int allocedDumpIds
Definition: common.c:38
static DumpableObject ** dumpIdMap
Definition: common.c:37
#define CATALOGIDHASH_INITIAL_SIZE
Definition: common.c:80
static catalogid_hash * catalogIdHash
Definition: common.c:82
static DumpId lastDumpId
Definition: common.c:39
#define OidIsValid(objectId)
Definition: c.h:774
Assert(PointerIsAligned(start, uint64))
#define DUMP_COMPONENT_ALL
Definition: pg_dump.h:117
#define DUMP_COMPONENT_DEFINITION
Definition: pg_dump.h:109
Oid tableoid
Definition: pg_backup.h:280
ExtensionInfo * ext
Definition: common.c:63
DumpableObject * dobj
Definition: common.c:62
DumpComponents dump
Definition: pg_dump.h:153
char * name
Definition: pg_dump.h:152
DumpId dumpId
Definition: pg_dump.h:151
bool ext_member
Definition: pg_dump.h:157
DumpComponents components
Definition: pg_dump.h:156
CatalogId catId
Definition: pg_dump.h:150
DumpComponents dump_contains
Definition: pg_dump.h:155
bool depends_on_ext
Definition: pg_dump.h:158

References _dumpableObject::allocDeps, allocedDumpIds, Assert(), catalogIdHash, CATALOGIDHASH_INITIAL_SIZE, _dumpableObject::catId, _dumpableObject::components, _dumpableObject::dependencies, _dumpableObject::depends_on_ext, _catalogIdMapEntry::dobj, _dumpableObject::dump, DUMP_COMPONENT_ALL, DUMP_COMPONENT_DEFINITION, _dumpableObject::dump_contains, _dumpableObject::dumpId, dumpIdMap, _catalogIdMapEntry::ext, _dumpableObject::ext_member, lastDumpId, _dumpableObject::name, _dumpableObject::nDeps, OidIsValid, pg_malloc_array, pg_realloc_array, and CatalogId::tableoid.

Referenced by createBoundaryObjects(), flagInhAttrs(), flagInhIndexes(), flagInhTables(), getAccessMethods(), getAggregates(), getCasts(), getCollations(), getConstraints(), getConversions(), getDefaultACLs(), getDomainConstraints(), getEventTriggers(), getExtendedStatistics(), getExtensions(), getForeignDataWrappers(), getForeignServers(), getFuncs(), getIndexes(), getLOs(), getNamespaces(), getOpclasses(), getOperators(), getOpfamilies(), getPolicies(), getProcLangs(), getPublicationNamespaces(), getPublications(), getPublicationTables(), getRelationStatistics(), getRules(), getSubscriptions(), getSubscriptionTables(), getTableAttrs(), getTables(), getTransforms(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), and makeTableDataInfo().

◆ createDumpId()

◆ findAccessMethodByOid()

AccessMethodInfo * findAccessMethodByOid ( Oid  oid)

Definition at line 954 of file common.c.

955{
956 CatalogId catId;
957 DumpableObject *dobj;
958
959 catId.tableoid = AccessMethodRelationId;
960 catId.oid = oid;
961 dobj = findObjectByCatalogId(catId);
962 Assert(dobj == NULL || dobj->objType == DO_ACCESS_METHOD);
963 return (AccessMethodInfo *) dobj;
964}
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
Definition: common.c:778
@ DO_ACCESS_METHOD
Definition: pg_dump.h:48
DumpableObjectType objType
Definition: pg_dump.h:149

References Assert(), DO_ACCESS_METHOD, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by accessMethodNameCompare().

◆ findCollationByOid()

CollInfo * findCollationByOid ( Oid  oid)

Definition at line 972 of file common.c.

973{
974 CatalogId catId;
975 DumpableObject *dobj;
976
977 catId.tableoid = CollationRelationId;
978 catId.oid = oid;
979 dobj = findObjectByCatalogId(catId);
980 Assert(dobj == NULL || dobj->objType == DO_COLLATION);
981 return (CollInfo *) dobj;
982}
@ DO_COLLATION
Definition: pg_dump.h:51

References Assert(), DO_COLLATION, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by createDummyViewAsClause(), dumpCompositeType(), dumpDomain(), dumpRangeType(), and dumpTableSchema().

◆ findExtensionByOid()

ExtensionInfo * findExtensionByOid ( Oid  oid)

Definition at line 1008 of file common.c.

1009{
1010 CatalogId catId;
1011 DumpableObject *dobj;
1012
1013 catId.tableoid = ExtensionRelationId;
1014 catId.oid = oid;
1015 dobj = findObjectByCatalogId(catId);
1016 Assert(dobj == NULL || dobj->objType == DO_EXTENSION);
1017 return (ExtensionInfo *) dobj;
1018}
@ DO_EXTENSION
Definition: pg_dump.h:42

References Assert(), DO_EXTENSION, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by getExtensionMembership().

◆ findFuncByOid()

FuncInfo * findFuncByOid ( Oid  oid)

Definition at line 918 of file common.c.

919{
920 CatalogId catId;
921 DumpableObject *dobj;
922
923 catId.tableoid = ProcedureRelationId;
924 catId.oid = oid;
925 dobj = findObjectByCatalogId(catId);
926 Assert(dobj == NULL || dobj->objType == DO_FUNC);
927 return (FuncInfo *) dobj;
928}
@ DO_FUNC
Definition: pg_dump.h:45

References Assert(), DO_FUNC, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by dumpCast(), dumpProcLang(), and dumpTransform().

◆ findIndexByOid()

static IndxInfo * findIndexByOid ( Oid  oid)
static

Definition at line 881 of file common.c.

882{
883 CatalogId catId;
884 DumpableObject *dobj;
885
886 catId.tableoid = RelationRelationId;
887 catId.oid = oid;
888 dobj = findObjectByCatalogId(catId);
889 Assert(dobj == NULL || dobj->objType == DO_INDEX);
890 return (IndxInfo *) dobj;
891}
@ DO_INDEX
Definition: pg_dump.h:56

References Assert(), DO_INDEX, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by flagInhIndexes().

◆ findNamespaceByOid()

NamespaceInfo * findNamespaceByOid ( Oid  oid)

Definition at line 990 of file common.c.

991{
992 CatalogId catId;
993 DumpableObject *dobj;
994
995 catId.tableoid = NamespaceRelationId;
996 catId.oid = oid;
997 dobj = findObjectByCatalogId(catId);
998 Assert(dobj == NULL || dobj->objType == DO_NAMESPACE);
999 return (NamespaceInfo *) dobj;
1000}
@ DO_NAMESPACE
Definition: pg_dump.h:41

References Assert(), DO_NAMESPACE, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by findNamespace(), and getPublicationNamespaces().

◆ findObjectByCatalogId()

DumpableObject * findObjectByCatalogId ( CatalogId  catalogId)

Definition at line 778 of file common.c.

779{
780 CatalogIdMapEntry *entry;
781
782 if (catalogIdHash == NULL)
783 return NULL; /* no objects exist yet */
784
785 entry = catalogid_lookup(catalogIdHash, catalogId);
786 if (entry == NULL)
787 return NULL;
788 return entry->dobj;
789}

References catalogIdHash, and _catalogIdMapEntry::dobj.

Referenced by buildMatViewRefreshDependencies(), collectComments(), collectSecLabels(), findAccessMethodByOid(), findCollationByOid(), findExtensionByOid(), findFuncByOid(), findIndexByOid(), findNamespaceByOid(), findOprByOid(), findPublicationByOid(), findSubscriptionByOid(), findTableByOid(), findTypeByOid(), getAdditionalACLs(), and getDependencies().

◆ findObjectByDumpId()

DumpableObject * findObjectByDumpId ( DumpId  dumpId)

Definition at line 765 of file common.c.

766{
767 if (dumpId <= 0 || dumpId >= allocedDumpIds)
768 return NULL; /* out of range? */
769 return dumpIdMap[dumpId];
770}

References allocedDumpIds, and dumpIdMap.

Referenced by binary_upgrade_extension_member(), BuildArchiveDependencies(), dumpConstraint(), dumpDumpableObject(), dumpExtension(), findDumpableDependencies(), and findLoop().

◆ findOprByOid()

OprInfo * findOprByOid ( Oid  oid)

Definition at line 936 of file common.c.

937{
938 CatalogId catId;
939 DumpableObject *dobj;
940
941 catId.tableoid = OperatorRelationId;
942 catId.oid = oid;
943 dobj = findObjectByCatalogId(catId);
944 Assert(dobj == NULL || dobj->objType == DO_OPERATOR);
945 return (OprInfo *) dobj;
946}
@ DO_OPERATOR
Definition: pg_dump.h:47

References Assert(), DO_OPERATOR, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by getFormattedOperatorName().

◆ findOwningExtension()

ExtensionInfo * findOwningExtension ( CatalogId  catalogId)

Definition at line 1087 of file common.c.

1088{
1089 CatalogIdMapEntry *entry;
1090
1091 if (catalogIdHash == NULL)
1092 return NULL; /* no objects exist yet */
1093
1094 entry = catalogid_lookup(catalogIdHash, catalogId);
1095 if (entry == NULL)
1096 return NULL;
1097 return entry->ext;
1098}

References catalogIdHash, and _catalogIdMapEntry::ext.

Referenced by checkExtensionMembership().

◆ findPublicationByOid()

PublicationInfo * findPublicationByOid ( Oid  oid)

Definition at line 1026 of file common.c.

1027{
1028 CatalogId catId;
1029 DumpableObject *dobj;
1030
1031 catId.tableoid = PublicationRelationId;
1032 catId.oid = oid;
1033 dobj = findObjectByCatalogId(catId);
1034 Assert(dobj == NULL || dobj->objType == DO_PUBLICATION);
1035 return (PublicationInfo *) dobj;
1036}
@ DO_PUBLICATION
Definition: pg_dump.h:83

References Assert(), DO_PUBLICATION, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by getPublicationNamespaces(), and getPublicationTables().

◆ findSubscriptionByOid()

SubscriptionInfo * findSubscriptionByOid ( Oid  oid)

Definition at line 1044 of file common.c.

1045{
1046 CatalogId catId;
1047 DumpableObject *dobj;
1048
1049 catId.tableoid = SubscriptionRelationId;
1050 catId.oid = oid;
1051 dobj = findObjectByCatalogId(catId);
1052 Assert(dobj == NULL || dobj->objType == DO_SUBSCRIPTION);
1053 return (SubscriptionInfo *) dobj;
1054}
@ DO_SUBSCRIPTION
Definition: pg_dump.h:87

References Assert(), DO_SUBSCRIPTION, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by getSubscriptionTables().

◆ findTableByOid()

◆ findTypeByOid()

TypeInfo * findTypeByOid ( Oid  oid)

Definition at line 899 of file common.c.

900{
901 CatalogId catId;
902 DumpableObject *dobj;
903
904 catId.tableoid = TypeRelationId;
905 catId.oid = oid;
906 dobj = findObjectByCatalogId(catId);
907 Assert(dobj == NULL ||
908 dobj->objType == DO_TYPE || dobj->objType == DO_DUMMY_TYPE);
909 return (TypeInfo *) dobj;
910}
@ DO_TYPE
Definition: pg_dump.h:43
@ DO_DUMMY_TYPE
Definition: pg_dump.h:67

References Assert(), DO_DUMMY_TYPE, DO_TYPE, findObjectByCatalogId(), _dumpableObject::objType, CatalogId::oid, and CatalogId::tableoid.

Referenced by binary_upgrade_set_type_oids_by_type_oid(), collectComments(), collectSecLabels(), getCasts(), getFormattedTypeName(), getTransforms(), and pgTypeNameCompare().

◆ flagInhAttrs()

static void flagInhAttrs ( Archive fout,
DumpOptions dopt,
TableInfo tblinfo,
int  numTables 
)
static

Definition at line 478 of file common.c.

479{
480 int i,
481 j,
482 k;
483
484 /*
485 * We scan the tables in OID order, since that's how tblinfo[] is sorted.
486 * Hence we will typically visit parents before their children --- but
487 * that is *not* guaranteed. Thus this loop must be careful that it does
488 * not alter table properties in a way that could change decisions made at
489 * child tables during other iterations.
490 */
491 for (i = 0; i < numTables; i++)
492 {
493 TableInfo *tbinfo = &(tblinfo[i]);
494 int numParents;
495 TableInfo **parents;
496
497 /* Some kinds never have parents */
498 if (tbinfo->relkind == RELKIND_SEQUENCE ||
499 tbinfo->relkind == RELKIND_VIEW ||
500 tbinfo->relkind == RELKIND_MATVIEW)
501 continue;
502
503 /* Don't bother computing anything for non-target tables, either */
504 if (!tbinfo->dobj.dump)
505 continue;
506
507 numParents = tbinfo->numParents;
508 parents = tbinfo->parents;
509
510 if (numParents == 0)
511 continue; /* nothing to see here, move along */
512
513 /* For each column, search for matching column names in parent(s) */
514 for (j = 0; j < tbinfo->numatts; j++)
515 {
516 bool foundNotNull; /* Attr was NOT NULL in a parent */
517 bool foundDefault; /* Found a default in a parent */
518 bool foundSameGenerated; /* Found matching GENERATED */
519 bool foundDiffGenerated; /* Found non-matching GENERATED */
520 bool allNotNullsInvalid = true; /* is NOT NULL NOT VALID
521 * on all parents? */
522
523 /* no point in examining dropped columns */
524 if (tbinfo->attisdropped[j])
525 continue;
526
527 foundNotNull = false;
528 foundDefault = false;
529 foundSameGenerated = false;
530 foundDiffGenerated = false;
531 for (k = 0; k < numParents; k++)
532 {
533 TableInfo *parent = parents[k];
534 int inhAttrInd;
535
536 inhAttrInd = strInArray(tbinfo->attnames[j],
537 parent->attnames,
538 parent->numatts);
539 if (inhAttrInd >= 0)
540 {
541 AttrDefInfo *parentDef = parent->attrdefs[inhAttrInd];
542
543 /*
544 * Account for each parent having a not-null constraint.
545 * In versions 18 and later, we don't need this (and those
546 * didn't have NO INHERIT.)
547 */
548 if (fout->remoteVersion < 180000 &&
549 parent->notnull_constrs[inhAttrInd] != NULL)
550 foundNotNull = true;
551
552 /*
553 * Keep track of whether all the parents that have a
554 * not-null constraint on this column have it as NOT
555 * VALID; if they all are, arrange to have it printed for
556 * this column. If at least one parent has it as valid,
557 * there's no need.
558 */
559 if (fout->remoteVersion >= 180000 &&
560 parent->notnull_constrs[inhAttrInd] &&
561 !parent->notnull_invalid[inhAttrInd])
562 allNotNullsInvalid = false;
563
564 foundDefault |= (parentDef != NULL &&
565 strcmp(parentDef->adef_expr, "NULL") != 0 &&
566 !parent->attgenerated[inhAttrInd]);
567 if (parent->attgenerated[inhAttrInd])
568 {
569 /* these pointer nullness checks are just paranoia */
570 if (parentDef != NULL &&
571 tbinfo->attrdefs[j] != NULL &&
572 strcmp(parentDef->adef_expr,
573 tbinfo->attrdefs[j]->adef_expr) == 0)
574 foundSameGenerated = true;
575 else
576 foundDiffGenerated = true;
577 }
578 }
579 }
580
581 /*
582 * In versions < 18, for lack of a better system, we arbitrarily
583 * decide that a not-null constraint is not locally defined if at
584 * least one of the parents has it.
585 */
586 if (fout->remoteVersion < 180000 && foundNotNull)
587 tbinfo->notnull_islocal[j] = false;
588
589 /*
590 * For versions >18, we must print the not-null constraint locally
591 * for this table even if it isn't really locally defined, but is
592 * valid for the child and no parent has it as valid.
593 */
594 if (fout->remoteVersion >= 180000 && allNotNullsInvalid)
595 tbinfo->notnull_islocal[j] = true;
596
597 /*
598 * Manufacture a DEFAULT NULL clause if necessary. This breaks
599 * the advice given above to avoid changing state that might get
600 * inspected in other loop iterations. We prevent trouble by
601 * having the foundDefault test above check whether adef_expr is
602 * "NULL", so that it will reach the same conclusion before or
603 * after this is done.
604 */
605 if (foundDefault && tbinfo->attrdefs[j] == NULL)
606 {
607 AttrDefInfo *attrDef;
608
609 attrDef = pg_malloc_object(AttrDefInfo);
610 attrDef->dobj.objType = DO_ATTRDEF;
611 attrDef->dobj.catId.tableoid = 0;
612 attrDef->dobj.catId.oid = 0;
613 AssignDumpId(&attrDef->dobj);
614 attrDef->dobj.name = pg_strdup(tbinfo->dobj.name);
615 attrDef->dobj.namespace = tbinfo->dobj.namespace;
616 attrDef->dobj.dump = tbinfo->dobj.dump;
617
618 attrDef->adtable = tbinfo;
619 attrDef->adnum = j + 1;
620 attrDef->adef_expr = pg_strdup("NULL");
621
622 /* Will column be dumped explicitly? */
623 if (shouldPrintColumn(dopt, tbinfo, j))
624 {
625 attrDef->separate = false;
626 /* No dependency needed: NULL cannot have dependencies */
627 }
628 else
629 {
630 /* column will be suppressed, print default separately */
631 attrDef->separate = true;
632 /* ensure it comes out after the table */
633 addObjectDependency(&attrDef->dobj,
634 tbinfo->dobj.dumpId);
635 }
636
637 tbinfo->attrdefs[j] = attrDef;
638 }
639
640 /* No need to dump generation expression if it's inheritable */
641 if (foundSameGenerated && !foundDiffGenerated &&
642 !tbinfo->ispartition && !dopt->binary_upgrade)
644 }
645 }
646}
void addObjectDependency(DumpableObject *dobj, DumpId refId)
Definition: common.c:818
void AssignDumpId(DumpableObject *dobj)
Definition: common.c:657
static int strInArray(const char *pattern, char **arr, int arr_size)
Definition: common.c:1158
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
#define pg_malloc_object(type)
Definition: fe_memutils.h:50
int j
Definition: isn.c:78
int i
Definition: isn.c:77
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
Definition: pg_dump.c:10109
#define DUMP_COMPONENT_NONE
Definition: pg_dump.h:108
@ DO_ATTRDEF
Definition: pg_dump.h:55
int remoteVersion
Definition: pg_backup.h:233
DumpableObject dobj
Definition: pg_dump.h:404
char * adef_expr
Definition: pg_dump.h:407
TableInfo * adtable
Definition: pg_dump.h:405
bool separate
Definition: pg_dump.h:408
int binary_upgrade
Definition: pg_backup.h:174
bool * notnull_invalid
Definition: pg_dump.h:376
char ** notnull_constrs
Definition: pg_dump.h:371
bool ispartition
Definition: pg_dump.h:344
DumpableObject dobj
Definition: pg_dump.h:307
int numParents
Definition: pg_dump.h:347
struct _tableInfo ** parents
Definition: pg_dump.h:348
char * attgenerated
Definition: pg_dump.h:362
bool * attisdropped
Definition: pg_dump.h:360
bool * notnull_islocal
Definition: pg_dump.h:378
int numatts
Definition: pg_dump.h:354
struct _attrDefInfo ** attrdefs
Definition: pg_dump.h:379
char ** attnames
Definition: pg_dump.h:355
char relkind
Definition: pg_dump.h:310

References addObjectDependency(), _attrDefInfo::adef_expr, _attrDefInfo::adnum, _attrDefInfo::adtable, AssignDumpId(), _tableInfo::attgenerated, _tableInfo::attisdropped, _tableInfo::attnames, _tableInfo::attrdefs, _dumpOptions::binary_upgrade, _dumpableObject::catId, DO_ATTRDEF, _tableInfo::dobj, _attrDefInfo::dobj, _dumpableObject::dump, DUMP_COMPONENT_NONE, _dumpableObject::dumpId, i, _tableInfo::ispartition, j, _dumpableObject::name, _tableInfo::notnull_constrs, _tableInfo::notnull_invalid, _tableInfo::notnull_islocal, _tableInfo::numatts, _tableInfo::numParents, _dumpableObject::objType, CatalogId::oid, _tableInfo::parents, pg_malloc_object, pg_strdup(), _tableInfo::relkind, Archive::remoteVersion, _attrDefInfo::separate, shouldPrintColumn(), strInArray(), and CatalogId::tableoid.

Referenced by getSchemaData().

◆ flagInhIndexes() [1/2]

static void flagInhIndexes ( Archive fout,
TableInfo tblinfo,
int  numTables 
)
static

Referenced by getSchemaData().

◆ flagInhIndexes() [2/2]

static void flagInhIndexes ( Archive fout,
TableInfo  tblinfo[],
int  numTables 
)
static

Definition at line 387 of file common.c.

388{
389 int i,
390 j;
391
392 for (i = 0; i < numTables; i++)
393 {
394 if (!tblinfo[i].ispartition || tblinfo[i].numParents == 0)
395 continue;
396
397 Assert(tblinfo[i].numParents == 1);
398
399 for (j = 0; j < tblinfo[i].numIndexes; j++)
400 {
401 IndxInfo *index = &(tblinfo[i].indexes[j]);
402 IndxInfo *parentidx;
403 IndexAttachInfo *attachinfo;
404
405 if (index->parentidx == 0)
406 continue;
407
408 parentidx = findIndexByOid(index->parentidx);
409 if (parentidx == NULL)
410 continue;
411
412 attachinfo = pg_malloc_object(IndexAttachInfo);
413
414 attachinfo->dobj.objType = DO_INDEX_ATTACH;
415 attachinfo->dobj.catId.tableoid = 0;
416 attachinfo->dobj.catId.oid = 0;
417 AssignDumpId(&attachinfo->dobj);
418 attachinfo->dobj.name = pg_strdup(index->dobj.name);
419 attachinfo->dobj.namespace = index->indextable->dobj.namespace;
420 attachinfo->parentIdx = parentidx;
421 attachinfo->partitionIdx = index;
422
423 /*
424 * We must state the DO_INDEX_ATTACH object's dependencies
425 * explicitly, since it will not match anything in pg_depend.
426 *
427 * Give it dependencies on both the partition index and the parent
428 * index, so that it will not be executed till both of those
429 * exist. (There's no need to care what order those are created
430 * in.)
431 *
432 * In addition, give it dependencies on the indexes' underlying
433 * tables. This does nothing of great value so far as serial
434 * restore ordering goes, but it ensures that a parallel restore
435 * will not try to run the ATTACH concurrently with other
436 * operations on those tables.
437 */
438 addObjectDependency(&attachinfo->dobj, index->dobj.dumpId);
439 addObjectDependency(&attachinfo->dobj, parentidx->dobj.dumpId);
440 addObjectDependency(&attachinfo->dobj,
441 index->indextable->dobj.dumpId);
442 addObjectDependency(&attachinfo->dobj,
443 parentidx->indextable->dobj.dumpId);
444
445 /* keep track of the list of partitions in the parent index */
446 simple_ptr_list_append(&parentidx->partattaches, &attachinfo->dobj);
447 }
448 }
449}
static IndxInfo * findIndexByOid(Oid oid)
Definition: common.c:881
@ DO_INDEX_ATTACH
Definition: pg_dump.h:57
void simple_ptr_list_append(SimplePtrList *list, void *ptr)
Definition: simple_list.c:162
IndxInfo * partitionIdx
Definition: pg_dump.h:445
DumpableObject dobj
Definition: pg_dump.h:443
IndxInfo * parentIdx
Definition: pg_dump.h:444
TableInfo * indextable
Definition: pg_dump.h:421
SimplePtrList partattaches
Definition: pg_dump.h:435
DumpableObject dobj
Definition: pg_dump.h:420
struct _indxInfo * indexes
Definition: pg_dump.h:389
int numIndexes
Definition: pg_dump.h:388
Definition: type.h:96

References addObjectDependency(), Assert(), AssignDumpId(), _dumpableObject::catId, DO_INDEX_ATTACH, _tableInfo::dobj, _indxInfo::dobj, _indexAttachInfo::dobj, _dumpableObject::dumpId, findIndexByOid(), i, _tableInfo::indexes, _indxInfo::indextable, j, _dumpableObject::name, _tableInfo::numIndexes, _dumpableObject::objType, CatalogId::oid, _indexAttachInfo::parentIdx, _indxInfo::partattaches, _indexAttachInfo::partitionIdx, pg_malloc_object, pg_strdup(), simple_ptr_list_append(), and CatalogId::tableoid.

◆ flagInhTables()

static void flagInhTables ( Archive fout,
TableInfo tblinfo,
int  numTables,
InhInfo inhinfo,
int  numInherits 
)
static

Definition at line 269 of file common.c.

271{
272 TableInfo *child = NULL;
273 TableInfo *parent = NULL;
274 int i,
275 j;
276
277 /*
278 * Set up links from child tables to their parents.
279 *
280 * We used to attempt to skip this work for tables that are not to be
281 * dumped; but the optimizable cases are rare in practice, and setting up
282 * these links in bulk is cheaper than the old way. (Note in particular
283 * that it's very rare for a child to have more than one parent.)
284 */
285 for (i = 0; i < numInherits; i++)
286 {
287 /*
288 * Skip a hashtable lookup if it's same table as last time. This is
289 * unlikely for the child, but less so for the parent. (Maybe we
290 * should ask the backend for a sorted array to make it more likely?
291 * Not clear the sorting effort would be repaid, though.)
292 */
293 if (child == NULL ||
294 child->dobj.catId.oid != inhinfo[i].inhrelid)
295 {
296 child = findTableByOid(inhinfo[i].inhrelid);
297
298 /*
299 * If we find no TableInfo, assume the pg_inherits entry is for a
300 * partitioned index, which we don't need to track.
301 */
302 if (child == NULL)
303 continue;
304 }
305 if (parent == NULL ||
306 parent->dobj.catId.oid != inhinfo[i].inhparent)
307 {
308 parent = findTableByOid(inhinfo[i].inhparent);
309 if (parent == NULL)
310 pg_fatal("failed sanity check, parent OID %u of table \"%s\" (OID %u) not found",
311 inhinfo[i].inhparent,
312 child->dobj.name,
313 child->dobj.catId.oid);
314 }
315 /* Add this parent to the child's list of parents. */
316 if (child->numParents > 0)
317 child->parents = pg_realloc_array(child->parents,
318 TableInfo *,
319 child->numParents + 1);
320 else
321 child->parents = pg_malloc_array(TableInfo *, 1);
322 child->parents[child->numParents++] = parent;
323 }
324
325 /*
326 * Now consider all child tables and mark parents interesting as needed.
327 */
328 for (i = 0; i < numTables; i++)
329 {
330 /*
331 * If needed, mark the parents as interesting for getTableAttrs and
332 * getIndexes. We only need this for direct parents of dumpable
333 * tables.
334 */
335 if (tblinfo[i].dobj.dump)
336 {
337 int numParents = tblinfo[i].numParents;
338 TableInfo **parents = tblinfo[i].parents;
339
340 for (j = 0; j < numParents; j++)
341 parents[j]->interesting = true;
342 }
343
344 /* Create TableAttachInfo object if needed */
345 if ((tblinfo[i].dobj.dump & DUMP_COMPONENT_DEFINITION) &&
346 tblinfo[i].ispartition)
347 {
348 TableAttachInfo *attachinfo;
349
350 /* With partitions there can only be one parent */
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);
355
356 attachinfo = (TableAttachInfo *) palloc(sizeof(TableAttachInfo));
357 attachinfo->dobj.objType = DO_TABLE_ATTACH;
358 attachinfo->dobj.catId.tableoid = 0;
359 attachinfo->dobj.catId.oid = 0;
360 AssignDumpId(&attachinfo->dobj);
361 attachinfo->dobj.name = pg_strdup(tblinfo[i].dobj.name);
362 attachinfo->dobj.namespace = tblinfo[i].dobj.namespace;
363 attachinfo->parentTbl = tblinfo[i].parents[0];
364 attachinfo->partitionTbl = &tblinfo[i];
365
366 /*
367 * We must state the DO_TABLE_ATTACH object's dependencies
368 * explicitly, since it will not match anything in pg_depend.
369 *
370 * Give it dependencies on both the partition table and the parent
371 * table, so that it will not be executed till both of those
372 * exist. (There's no need to care what order those are created
373 * in.)
374 */
375 addObjectDependency(&attachinfo->dobj, tblinfo[i].dobj.dumpId);
376 addObjectDependency(&attachinfo->dobj, tblinfo[i].parents[0]->dobj.dumpId);
377 }
378 }
379}
TableInfo * findTableByOid(Oid oid)
Definition: common.c:863
void * palloc(Size size)
Definition: mcxt.c:1365
#define pg_fatal(...)
@ DO_TABLE_ATTACH
Definition: pg_dump.h:54
TableInfo * partitionTbl
Definition: pg_dump.h:399
DumpableObject dobj
Definition: pg_dump.h:397
TableInfo * parentTbl
Definition: pg_dump.h:398

References addObjectDependency(), AssignDumpId(), _dumpableObject::catId, DO_TABLE_ATTACH, _tableInfo::dobj, _tableAttachInfo::dobj, DUMP_COMPONENT_DEFINITION, _dumpableObject::dumpId, findTableByOid(), i, _inhInfo::inhparent, _inhInfo::inhrelid, _tableInfo::ispartition, j, _dumpableObject::name, _tableInfo::numParents, _dumpableObject::objType, CatalogId::oid, palloc(), _tableInfo::parents, _tableAttachInfo::parentTbl, _tableAttachInfo::partitionTbl, pg_fatal, pg_malloc_array, pg_realloc_array, pg_strdup(), and CatalogId::tableoid.

Referenced by getSchemaData().

◆ getDumpableObjects()

void getDumpableObjects ( DumpableObject ***  objs,
int *  numObjs 
)

Definition at line 797 of file common.c.

798{
799 int i,
800 j;
801
803 j = 0;
804 for (i = 1; i < allocedDumpIds; i++)
805 {
806 if (dumpIdMap[i])
807 (*objs)[j++] = dumpIdMap[i];
808 }
809 *numObjs = j;
810}

References allocedDumpIds, dumpIdMap, i, j, and pg_malloc_array.

Referenced by getTableDataFKConstraints(), and main().

◆ getMaxDumpId()

DumpId getMaxDumpId ( void  )

Definition at line 754 of file common.c.

755{
756 return lastDumpId;
757}

References lastDumpId.

Referenced by findDependencyLoops(), and TopoSort().

◆ getSchemaData()

TableInfo * getSchemaData ( Archive fout,
int *  numTablesPtr 
)

Definition at line 98 of file common.c.

99{
100 TableInfo *tblinfo;
101 ExtensionInfo *extinfo;
102 InhInfo *inhinfo;
103 int numTables;
104 int numExtensions;
105 int numInherits;
106
107 /*
108 * We must read extensions and extension membership info first, because
109 * extension membership needs to be consultable during decisions about
110 * whether other objects are to be dumped.
111 */
112 pg_log_info("reading extensions");
113 extinfo = getExtensions(fout, &numExtensions);
114
115 pg_log_info("identifying extension members");
116 getExtensionMembership(fout, extinfo, numExtensions);
117
118 pg_log_info("reading schemas");
119 getNamespaces(fout);
120
121 /*
122 * getTables should be done as soon as possible, so as to minimize the
123 * window between starting our transaction and acquiring per-table locks.
124 * However, we have to do getNamespaces first because the tables get
125 * linked to their containing namespaces during getTables.
126 */
127 pg_log_info("reading user-defined tables");
128 tblinfo = getTables(fout, &numTables);
129
130 getOwnedSeqs(fout, tblinfo, numTables);
131
132 pg_log_info("reading user-defined functions");
133 getFuncs(fout);
134
135 /* this must be after getTables and getFuncs */
136 pg_log_info("reading user-defined types");
137 getTypes(fout);
138
139 /* this must be after getFuncs, too */
140 pg_log_info("reading procedural languages");
141 getProcLangs(fout);
142
143 pg_log_info("reading user-defined aggregate functions");
144 getAggregates(fout);
145
146 pg_log_info("reading user-defined operators");
147 getOperators(fout);
148
149 pg_log_info("reading user-defined access methods");
150 getAccessMethods(fout);
151
152 pg_log_info("reading user-defined operator classes");
153 getOpclasses(fout);
154
155 pg_log_info("reading user-defined operator families");
156 getOpfamilies(fout);
157
158 pg_log_info("reading user-defined text search parsers");
159 getTSParsers(fout);
160
161 pg_log_info("reading user-defined text search templates");
162 getTSTemplates(fout);
163
164 pg_log_info("reading user-defined text search dictionaries");
165 getTSDictionaries(fout);
166
167 pg_log_info("reading user-defined text search configurations");
169
170 pg_log_info("reading user-defined foreign-data wrappers");
172
173 pg_log_info("reading user-defined foreign servers");
174 getForeignServers(fout);
175
176 pg_log_info("reading default privileges");
177 getDefaultACLs(fout);
178
179 pg_log_info("reading user-defined collations");
180 getCollations(fout);
181
182 pg_log_info("reading user-defined conversions");
183 getConversions(fout);
184
185 pg_log_info("reading type casts");
186 getCasts(fout);
187
188 pg_log_info("reading transforms");
189 getTransforms(fout);
190
191 pg_log_info("reading table inheritance information");
192 inhinfo = getInherits(fout, &numInherits);
193
194 pg_log_info("reading event triggers");
195 getEventTriggers(fout);
196
197 /* Identify extension configuration tables that should be dumped */
198 pg_log_info("finding extension tables");
199 processExtensionTables(fout, extinfo, numExtensions);
200
201 /* Link tables to parents, mark parents of target tables interesting */
202 pg_log_info("finding inheritance relationships");
203 flagInhTables(fout, tblinfo, numTables, inhinfo, numInherits);
204
205 pg_log_info("reading column info for interesting tables");
206 getTableAttrs(fout, tblinfo, numTables);
207
208 pg_log_info("flagging inherited columns in subtables");
209 flagInhAttrs(fout, fout->dopt, tblinfo, numTables);
210
211 pg_log_info("reading partitioning data");
213
214 pg_log_info("reading indexes");
215 getIndexes(fout, tblinfo, numTables);
216
217 pg_log_info("flagging indexes in partitioned tables");
218 flagInhIndexes(fout, tblinfo, numTables);
219
220 pg_log_info("reading extended statistics");
222
223 pg_log_info("reading constraints");
224 getConstraints(fout, tblinfo, numTables);
225
226 pg_log_info("reading triggers");
227 getTriggers(fout, tblinfo, numTables);
228
229 pg_log_info("reading rewrite rules");
230 getRules(fout);
231
232 pg_log_info("reading policies");
233 getPolicies(fout, tblinfo, numTables);
234
235 pg_log_info("reading publications");
236 getPublications(fout);
237
238 pg_log_info("reading publication membership of tables");
239 getPublicationTables(fout, tblinfo, numTables);
240
241 pg_log_info("reading publication membership of schemas");
243
244 pg_log_info("reading subscriptions");
245 getSubscriptions(fout);
246
247 pg_log_info("reading subscription membership of tables");
249
250 free(inhinfo); /* not needed any longer */
251
252 *numTablesPtr = numTables;
253 return tblinfo;
254}
static void flagInhAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables)
Definition: common.c:478
static void flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, InhInfo *inhinfo, int numInherits)
Definition: common.c:269
static void flagInhIndexes(Archive *fout, TableInfo *tblinfo, int numTables)
#define free(a)
Definition: header.h:65
#define pg_log_info(...)
Definition: logging.h:124
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:8264
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
Definition: pg_dump.c:6096
void getPublicationNamespaces(Archive *fout)
Definition: pg_dump.c:4729
void getPartitioningInfo(Archive *fout)
Definition: pg_dump.c:7756
InhInfo * getInherits(Archive *fout, int *numInherits)
Definition: pg_dump.c:7700
void getForeignDataWrappers(Archive *fout)
Definition: pg_dump.c:10382
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:4233
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
Definition: pg_dump.c:19658
void getTypes(Archive *fout)
Definition: pg_dump.c:6171
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:7635
void getOpclasses(Archive *fout)
Definition: pg_dump.c:6617
void getForeignServers(Archive *fout)
Definition: pg_dump.c:10466
void getFuncs(Archive *fout)
Definition: pg_dump.c:6886
void getTSDictionaries(Archive *fout)
Definition: pg_dump.c:10198
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:4809
void getCasts(Archive *fout)
Definition: pg_dump.c:9013
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:7816
void getTSConfigurations(Archive *fout)
Definition: pg_dump.c:10323
void getAccessMethods(Archive *fout)
Definition: pg_dump.c:6543
void getConversions(Archive *fout)
Definition: pg_dump.c:6481
void getRules(Archive *fout)
Definition: pg_dump.c:8558
void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
Definition: pg_dump.c:9207
void getSubscriptionTables(Archive *fout)
Definition: pg_dump.c:5300
void getCollations(Archive *fout)
Definition: pg_dump.c:6415
void getAggregates(Archive *fout)
Definition: pg_dump.c:6745
void getNamespaces(Archive *fout)
Definition: pg_dump.c:5964
void getPublications(Archive *fout)
Definition: pg_dump.c:4523
void getTSParsers(Archive *fout)
Definition: pg_dump.c:10124
TableInfo * getTables(Archive *fout, int *numTables)
Definition: pg_dump.c:7158
void getExtendedStatistics(Archive *fout)
Definition: pg_dump.c:8185
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
Definition: pg_dump.c:19751
void getDefaultACLs(Archive *fout)
Definition: pg_dump.c:10554
void getSubscriptions(Archive *fout)
Definition: pg_dump.c:5080
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:8655
void getTransforms(Archive *fout)
Definition: pg_dump.c:9123
void getEventTriggers(Archive *fout)
Definition: pg_dump.c:8851
void getTSTemplates(Archive *fout)
Definition: pg_dump.c:10264
void getProcLangs(Archive *fout)
Definition: pg_dump.c:8929
void getOperators(Archive *fout)
Definition: pg_dump.c:6339
void getOpfamilies(Archive *fout)
Definition: pg_dump.c:6680
DumpOptions * dopt
Definition: pg_backup.h:228

References Archive::dopt, flagInhAttrs(), flagInhIndexes(), flagInhTables(), free, getAccessMethods(), getAggregates(), getCasts(), getCollations(), getConstraints(), getConversions(), getDefaultACLs(), getEventTriggers(), getExtendedStatistics(), getExtensionMembership(), getExtensions(), getForeignDataWrappers(), getForeignServers(), getFuncs(), getIndexes(), getInherits(), getNamespaces(), getOpclasses(), getOperators(), getOpfamilies(), getOwnedSeqs(), getPartitioningInfo(), getPolicies(), getProcLangs(), getPublicationNamespaces(), getPublications(), getPublicationTables(), getRules(), getSubscriptions(), getSubscriptionTables(), getTableAttrs(), getTables(), getTransforms(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), pg_log_info, and processExtensionTables().

Referenced by main().

◆ parseOidArray()

void parseOidArray ( const char *  str,
Oid array,
int  arraysize 
)

Definition at line 1111 of file common.c.

1112{
1113 int j,
1114 argNum;
1115 char temp[100];
1116 char s;
1117
1118 argNum = 0;
1119 j = 0;
1120 for (;;)
1121 {
1122 s = *str++;
1123 if (s == ' ' || s == '\0')
1124 {
1125 if (j > 0)
1126 {
1127 if (argNum >= arraysize)
1128 pg_fatal("could not parse numeric array \"%s\": too many numbers", str);
1129 temp[j] = '\0';
1130 array[argNum++] = atooid(temp);
1131 j = 0;
1132 }
1133 if (s == '\0')
1134 break;
1135 }
1136 else
1137 {
1138 if (!(isdigit((unsigned char) s) || s == '-') ||
1139 j >= sizeof(temp) - 1)
1140 pg_fatal("could not parse numeric array \"%s\": invalid character in number", str);
1141 temp[j++] = s;
1142 }
1143 }
1144
1145 while (argNum < arraysize)
1146 array[argNum++] = InvalidOid;
1147}
const char * str
#define InvalidOid
Definition: postgres_ext.h:37
#define atooid(x)
Definition: postgres_ext.h:43

References atooid, InvalidOid, j, pg_fatal, and str.

Referenced by dumpFunc(), getAggregates(), getFuncs(), and getIndexes().

◆ recordAdditionalCatalogID()

void recordAdditionalCatalogID ( CatalogId  catId,
DumpableObject dobj 
)

Definition at line 719 of file common.c.

720{
721 CatalogIdMapEntry *entry;
722 bool found;
723
724 /* CatalogId hash table must exist, if we have a DumpableObject */
725 Assert(catalogIdHash != NULL);
726
727 /* Add reference to CatalogId hash */
728 entry = catalogid_insert(catalogIdHash, catId, &found);
729 if (!found)
730 {
731 entry->dobj = NULL;
732 entry->ext = NULL;
733 }
734 Assert(entry->dobj == NULL);
735 entry->dobj = dobj;
736}

References Assert(), catalogIdHash, _catalogIdMapEntry::dobj, and _catalogIdMapEntry::ext.

Referenced by getLOs().

◆ recordExtensionMembership()

void recordExtensionMembership ( CatalogId  catId,
ExtensionInfo ext 
)

Definition at line 1063 of file common.c.

1064{
1065 CatalogIdMapEntry *entry;
1066 bool found;
1067
1068 /* CatalogId hash table must exist, if we have an ExtensionInfo */
1069 Assert(catalogIdHash != NULL);
1070
1071 /* Add reference to CatalogId hash */
1072 entry = catalogid_insert(catalogIdHash, catId, &found);
1073 if (!found)
1074 {
1075 entry->dobj = NULL;
1076 entry->ext = NULL;
1077 }
1078 Assert(entry->ext == NULL);
1079 entry->ext = ext;
1080}

References Assert(), catalogIdHash, _catalogIdMapEntry::dobj, and _catalogIdMapEntry::ext.

Referenced by getExtensionMembership().

◆ removeObjectDependency()

◆ strInArray()

static int strInArray ( const char *  pattern,
char **  arr,
int  arr_size 
)
static

Definition at line 1158 of file common.c.

1159{
1160 int i;
1161
1162 for (i = 0; i < arr_size; i++)
1163 {
1164 if (strcmp(pattern, arr[i]) == 0)
1165 return i;
1166 }
1167 return -1;
1168}

References i.

Referenced by flagInhAttrs().

Variable Documentation

◆ allocedDumpIds

int allocedDumpIds = 0
static

Definition at line 38 of file common.c.

Referenced by AssignDumpId(), findObjectByDumpId(), and getDumpableObjects().

◆ catalogIdHash

catalogid_hash* catalogIdHash = NULL
static

◆ dumpIdMap

DumpableObject** dumpIdMap = NULL
static

Definition at line 37 of file common.c.

Referenced by AssignDumpId(), findObjectByDumpId(), and getDumpableObjects().

◆ lastDumpId

DumpId lastDumpId = 0
static

Definition at line 39 of file common.c.

Referenced by AssignDumpId(), createDumpId(), and getMaxDumpId().