PostgreSQL Source Code  git master
common.c File Reference
#include "postgres_fe.h"
#include <ctype.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 "fe_utils/string_utils.h"
#include "pg_backup_archiver.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)
 
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 81 of file common.c.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 77 of file common.c.

◆ SH_DEFINE

#define SH_DEFINE

Definition at line 78 of file common.c.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   CatalogIdMapEntry

Definition at line 68 of file common.c.

◆ SH_EQUAL

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

Definition at line 72 of file common.c.

◆ SH_GET_HASH

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

Definition at line 74 of file common.c.

◆ SH_HASH_KEY

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

Definition at line 71 of file common.c.

◆ SH_KEY

#define SH_KEY   catId

Definition at line 70 of file common.c.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   CatalogId

Definition at line 69 of file common.c.

◆ SH_PREFIX

#define SH_PREFIX   catalogid

Definition at line 67 of file common.c.

◆ SH_RAW_ALLOCATOR

#define SH_RAW_ALLOCATOR   pg_malloc0

Definition at line 76 of file common.c.

◆ SH_SCOPE

#define SH_SCOPE   static inline

Definition at line 75 of file common.c.

◆ SH_STORE_HASH

#define SH_STORE_HASH

Definition at line 73 of file common.c.

Typedef Documentation

◆ CatalogIdMapEntry

Function Documentation

◆ addObjectDependency()

void addObjectDependency ( DumpableObject dobj,
DumpId  refId 
)

◆ AssignDumpId()

void AssignDumpId ( DumpableObject dobj)

Definition at line 648 of file common.c.

649 {
650  dobj->dumpId = ++lastDumpId;
651  dobj->name = NULL; /* must be set later */
652  dobj->namespace = NULL; /* may be set later */
653  dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
654  dobj->dump_contains = DUMP_COMPONENT_ALL; /* default assumption */
655  /* All objects have definitions; we may set more components bits later */
657  dobj->ext_member = false; /* default assumption */
658  dobj->depends_on_ext = false; /* default assumption */
659  dobj->dependencies = NULL;
660  dobj->nDeps = 0;
661  dobj->allocDeps = 0;
662 
663  /* Add object to dumpIdMap[], enlarging that array if need be */
664  while (dobj->dumpId >= allocedDumpIds)
665  {
666  int newAlloc;
667 
668  if (allocedDumpIds <= 0)
669  {
670  newAlloc = 256;
672  }
673  else
674  {
675  newAlloc = allocedDumpIds * 2;
677  }
678  memset(dumpIdMap + allocedDumpIds, 0,
679  (newAlloc - allocedDumpIds) * sizeof(DumpableObject *));
680  allocedDumpIds = newAlloc;
681  }
682  dumpIdMap[dobj->dumpId] = dobj;
683 
684  /* If it has a valid CatalogId, enter it into the hash table */
685  if (OidIsValid(dobj->catId.tableoid))
686  {
687  CatalogIdMapEntry *entry;
688  bool found;
689 
690  /* Initialize CatalogId hash table if not done yet */
691  if (catalogIdHash == NULL)
692  catalogIdHash = catalogid_create(CATALOGIDHASH_INITIAL_SIZE, NULL);
693 
694  entry = catalogid_insert(catalogIdHash, dobj->catId, &found);
695  if (!found)
696  {
697  entry->dobj = NULL;
698  entry->ext = NULL;
699  }
700  Assert(entry->dobj == NULL);
701  entry->dobj = dobj;
702  }
703 }
static int allocedDumpIds
Definition: common.c:39
static DumpableObject ** dumpIdMap
Definition: common.c:38
#define CATALOGIDHASH_INITIAL_SIZE
Definition: common.c:81
static catalogid_hash * catalogIdHash
Definition: common.c:83
static DumpId lastDumpId
Definition: common.c:40
#define Assert(condition)
Definition: c.h:858
#define OidIsValid(objectId)
Definition: c.h:775
#define DUMP_COMPONENT_ALL
Definition: pg_dump.h:104
#define DUMP_COMPONENT_DEFINITION
Definition: pg_dump.h:97
Oid tableoid
Definition: pg_backup.h:266
ExtensionInfo * ext
Definition: common.c:64
DumpableObject * dobj
Definition: common.c:63
DumpComponents dump
Definition: pg_dump.h:139
char * name
Definition: pg_dump.h:138
DumpId dumpId
Definition: pg_dump.h:137
bool ext_member
Definition: pg_dump.h:143
DumpComponents components
Definition: pg_dump.h:142
CatalogId catId
Definition: pg_dump.h:136
DumpComponents dump_contains
Definition: pg_dump.h:141
bool depends_on_ext
Definition: pg_dump.h:144

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(), getRules(), getSubscriptions(), getSubscriptionTables(), getTableAttrs(), getTables(), getTransforms(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), and makeTableDataInfo().

◆ createDumpId()

◆ findCollationByOid()

CollInfo* findCollationByOid ( Oid  oid)

Definition at line 945 of file common.c.

946 {
947  CatalogId catId;
948  DumpableObject *dobj;
949 
950  catId.tableoid = CollationRelationId;
951  catId.oid = oid;
952  dobj = findObjectByCatalogId(catId);
953  Assert(dobj == NULL || dobj->objType == DO_COLLATION);
954  return (CollInfo *) dobj;
955 }
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
Definition: common.c:769
@ DO_COLLATION
Definition: pg_dump.h:50
DumpableObjectType objType
Definition: pg_dump.h:135

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 981 of file common.c.

982 {
983  CatalogId catId;
984  DumpableObject *dobj;
985 
986  catId.tableoid = ExtensionRelationId;
987  catId.oid = oid;
988  dobj = findObjectByCatalogId(catId);
989  Assert(dobj == NULL || dobj->objType == DO_EXTENSION);
990  return (ExtensionInfo *) dobj;
991 }
@ DO_EXTENSION
Definition: pg_dump.h:41

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

Referenced by getExtensionMembership().

◆ findFuncByOid()

FuncInfo* findFuncByOid ( Oid  oid)

Definition at line 909 of file common.c.

910 {
911  CatalogId catId;
912  DumpableObject *dobj;
913 
914  catId.tableoid = ProcedureRelationId;
915  catId.oid = oid;
916  dobj = findObjectByCatalogId(catId);
917  Assert(dobj == NULL || dobj->objType == DO_FUNC);
918  return (FuncInfo *) dobj;
919 }
@ DO_FUNC
Definition: pg_dump.h:44

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 872 of file common.c.

873 {
874  CatalogId catId;
875  DumpableObject *dobj;
876 
877  catId.tableoid = RelationRelationId;
878  catId.oid = oid;
879  dobj = findObjectByCatalogId(catId);
880  Assert(dobj == NULL || dobj->objType == DO_INDEX);
881  return (IndxInfo *) dobj;
882 }
@ DO_INDEX
Definition: pg_dump.h:55

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

Referenced by flagInhIndexes().

◆ findNamespaceByOid()

NamespaceInfo* findNamespaceByOid ( Oid  oid)

Definition at line 963 of file common.c.

964 {
965  CatalogId catId;
966  DumpableObject *dobj;
967 
968  catId.tableoid = NamespaceRelationId;
969  catId.oid = oid;
970  dobj = findObjectByCatalogId(catId);
971  Assert(dobj == NULL || dobj->objType == DO_NAMESPACE);
972  return (NamespaceInfo *) dobj;
973 }
@ DO_NAMESPACE
Definition: pg_dump.h:40

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 769 of file common.c.

770 {
771  CatalogIdMapEntry *entry;
772 
773  if (catalogIdHash == NULL)
774  return NULL; /* no objects exist yet */
775 
776  entry = catalogid_lookup(catalogIdHash, catalogId);
777  if (entry == NULL)
778  return NULL;
779  return entry->dobj;
780 }

References catalogIdHash, and _catalogIdMapEntry::dobj.

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

◆ findObjectByDumpId()

DumpableObject* findObjectByDumpId ( DumpId  dumpId)

Definition at line 756 of file common.c.

757 {
758  if (dumpId <= 0 || dumpId >= allocedDumpIds)
759  return NULL; /* out of range? */
760  return dumpIdMap[dumpId];
761 }

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 927 of file common.c.

928 {
929  CatalogId catId;
930  DumpableObject *dobj;
931 
932  catId.tableoid = OperatorRelationId;
933  catId.oid = oid;
934  dobj = findObjectByCatalogId(catId);
935  Assert(dobj == NULL || dobj->objType == DO_OPERATOR);
936  return (OprInfo *) dobj;
937 }
@ DO_OPERATOR
Definition: pg_dump.h:46

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

Referenced by getFormattedOperatorName().

◆ findOwningExtension()

ExtensionInfo* findOwningExtension ( CatalogId  catalogId)

Definition at line 1060 of file common.c.

1061 {
1062  CatalogIdMapEntry *entry;
1063 
1064  if (catalogIdHash == NULL)
1065  return NULL; /* no objects exist yet */
1066 
1067  entry = catalogid_lookup(catalogIdHash, catalogId);
1068  if (entry == NULL)
1069  return NULL;
1070  return entry->ext;
1071 }

References catalogIdHash, and _catalogIdMapEntry::ext.

Referenced by checkExtensionMembership().

◆ findPublicationByOid()

PublicationInfo* findPublicationByOid ( Oid  oid)

Definition at line 999 of file common.c.

1000 {
1001  CatalogId catId;
1002  DumpableObject *dobj;
1003 
1004  catId.tableoid = PublicationRelationId;
1005  catId.oid = oid;
1006  dobj = findObjectByCatalogId(catId);
1007  Assert(dobj == NULL || dobj->objType == DO_PUBLICATION);
1008  return (PublicationInfo *) dobj;
1009 }
@ DO_PUBLICATION
Definition: pg_dump.h:82

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 1017 of file common.c.

1018 {
1019  CatalogId catId;
1020  DumpableObject *dobj;
1021 
1022  catId.tableoid = SubscriptionRelationId;
1023  catId.oid = oid;
1024  dobj = findObjectByCatalogId(catId);
1025  Assert(dobj == NULL || dobj->objType == DO_SUBSCRIPTION);
1026  return (SubscriptionInfo *) dobj;
1027 }
@ DO_SUBSCRIPTION
Definition: pg_dump.h:85

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

Referenced by getSubscriptionTables().

◆ findTableByOid()

TableInfo* findTableByOid ( Oid  oid)

◆ findTypeByOid()

TypeInfo* findTypeByOid ( Oid  oid)

Definition at line 890 of file common.c.

891 {
892  CatalogId catId;
893  DumpableObject *dobj;
894 
895  catId.tableoid = TypeRelationId;
896  catId.oid = oid;
897  dobj = findObjectByCatalogId(catId);
898  Assert(dobj == NULL ||
899  dobj->objType == DO_TYPE || dobj->objType == DO_DUMMY_TYPE);
900  return (TypeInfo *) dobj;
901 }
@ DO_TYPE
Definition: pg_dump.h:42
@ DO_DUMMY_TYPE
Definition: pg_dump.h:66

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

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

◆ flagInhAttrs()

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

Definition at line 502 of file common.c.

503 {
504  int i,
505  j,
506  k;
507 
508  /*
509  * We scan the tables in OID order, since that's how tblinfo[] is sorted.
510  * Hence we will typically visit parents before their children --- but
511  * that is *not* guaranteed. Thus this loop must be careful that it does
512  * not alter table properties in a way that could change decisions made at
513  * child tables during other iterations.
514  */
515  for (i = 0; i < numTables; i++)
516  {
517  TableInfo *tbinfo = &(tblinfo[i]);
518  int numParents;
519  TableInfo **parents;
520 
521  /* Some kinds never have parents */
522  if (tbinfo->relkind == RELKIND_SEQUENCE ||
523  tbinfo->relkind == RELKIND_VIEW ||
524  tbinfo->relkind == RELKIND_MATVIEW)
525  continue;
526 
527  /* Don't bother computing anything for non-target tables, either */
528  if (!tbinfo->dobj.dump)
529  continue;
530 
531  numParents = tbinfo->numParents;
532  parents = tbinfo->parents;
533 
534  if (numParents == 0)
535  continue; /* nothing to see here, move along */
536 
537  /* For each column, search for matching column names in parent(s) */
538  for (j = 0; j < tbinfo->numatts; j++)
539  {
540  bool foundNotNull; /* Attr was NOT NULL in a parent */
541  bool foundDefault; /* Found a default in a parent */
542  bool foundSameGenerated; /* Found matching GENERATED */
543  bool foundDiffGenerated; /* Found non-matching GENERATED */
544 
545  /* no point in examining dropped columns */
546  if (tbinfo->attisdropped[j])
547  continue;
548 
549  foundNotNull = false;
550  foundDefault = false;
551  foundSameGenerated = false;
552  foundDiffGenerated = false;
553  for (k = 0; k < numParents; k++)
554  {
555  TableInfo *parent = parents[k];
556  int inhAttrInd;
557 
558  inhAttrInd = strInArray(tbinfo->attnames[j],
559  parent->attnames,
560  parent->numatts);
561  if (inhAttrInd >= 0)
562  {
563  AttrDefInfo *parentDef = parent->attrdefs[inhAttrInd];
564 
565  foundNotNull |= (parent->notnull_constrs[inhAttrInd] != NULL &&
566  !parent->notnull_noinh[inhAttrInd]);
567  foundDefault |= (parentDef != NULL &&
568  strcmp(parentDef->adef_expr, "NULL") != 0 &&
569  !parent->attgenerated[inhAttrInd]);
570  if (parent->attgenerated[inhAttrInd])
571  {
572  /* these pointer nullness checks are just paranoia */
573  if (parentDef != NULL &&
574  tbinfo->attrdefs[j] != NULL &&
575  strcmp(parentDef->adef_expr,
576  tbinfo->attrdefs[j]->adef_expr) == 0)
577  foundSameGenerated = true;
578  else
579  foundDiffGenerated = true;
580  }
581  }
582  }
583 
584  /* In versions < 17, remember if we found inherited NOT NULL */
585  if (fout->remoteVersion < 170000)
586  tbinfo->notnull_inh[j] = foundNotNull;
587 
588  /*
589  * Manufacture a DEFAULT NULL clause if necessary. This breaks
590  * the advice given above to avoid changing state that might get
591  * inspected in other loop iterations. We prevent trouble by
592  * having the foundDefault test above check whether adef_expr is
593  * "NULL", so that it will reach the same conclusion before or
594  * after this is done.
595  */
596  if (foundDefault && tbinfo->attrdefs[j] == NULL)
597  {
598  AttrDefInfo *attrDef;
599 
600  attrDef = pg_malloc_object(AttrDefInfo);
601  attrDef->dobj.objType = DO_ATTRDEF;
602  attrDef->dobj.catId.tableoid = 0;
603  attrDef->dobj.catId.oid = 0;
604  AssignDumpId(&attrDef->dobj);
605  attrDef->dobj.name = pg_strdup(tbinfo->dobj.name);
606  attrDef->dobj.namespace = tbinfo->dobj.namespace;
607  attrDef->dobj.dump = tbinfo->dobj.dump;
608 
609  attrDef->adtable = tbinfo;
610  attrDef->adnum = j + 1;
611  attrDef->adef_expr = pg_strdup("NULL");
612 
613  /* Will column be dumped explicitly? */
614  if (shouldPrintColumn(dopt, tbinfo, j))
615  {
616  attrDef->separate = false;
617  /* No dependency needed: NULL cannot have dependencies */
618  }
619  else
620  {
621  /* column will be suppressed, print default separately */
622  attrDef->separate = true;
623  /* ensure it comes out after the table */
624  addObjectDependency(&attrDef->dobj,
625  tbinfo->dobj.dumpId);
626  }
627 
628  tbinfo->attrdefs[j] = attrDef;
629  }
630 
631  /* No need to dump generation expression if it's inheritable */
632  if (foundSameGenerated && !foundDiffGenerated &&
633  !tbinfo->ispartition && !dopt->binary_upgrade)
634  tbinfo->attrdefs[j]->dobj.dump = DUMP_COMPONENT_NONE;
635  }
636  }
637 }
void addObjectDependency(DumpableObject *dobj, DumpId refId)
Definition: common.c:809
void AssignDumpId(DumpableObject *dobj)
Definition: common.c:648
static int strInArray(const char *pattern, char **arr, int arr_size)
Definition: common.c:1131
char * pg_strdup(const char *in)
Definition: fe_memutils.c:85
#define pg_malloc_object(type)
Definition: fe_memutils.h:38
int j
Definition: isn.c:74
int i
Definition: isn.c:73
bool shouldPrintColumn(const DumpOptions *dopt, const TableInfo *tbinfo, int colno)
Definition: pg_dump.c:9440
#define DUMP_COMPONENT_NONE
Definition: pg_dump.h:96
@ DO_ATTRDEF
Definition: pg_dump.h:54
int remoteVersion
Definition: pg_backup.h:219
DumpableObject dobj
Definition: pg_dump.h:380
char * adef_expr
Definition: pg_dump.h:383
TableInfo * adtable
Definition: pg_dump.h:381
bool separate
Definition: pg_dump.h:384
int binary_upgrade
Definition: pg_backup.h:166
char ** notnull_constrs
Definition: pg_dump.h:349
bool ispartition
Definition: pg_dump.h:322
DumpableObject dobj
Definition: pg_dump.h:285
int numParents
Definition: pg_dump.h:325
struct _tableInfo ** parents
Definition: pg_dump.h:326
char * attgenerated
Definition: pg_dump.h:340
bool * attisdropped
Definition: pg_dump.h:338
int numatts
Definition: pg_dump.h:332
struct _attrDefInfo ** attrdefs
Definition: pg_dump.h:356
bool * notnull_noinh
Definition: pg_dump.h:353
char ** attnames
Definition: pg_dump.h:333
char relkind
Definition: pg_dump.h:288
bool * notnull_inh
Definition: pg_dump.h:355

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_inh, _tableInfo::notnull_noinh, _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 411 of file common.c.

412 {
413  int i,
414  j;
415 
416  for (i = 0; i < numTables; i++)
417  {
418  if (!tblinfo[i].ispartition || tblinfo[i].numParents == 0)
419  continue;
420 
421  Assert(tblinfo[i].numParents == 1);
422 
423  for (j = 0; j < tblinfo[i].numIndexes; j++)
424  {
425  IndxInfo *index = &(tblinfo[i].indexes[j]);
426  IndxInfo *parentidx;
427  IndexAttachInfo *attachinfo;
428 
429  if (index->parentidx == 0)
430  continue;
431 
432  parentidx = findIndexByOid(index->parentidx);
433  if (parentidx == NULL)
434  continue;
435 
436  attachinfo = pg_malloc_object(IndexAttachInfo);
437 
438  attachinfo->dobj.objType = DO_INDEX_ATTACH;
439  attachinfo->dobj.catId.tableoid = 0;
440  attachinfo->dobj.catId.oid = 0;
441  AssignDumpId(&attachinfo->dobj);
442  attachinfo->dobj.name = pg_strdup(index->dobj.name);
443  attachinfo->dobj.namespace = index->indextable->dobj.namespace;
444  attachinfo->parentIdx = parentidx;
445  attachinfo->partitionIdx = index;
446 
447  /*
448  * We must state the DO_INDEX_ATTACH object's dependencies
449  * explicitly, since it will not match anything in pg_depend.
450  *
451  * Give it dependencies on both the partition index and the parent
452  * index, so that it will not be executed till both of those
453  * exist. (There's no need to care what order those are created
454  * in.)
455  *
456  * In addition, give it dependencies on the indexes' underlying
457  * tables. This does nothing of great value so far as serial
458  * restore ordering goes, but it ensures that a parallel restore
459  * will not try to run the ATTACH concurrently with other
460  * operations on those tables.
461  */
462  addObjectDependency(&attachinfo->dobj, index->dobj.dumpId);
463  addObjectDependency(&attachinfo->dobj, parentidx->dobj.dumpId);
464  addObjectDependency(&attachinfo->dobj,
465  index->indextable->dobj.dumpId);
466  addObjectDependency(&attachinfo->dobj,
467  parentidx->indextable->dobj.dumpId);
468 
469  /* keep track of the list of partitions in the parent index */
470  simple_ptr_list_append(&parentidx->partattaches, &attachinfo->dobj);
471  }
472  }
473 }
static IndxInfo * findIndexByOid(Oid oid)
Definition: common.c:872
@ DO_INDEX_ATTACH
Definition: pg_dump.h:56
void simple_ptr_list_append(SimplePtrList *list, void *ptr)
Definition: simple_list.c:162
IndxInfo * partitionIdx
Definition: pg_dump.h:421
DumpableObject dobj
Definition: pg_dump.h:419
IndxInfo * parentIdx
Definition: pg_dump.h:420
TableInfo * indextable
Definition: pg_dump.h:397
SimplePtrList partattaches
Definition: pg_dump.h:411
DumpableObject dobj
Definition: pg_dump.h:396
struct _indxInfo * indexes
Definition: pg_dump.h:365
int numIndexes
Definition: pg_dump.h:364
Definition: type.h:95

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 293 of file common.c.

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

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 788 of file common.c.

789 {
790  int i,
791  j;
792 
794  j = 0;
795  for (i = 1; i < allocedDumpIds; i++)
796  {
797  if (dumpIdMap[i])
798  (*objs)[j++] = dumpIdMap[i];
799  }
800  *numObjs = j;
801 }

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

Referenced by getTableDataFKConstraints(), and main().

◆ getMaxDumpId()

DumpId getMaxDumpId ( void  )

Definition at line 745 of file common.c.

746 {
747  return lastDumpId;
748 }

References lastDumpId.

Referenced by findDependencyLoops(), and TopoSort().

◆ getSchemaData()

TableInfo* getSchemaData ( Archive fout,
int *  numTablesPtr 
)

Definition at line 99 of file common.c.

100 {
101  TableInfo *tblinfo;
102  ExtensionInfo *extinfo;
103  InhInfo *inhinfo;
104  int numTables;
105  int numTypes;
106  int numFuncs;
107  int numOperators;
108  int numCollations;
109  int numNamespaces;
110  int numExtensions;
111  int numPublications;
112  int numAggregates;
113  int numInherits;
114  int numRules;
115  int numProcLangs;
116  int numCasts;
117  int numTransforms;
118  int numAccessMethods;
119  int numOpclasses;
120  int numOpfamilies;
121  int numConversions;
122  int numTSParsers;
123  int numTSTemplates;
124  int numTSDicts;
125  int numTSConfigs;
126  int numForeignDataWrappers;
127  int numForeignServers;
128  int numDefaultACLs;
129  int numEventTriggers;
130 
131  /*
132  * We must read extensions and extension membership info first, because
133  * extension membership needs to be consultable during decisions about
134  * whether other objects are to be dumped.
135  */
136  pg_log_info("reading extensions");
137  extinfo = getExtensions(fout, &numExtensions);
138 
139  pg_log_info("identifying extension members");
140  getExtensionMembership(fout, extinfo, numExtensions);
141 
142  pg_log_info("reading schemas");
143  (void) getNamespaces(fout, &numNamespaces);
144 
145  /*
146  * getTables should be done as soon as possible, so as to minimize the
147  * window between starting our transaction and acquiring per-table locks.
148  * However, we have to do getNamespaces first because the tables get
149  * linked to their containing namespaces during getTables.
150  */
151  pg_log_info("reading user-defined tables");
152  tblinfo = getTables(fout, &numTables);
153 
154  getOwnedSeqs(fout, tblinfo, numTables);
155 
156  pg_log_info("reading user-defined functions");
157  (void) getFuncs(fout, &numFuncs);
158 
159  /* this must be after getTables and getFuncs */
160  pg_log_info("reading user-defined types");
161  (void) getTypes(fout, &numTypes);
162 
163  /* this must be after getFuncs, too */
164  pg_log_info("reading procedural languages");
165  getProcLangs(fout, &numProcLangs);
166 
167  pg_log_info("reading user-defined aggregate functions");
168  getAggregates(fout, &numAggregates);
169 
170  pg_log_info("reading user-defined operators");
171  (void) getOperators(fout, &numOperators);
172 
173  pg_log_info("reading user-defined access methods");
174  getAccessMethods(fout, &numAccessMethods);
175 
176  pg_log_info("reading user-defined operator classes");
177  getOpclasses(fout, &numOpclasses);
178 
179  pg_log_info("reading user-defined operator families");
180  getOpfamilies(fout, &numOpfamilies);
181 
182  pg_log_info("reading user-defined text search parsers");
183  getTSParsers(fout, &numTSParsers);
184 
185  pg_log_info("reading user-defined text search templates");
186  getTSTemplates(fout, &numTSTemplates);
187 
188  pg_log_info("reading user-defined text search dictionaries");
189  getTSDictionaries(fout, &numTSDicts);
190 
191  pg_log_info("reading user-defined text search configurations");
192  getTSConfigurations(fout, &numTSConfigs);
193 
194  pg_log_info("reading user-defined foreign-data wrappers");
195  getForeignDataWrappers(fout, &numForeignDataWrappers);
196 
197  pg_log_info("reading user-defined foreign servers");
198  getForeignServers(fout, &numForeignServers);
199 
200  pg_log_info("reading default privileges");
201  getDefaultACLs(fout, &numDefaultACLs);
202 
203  pg_log_info("reading user-defined collations");
204  (void) getCollations(fout, &numCollations);
205 
206  pg_log_info("reading user-defined conversions");
207  getConversions(fout, &numConversions);
208 
209  pg_log_info("reading type casts");
210  getCasts(fout, &numCasts);
211 
212  pg_log_info("reading transforms");
213  getTransforms(fout, &numTransforms);
214 
215  pg_log_info("reading table inheritance information");
216  inhinfo = getInherits(fout, &numInherits);
217 
218  pg_log_info("reading event triggers");
219  getEventTriggers(fout, &numEventTriggers);
220 
221  /* Identify extension configuration tables that should be dumped */
222  pg_log_info("finding extension tables");
223  processExtensionTables(fout, extinfo, numExtensions);
224 
225  /* Link tables to parents, mark parents of target tables interesting */
226  pg_log_info("finding inheritance relationships");
227  flagInhTables(fout, tblinfo, numTables, inhinfo, numInherits);
228 
229  pg_log_info("reading column info for interesting tables");
230  getTableAttrs(fout, tblinfo, numTables);
231 
232  pg_log_info("flagging inherited columns in subtables");
233  flagInhAttrs(fout, fout->dopt, tblinfo, numTables);
234 
235  pg_log_info("reading partitioning data");
236  getPartitioningInfo(fout);
237 
238  pg_log_info("reading indexes");
239  getIndexes(fout, tblinfo, numTables);
240 
241  pg_log_info("flagging indexes in partitioned tables");
242  flagInhIndexes(fout, tblinfo, numTables);
243 
244  pg_log_info("reading extended statistics");
245  getExtendedStatistics(fout);
246 
247  pg_log_info("reading constraints");
248  getConstraints(fout, tblinfo, numTables);
249 
250  pg_log_info("reading triggers");
251  getTriggers(fout, tblinfo, numTables);
252 
253  pg_log_info("reading rewrite rules");
254  getRules(fout, &numRules);
255 
256  pg_log_info("reading policies");
257  getPolicies(fout, tblinfo, numTables);
258 
259  pg_log_info("reading publications");
260  (void) getPublications(fout, &numPublications);
261 
262  pg_log_info("reading publication membership of tables");
263  getPublicationTables(fout, tblinfo, numTables);
264 
265  pg_log_info("reading publication membership of schemas");
267 
268  pg_log_info("reading subscriptions");
269  getSubscriptions(fout);
270 
271  pg_log_info("reading subscription membership of tables");
272  getSubscriptionTables(fout);
273 
274  free(inhinfo); /* not needed any longer */
275 
276  *numTablesPtr = numTables;
277  return tblinfo;
278 }
static void flagInhAttrs(Archive *fout, DumpOptions *dopt, TableInfo *tblinfo, int numTables)
Definition: common.c:502
static void flagInhTables(Archive *fout, TableInfo *tblinfo, int numTables, InhInfo *inhinfo, int numInherits)
Definition: common.c:293
static void flagInhIndexes(Archive *fout, TableInfo *tblinfo, int numTables)
#define free(a)
Definition: header.h:65
#define pg_log_info(...)
Definition: logging.h:124
NamespaceInfo * getNamespaces(Archive *fout, int *numNamespaces)
Definition: pg_dump.c:5559
void getConstraints(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:7725
void getPublicationNamespaces(Archive *fout)
Definition: pg_dump.c:4377
void getPartitioningInfo(Archive *fout)
Definition: pg_dump.c:7266
DefaultACLInfo * getDefaultACLs(Archive *fout, int *numDefaultACLs)
Definition: pg_dump.c:9924
void getPolicies(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:3892
void getExtensionMembership(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
Definition: pg_dump.c:18249
ForeignServerInfo * getForeignServers(Archive *fout, int *numForeignServers)
Definition: pg_dump.c:9830
AccessMethodInfo * getAccessMethods(Archive *fout, int *numAccessMethods)
Definition: pg_dump.c:6150
FdwInfo * getForeignDataWrappers(Archive *fout, int *numForeignDataWrappers)
Definition: pg_dump.c:9740
FuncInfo * getFuncs(Archive *fout, int *numFuncs)
Definition: pg_dump.c:6502
TSConfigInfo * getTSConfigurations(Archive *fout, int *numTSConfigs)
Definition: pg_dump.c:9675
ConvInfo * getConversions(Archive *fout, int *numConversions)
Definition: pg_dump.c:6082
void getOwnedSeqs(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:7147
void getPublicationTables(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:4464
AggInfo * getAggregates(Archive *fout, int *numAggs)
Definition: pg_dump.c:6355
void getIndexes(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:7326
TSDictInfo * getTSDictionaries(Archive *fout, int *numTSDicts)
Definition: pg_dump.c:9538
InhInfo * getInherits(Archive *fout, int *numInherits)
Definition: pg_dump.c:7210
OpfamilyInfo * getOpfamilies(Archive *fout, int *numOpfamilies)
Definition: pg_dump.c:6287
void getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
Definition: pg_dump.c:8686
void getSubscriptionTables(Archive *fout)
Definition: pg_dump.c:4913
PublicationInfo * getPublications(Archive *fout, int *numPublications)
Definition: pg_dump.c:4177
TSTemplateInfo * getTSTemplates(Archive *fout, int *numTSTemplates)
Definition: pg_dump.c:9610
ProcLangInfo * getProcLangs(Archive *fout, int *numProcLangs)
Definition: pg_dump.c:8389
TypeInfo * getTypes(Archive *fout, int *numTypes)
Definition: pg_dump.c:5770
void getExtendedStatistics(Archive *fout)
Definition: pg_dump.c:7646
void processExtensionTables(Archive *fout, ExtensionInfo extinfo[], int numExtensions)
Definition: pg_dump.c:18342
OpclassInfo * getOpclasses(Archive *fout, int *numOpclasses)
Definition: pg_dump.c:6221
CollInfo * getCollations(Archive *fout, int *numCollations)
Definition: pg_dump.c:6014
void getSubscriptions(Archive *fout)
Definition: pg_dump.c:4718
ExtensionInfo * getExtensions(Archive *fout, int *numExtensions)
Definition: pg_dump.c:5695
TSParserInfo * getTSParsers(Archive *fout, int *numTSParsers)
Definition: pg_dump.c:9458
TransformInfo * getTransforms(Archive *fout, int *numTransforms)
Definition: pg_dump.c:8595
void getTriggers(Archive *fout, TableInfo tblinfo[], int numTables)
Definition: pg_dump.c:8106
OprInfo * getOperators(Archive *fout, int *numOprs)
Definition: pg_dump.c:5940
RuleInfo * getRules(Archive *fout, int *numRules)
Definition: pg_dump.c:8005
EventTriggerInfo * getEventTriggers(Archive *fout, int *numEventTriggers)
Definition: pg_dump.c:8302
TableInfo * getTables(Archive *fout, int *numTables)
Definition: pg_dump.c:6701
CastInfo * getCasts(Archive *fout, int *numCasts)
Definition: pg_dump.c:8479
DumpOptions * dopt
Definition: pg_backup.h:214

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 1084 of file common.c.

1085 {
1086  int j,
1087  argNum;
1088  char temp[100];
1089  char s;
1090 
1091  argNum = 0;
1092  j = 0;
1093  for (;;)
1094  {
1095  s = *str++;
1096  if (s == ' ' || s == '\0')
1097  {
1098  if (j > 0)
1099  {
1100  if (argNum >= arraysize)
1101  pg_fatal("could not parse numeric array \"%s\": too many numbers", str);
1102  temp[j] = '\0';
1103  array[argNum++] = atooid(temp);
1104  j = 0;
1105  }
1106  if (s == '\0')
1107  break;
1108  }
1109  else
1110  {
1111  if (!(isdigit((unsigned char) s) || s == '-') ||
1112  j >= sizeof(temp) - 1)
1113  pg_fatal("could not parse numeric array \"%s\": invalid character in number", str);
1114  temp[j++] = s;
1115  }
1116  }
1117 
1118  while (argNum < arraysize)
1119  array[argNum++] = InvalidOid;
1120 }
const char * str
#define InvalidOid
Definition: postgres_ext.h:36
#define atooid(x)
Definition: postgres_ext.h:42

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 710 of file common.c.

711 {
712  CatalogIdMapEntry *entry;
713  bool found;
714 
715  /* CatalogId hash table must exist, if we have a DumpableObject */
716  Assert(catalogIdHash != NULL);
717 
718  /* Add reference to CatalogId hash */
719  entry = catalogid_insert(catalogIdHash, catId, &found);
720  if (!found)
721  {
722  entry->dobj = NULL;
723  entry->ext = NULL;
724  }
725  Assert(entry->dobj == NULL);
726  entry->dobj = dobj;
727 }

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

Referenced by getLOs().

◆ recordExtensionMembership()

void recordExtensionMembership ( CatalogId  catId,
ExtensionInfo ext 
)

Definition at line 1036 of file common.c.

1037 {
1038  CatalogIdMapEntry *entry;
1039  bool found;
1040 
1041  /* CatalogId hash table must exist, if we have an ExtensionInfo */
1042  Assert(catalogIdHash != NULL);
1043 
1044  /* Add reference to CatalogId hash */
1045  entry = catalogid_insert(catalogIdHash, catId, &found);
1046  if (!found)
1047  {
1048  entry->dobj = NULL;
1049  entry->ext = NULL;
1050  }
1051  Assert(entry->ext == NULL);
1052  entry->ext = ext;
1053 }

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

Referenced by getExtensionMembership().

◆ removeObjectDependency()

void removeObjectDependency ( DumpableObject dobj,
DumpId  refId 
)

◆ strInArray()

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

Definition at line 1131 of file common.c.

1132 {
1133  int i;
1134 
1135  for (i = 0; i < arr_size; i++)
1136  {
1137  if (strcmp(pattern, arr[i]) == 0)
1138  return i;
1139  }
1140  return -1;
1141 }

References i.

Referenced by flagInhAttrs().

Variable Documentation

◆ allocedDumpIds

int allocedDumpIds = 0
static

Definition at line 39 of file common.c.

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

◆ catalogIdHash

catalogid_hash* catalogIdHash = NULL
static

◆ dumpIdMap

DumpableObject** dumpIdMap = NULL
static

Definition at line 38 of file common.c.

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

◆ lastDumpId

DumpId lastDumpId = 0
static

Definition at line 40 of file common.c.

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