Header And Logo

PostgreSQL
| The world's most advanced open source database.

Functions | Variables

common.c File Reference

#include "pg_backup_archiver.h"
#include "pg_backup_utils.h"
#include <ctype.h>
#include "catalog/pg_class.h"
Include dependency graph for common.c:

Go to the source code of this file.

Functions

static void flagInhTables (TableInfo *tbinfo, int numTables, InhInfo *inhinfo, int numInherits)
static void flagInhAttrs (TableInfo *tblinfo, int numTables)
static DumpableObject ** buildIndexArray (void *objArray, int numObjs, Size objSize)
static int DOCatalogIdCompare (const void *p1, const void *p2)
static void findParentsByOid (TableInfo *self, InhInfo *inhinfo, int numInherits)
static int strInArray (const char *pattern, char **arr, int arr_size)
TableInfogetSchemaData (Archive *fout, int *numTablesPtr)
void AssignDumpId (DumpableObject *dobj)
DumpId createDumpId (void)
DumpId getMaxDumpId (void)
DumpableObjectfindObjectByDumpId (DumpId dumpId)
DumpableObjectfindObjectByCatalogId (CatalogId catalogId)
static DumpableObjectfindObjectByOid (Oid oid, DumpableObject **indexArray, int numObjs)
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)
void parseOidArray (const char *str, Oid *array, int arraysize)
void simple_oid_list_append (SimpleOidList *list, Oid val)
bool simple_oid_list_member (SimpleOidList *list, Oid val)

Variables

static DumpableObject ** dumpIdMap = NULL
static int allocedDumpIds = 0
static DumpId lastDumpId = 0
static bool catalogIdMapValid = false
static DumpableObject ** catalogIdMap = NULL
static int numCatalogIds = 0
static TableInfotblinfo
static TypeInfotypinfo
static FuncInfofuninfo
static OprInfooprinfo
static NamespaceInfonspinfo
static int numTables
static int numTypes
static int numFuncs
static int numOperators
static int numCollations
static int numNamespaces
static DumpableObject ** tblinfoindex
static DumpableObject ** typinfoindex
static DumpableObject ** funinfoindex
static DumpableObject ** oprinfoindex
static DumpableObject ** collinfoindex
static DumpableObject ** nspinfoindex

Function Documentation

void addObjectDependency ( DumpableObject dobj,
DumpId  refId 
)
void AssignDumpId ( DumpableObject dobj  ) 

Definition at line 412 of file common.c.

References _dumpableObject::allocDeps, allocedDumpIds, catalogIdMapValid, _dumpableObject::dependencies, _dumpableObject::dump, _dumpableObject::dumpId, _dumpableObject::ext_member, lastDumpId, _dumpableObject::name, _dumpableObject::nDeps, pg_malloc(), and pg_realloc().

Referenced by createBoundaryObjects(), flagInhAttrs(), getAggregates(), getBlobs(), getCasts(), getCollations(), getConstraints(), getConversions(), getDefaultACLs(), getDomainConstraints(), getEventTriggers(), getExtensions(), getForeignDataWrappers(), getForeignServers(), getFuncs(), getIndexes(), getNamespaces(), getOpclasses(), getOperators(), getOpfamilies(), getProcLangs(), getRules(), getTableAttrs(), getTables(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), and makeTableDataInfo().

{
    dobj->dumpId = ++lastDumpId;
    dobj->name = NULL;          /* must be set later */
    dobj->namespace = NULL;     /* may be set later */
    dobj->dump = true;          /* default assumption */
    dobj->ext_member = false;   /* default assumption */
    dobj->dependencies = NULL;
    dobj->nDeps = 0;
    dobj->allocDeps = 0;

    while (dobj->dumpId >= allocedDumpIds)
    {
        int         newAlloc;

        if (allocedDumpIds <= 0)
        {
            newAlloc = 256;
            dumpIdMap = (DumpableObject **)
                pg_malloc(newAlloc * sizeof(DumpableObject *));
        }
        else
        {
            newAlloc = allocedDumpIds * 2;
            dumpIdMap = (DumpableObject **)
                pg_realloc(dumpIdMap, newAlloc * sizeof(DumpableObject *));
        }
        memset(dumpIdMap + allocedDumpIds, 0,
               (newAlloc - allocedDumpIds) * sizeof(DumpableObject *));
        allocedDumpIds = newAlloc;
    }
    dumpIdMap[dobj->dumpId] = dobj;

    /* mark catalogIdMap invalid, but don't rebuild it yet */
    catalogIdMapValid = false;
}

static DumpableObject ** buildIndexArray ( void *  objArray,
int  numObjs,
Size  objSize 
) [static]

Definition at line 583 of file common.c.

References DOCatalogIdCompare(), i, pg_malloc(), and qsort.

Referenced by getSchemaData().

{
    DumpableObject **ptrs;
    int         i;

    ptrs = (DumpableObject **) pg_malloc(numObjs * sizeof(DumpableObject *));
    for (i = 0; i < numObjs; i++)
        ptrs[i] = (DumpableObject *) ((char *) objArray + i * objSize);

    /* We can use DOCatalogIdCompare to sort since its first key is OID */
    if (numObjs > 1)
        qsort((void *) ptrs, numObjs, sizeof(DumpableObject *),
              DOCatalogIdCompare);

    return ptrs;
}

DumpId createDumpId ( void   ) 
static int DOCatalogIdCompare ( const void *  p1,
const void *  p2 
) [static]

Definition at line 604 of file common.c.

References _dumpableObject::catId, CatalogId::oid, oidcmp, and CatalogId::tableoid.

Referenced by buildIndexArray(), and findObjectByCatalogId().

{
    const DumpableObject *obj1 = *(DumpableObject *const *) p1;
    const DumpableObject *obj2 = *(DumpableObject *const *) p2;
    int         cmpval;

    /*
     * Compare OID first since it's usually unique, whereas there will only be
     * a few distinct values of tableoid.
     */
    cmpval = oidcmp(obj1->catId.oid, obj2->catId.oid);
    if (cmpval == 0)
        cmpval = oidcmp(obj1->catId.tableoid, obj2->catId.tableoid);
    return cmpval;
}

CollInfo* findCollationByOid ( Oid  oid  ) 

Definition at line 739 of file common.c.

References findObjectByOid(), and numCollations.

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

FuncInfo* findFuncByOid ( Oid  oid  ) 

Definition at line 717 of file common.c.

References findObjectByOid(), and numFuncs.

Referenced by dumpCast(), dumpProcLang(), getCasts(), getProcLangs(), and getTypes().

NamespaceInfo* findNamespaceByOid ( Oid  oid  ) 

Definition at line 750 of file common.c.

References findObjectByOid(), and numNamespaces.

Referenced by findNamespace().

DumpableObject* findObjectByCatalogId ( CatalogId  catalogId  ) 

Definition at line 494 of file common.c.

References catalogIdMapValid, DOCatalogIdCompare(), free, getDumpableObjects(), numCatalogIds, CatalogId::oid, oidcmp, qsort, and CatalogId::tableoid.

Referenced by buildMatViewRefreshDependencies(), getDependencies(), and getExtensionMembership().

{
    DumpableObject **low;
    DumpableObject **high;

    if (!catalogIdMapValid)
    {
        if (catalogIdMap)
            free(catalogIdMap);
        getDumpableObjects(&catalogIdMap, &numCatalogIds);
        if (numCatalogIds > 1)
            qsort((void *) catalogIdMap, numCatalogIds,
                  sizeof(DumpableObject *), DOCatalogIdCompare);
        catalogIdMapValid = true;
    }

    /*
     * We could use bsearch() here, but the notational cruft of calling
     * bsearch is nearly as bad as doing it ourselves; and the generalized
     * bsearch function is noticeably slower as well.
     */
    if (numCatalogIds <= 0)
        return NULL;
    low = catalogIdMap;
    high = catalogIdMap + (numCatalogIds - 1);
    while (low <= high)
    {
        DumpableObject **middle;
        int         difference;

        middle = low + (high - low) / 2;
        /* comparison must match DOCatalogIdCompare, below */
        difference = oidcmp((*middle)->catId.oid, catalogId.oid);
        if (difference == 0)
            difference = oidcmp((*middle)->catId.tableoid, catalogId.tableoid);
        if (difference == 0)
            return *middle;
        else if (difference < 0)
            low = middle + 1;
        else
            high = middle - 1;
    }
    return NULL;
}

DumpableObject* findObjectByDumpId ( DumpId  dumpId  ) 

Definition at line 476 of file common.c.

References allocedDumpIds.

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

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

static DumpableObject* findObjectByOid ( Oid  oid,
DumpableObject **  indexArray,
int  numObjs 
) [static]

Definition at line 545 of file common.c.

References oidcmp.

Referenced by findCollationByOid(), findFuncByOid(), findNamespaceByOid(), findOprByOid(), findTableByOid(), and findTypeByOid().

{
    DumpableObject **low;
    DumpableObject **high;

    /*
     * This is the same as findObjectByCatalogId except we assume we need not
     * look at table OID because the objects are all the same type.
     *
     * We could use bsearch() here, but the notational cruft of calling
     * bsearch is nearly as bad as doing it ourselves; and the generalized
     * bsearch function is noticeably slower as well.
     */
    if (numObjs <= 0)
        return NULL;
    low = indexArray;
    high = indexArray + (numObjs - 1);
    while (low <= high)
    {
        DumpableObject **middle;
        int         difference;

        middle = low + (high - low) / 2;
        difference = oidcmp((*middle)->catId.oid, oid);
        if (difference == 0)
            return *middle;
        else if (difference < 0)
            low = middle + 1;
        else
            high = middle - 1;
    }
    return NULL;
}

OprInfo* findOprByOid ( Oid  oid  ) 

Definition at line 728 of file common.c.

References findObjectByOid(), and numOperators.

Referenced by convertOperatorReference().

static void findParentsByOid ( TableInfo self,
InhInfo inhinfo,
int  numInherits 
) [static]

Definition at line 761 of file common.c.

References exit_nicely, findTableByOid(), i, NULL, _tableInfo::parents, pg_malloc(), and write_msg().

Referenced by flagInhTables().

{
    Oid         oid = self->dobj.catId.oid;
    int         i,
                j;
    int         numParents;

    numParents = 0;
    for (i = 0; i < numInherits; i++)
    {
        if (inhinfo[i].inhrelid == oid)
            numParents++;
    }

    self->numParents = numParents;

    if (numParents > 0)
    {
        self->parents = (TableInfo **)
            pg_malloc(sizeof(TableInfo *) * numParents);
        j = 0;
        for (i = 0; i < numInherits; i++)
        {
            if (inhinfo[i].inhrelid == oid)
            {
                TableInfo  *parent;

                parent = findTableByOid(inhinfo[i].inhparent);
                if (parent == NULL)
                {
                    write_msg(NULL, "failed sanity check, parent OID %u of table \"%s\" (OID %u) not found\n",
                              inhinfo[i].inhparent,
                              self->dobj.name,
                              oid);
                    exit_nicely(1);
                }
                self->parents[j++] = parent;
            }
        }
    }
    else
        self->parents = NULL;
}

TableInfo* findTableByOid ( Oid  oid  ) 
TypeInfo* findTypeByOid ( Oid  oid  ) 

Definition at line 706 of file common.c.

References findObjectByOid(), and numTypes.

Referenced by dumpCast(), and getCasts().

static void flagInhAttrs ( TableInfo tblinfo,
int  numTables 
) [static]

Definition at line 306 of file common.c.

References addObjectDependency(), _attrDefInfo::adef_expr, _attrDefInfo::adnum, _attrDefInfo::adtable, AssignDumpId(), _tableInfo::attisdropped, _tableInfo::attnames, _tableInfo::attrdefs, _dumpableObject::catId, _attrDefInfo::dobj, _tableInfo::dobj, _dumpableObject::dump, _dumpableObject::dumpId, i, _tableInfo::inhNotNull, _dumpableObject::name, _tableInfo::notnull, NULL, _tableInfo::numatts, _tableInfo::numParents, _dumpableObject::objType, CatalogId::oid, _tableInfo::parents, pg_malloc(), pg_strdup(), _tableInfo::relkind, RELKIND_MATVIEW, RELKIND_SEQUENCE, RELKIND_VIEW, _attrDefInfo::separate, shouldPrintColumn(), strInArray(), and CatalogId::tableoid.

Referenced by getSchemaData().

{
    int         i,
                j,
                k;

    for (i = 0; i < numTables; i++)
    {
        TableInfo  *tbinfo = &(tblinfo[i]);
        int         numParents;
        TableInfo **parents;

        /* Sequences and views never have parents */
        if (tbinfo->relkind == RELKIND_SEQUENCE ||
            tbinfo->relkind == RELKIND_VIEW ||
            tbinfo->relkind == RELKIND_MATVIEW)
            continue;

        /* Don't bother computing anything for non-target tables, either */
        if (!tbinfo->dobj.dump)
            continue;

        numParents = tbinfo->numParents;
        parents = tbinfo->parents;

        if (numParents == 0)
            continue;           /* nothing to see here, move along */

        /* For each column, search for matching column names in parent(s) */
        for (j = 0; j < tbinfo->numatts; j++)
        {
            bool        foundNotNull;   /* Attr was NOT NULL in a parent */
            bool        foundDefault;   /* Found a default in a parent */

            /* no point in examining dropped columns */
            if (tbinfo->attisdropped[j])
                continue;

            foundNotNull = false;
            foundDefault = false;
            for (k = 0; k < numParents; k++)
            {
                TableInfo  *parent = parents[k];
                int         inhAttrInd;

                inhAttrInd = strInArray(tbinfo->attnames[j],
                                        parent->attnames,
                                        parent->numatts);
                if (inhAttrInd >= 0)
                {
                    foundNotNull |= parent->notnull[inhAttrInd];
                    foundDefault |= (parent->attrdefs[inhAttrInd] != NULL);
                }
            }

            /* Remember if we found inherited NOT NULL */
            tbinfo->inhNotNull[j] = foundNotNull;

            /* Manufacture a DEFAULT NULL clause if necessary */
            if (foundDefault && tbinfo->attrdefs[j] == NULL)
            {
                AttrDefInfo *attrDef;

                attrDef = (AttrDefInfo *) pg_malloc(sizeof(AttrDefInfo));
                attrDef->dobj.objType = DO_ATTRDEF;
                attrDef->dobj.catId.tableoid = 0;
                attrDef->dobj.catId.oid = 0;
                AssignDumpId(&attrDef->dobj);
                attrDef->dobj.name = pg_strdup(tbinfo->dobj.name);
                attrDef->dobj.namespace = tbinfo->dobj.namespace;
                attrDef->dobj.dump = tbinfo->dobj.dump;

                attrDef->adtable = tbinfo;
                attrDef->adnum = j + 1;
                attrDef->adef_expr = pg_strdup("NULL");

                /* Will column be dumped explicitly? */
                if (shouldPrintColumn(tbinfo, j))
                {
                    attrDef->separate = false;
                    /* No dependency needed: NULL cannot have dependencies */
                }
                else
                {
                    /* column will be suppressed, print default separately */
                    attrDef->separate = true;
                    /* ensure it comes out after the table */
                    addObjectDependency(&attrDef->dobj,
                                        tbinfo->dobj.dumpId);
                }

                tbinfo->attrdefs[j] = attrDef;
            }
        }
    }
}

static void flagInhTables ( TableInfo tbinfo,
int  numTables,
InhInfo inhinfo,
int  numInherits 
) [static]

Definition at line 262 of file common.c.

References findParentsByOid(), i, _tableInfo::numParents, _tableInfo::parents, RELKIND_MATVIEW, RELKIND_SEQUENCE, and RELKIND_VIEW.

Referenced by getSchemaData().

{
    int         i,
                j;
    int         numParents;
    TableInfo **parents;

    for (i = 0; i < numTables; i++)
    {
        /* Sequences and views never have parents */
        if (tblinfo[i].relkind == RELKIND_SEQUENCE ||
            tblinfo[i].relkind == RELKIND_VIEW ||
            tblinfo[i].relkind == RELKIND_MATVIEW)
            continue;

        /* Don't bother computing anything for non-target tables, either */
        if (!tblinfo[i].dobj.dump)
            continue;

        /* Find all the immediate parent tables */
        findParentsByOid(&tblinfo[i], inhinfo, numInherits);

        /* Mark the parents as interesting for getTableAttrs */
        numParents = tblinfo[i].numParents;
        parents = tblinfo[i].parents;
        for (j = 0; j < numParents; j++)
            parents[j]->interesting = true;
    }
}

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

Definition at line 626 of file common.c.

References allocedDumpIds, i, and pg_malloc().

Referenced by findObjectByCatalogId(), getTableDataFKConstraints(), and main().

{
    int         i,
                j;

    *objs = (DumpableObject **)
        pg_malloc(allocedDumpIds * sizeof(DumpableObject *));
    j = 0;
    for (i = 1; i < allocedDumpIds; i++)
    {
        if (dumpIdMap[i])
            (*objs)[j++] = dumpIdMap[i];
    }
    *numObjs = j;
}

DumpId getMaxDumpId ( void   ) 

Definition at line 465 of file common.c.

References lastDumpId.

Referenced by findDependencyLoops(), and TopoSort().

{
    return lastDumpId;
}

TableInfo* getSchemaData ( Archive fout,
int *  numTablesPtr 
)

Definition at line 81 of file common.c.

References buildIndexArray(), flagInhAttrs(), flagInhTables(), g_verbose, getAggregates(), getCasts(), getCollations(), getConstraints(), getConversions(), getDefaultACLs(), getEventTriggers(), getExtensionMembership(), getExtensions(), getForeignDataWrappers(), getForeignServers(), getFuncs(), getIndexes(), getInherits(), getNamespaces(), getOpclasses(), getOperators(), getOpfamilies(), getOwnedSeqs(), getProcLangs(), getRules(), getTableAttrs(), getTables(), getTriggers(), getTSConfigurations(), getTSDictionaries(), getTSParsers(), getTSTemplates(), getTypes(), NULL, numCollations, numFuncs, numNamespaces, numOperators, numTables, numTypes, and write_msg().

Referenced by main().

{
    ExtensionInfo *extinfo;
    InhInfo    *inhinfo;
    CollInfo   *collinfo;
    int         numExtensions;
    int         numAggregates;
    int         numInherits;
    int         numRules;
    int         numProcLangs;
    int         numCasts;
    int         numOpclasses;
    int         numOpfamilies;
    int         numConversions;
    int         numTSParsers;
    int         numTSTemplates;
    int         numTSDicts;
    int         numTSConfigs;
    int         numForeignDataWrappers;
    int         numForeignServers;
    int         numDefaultACLs;
    int         numEventTriggers;

    if (g_verbose)
        write_msg(NULL, "reading schemas\n");
    nspinfo = getNamespaces(fout, &numNamespaces);
    nspinfoindex = buildIndexArray(nspinfo, numNamespaces, sizeof(NamespaceInfo));

    /*
     * getTables should be done as soon as possible, so as to minimize the
     * window between starting our transaction and acquiring per-table locks.
     * However, we have to do getNamespaces first because the tables get
     * linked to their containing namespaces during getTables.
     */
    if (g_verbose)
        write_msg(NULL, "reading user-defined tables\n");
    tblinfo = getTables(fout, &numTables);
    tblinfoindex = buildIndexArray(tblinfo, numTables, sizeof(TableInfo));

    /* Do this after we've built tblinfoindex */
    getOwnedSeqs(fout, tblinfo, numTables);

    if (g_verbose)
        write_msg(NULL, "reading extensions\n");
    extinfo = getExtensions(fout, &numExtensions);

    if (g_verbose)
        write_msg(NULL, "reading user-defined functions\n");
    funinfo = getFuncs(fout, &numFuncs);
    funinfoindex = buildIndexArray(funinfo, numFuncs, sizeof(FuncInfo));

    /* this must be after getTables and getFuncs */
    if (g_verbose)
        write_msg(NULL, "reading user-defined types\n");
    typinfo = getTypes(fout, &numTypes);
    typinfoindex = buildIndexArray(typinfo, numTypes, sizeof(TypeInfo));

    /* this must be after getFuncs, too */
    if (g_verbose)
        write_msg(NULL, "reading procedural languages\n");
    getProcLangs(fout, &numProcLangs);

    if (g_verbose)
        write_msg(NULL, "reading user-defined aggregate functions\n");
    getAggregates(fout, &numAggregates);

    if (g_verbose)
        write_msg(NULL, "reading user-defined operators\n");
    oprinfo = getOperators(fout, &numOperators);
    oprinfoindex = buildIndexArray(oprinfo, numOperators, sizeof(OprInfo));

    if (g_verbose)
        write_msg(NULL, "reading user-defined operator classes\n");
    getOpclasses(fout, &numOpclasses);

    if (g_verbose)
        write_msg(NULL, "reading user-defined operator families\n");
    getOpfamilies(fout, &numOpfamilies);

    if (g_verbose)
        write_msg(NULL, "reading user-defined text search parsers\n");
    getTSParsers(fout, &numTSParsers);

    if (g_verbose)
        write_msg(NULL, "reading user-defined text search templates\n");
    getTSTemplates(fout, &numTSTemplates);

    if (g_verbose)
        write_msg(NULL, "reading user-defined text search dictionaries\n");
    getTSDictionaries(fout, &numTSDicts);

    if (g_verbose)
        write_msg(NULL, "reading user-defined text search configurations\n");
    getTSConfigurations(fout, &numTSConfigs);

    if (g_verbose)
        write_msg(NULL, "reading user-defined foreign-data wrappers\n");
    getForeignDataWrappers(fout, &numForeignDataWrappers);

    if (g_verbose)
        write_msg(NULL, "reading user-defined foreign servers\n");
    getForeignServers(fout, &numForeignServers);

    if (g_verbose)
        write_msg(NULL, "reading default privileges\n");
    getDefaultACLs(fout, &numDefaultACLs);

    if (g_verbose)
        write_msg(NULL, "reading user-defined collations\n");
    collinfo = getCollations(fout, &numCollations);
    collinfoindex = buildIndexArray(collinfo, numCollations, sizeof(CollInfo));

    if (g_verbose)
        write_msg(NULL, "reading user-defined conversions\n");
    getConversions(fout, &numConversions);

    if (g_verbose)
        write_msg(NULL, "reading type casts\n");
    getCasts(fout, &numCasts);

    if (g_verbose)
        write_msg(NULL, "reading table inheritance information\n");
    inhinfo = getInherits(fout, &numInherits);

    if (g_verbose)
        write_msg(NULL, "reading rewrite rules\n");
    getRules(fout, &numRules);

    /*
     * Identify extension member objects and mark them as not to be dumped.
     * This must happen after reading all objects that can be direct members
     * of extensions, but before we begin to process table subsidiary objects.
     */
    if (g_verbose)
        write_msg(NULL, "finding extension members\n");
    getExtensionMembership(fout, extinfo, numExtensions);

    /* Link tables to parents, mark parents of target tables interesting */
    if (g_verbose)
        write_msg(NULL, "finding inheritance relationships\n");
    flagInhTables(tblinfo, numTables, inhinfo, numInherits);

    if (g_verbose)
        write_msg(NULL, "reading column info for interesting tables\n");
    getTableAttrs(fout, tblinfo, numTables);

    if (g_verbose)
        write_msg(NULL, "flagging inherited columns in subtables\n");
    flagInhAttrs(tblinfo, numTables);

    if (g_verbose)
        write_msg(NULL, "reading indexes\n");
    getIndexes(fout, tblinfo, numTables);

    if (g_verbose)
        write_msg(NULL, "reading constraints\n");
    getConstraints(fout, tblinfo, numTables);

    if (g_verbose)
        write_msg(NULL, "reading triggers\n");
    getTriggers(fout, tblinfo, numTables);

    if (g_verbose)
        write_msg(NULL, "reading event triggers\n");
    getEventTriggers(fout, &numEventTriggers);

    *numTablesPtr = numTables;
    return tblinfo;
}

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

Definition at line 816 of file common.c.

References atooid, exit_nicely, NULL, and write_msg().

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

{
    int         j,
                argNum;
    char        temp[100];
    char        s;

    argNum = 0;
    j = 0;
    for (;;)
    {
        s = *str++;
        if (s == ' ' || s == '\0')
        {
            if (j > 0)
            {
                if (argNum >= arraysize)
                {
                    write_msg(NULL, "could not parse numeric array \"%s\": too many numbers\n", str);
                    exit_nicely(1);
                }
                temp[j] = '\0';
                array[argNum++] = atooid(temp);
                j = 0;
            }
            if (s == '\0')
                break;
        }
        else
        {
            if (!(isdigit((unsigned char) s) || s == '-') ||
                j >= sizeof(temp) - 1)
            {
                write_msg(NULL, "could not parse numeric array \"%s\": invalid character in number\n", str);
                exit_nicely(1);
            }
            temp[j++] = s;
        }
    }

    while (argNum < arraysize)
        array[argNum++] = InvalidOid;
}

void removeObjectDependency ( DumpableObject dobj,
DumpId  refId 
)
void simple_oid_list_append ( SimpleOidList list,
Oid  val 
)

Definition at line 887 of file common.c.

References SimpleOidList::head, SimpleOidListCell::next, pg_malloc(), SimpleOidList::tail, and SimpleOidListCell::val.

Referenced by expand_schema_name_patterns(), and expand_table_name_patterns().

{
    SimpleOidListCell *cell;

    cell = (SimpleOidListCell *) pg_malloc(sizeof(SimpleOidListCell));
    cell->next = NULL;
    cell->val = val;

    if (list->tail)
        list->tail->next = cell;
    else
        list->head = cell;
    list->tail = cell;
}

bool simple_oid_list_member ( SimpleOidList list,
Oid  val 
)

Definition at line 903 of file common.c.

References SimpleOidList::head, SimpleOidListCell::next, and SimpleOidListCell::val.

Referenced by getExtensionMembership(), makeTableDataInfo(), selectDumpableNamespace(), and selectDumpableTable().

{
    SimpleOidListCell *cell;

    for (cell = list->head; cell; cell = cell->next)
    {
        if (cell->val == val)
            return true;
    }
    return false;
}

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

Definition at line 869 of file common.c.

References i.

Referenced by flagInhAttrs().

{
    int         i;

    for (i = 0; i < arr_size; i++)
    {
        if (strcmp(pattern, arr[i]) == 0)
            return i;
    }
    return -1;
}


Variable Documentation

int allocedDumpIds = 0 [static]

Definition at line 28 of file common.c.

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

DumpableObject** catalogIdMap = NULL [static]

Definition at line 35 of file common.c.

bool catalogIdMapValid = false [static]

Definition at line 34 of file common.c.

Referenced by AssignDumpId(), and findObjectByCatalogId().

Definition at line 61 of file common.c.

DumpableObject** dumpIdMap = NULL [static]

Definition at line 27 of file common.c.

FuncInfo* funinfo [static]

Definition at line 48 of file common.c.

Definition at line 59 of file common.c.

DumpId lastDumpId = 0 [static]

Definition at line 29 of file common.c.

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

Definition at line 50 of file common.c.

Definition at line 62 of file common.c.

int numCatalogIds = 0 [static]

Definition at line 36 of file common.c.

Referenced by findObjectByCatalogId().

int numCollations [static]

Definition at line 55 of file common.c.

Referenced by findCollationByOid(), and getSchemaData().

int numFuncs [static]

Definition at line 53 of file common.c.

Referenced by findFuncByOid(), and getSchemaData().

int numNamespaces [static]

Definition at line 56 of file common.c.

Referenced by findNamespaceByOid(), and getSchemaData().

int numOperators [static]

Definition at line 54 of file common.c.

Referenced by findOprByOid(), and getSchemaData().

int numTables [static]

Definition at line 51 of file common.c.

Referenced by findTableByOid(), getSchemaData(), and main().

int numTypes [static]

Definition at line 52 of file common.c.

Referenced by findTypeByOid(), and getSchemaData().

OprInfo* oprinfo [static]

Definition at line 49 of file common.c.

Referenced by getOperators().

Definition at line 60 of file common.c.

TableInfo* tblinfo [static]

Definition at line 46 of file common.c.

Referenced by getTables(), and main().

Definition at line 57 of file common.c.

TypeInfo* typinfo [static]

Definition at line 47 of file common.c.

Definition at line 58 of file common.c.