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

646 {
647  dobj->dumpId = ++lastDumpId;
648  dobj->name = NULL; /* must be set later */
649  dobj->namespace = NULL; /* may be set later */
650  dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
651  dobj->dump_contains = DUMP_COMPONENT_ALL; /* default assumption */
652  /* All objects have definitions; we may set more components bits later */
654  dobj->ext_member = false; /* default assumption */
655  dobj->depends_on_ext = false; /* default assumption */
656  dobj->dependencies = NULL;
657  dobj->nDeps = 0;
658  dobj->allocDeps = 0;
659 
660  /* Add object to dumpIdMap[], enlarging that array if need be */
661  while (dobj->dumpId >= allocedDumpIds)
662  {
663  int newAlloc;
664 
665  if (allocedDumpIds <= 0)
666  {
667  newAlloc = 256;
669  }
670  else
671  {
672  newAlloc = allocedDumpIds * 2;
674  }
675  memset(dumpIdMap + allocedDumpIds, 0,
676  (newAlloc - allocedDumpIds) * sizeof(DumpableObject *));
677  allocedDumpIds = newAlloc;
678  }
679  dumpIdMap[dobj->dumpId] = dobj;
680 
681  /* If it has a valid CatalogId, enter it into the hash table */
682  if (OidIsValid(dobj->catId.tableoid))
683  {
684  CatalogIdMapEntry *entry;
685  bool found;
686 
687  /* Initialize CatalogId hash table if not done yet */
688  if (catalogIdHash == NULL)
689  catalogIdHash = catalogid_create(CATALOGIDHASH_INITIAL_SIZE, NULL);
690 
691  entry = catalogid_insert(catalogIdHash, dobj->catId, &found);
692  if (!found)
693  {
694  entry->dobj = NULL;
695  entry->ext = NULL;
696  }
697  Assert(entry->dobj == NULL);
698  entry->dobj = dobj;
699  }
700 }
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 942 of file common.c.

943 {
944  CatalogId catId;
945  DumpableObject *dobj;
946 
947  catId.tableoid = CollationRelationId;
948  catId.oid = oid;
949  dobj = findObjectByCatalogId(catId);
950  Assert(dobj == NULL || dobj->objType == DO_COLLATION);
951  return (CollInfo *) dobj;
952 }
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
Definition: common.c:766
@ 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 978 of file common.c.

979 {
980  CatalogId catId;
981  DumpableObject *dobj;
982 
983  catId.tableoid = ExtensionRelationId;
984  catId.oid = oid;
985  dobj = findObjectByCatalogId(catId);
986  Assert(dobj == NULL || dobj->objType == DO_EXTENSION);
987  return (ExtensionInfo *) dobj;
988 }
@ 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 906 of file common.c.

907 {
908  CatalogId catId;
909  DumpableObject *dobj;
910 
911  catId.tableoid = ProcedureRelationId;
912  catId.oid = oid;
913  dobj = findObjectByCatalogId(catId);
914  Assert(dobj == NULL || dobj->objType == DO_FUNC);
915  return (FuncInfo *) dobj;
916 }
@ 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 869 of file common.c.

870 {
871  CatalogId catId;
872  DumpableObject *dobj;
873 
874  catId.tableoid = RelationRelationId;
875  catId.oid = oid;
876  dobj = findObjectByCatalogId(catId);
877  Assert(dobj == NULL || dobj->objType == DO_INDEX);
878  return (IndxInfo *) dobj;
879 }
@ 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 960 of file common.c.

961 {
962  CatalogId catId;
963  DumpableObject *dobj;
964 
965  catId.tableoid = NamespaceRelationId;
966  catId.oid = oid;
967  dobj = findObjectByCatalogId(catId);
968  Assert(dobj == NULL || dobj->objType == DO_NAMESPACE);
969  return (NamespaceInfo *) dobj;
970 }
@ 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 766 of file common.c.

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

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

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

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

925 {
926  CatalogId catId;
927  DumpableObject *dobj;
928 
929  catId.tableoid = OperatorRelationId;
930  catId.oid = oid;
931  dobj = findObjectByCatalogId(catId);
932  Assert(dobj == NULL || dobj->objType == DO_OPERATOR);
933  return (OprInfo *) dobj;
934 }
@ 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 1057 of file common.c.

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

References catalogIdHash, and _catalogIdMapEntry::ext.

Referenced by checkExtensionMembership().

◆ findPublicationByOid()

PublicationInfo* findPublicationByOid ( Oid  oid)

Definition at line 996 of file common.c.

997 {
998  CatalogId catId;
999  DumpableObject *dobj;
1000 
1001  catId.tableoid = PublicationRelationId;
1002  catId.oid = oid;
1003  dobj = findObjectByCatalogId(catId);
1004  Assert(dobj == NULL || dobj->objType == DO_PUBLICATION);
1005  return (PublicationInfo *) dobj;
1006 }
@ 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 1014 of file common.c.

1015 {
1016  CatalogId catId;
1017  DumpableObject *dobj;
1018 
1019  catId.tableoid = SubscriptionRelationId;
1020  catId.oid = oid;
1021  dobj = findObjectByCatalogId(catId);
1022  Assert(dobj == NULL || dobj->objType == DO_SUBSCRIPTION);
1023  return (SubscriptionInfo *) dobj;
1024 }
@ 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 887 of file common.c.

888 {
889  CatalogId catId;
890  DumpableObject *dobj;
891 
892  catId.tableoid = TypeRelationId;
893  catId.oid = oid;
894  dobj = findObjectByCatalogId(catId);
895  Assert(dobj == NULL ||
896  dobj->objType == DO_TYPE || dobj->objType == DO_DUMMY_TYPE);
897  return (TypeInfo *) dobj;
898 }
@ 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,
TableInfo tblinfo,
int  numTables 
)
static

Definition at line 500 of file common.c.

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

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, Archive::dopt, _dumpableObject::dump, DUMP_COMPONENT_NONE, _dumpableObject::dumpId, i, _tableInfo::inhNotNull, _tableInfo::ispartition, j, _dumpableObject::name, _tableInfo::notnull, _tableInfo::numatts, _tableInfo::numParents, _dumpableObject::objType, CatalogId::oid, _tableInfo::parents, pg_malloc_object, pg_strdup(), _tableInfo::relkind, _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 410 of file common.c.

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

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

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

786 {
787  int i,
788  j;
789 
791  j = 0;
792  for (i = 1; i < allocedDumpIds; i++)
793  {
794  if (dumpIdMap[i])
795  (*objs)[j++] = dumpIdMap[i];
796  }
797  *numObjs = j;
798 }

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

Referenced by getTableDataFKConstraints(), and main().

◆ getMaxDumpId()

DumpId getMaxDumpId ( void  )

Definition at line 742 of file common.c.

743 {
744  return lastDumpId;
745 }

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

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

1082 {
1083  int j,
1084  argNum;
1085  char temp[100];
1086  char s;
1087 
1088  argNum = 0;
1089  j = 0;
1090  for (;;)
1091  {
1092  s = *str++;
1093  if (s == ' ' || s == '\0')
1094  {
1095  if (j > 0)
1096  {
1097  if (argNum >= arraysize)
1098  pg_fatal("could not parse numeric array \"%s\": too many numbers", str);
1099  temp[j] = '\0';
1100  array[argNum++] = atooid(temp);
1101  j = 0;
1102  }
1103  if (s == '\0')
1104  break;
1105  }
1106  else
1107  {
1108  if (!(isdigit((unsigned char) s) || s == '-') ||
1109  j >= sizeof(temp) - 1)
1110  pg_fatal("could not parse numeric array \"%s\": invalid character in number", str);
1111  temp[j++] = s;
1112  }
1113  }
1114 
1115  while (argNum < arraysize)
1116  array[argNum++] = InvalidOid;
1117 }
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 707 of file common.c.

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

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

Referenced by getLOs().

◆ recordExtensionMembership()

void recordExtensionMembership ( CatalogId  catId,
ExtensionInfo ext 
)

Definition at line 1033 of file common.c.

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

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

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

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().