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_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)
 
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)
 
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 78 of file common.c.

◆ SH_DECLARE

#define SH_DECLARE

Definition at line 74 of file common.c.

◆ SH_DEFINE

#define SH_DEFINE

Definition at line 75 of file common.c.

◆ SH_ELEMENT_TYPE

#define SH_ELEMENT_TYPE   CatalogIdMapEntry

Definition at line 65 of file common.c.

◆ SH_EQUAL

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

Definition at line 69 of file common.c.

◆ SH_GET_HASH

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

Definition at line 71 of file common.c.

◆ SH_HASH_KEY

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

Definition at line 68 of file common.c.

◆ SH_KEY

#define SH_KEY   catId

Definition at line 67 of file common.c.

◆ SH_KEY_TYPE

#define SH_KEY_TYPE   CatalogId

Definition at line 66 of file common.c.

◆ SH_PREFIX

#define SH_PREFIX   catalogid

Definition at line 64 of file common.c.

◆ SH_RAW_ALLOCATOR

#define SH_RAW_ALLOCATOR   pg_malloc0

Definition at line 73 of file common.c.

◆ SH_SCOPE

#define SH_SCOPE   static inline

Definition at line 72 of file common.c.

◆ SH_STORE_HASH

#define SH_STORE_HASH

Definition at line 70 of file common.c.

Typedef Documentation

◆ CatalogIdMapEntry

Function Documentation

◆ addObjectDependency()

void addObjectDependency ( DumpableObject dobj,
DumpId  refId 
)

◆ AssignDumpId()

void AssignDumpId ( DumpableObject dobj)

Definition at line 642 of file common.c.

643 {
644  dobj->dumpId = ++lastDumpId;
645  dobj->name = NULL; /* must be set later */
646  dobj->namespace = NULL; /* may be set later */
647  dobj->dump = DUMP_COMPONENT_ALL; /* default assumption */
648  dobj->dump_contains = DUMP_COMPONENT_ALL; /* default assumption */
649  /* All objects have definitions; we may set more components bits later */
651  dobj->ext_member = false; /* default assumption */
652  dobj->depends_on_ext = false; /* default assumption */
653  dobj->dependencies = NULL;
654  dobj->nDeps = 0;
655  dobj->allocDeps = 0;
656 
657  /* Add object to dumpIdMap[], enlarging that array if need be */
658  while (dobj->dumpId >= allocedDumpIds)
659  {
660  int newAlloc;
661 
662  if (allocedDumpIds <= 0)
663  {
664  newAlloc = 256;
666  }
667  else
668  {
669  newAlloc = allocedDumpIds * 2;
671  }
672  memset(dumpIdMap + allocedDumpIds, 0,
673  (newAlloc - allocedDumpIds) * sizeof(DumpableObject *));
674  allocedDumpIds = newAlloc;
675  }
676  dumpIdMap[dobj->dumpId] = dobj;
677 
678  /* If it has a valid CatalogId, enter it into the hash table */
679  if (OidIsValid(dobj->catId.tableoid))
680  {
681  CatalogIdMapEntry *entry;
682  bool found;
683 
684  /* Initialize CatalogId hash table if not done yet */
685  if (catalogIdHash == NULL)
686  catalogIdHash = catalogid_create(CATALOGIDHASH_INITIAL_SIZE, NULL);
687 
688  entry = catalogid_insert(catalogIdHash, dobj->catId, &found);
689  if (!found)
690  {
691  entry->dobj = NULL;
692  entry->ext = NULL;
693  }
694  Assert(entry->dobj == NULL);
695  entry->dobj = dobj;
696  }
697 }
static int allocedDumpIds
Definition: common.c:38
static DumpableObject ** dumpIdMap
Definition: common.c:37
#define CATALOGIDHASH_INITIAL_SIZE
Definition: common.c:78
static catalogid_hash * catalogIdHash
Definition: common.c:80
static DumpId lastDumpId
Definition: common.c:39
#define OidIsValid(objectId)
Definition: c.h:764
Assert(fmt[strlen(fmt) - 1] !='\n')
#define DUMP_COMPONENT_ALL
Definition: pg_dump.h:103
#define DUMP_COMPONENT_DEFINITION
Definition: pg_dump.h:96
Oid tableoid
Definition: pg_backup.h:264
ExtensionInfo * ext
Definition: common.c:61
DumpableObject * dobj
Definition: common.c:60
DumpComponents dump
Definition: pg_dump.h:138
char * name
Definition: pg_dump.h:137
DumpId dumpId
Definition: pg_dump.h:136
bool ext_member
Definition: pg_dump.h:142
DumpComponents components
Definition: pg_dump.h:141
CatalogId catId
Definition: pg_dump.h:135
DumpComponents dump_contains
Definition: pg_dump.h:140
bool depends_on_ext
Definition: pg_dump.h:143

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

◆ createDumpId()

◆ findCollationByOid()

CollInfo* findCollationByOid ( Oid  oid)

Definition at line 915 of file common.c.

916 {
917  CatalogId catId;
918  DumpableObject *dobj;
919 
920  catId.tableoid = CollationRelationId;
921  catId.oid = oid;
922  dobj = findObjectByCatalogId(catId);
923  Assert(dobj == NULL || dobj->objType == DO_COLLATION);
924  return (CollInfo *) dobj;
925 }
DumpableObject * findObjectByCatalogId(CatalogId catalogId)
Definition: common.c:739
@ DO_COLLATION
Definition: pg_dump.h:50
DumpableObjectType objType
Definition: pg_dump.h:134

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

952 {
953  CatalogId catId;
954  DumpableObject *dobj;
955 
956  catId.tableoid = ExtensionRelationId;
957  catId.oid = oid;
958  dobj = findObjectByCatalogId(catId);
959  Assert(dobj == NULL || dobj->objType == DO_EXTENSION);
960  return (ExtensionInfo *) dobj;
961 }
@ 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 879 of file common.c.

880 {
881  CatalogId catId;
882  DumpableObject *dobj;
883 
884  catId.tableoid = ProcedureRelationId;
885  catId.oid = oid;
886  dobj = findObjectByCatalogId(catId);
887  Assert(dobj == NULL || dobj->objType == DO_FUNC);
888  return (FuncInfo *) dobj;
889 }
@ 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 842 of file common.c.

843 {
844  CatalogId catId;
845  DumpableObject *dobj;
846 
847  catId.tableoid = RelationRelationId;
848  catId.oid = oid;
849  dobj = findObjectByCatalogId(catId);
850  Assert(dobj == NULL || dobj->objType == DO_INDEX);
851  return (IndxInfo *) dobj;
852 }
@ 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 933 of file common.c.

934 {
935  CatalogId catId;
936  DumpableObject *dobj;
937 
938  catId.tableoid = NamespaceRelationId;
939  catId.oid = oid;
940  dobj = findObjectByCatalogId(catId);
941  Assert(dobj == NULL || dobj->objType == DO_NAMESPACE);
942  return (NamespaceInfo *) dobj;
943 }
@ 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 739 of file common.c.

740 {
741  CatalogIdMapEntry *entry;
742 
743  if (catalogIdHash == NULL)
744  return NULL; /* no objects exist yet */
745 
746  entry = catalogid_lookup(catalogIdHash, catalogId);
747  if (entry == NULL)
748  return NULL;
749  return entry->dobj;
750 }

References catalogIdHash, and _catalogIdMapEntry::dobj.

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

◆ findObjectByDumpId()

DumpableObject* findObjectByDumpId ( DumpId  dumpId)

Definition at line 726 of file common.c.

727 {
728  if (dumpId <= 0 || dumpId >= allocedDumpIds)
729  return NULL; /* out of range? */
730  return dumpIdMap[dumpId];
731 }

References allocedDumpIds, and dumpIdMap.

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

◆ findOprByOid()

OprInfo* findOprByOid ( Oid  oid)

Definition at line 897 of file common.c.

898 {
899  CatalogId catId;
900  DumpableObject *dobj;
901 
902  catId.tableoid = OperatorRelationId;
903  catId.oid = oid;
904  dobj = findObjectByCatalogId(catId);
905  Assert(dobj == NULL || dobj->objType == DO_OPERATOR);
906  return (OprInfo *) dobj;
907 }
@ 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 1012 of file common.c.

1013 {
1014  CatalogIdMapEntry *entry;
1015 
1016  if (catalogIdHash == NULL)
1017  return NULL; /* no objects exist yet */
1018 
1019  entry = catalogid_lookup(catalogIdHash, catalogId);
1020  if (entry == NULL)
1021  return NULL;
1022  return entry->ext;
1023 }

References catalogIdHash, and _catalogIdMapEntry::ext.

Referenced by checkExtensionMembership().

◆ findPublicationByOid()

PublicationInfo* findPublicationByOid ( Oid  oid)

Definition at line 969 of file common.c.

970 {
971  CatalogId catId;
972  DumpableObject *dobj;
973 
974  catId.tableoid = PublicationRelationId;
975  catId.oid = oid;
976  dobj = findObjectByCatalogId(catId);
977  Assert(dobj == NULL || dobj->objType == DO_PUBLICATION);
978  return (PublicationInfo *) dobj;
979 }
@ DO_PUBLICATION
Definition: pg_dump.h:82

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

Referenced by getPublicationNamespaces(), and getPublicationTables().

◆ findTableByOid()

TableInfo* findTableByOid ( Oid  oid)

Definition at line 824 of file common.c.

825 {
826  CatalogId catId;
827  DumpableObject *dobj;
828 
829  catId.tableoid = RelationRelationId;
830  catId.oid = oid;
831  dobj = findObjectByCatalogId(catId);
832  Assert(dobj == NULL || dobj->objType == DO_TABLE);
833  return (TableInfo *) dobj;
834 }
@ DO_TABLE
Definition: pg_dump.h:52

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

Referenced by dumpSequence(), flagInhTables(), getAdditionalACLs(), getConstraints(), getOwnedSeqs(), getPartitioningInfo(), getPolicies(), getPublicationTables(), getRules(), getTableDataFKConstraints(), processExtensionTables(), and selectDumpableType().

◆ findTypeByOid()

TypeInfo* findTypeByOid ( Oid  oid)

Definition at line 860 of file common.c.

861 {
862  CatalogId catId;
863  DumpableObject *dobj;
864 
865  catId.tableoid = TypeRelationId;
866  catId.oid = oid;
867  dobj = findObjectByCatalogId(catId);
868  Assert(dobj == NULL ||
869  dobj->objType == DO_TYPE || dobj->objType == DO_DUMMY_TYPE);
870  return (TypeInfo *) dobj;
871 }
@ 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 496 of file common.c.

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

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

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

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

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

759 {
760  int i,
761  j;
762 
764  j = 0;
765  for (i = 1; i < allocedDumpIds; i++)
766  {
767  if (dumpIdMap[i])
768  (*objs)[j++] = dumpIdMap[i];
769  }
770  *numObjs = j;
771 }

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

Referenced by getTableDataFKConstraints(), and main().

◆ getMaxDumpId()

DumpId getMaxDumpId ( void  )

Definition at line 715 of file common.c.

716 {
717  return lastDumpId;
718 }

References lastDumpId.

Referenced by findDependencyLoops(), and TopoSort().

◆ getSchemaData()

TableInfo* getSchemaData ( Archive fout,
int *  numTablesPtr 
)

Definition at line 96 of file common.c.

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

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(), 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 1036 of file common.c.

1037 {
1038  int j,
1039  argNum;
1040  char temp[100];
1041  char s;
1042 
1043  argNum = 0;
1044  j = 0;
1045  for (;;)
1046  {
1047  s = *str++;
1048  if (s == ' ' || s == '\0')
1049  {
1050  if (j > 0)
1051  {
1052  if (argNum >= arraysize)
1053  pg_fatal("could not parse numeric array \"%s\": too many numbers", str);
1054  temp[j] = '\0';
1055  array[argNum++] = atooid(temp);
1056  j = 0;
1057  }
1058  if (s == '\0')
1059  break;
1060  }
1061  else
1062  {
1063  if (!(isdigit((unsigned char) s) || s == '-') ||
1064  j >= sizeof(temp) - 1)
1065  pg_fatal("could not parse numeric array \"%s\": invalid character in number", str);
1066  temp[j++] = s;
1067  }
1068  }
1069 
1070  while (argNum < arraysize)
1071  array[argNum++] = InvalidOid;
1072 }
#define InvalidOid
Definition: postgres_ext.h:36
#define atooid(x)
Definition: postgres_ext.h:42

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

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

◆ recordExtensionMembership()

void recordExtensionMembership ( CatalogId  catId,
ExtensionInfo ext 
)

Definition at line 988 of file common.c.

989 {
990  CatalogIdMapEntry *entry;
991  bool found;
992 
993  /* CatalogId hash table must exist, if we have an ExtensionInfo */
994  Assert(catalogIdHash != NULL);
995 
996  /* Add reference to CatalogId hash */
997  entry = catalogid_insert(catalogIdHash, catId, &found);
998  if (!found)
999  {
1000  entry->dobj = NULL;
1001  entry->ext = NULL;
1002  }
1003  Assert(entry->ext == NULL);
1004  entry->ext = ext;
1005 }

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

1084 {
1085  int i;
1086 
1087  for (i = 0; i < arr_size; i++)
1088  {
1089  if (strcmp(pattern, arr[i]) == 0)
1090  return i;
1091  }
1092  return -1;
1093 }

References i.

Referenced by flagInhAttrs().

Variable Documentation

◆ allocedDumpIds

int allocedDumpIds = 0
static

Definition at line 38 of file common.c.

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

◆ catalogIdHash

catalogid_hash* catalogIdHash = NULL
static

◆ dumpIdMap

DumpableObject** dumpIdMap = NULL
static

Definition at line 37 of file common.c.

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

◆ lastDumpId

DumpId lastDumpId = 0
static

Definition at line 39 of file common.c.

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