Header And Logo

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

Data Structures | Defines | Typedefs | Enumerations | Functions | Variables

lsyscache.h File Reference

#include "access/attnum.h"
#include "access/htup.h"
#include "nodes/pg_list.h"
Include dependency graph for lsyscache.h:

Go to the source code of this file.

Data Structures

struct  OpBtreeInterpretation

Defines

#define type_is_array(typid)   (get_element_type(typid) != InvalidOid)
#define type_is_array_domain(typid)   (get_base_element_type(typid) != InvalidOid)
#define TypeIsToastable(typid)   (get_typstorage(typid) != 'p')

Typedefs

typedef struct
OpBtreeInterpretation 
OpBtreeInterpretation
typedef enum IOFuncSelector IOFuncSelector
typedef int32(* get_attavgwidth_hook_type )(Oid relid, AttrNumber attnum)

Enumerations

enum  IOFuncSelector { IOFunc_input, IOFunc_output, IOFunc_receive, IOFunc_send }

Functions

bool op_in_opfamily (Oid opno, Oid opfamily)
int get_op_opfamily_strategy (Oid opno, Oid opfamily)
Oid get_op_opfamily_sortfamily (Oid opno, Oid opfamily)
void get_op_opfamily_properties (Oid opno, Oid opfamily, bool ordering_op, int *strategy, Oid *lefttype, Oid *righttype)
Oid get_opfamily_member (Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
bool get_ordering_op_properties (Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
bool get_sort_function_for_ordering_op (Oid opno, Oid *sortfunc, bool *issupport, bool *reverse)
Oid get_equality_op_for_ordering_op (Oid opno, bool *reverse)
Oid get_ordering_op_for_equality_op (Oid opno, bool use_lhs_type)
Listget_mergejoin_opfamilies (Oid opno)
bool get_compatible_hash_operators (Oid opno, Oid *lhs_opno, Oid *rhs_opno)
bool get_op_hash_functions (Oid opno, RegProcedure *lhs_procno, RegProcedure *rhs_procno)
Listget_op_btree_interpretation (Oid opno)
bool equality_ops_are_compatible (Oid opno1, Oid opno2)
Oid get_opfamily_proc (Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
char * get_attname (Oid relid, AttrNumber attnum)
char * get_relid_attribute_name (Oid relid, AttrNumber attnum)
AttrNumber get_attnum (Oid relid, const char *attname)
Oid get_atttype (Oid relid, AttrNumber attnum)
int32 get_atttypmod (Oid relid, AttrNumber attnum)
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
char * get_collation_name (Oid colloid)
char * get_constraint_name (Oid conoid)
Oid get_opclass_family (Oid opclass)
Oid get_opclass_input_type (Oid opclass)
RegProcedure get_opcode (Oid opno)
char * get_opname (Oid opno)
void op_input_types (Oid opno, Oid *lefttype, Oid *righttype)
bool op_mergejoinable (Oid opno, Oid inputtype)
bool op_hashjoinable (Oid opno, Oid inputtype)
bool op_strict (Oid opno)
char op_volatile (Oid opno)
Oid get_commutator (Oid opno)
Oid get_negator (Oid opno)
RegProcedure get_oprrest (Oid opno)
RegProcedure get_oprjoin (Oid opno)
char * get_func_name (Oid funcid)
Oid get_func_namespace (Oid funcid)
Oid get_func_rettype (Oid funcid)
int get_func_nargs (Oid funcid)
Oid get_func_signature (Oid funcid, Oid **argtypes, int *nargs)
bool get_func_retset (Oid funcid)
bool func_strict (Oid funcid)
char func_volatile (Oid funcid)
bool get_func_leakproof (Oid funcid)
float4 get_func_cost (Oid funcid)
float4 get_func_rows (Oid funcid)
Oid get_relname_relid (const char *relname, Oid relnamespace)
char * get_rel_name (Oid relid)
Oid get_rel_namespace (Oid relid)
Oid get_rel_type_id (Oid relid)
char get_rel_relkind (Oid relid)
Oid get_rel_tablespace (Oid relid)
bool get_typisdefined (Oid typid)
int16 get_typlen (Oid typid)
bool get_typbyval (Oid typid)
void get_typlenbyval (Oid typid, int16 *typlen, bool *typbyval)
void get_typlenbyvalalign (Oid typid, int16 *typlen, bool *typbyval, char *typalign)
Oid getTypeIOParam (HeapTuple typeTuple)
void get_type_io_data (Oid typid, IOFuncSelector which_func, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *func)
char get_typstorage (Oid typid)
Nodeget_typdefault (Oid typid)
char get_typtype (Oid typid)
bool type_is_rowtype (Oid typid)
bool type_is_enum (Oid typid)
bool type_is_range (Oid typid)
void get_type_category_preferred (Oid typid, char *typcategory, bool *typispreferred)
Oid get_typ_typrelid (Oid typid)
Oid get_element_type (Oid typid)
Oid get_array_type (Oid typid)
Oid get_base_element_type (Oid typid)
void getTypeInputInfo (Oid type, Oid *typInput, Oid *typIOParam)
void getTypeOutputInfo (Oid type, Oid *typOutput, bool *typIsVarlena)
void getTypeBinaryInputInfo (Oid type, Oid *typReceive, Oid *typIOParam)
void getTypeBinaryOutputInfo (Oid type, Oid *typSend, bool *typIsVarlena)
Oid get_typmodin (Oid typid)
Oid get_typcollation (Oid typid)
bool type_is_collatable (Oid typid)
Oid getBaseType (Oid typid)
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
int32 get_typavgwidth (Oid typid, int32 typmod)
int32 get_attavgwidth (Oid relid, AttrNumber attnum)
bool get_attstatsslot (HeapTuple statstuple, Oid atttype, int32 atttypmod, int reqkind, Oid reqop, Oid *actualop, Datum **values, int *nvalues, float4 **numbers, int *nnumbers)
void free_attstatsslot (Oid atttype, Datum *values, int nvalues, float4 *numbers, int nnumbers)
char * get_namespace_name (Oid nspid)
Oid get_range_subtype (Oid rangeOid)

Variables

PGDLLIMPORT
get_attavgwidth_hook_type 
get_attavgwidth_hook

Define Documentation

#define type_is_array (   typid  )     (get_element_type(typid) != InvalidOid)

Definition at line 156 of file lsyscache.h.

Referenced by IsBinaryCoercible(), resolve_polymorphic_tupdesc(), and transformArrayExpr().

#define type_is_array_domain (   typid  )     (get_base_element_type(typid) != InvalidOid)
#define TypeIsToastable (   typid  )     (get_typstorage(typid) != 'p')

Definition at line 160 of file lsyscache.h.

Referenced by ATExecSetStorage(), ExecIndexBuildScanKeys(), and fmgr_info_C_lang().


Typedef Documentation

typedef int32(* get_attavgwidth_hook_type)(Oid relid, AttrNumber attnum)

Definition at line 39 of file lsyscache.h.


Enumeration Type Documentation

Enumerator:
IOFunc_input 
IOFunc_output 
IOFunc_receive 
IOFunc_send 

Definition at line 30 of file lsyscache.h.

{
    IOFunc_input,
    IOFunc_output,
    IOFunc_receive,
    IOFunc_send
} IOFuncSelector;


Function Documentation

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 747 of file lsyscache.c.

References AMOPOPID, BTREE_AM_OID, GETSTRUCT, HASH_AM_OID, i, catclist::members, catclist::n_members, ObjectIdGetDatum, op_in_opfamily(), ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by query_is_distinct_for().

{
    bool        result;
    CatCList   *catlist;
    int         i;

    /* Easy if they're the same operator */
    if (opno1 == opno2)
        return true;

    /*
     * We search through all the pg_amop entries for opno1.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));

    result = false;
    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   op_tuple = &catlist->members[i]->tuple;
        Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);

        /* must be btree or hash */
        if (op_form->amopmethod == BTREE_AM_OID ||
            op_form->amopmethod == HASH_AM_OID)
        {
            if (op_in_opfamily(opno2, op_form->amopfamily))
            {
                result = true;
                break;
            }
        }
    }

    ReleaseSysCacheList(catlist);

    return result;
}

void free_attstatsslot ( Oid  atttype,
Datum values,
int  nvalues,
float4 numbers,
int  nnumbers 
)
bool func_strict ( Oid  funcid  ) 
char func_volatile ( Oid  funcid  ) 

Definition at line 1538 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by contain_mutable_functions_walker(), contain_volatile_functions_walker(), eval_const_expressions_mutator(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), and op_volatile().

{
    HeapTuple   tp;
    char        result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
    ReleaseSysCache(tp);
    return result;
}

Oid get_array_type ( Oid  typid  ) 
int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 2675 of file lsyscache.c.

References BoolGetDatum, get_attavgwidth_hook, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache3, and STATRELATTINH.

Referenced by get_rel_data_width(), and set_rel_width().

{
    HeapTuple   tp;
    int32       stawidth;

    if (get_attavgwidth_hook)
    {
        stawidth = (*get_attavgwidth_hook) (relid, attnum);
        if (stawidth > 0)
            return stawidth;
    }
    tp = SearchSysCache3(STATRELATTINH,
                         ObjectIdGetDatum(relid),
                         Int16GetDatum(attnum),
                         BoolGetDatum(false));
    if (HeapTupleIsValid(tp))
    {
        stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
        ReleaseSysCache(tp);
        if (stawidth > 0)
            return stawidth;
    }
    return 0;
}

char* get_attname ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 826 of file lsyscache.c.

References ATTNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache2.

Referenced by AddRelationNewConstraints(), fixup_inherited_columns(), and get_relid_attribute_name().

{
    HeapTuple   tp;

    tp = SearchSysCache2(ATTNUM,
                         ObjectIdGetDatum(relid),
                         Int16GetDatum(attnum));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
        char       *result;

        result = pstrdup(NameStr(att_tup->attname));
        ReleaseSysCache(tp);
        return result;
    }
    else
        return NULL;
}

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)
bool get_attstatsslot ( HeapTuple  statstuple,
Oid  atttype,
int32  atttypmod,
int  reqkind,
Oid  reqop,
Oid actualop,
Datum **  values,
int *  nvalues,
float4 **  numbers,
int *  nnumbers 
)

Definition at line 2733 of file lsyscache.c.

References Anum_pg_statistic_stanumbers1, Anum_pg_statistic_stavalues1, ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, datumCopy(), DatumGetArrayTypeP, DatumGetPointer, deconstruct_array(), elog, ERROR, FLOAT4OID, GETSTRUCT, HeapTupleIsValid, i, InvalidOid, NULL, ObjectIdGetDatum, palloc(), pfree(), ReleaseSysCache(), SearchSysCache1, STATRELATTINH, SysCacheGetAttr(), TYPEOID, and val.

Referenced by booltestsel(), btcostestimate(), calc_arraycontsel(), calc_hist_selectivity(), calc_rangesel(), eqjoinsel_inner(), eqjoinsel_semi(), estimate_hash_bucketsize(), ExecHashBuildSkewHash(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), scalararraysel_containment(), tsquerysel(), var_eq_const(), and var_eq_non_const().

{
    Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
    int         i,
                j;
    Datum       val;
    bool        isnull;
    ArrayType  *statarray;
    Oid         arrayelemtype;
    int         narrayelem;
    HeapTuple   typeTuple;
    Form_pg_type typeForm;

    for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
    {
        if ((&stats->stakind1)[i] == reqkind &&
            (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
            break;
    }
    if (i >= STATISTIC_NUM_SLOTS)
        return false;           /* not there */

    if (actualop)
        *actualop = (&stats->staop1)[i];

    if (values)
    {
        val = SysCacheGetAttr(STATRELATTINH, statstuple,
                              Anum_pg_statistic_stavalues1 + i,
                              &isnull);
        if (isnull)
            elog(ERROR, "stavalues is null");
        statarray = DatumGetArrayTypeP(val);

        /*
         * Need to get info about the array element type.  We look at the
         * actual element type embedded in the array, which might be only
         * binary-compatible with the passed-in atttype.  The info we extract
         * here should be the same either way, but deconstruct_array is picky
         * about having an exact type OID match.
         */
        arrayelemtype = ARR_ELEMTYPE(statarray);
        typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
        if (!HeapTupleIsValid(typeTuple))
            elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
        typeForm = (Form_pg_type) GETSTRUCT(typeTuple);

        /* Deconstruct array into Datum elements; NULLs not expected */
        deconstruct_array(statarray,
                          arrayelemtype,
                          typeForm->typlen,
                          typeForm->typbyval,
                          typeForm->typalign,
                          values, NULL, nvalues);

        /*
         * If the element type is pass-by-reference, we now have a bunch of
         * Datums that are pointers into the syscache value.  Copy them to
         * avoid problems if syscache decides to drop the entry.
         */
        if (!typeForm->typbyval)
        {
            for (j = 0; j < *nvalues; j++)
            {
                (*values)[j] = datumCopy((*values)[j],
                                         typeForm->typbyval,
                                         typeForm->typlen);
            }
        }

        ReleaseSysCache(typeTuple);

        /*
         * Free statarray if it's a detoasted copy.
         */
        if ((Pointer) statarray != DatumGetPointer(val))
            pfree(statarray);
    }

    if (numbers)
    {
        val = SysCacheGetAttr(STATRELATTINH, statstuple,
                              Anum_pg_statistic_stanumbers1 + i,
                              &isnull);
        if (isnull)
            elog(ERROR, "stanumbers is null");
        statarray = DatumGetArrayTypeP(val);

        /*
         * We expect the array to be a 1-D float4 array; verify that. We don't
         * need to use deconstruct_array() since the array data is just going
         * to look like a C array of float4 values.
         */
        narrayelem = ARR_DIMS(statarray)[0];
        if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
            ARR_HASNULL(statarray) ||
            ARR_ELEMTYPE(statarray) != FLOAT4OID)
            elog(ERROR, "stanumbers is not a 1-D float4 array");
        *numbers = (float4 *) palloc(narrayelem * sizeof(float4));
        memcpy(*numbers, ARR_DATA_PTR(statarray), narrayelem * sizeof(float4));
        *nnumbers = narrayelem;

        /*
         * Free statarray if it's a detoasted copy.
         */
        if ((Pointer) statarray != DatumGetPointer(val))
            pfree(statarray);
    }

    return true;
}

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 898 of file lsyscache.c.

References ATTNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2.

Referenced by generateClonedIndexStmt(), and LookupTypeName().

{
    HeapTuple   tp;

    tp = SearchSysCache2(ATTNUM,
                         ObjectIdGetDatum(relid),
                         Int16GetDatum(attnum));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
        Oid         result;

        result = att_tup->atttypid;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

void get_atttypetypmodcoll ( Oid  relid,
AttrNumber  attnum,
Oid typid,
int32 typmod,
Oid collid 
)

Definition at line 955 of file lsyscache.c.

References ATTNUM, elog, ERROR, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2.

Referenced by pg_get_indexdef_worker(), and transformAssignmentIndirection().

{
    HeapTuple   tp;
    Form_pg_attribute att_tup;

    tp = SearchSysCache2(ATTNUM,
                         ObjectIdGetDatum(relid),
                         Int16GetDatum(attnum));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for attribute %d of relation %u",
             attnum, relid);
    att_tup = (Form_pg_attribute) GETSTRUCT(tp);

    *typid = att_tup->atttypid;
    *typmod = att_tup->atttypmod;
    *collid = att_tup->attcollation;
    ReleaseSysCache(tp);
}

int32 get_atttypmod ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 925 of file lsyscache.c.

References ATTNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2.

{
    HeapTuple   tp;

    tp = SearchSysCache2(ATTNUM,
                         ObjectIdGetDatum(relid),
                         Int16GetDatum(attnum));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp);
        int32       result;

        result = att_tup->atttypmod;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return -1;
}

Oid get_base_element_type ( Oid  typid  ) 

Definition at line 2404 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, TYPEOID, and TYPTYPE_DOMAIN.

Referenced by array_typanalyze(), arraycontsel(), cache_array_element_properties(), find_coercion_pathway(), get_call_expr_argtype(), get_rule_expr(), make_scalar_array_op(), plperl_hash_from_tuple(), and scalararraysel().

{
    /*
     * We loop to find the bottom base type in a stack of domains.
     */
    for (;;)
    {
        HeapTuple   tup;
        Form_pg_type typTup;

        tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
        if (!HeapTupleIsValid(tup))
            break;
        typTup = (Form_pg_type) GETSTRUCT(tup);
        if (typTup->typtype != TYPTYPE_DOMAIN)
        {
            /* Not a domain, so stop descending */
            Oid         result;

            /* This test must match get_element_type */
            if (typTup->typlen == -1)
                result = typTup->typelem;
            else
                result = InvalidOid;
            ReleaseSysCache(tup);
            return result;
        }

        typid = typTup->typbasetype;
        ReleaseSysCache(tup);
    }

    /* Like get_element_type, silently return InvalidOid for bogus input */
    return InvalidOid;
}

char* get_collation_name ( Oid  colloid  ) 

Definition at line 987 of file lsyscache.c.

References COLLOID, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1.

Referenced by analyzeCTE(), assign_collations_walker(), ATExecAddColumn(), MergeAttributes(), and select_common_collation().

{
    HeapTuple   tp;

    tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_collation colltup = (Form_pg_collation) GETSTRUCT(tp);
        char       *result;

        result = pstrdup(NameStr(colltup->collname));
        ReleaseSysCache(tp);
        return result;
    }
    else
        return NULL;
}

Oid get_commutator ( Oid  opno  ) 
bool get_compatible_hash_operators ( Oid  opno,
Oid lhs_opno,
Oid rhs_opno 
)

Definition at line 459 of file lsyscache.c.

References AMOPOPID, get_opfamily_member(), GETSTRUCT, HASH_AM_OID, HTEqualStrategyNumber, i, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by create_unique_plan(), and ExecInitSubPlan().

{
    bool        result = false;
    CatCList   *catlist;
    int         i;

    /* Ensure output args are initialized on failure */
    if (lhs_opno)
        *lhs_opno = InvalidOid;
    if (rhs_opno)
        *rhs_opno = InvalidOid;

    /*
     * Search pg_amop to see if the target operator is registered as the "="
     * operator of any hash opfamily.  If the operator is registered in
     * multiple opfamilies, assume we can use any one.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));

    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   tuple = &catlist->members[i]->tuple;
        Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);

        if (aform->amopmethod == HASH_AM_OID &&
            aform->amopstrategy == HTEqualStrategyNumber)
        {
            /* No extra lookup needed if given operator is single-type */
            if (aform->amoplefttype == aform->amoprighttype)
            {
                if (lhs_opno)
                    *lhs_opno = opno;
                if (rhs_opno)
                    *rhs_opno = opno;
                result = true;
                break;
            }

            /*
             * Get the matching single-type operator(s).  Failure probably
             * shouldn't happen --- it implies a bogus opfamily --- but
             * continue looking if so.
             */
            if (lhs_opno)
            {
                *lhs_opno = get_opfamily_member(aform->amopfamily,
                                                aform->amoplefttype,
                                                aform->amoplefttype,
                                                HTEqualStrategyNumber);
                if (!OidIsValid(*lhs_opno))
                    continue;
                /* Matching LHS found, done if caller doesn't want RHS */
                if (!rhs_opno)
                {
                    result = true;
                    break;
                }
            }
            if (rhs_opno)
            {
                *rhs_opno = get_opfamily_member(aform->amopfamily,
                                                aform->amoprighttype,
                                                aform->amoprighttype,
                                                HTEqualStrategyNumber);
                if (!OidIsValid(*rhs_opno))
                {
                    /* Forget any LHS operator from this opfamily */
                    if (lhs_opno)
                        *lhs_opno = InvalidOid;
                    continue;
                }
                /* Matching RHS found, so done */
                result = true;
                break;
            }
        }
    }

    ReleaseSysCacheList(catlist);

    return result;
}

char* get_constraint_name ( Oid  conoid  ) 

Definition at line 1017 of file lsyscache.c.

References CONSTROID, GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1.

Referenced by report_triggers().

{
    HeapTuple   tp;

    tp = SearchSysCache1(CONSTROID, ObjectIdGetDatum(conoid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_constraint contup = (Form_pg_constraint) GETSTRUCT(tp);
        char       *result;

        result = pstrdup(NameStr(contup->conname));
        ReleaseSysCache(tp);
        return result;
    }
    else
        return NULL;
}

Oid get_element_type ( Oid  typid  ) 
Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 316 of file lsyscache.c.

References BTEqualStrategyNumber, get_opfamily_member(), and get_ordering_op_properties().

Referenced by addTargetToSortList(), create_unique_plan(), and preprocess_minmax_aggregates().

{
    Oid         result = InvalidOid;
    Oid         opfamily;
    Oid         opcintype;
    int16       strategy;

    /* Find the operator in pg_amop */
    if (get_ordering_op_properties(opno,
                                   &opfamily, &opcintype, &strategy))
    {
        /* Found a suitable opfamily, get matching equality operator */
        result = get_opfamily_member(opfamily,
                                     opcintype,
                                     opcintype,
                                     BTEqualStrategyNumber);
        if (reverse)
            *reverse = (strategy == BTGreaterStrategyNumber);
    }

    return result;
}

float4 get_func_cost ( Oid  funcid  ) 

Definition at line 1576 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by cost_qual_eval_walker(), cost_windowagg(), and count_agg_clauses_walker().

{
    HeapTuple   tp;
    float4      result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    result = ((Form_pg_proc) GETSTRUCT(tp))->procost;
    ReleaseSysCache(tp);
    return result;
}

bool get_func_leakproof ( Oid  funcid  ) 

Definition at line 1557 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by contain_leaky_functions_walker().

{
    HeapTuple   tp;
    bool        result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
    ReleaseSysCache(tp);
    return result;
}

char* get_func_name ( Oid  funcid  ) 
Oid get_func_namespace ( Oid  funcid  ) 

Definition at line 1409 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by sepgsql_proc_drop().

{
    HeapTuple   tp;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
        Oid         result;

        result = functup->pronamespace;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

int get_func_nargs ( Oid  funcid  ) 

Definition at line 1451 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

{
    HeapTuple   tp;
    int         result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
    ReleaseSysCache(tp);
    return result;
}

bool get_func_retset ( Oid  funcid  ) 

Definition at line 1500 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by make_op(), and make_scalar_array_op().

{
    HeapTuple   tp;
    bool        result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
    ReleaseSysCache(tp);
    return result;
}

Oid get_func_rettype ( Oid  funcid  ) 
float4 get_func_rows ( Oid  funcid  ) 

Definition at line 1595 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by expression_returns_set_rows_walker().

{
    HeapTuple   tp;
    float4      result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    result = ((Form_pg_proc) GETSTRUCT(tp))->prorows;
    ReleaseSysCache(tp);
    return result;
}

Oid get_func_signature ( Oid  funcid,
Oid **  argtypes,
int *  nargs 
)

Definition at line 1473 of file lsyscache.c.

References Assert, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, palloc(), PROCOID, ReleaseSysCache(), and SearchSysCache1.

Referenced by count_agg_clauses_walker(), ExecInitAgg(), and initialize_peragg().

{
    HeapTuple   tp;
    Form_pg_proc procstruct;
    Oid         result;

    tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for function %u", funcid);

    procstruct = (Form_pg_proc) GETSTRUCT(tp);

    result = procstruct->prorettype;
    *nargs = (int) procstruct->pronargs;
    Assert(*nargs == procstruct->proargtypes.dim1);
    *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
    memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));

    ReleaseSysCache(tp);
    return result;
}

List* get_mergejoin_opfamilies ( Oid  opno  ) 

Definition at line 415 of file lsyscache.c.

References AMOPOPID, BTEqualStrategyNumber, BTREE_AM_OID, GETSTRUCT, i, lappend_oid(), catclist::members, catclist::n_members, ObjectIdGetDatum, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by check_mergejoinable(), create_unique_path(), and make_pathkey_from_sortinfo().

{
    List       *result = NIL;
    CatCList   *catlist;
    int         i;

    /*
     * Search pg_amop to see if the target operator is registered as the "="
     * operator of any btree opfamily.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));

    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   tuple = &catlist->members[i]->tuple;
        Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);

        /* must be btree equality */
        if (aform->amopmethod == BTREE_AM_OID &&
            aform->amopstrategy == BTEqualStrategyNumber)
            result = lappend_oid(result, aform->amopfamily);
    }

    ReleaseSysCacheList(catlist);

    return result;
}

char* get_namespace_name ( Oid  nspid  ) 

Definition at line 2885 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NAMESPACEOID, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), and SearchSysCache1.

Referenced by AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterRelationNamespaceInternal(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ApplyExtensionUpdates(), ATExecChangeOwner(), check_TSCurrentConfig(), CheckSetNamespace(), compute_return_type(), copy_heap_data(), CreateConversionCommand(), CreateExtension(), createForeignKeyTriggers(), CreateFunction(), current_schema(), current_schemas(), DefineAggregate(), DefineCollation(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineRange(), DefineTSConfiguration(), DefineTSDictionary(), DefineType(), deparseFuncExpr(), deparseOperatorName(), deparseRelation(), do_analyze_rel(), do_autovacuum(), errdatatype(), errtable(), EventTriggerSQLDropAddObject(), exec_object_restorecon(), ExecAlterExtensionContentsStmt(), execute_extension_script(), ExplainTargetRel(), format_operator_internal(), format_procedure_internal(), format_type_internal(), generate_collation_name(), generate_function_name(), generate_operator_name(), generate_relation_name(), generateClonedIndexStmt(), get_collation(), get_opclass(), get_opclass_name(), get_other_operator(), getObjectDescription(), getObjectIdentity(), getOpFamilyDescription(), getOpFamilyIdentity(), getRelationDescription(), getRelationIdentity(), GetTempNamespaceBackendId(), HandleFunctionRequest(), index_constraint_create(), isAnyTempNamespace(), IsThereCollationInNamespace(), IsThereFunctionInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), lazy_scan_heap(), lazy_vacuum_rel(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), pg_get_functiondef(), pg_get_serial_sequence(), pg_identify_object(), plpgsql_exec_trigger(), pltcl_init_load_unknown(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), regclassout(), regconfigout(), regdictionaryout(), regoperout(), regprocout(), ReindexDatabase(), report_namespace_conflict(), ri_add_cast_to(), ri_GenerateQual(), ri_GenerateQualCollation(), schema_to_xml_internal(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), SPI_getnspname(), transformColumnDefinition(), and transformCreateStmt().

{
    HeapTuple   tp;

    tp = SearchSysCache1(NAMESPACEOID, ObjectIdGetDatum(nspid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_namespace nsptup = (Form_pg_namespace) GETSTRUCT(tp);
        char       *result;

        result = pstrdup(NameStr(nsptup->nspname));
        ReleaseSysCache(tp);
        return result;
    }
    else
        return NULL;
}

Oid get_negator ( Oid  opno  ) 

Definition at line 1310 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1.

Referenced by get_btree_test_op(), get_op_btree_interpretation(), negate_clause(), neqjoinsel(), neqsel(), and scalararraysel().

{
    HeapTuple   tp;

    tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
        Oid         result;

        result = optup->oprnegate;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

List* get_op_btree_interpretation ( Oid  opno  ) 

Definition at line 650 of file lsyscache.c.

References AMOPOPID, Assert, BTEqualStrategyNumber, BTREE_AM_OID, get_negator(), GETSTRUCT, i, lappend(), catclist::members, catclist::n_members, NIL, ObjectIdGetDatum, OidIsValid, OpBtreeInterpretation::opfamily_id, OpBtreeInterpretation::oplefttype, OpBtreeInterpretation::oprighttype, palloc(), ReleaseSysCacheList, SearchSysCacheList1, OpBtreeInterpretation::strategy, and catctup::tuple.

Referenced by get_btree_test_op(), and make_row_comparison_op().

{
    List       *result = NIL;
    OpBtreeInterpretation *thisresult;
    CatCList   *catlist;
    int         i;

    /*
     * Find all the pg_amop entries containing the operator.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));

    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   op_tuple = &catlist->members[i]->tuple;
        Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
        StrategyNumber op_strategy;

        /* must be btree */
        if (op_form->amopmethod != BTREE_AM_OID)
            continue;

        /* Get the operator's btree strategy number */
        op_strategy = (StrategyNumber) op_form->amopstrategy;
        Assert(op_strategy >= 1 && op_strategy <= 5);

        thisresult = (OpBtreeInterpretation *)
            palloc(sizeof(OpBtreeInterpretation));
        thisresult->opfamily_id = op_form->amopfamily;
        thisresult->strategy = op_strategy;
        thisresult->oplefttype = op_form->amoplefttype;
        thisresult->oprighttype = op_form->amoprighttype;
        result = lappend(result, thisresult);
    }

    ReleaseSysCacheList(catlist);

    /*
     * If we didn't find any btree opfamily containing the operator, perhaps
     * it is a <> operator.  See if it has a negator that is in an opfamily.
     */
    if (result == NIL)
    {
        Oid         op_negator = get_negator(opno);

        if (OidIsValid(op_negator))
        {
            catlist = SearchSysCacheList1(AMOPOPID,
                                          ObjectIdGetDatum(op_negator));

            for (i = 0; i < catlist->n_members; i++)
            {
                HeapTuple   op_tuple = &catlist->members[i]->tuple;
                Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
                StrategyNumber op_strategy;

                /* must be btree */
                if (op_form->amopmethod != BTREE_AM_OID)
                    continue;

                /* Get the operator's btree strategy number */
                op_strategy = (StrategyNumber) op_form->amopstrategy;
                Assert(op_strategy >= 1 && op_strategy <= 5);

                /* Only consider negators that are = */
                if (op_strategy != BTEqualStrategyNumber)
                    continue;

                /* OK, report it with "strategy" ROWCOMPARE_NE */
                thisresult = (OpBtreeInterpretation *)
                    palloc(sizeof(OpBtreeInterpretation));
                thisresult->opfamily_id = op_form->amopfamily;
                thisresult->strategy = ROWCOMPARE_NE;
                thisresult->oplefttype = op_form->amoplefttype;
                thisresult->oprighttype = op_form->amoprighttype;
                result = lappend(result, thisresult);
            }

            ReleaseSysCacheList(catlist);
        }
    }

    return result;
}

bool get_op_hash_functions ( Oid  opno,
RegProcedure lhs_procno,
RegProcedure rhs_procno 
)

Definition at line 559 of file lsyscache.c.

References AMOPOPID, get_opfamily_proc(), GETSTRUCT, HASH_AM_OID, HASHPROC, HTEqualStrategyNumber, i, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by ExecHashTableCreate(), ExecInitSubPlan(), and execTuplesHashPrepare().

{
    bool        result = false;
    CatCList   *catlist;
    int         i;

    /* Ensure output args are initialized on failure */
    if (lhs_procno)
        *lhs_procno = InvalidOid;
    if (rhs_procno)
        *rhs_procno = InvalidOid;

    /*
     * Search pg_amop to see if the target operator is registered as the "="
     * operator of any hash opfamily.  If the operator is registered in
     * multiple opfamilies, assume we can use any one.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));

    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   tuple = &catlist->members[i]->tuple;
        Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);

        if (aform->amopmethod == HASH_AM_OID &&
            aform->amopstrategy == HTEqualStrategyNumber)
        {
            /*
             * Get the matching support function(s).  Failure probably
             * shouldn't happen --- it implies a bogus opfamily --- but
             * continue looking if so.
             */
            if (lhs_procno)
            {
                *lhs_procno = get_opfamily_proc(aform->amopfamily,
                                                aform->amoplefttype,
                                                aform->amoplefttype,
                                                HASHPROC);
                if (!OidIsValid(*lhs_procno))
                    continue;
                /* Matching LHS found, done if caller doesn't want RHS */
                if (!rhs_procno)
                {
                    result = true;
                    break;
                }
                /* Only one lookup needed if given operator is single-type */
                if (aform->amoplefttype == aform->amoprighttype)
                {
                    *rhs_procno = *lhs_procno;
                    result = true;
                    break;
                }
            }
            if (rhs_procno)
            {
                *rhs_procno = get_opfamily_proc(aform->amopfamily,
                                                aform->amoprighttype,
                                                aform->amoprighttype,
                                                HASHPROC);
                if (!OidIsValid(*rhs_procno))
                {
                    /* Forget any LHS function from this opfamily */
                    if (lhs_procno)
                        *lhs_procno = InvalidOid;
                    continue;
                }
                /* Matching RHS found, so done */
                result = true;
                break;
            }
        }
    }

    ReleaseSysCacheList(catlist);

    return result;
}

void get_op_opfamily_properties ( Oid  opno,
Oid  opfamily,
bool  ordering_op,
int *  strategy,
Oid lefttype,
Oid righttype 
)

Definition at line 129 of file lsyscache.c.

References AMOP_ORDER, AMOP_SEARCH, AMOPOPID, CharGetDatum, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache3.

Referenced by adjust_rowcompare_for_index(), ExecIndexBuildScanKeys(), ExecInitExpr(), gincost_pattern(), mergejoinscansel(), and MJExamineQuals().

{
    HeapTuple   tp;
    Form_pg_amop amop_tup;

    tp = SearchSysCache3(AMOPOPID,
                         ObjectIdGetDatum(opno),
                         CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
                         ObjectIdGetDatum(opfamily));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "operator %u is not a member of opfamily %u",
             opno, opfamily);
    amop_tup = (Form_pg_amop) GETSTRUCT(tp);
    *strategy = amop_tup->amopstrategy;
    *lefttype = amop_tup->amoplefttype;
    *righttype = amop_tup->amoprighttype;
    ReleaseSysCache(tp);
}

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 101 of file lsyscache.c.

References AMOP_ORDER, AMOPOPID, CharGetDatum, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache3.

Referenced by match_clause_to_ordering_op().

{
    HeapTuple   tp;
    Form_pg_amop amop_tup;
    Oid         result;

    tp = SearchSysCache3(AMOPOPID,
                         ObjectIdGetDatum(opno),
                         CharGetDatum(AMOP_ORDER),
                         ObjectIdGetDatum(opfamily));
    if (!HeapTupleIsValid(tp))
        return InvalidOid;
    amop_tup = (Form_pg_amop) GETSTRUCT(tp);
    result = amop_tup->amopsortfamily;
    ReleaseSysCache(tp);
    return result;
}

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)
Oid get_opclass_family ( Oid  opclass  ) 

Definition at line 1043 of file lsyscache.c.

References CLAOID, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1.

Referenced by ComputeIndexAttrs(), load_rangetype_info(), and lookup_type_cache().

{
    HeapTuple   tp;
    Form_pg_opclass cla_tup;
    Oid         result;

    tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for opclass %u", opclass);
    cla_tup = (Form_pg_opclass) GETSTRUCT(tp);

    result = cla_tup->opcfamily;
    ReleaseSysCache(tp);
    return result;
}

Oid get_opclass_input_type ( Oid  opclass  ) 

Definition at line 1065 of file lsyscache.c.

References CLAOID, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache1.

Referenced by CheckIndexCompatible(), findRangeSubOpclass(), load_rangetype_info(), and lookup_type_cache().

{
    HeapTuple   tp;
    Form_pg_opclass cla_tup;
    Oid         result;

    tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for opclass %u", opclass);
    cla_tup = (Form_pg_opclass) GETSTRUCT(tp);

    result = cla_tup->opcintype;
    ReleaseSysCache(tp);
    return result;
}

RegProcedure get_opcode ( Oid  opno  ) 
Oid get_opfamily_member ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  strategy 
)
Oid get_opfamily_proc ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  procnum 
)
char* get_opname ( Oid  opno  ) 

Definition at line 1115 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, OPEROID, pstrdup(), ReleaseSysCache(), and SearchSysCache1.

Referenced by AlterOpFamilyAdd(), DefineOpClass(), and print_expr().

{
    HeapTuple   tp;

    tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
        char       *result;

        result = pstrdup(NameStr(optup->oprname));
        ReleaseSysCache(tp);
        return result;
    }
    else
        return NULL;
}

RegProcedure get_oprjoin ( Oid  opno  ) 

Definition at line 1358 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1.

Referenced by join_selectivity(), and scalararraysel().

{
    HeapTuple   tp;

    tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
        RegProcedure result;

        result = optup->oprjoin;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return (RegProcedure) InvalidOid;
}

RegProcedure get_oprrest ( Oid  opno  ) 

Definition at line 1334 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1.

Referenced by clauselist_selectivity(), restriction_selectivity(), and scalararraysel().

{
    HeapTuple   tp;

    tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
        RegProcedure result;

        result = optup->oprrest;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return (RegProcedure) InvalidOid;
}

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 354 of file lsyscache.c.

References AMOPOPID, BTEqualStrategyNumber, BTLessStrategyNumber, BTREE_AM_OID, get_opfamily_member(), GETSTRUCT, i, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by create_unique_plan().

{
    Oid         result = InvalidOid;
    CatCList   *catlist;
    int         i;

    /*
     * Search pg_amop to see if the target operator is registered as the "="
     * operator of any btree opfamily.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));

    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   tuple = &catlist->members[i]->tuple;
        Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);

        /* must be btree */
        if (aform->amopmethod != BTREE_AM_OID)
            continue;

        if (aform->amopstrategy == BTEqualStrategyNumber)
        {
            /* Found a suitable opfamily, get matching ordering operator */
            Oid         typid;

            typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
            result = get_opfamily_member(aform->amopfamily,
                                         typid, typid,
                                         BTLessStrategyNumber);
            if (OidIsValid(result))
                break;
            /* failure probably shouldn't happen, but keep looking if so */
        }
    }

    ReleaseSysCacheList(catlist);

    return result;
}

bool get_ordering_op_properties ( Oid  opno,
Oid opfamily,
Oid opcintype,
int16 strategy 
)

Definition at line 200 of file lsyscache.c.

References AMOPOPID, BTGreaterStrategyNumber, BTLessStrategyNumber, BTREE_AM_OID, GETSTRUCT, i, catclist::members, catclist::n_members, ObjectIdGetDatum, ReleaseSysCacheList, SearchSysCacheList1, and catctup::tuple.

Referenced by get_equality_op_for_ordering_op(), get_relation_info(), get_sort_function_for_ordering_op(), and make_pathkey_from_sortop().

{
    bool        result = false;
    CatCList   *catlist;
    int         i;

    /* ensure outputs are initialized on failure */
    *opfamily = InvalidOid;
    *opcintype = InvalidOid;
    *strategy = 0;

    /*
     * Search pg_amop to see if the target operator is registered as the "<"
     * or ">" operator of any btree opfamily.
     */
    catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno));

    for (i = 0; i < catlist->n_members; i++)
    {
        HeapTuple   tuple = &catlist->members[i]->tuple;
        Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);

        /* must be btree */
        if (aform->amopmethod != BTREE_AM_OID)
            continue;

        if (aform->amopstrategy == BTLessStrategyNumber ||
            aform->amopstrategy == BTGreaterStrategyNumber)
        {
            /* Found it ... should have consistent input types */
            if (aform->amoplefttype == aform->amoprighttype)
            {
                /* Found a suitable opfamily, return info */
                *opfamily = aform->amopfamily;
                *opcintype = aform->amoplefttype;
                *strategy = aform->amopstrategy;
                result = true;
                break;
            }
        }
    }

    ReleaseSysCacheList(catlist);

    return result;
}

Oid get_range_subtype ( Oid  rangeOid  ) 

Definition at line 2912 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, RANGETYPE, ReleaseSysCache(), and SearchSysCache1.

Referenced by check_generic_type_consistency(), enforce_generic_type_consistency(), and resolve_generic_type().

{
    HeapTuple   tp;

    tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
        Oid         result;

        result = rngtup->rngsubtype;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

char* get_rel_name ( Oid  relid  ) 
Oid get_rel_namespace ( Oid  relid  ) 

Definition at line 1685 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1.

Referenced by check_relation_privileges(), do_autovacuum(), exec_object_restorecon(), ExecCheckXactReadOnly(), ReindexDatabase(), and sepgsql_relation_drop().

{
    HeapTuple   tp;

    tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
        Oid         result;

        result = reltup->relnamespace;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

char get_rel_relkind ( Oid  relid  ) 
Oid get_rel_tablespace ( Oid  relid  ) 

Definition at line 1763 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1.

Referenced by pg_get_constraintdef_worker(), and pg_get_indexdef_worker().

{
    HeapTuple   tp;

    tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
        Oid         result;

        result = reltup->reltablespace;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

Oid get_rel_type_id ( Oid  relid  ) 

Definition at line 1712 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1.

Referenced by makeWholeRowVar(), plpgsql_parse_cwordrowtype(), and plpgsql_parse_wordrowtype().

{
    HeapTuple   tp;

    tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
        Oid         result;

        result = reltup->reltype;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

char* get_relid_attribute_name ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 853 of file lsyscache.c.

References elog, ERROR, get_attname(), and NULL.

Referenced by decompile_column_index_array(), deparseColumnRef(), errtablecol(), generateClonedIndexStmt(), get_insert_query_def(), get_rte_attribute_name(), get_update_query_def(), getObjectDescription(), getObjectIdentity(), make_ruledef(), pg_get_indexdef_worker(), pg_get_triggerdef_worker(), and processIndirection().

{
    char       *attname;

    attname = get_attname(relid, attnum);
    if (attname == NULL)
        elog(ERROR, "cache lookup failed for attribute %d of relation %u",
             attnum, relid);
    return attname;
}

Oid get_relname_relid ( const char *  relname,
Oid  relnamespace 
)
bool get_sort_function_for_ordering_op ( Oid  opno,
Oid sortfunc,
bool issupport,
bool reverse 
)

Definition at line 263 of file lsyscache.c.

References BTORDER_PROC, BTSORTSUPPORT_PROC, elog, ERROR, get_opfamily_proc(), get_ordering_op_properties(), and OidIsValid.

Referenced by PrepareSortSupportFromOrderingOp().

{
    Oid         opfamily;
    Oid         opcintype;
    int16       strategy;

    /* Find the operator in pg_amop */
    if (get_ordering_op_properties(opno,
                                   &opfamily, &opcintype, &strategy))
    {
        /* Found a suitable opfamily, get matching support function */
        *sortfunc = get_opfamily_proc(opfamily,
                                      opcintype,
                                      opcintype,
                                      BTSORTSUPPORT_PROC);
        if (OidIsValid(*sortfunc))
            *issupport = true;
        else
        {
            /* opfamily doesn't provide sort support, get comparison func */
            *sortfunc = get_opfamily_proc(opfamily,
                                          opcintype,
                                          opcintype,
                                          BTORDER_PROC);
            if (!OidIsValid(*sortfunc)) /* should not happen */
                elog(ERROR, "missing support function %d(%u,%u) in opfamily %u",
                     BTORDER_PROC, opcintype, opcintype, opfamily);
            *issupport = false;
        }
        *reverse = (strategy == BTGreaterStrategyNumber);
        return true;
    }

    /* ensure outputs are set on failure */
    *sortfunc = InvalidOid;
    *issupport = false;
    *reverse = false;
    return false;
}

Oid get_typ_typrelid ( Oid  typid  ) 

Definition at line 2325 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by CheckAttributeType(), and processIndirection().

{
    HeapTuple   tp;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
        Oid         result;

        result = typtup->typrelid;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2196 of file lsyscache.c.

References BPCHAROID, get_typlen(), and type_maximum_size().

Referenced by count_agg_clauses_walker(), find_placeholder_info(), get_rel_data_width(), set_append_rel_size(), and set_rel_width().

{
    int         typlen = get_typlen(typid);
    int32       maxwidth;

    /*
     * Easy if it's a fixed-width type
     */
    if (typlen > 0)
        return typlen;

    /*
     * type_maximum_size knows the encoding of typmod for some datatypes;
     * don't duplicate that knowledge here.
     */
    maxwidth = type_maximum_size(typid, typmod);
    if (maxwidth > 0)
    {
        /*
         * For BPCHAR, the max width is also the only width.  Otherwise we
         * need to guess about the typical data width given the max. A sliding
         * scale for percentage of max width seems reasonable.
         */
        if (typid == BPCHAROID)
            return maxwidth;
        if (maxwidth <= 32)
            return maxwidth;    /* assume full width */
        if (maxwidth < 1000)
            return 32 + (maxwidth - 32) / 2;    /* assume 50% */

        /*
         * Beyond 1000, assume we're looking at something like
         * "varchar(10000)" where the limit isn't actually reached often, and
         * use a fixed estimate.
         */
        return 32 + (1000 - 32) / 2;
    }

    /*
     * Ooops, we have no idea ... wild guess time.
     */
    return 32;
}

bool get_typbyval ( Oid  typid  ) 

Definition at line 1840 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by count_agg_clauses_walker(), and free_attstatsslot().

{
    HeapTuple   tp;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
        bool        result;

        result = typtup->typbyval;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return false;
}

Oid get_typcollation ( Oid  typid  ) 
Node* get_typdefault ( Oid  typid  ) 

Definition at line 2066 of file lsyscache.c.

References Anum_pg_type_typdefault, Anum_pg_type_typdefaultbin, elog, ERROR, GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, makeConst(), ObjectIdGetDatum, OidInputFunctionCall(), pfree(), ReleaseSysCache(), SearchSysCache1, stringToNode(), SysCacheGetAttr(), TextDatumGetCString, and TYPEOID.

Referenced by build_column_default().

{
    HeapTuple   typeTuple;
    Form_pg_type type;
    Datum       datum;
    bool        isNull;
    Node       *expr;

    typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (!HeapTupleIsValid(typeTuple))
        elog(ERROR, "cache lookup failed for type %u", typid);
    type = (Form_pg_type) GETSTRUCT(typeTuple);

    /*
     * typdefault and typdefaultbin are potentially null, so don't try to
     * access 'em as struct fields. Must do it the hard way with
     * SysCacheGetAttr.
     */
    datum = SysCacheGetAttr(TYPEOID,
                            typeTuple,
                            Anum_pg_type_typdefaultbin,
                            &isNull);

    if (!isNull)
    {
        /* We have an expression default */
        expr = stringToNode(TextDatumGetCString(datum));
    }
    else
    {
        /* Perhaps we have a plain literal default */
        datum = SysCacheGetAttr(TYPEOID,
                                typeTuple,
                                Anum_pg_type_typdefault,
                                &isNull);

        if (!isNull)
        {
            char       *strDefaultVal;

            /* Convert text datum to C string */
            strDefaultVal = TextDatumGetCString(datum);
            /* Convert C string to a value of the given type */
            datum = OidInputFunctionCall(type->typinput, strDefaultVal,
                                         getTypeIOParam(typeTuple), -1);
            /* Build a Const node containing the value */
            expr = (Node *) makeConst(typid,
                                      -1,
                                      type->typcollation,
                                      type->typlen,
                                      datum,
                                      false,
                                      type->typbyval);
            pfree(strDefaultVal);
        }
        else
        {
            /* No default */
            expr = NULL;
        }
    }

    ReleaseSysCache(typeTuple);

    return expr;
}

void get_type_category_preferred ( Oid  typid,
char *  typcategory,
bool typispreferred 
)

Definition at line 2304 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by func_select_candidate(), IsPreferredType(), select_common_type(), and TypeCategory().

{
    HeapTuple   tp;
    Form_pg_type typtup;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (!HeapTupleIsValid(tp))
        elog(ERROR, "cache lookup failed for type %u", typid);
    typtup = (Form_pg_type) GETSTRUCT(tp);
    *typcategory = typtup->typcategory;
    *typispreferred = typtup->typispreferred;
    ReleaseSysCache(tp);
}

void get_type_io_data ( Oid  typid,
IOFuncSelector  which_func,
int16 typlen,
bool typbyval,
char *  typalign,
char *  typdelim,
Oid typioparam,
Oid func 
)

Definition at line 1943 of file lsyscache.c.

References boot_get_type_io_data(), elog, ERROR, GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, IOFunc_input, IOFunc_output, IOFunc_receive, IOFunc_send, IsBootstrapProcessingMode, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by array_in(), array_out(), array_recv(), array_send(), array_to_json_internal(), array_to_text_internal(), get_range_io_data(), plperl_ref_from_pg_array(), PLy_input_datum_func2(), and PLy_output_datum_func2().

{
    HeapTuple   typeTuple;
    Form_pg_type typeStruct;

    /*
     * In bootstrap mode, pass it off to bootstrap.c.  This hack allows us to
     * use array_in and array_out during bootstrap.
     */
    if (IsBootstrapProcessingMode())
    {
        Oid         typinput;
        Oid         typoutput;

        boot_get_type_io_data(typid,
                              typlen,
                              typbyval,
                              typalign,
                              typdelim,
                              typioparam,
                              &typinput,
                              &typoutput);
        switch (which_func)
        {
            case IOFunc_input:
                *func = typinput;
                break;
            case IOFunc_output:
                *func = typoutput;
                break;
            default:
                elog(ERROR, "binary I/O not supported during bootstrap");
                break;
        }
        return;
    }

    typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (!HeapTupleIsValid(typeTuple))
        elog(ERROR, "cache lookup failed for type %u", typid);
    typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);

    *typlen = typeStruct->typlen;
    *typbyval = typeStruct->typbyval;
    *typalign = typeStruct->typalign;
    *typdelim = typeStruct->typdelim;
    *typioparam = getTypeIOParam(typeTuple);
    switch (which_func)
    {
        case IOFunc_input:
            *func = typeStruct->typinput;
            break;
        case IOFunc_output:
            *func = typeStruct->typoutput;
            break;
        case IOFunc_receive:
            *func = typeStruct->typreceive;
            break;
        case IOFunc_send:
            *func = typeStruct->typsend;
            break;
    }
    ReleaseSysCache(typeTuple);
}

bool get_typisdefined ( Oid  typid  ) 

Definition at line 1791 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by DefineRange(), DefineType(), and moveArrayTypeName().

{
    HeapTuple   tp;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
        bool        result;

        result = typtup->typisdefined;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return false;
}

int16 get_typlen ( Oid  typid  ) 

Definition at line 1815 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by exec_assign_value(), ExecInitExpr(), get_typavgwidth(), and pg_column_size().

{
    HeapTuple   tp;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
        int16       result;

        result = typtup->typlen;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return 0;
}

void get_typlenbyval ( Oid  typid,
int16 typlen,
bool typbyval 
)
void get_typlenbyvalalign ( Oid  typid,
int16 typlen,
bool typbyval,
char *  typalign 
)
Oid get_typmodin ( Oid  typid  ) 

Definition at line 2578 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

{
    HeapTuple   tp;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
        Oid         result;

        result = typtup->typmodin;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return InvalidOid;
}

char get_typstorage ( Oid  typid  ) 

Definition at line 2037 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

{
    HeapTuple   tp;

    tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
    if (HeapTupleIsValid(tp))
    {
        Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
        char        result;

        result = typtup->typstorage;
        ReleaseSysCache(tp);
        return result;
    }
    else
        return 'p';
}

char get_typtype ( Oid  typid  ) 
Oid getBaseType ( Oid  typid  ) 
Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2156 of file lsyscache.c.

References Assert, elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, TYPEOID, and TYPTYPE_DOMAIN.

Referenced by ATExecAddColumn(), coerce_to_domain(), coerce_type(), domain_state_setup(), exec_assign_value(), getBaseType(), map_sql_type_to_xmlschema_type(), SendRowDescriptionMessage(), transformArrayType(), and transformExprRecurse().

{
    /*
     * We loop to find the bottom base type in a stack of domains.
     */
    for (;;)
    {
        HeapTuple   tup;
        Form_pg_type typTup;

        tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
        if (!HeapTupleIsValid(tup))
            elog(ERROR, "cache lookup failed for type %u", typid);
        typTup = (Form_pg_type) GETSTRUCT(tup);
        if (typTup->typtype != TYPTYPE_DOMAIN)
        {
            /* Not a domain, so done */
            ReleaseSysCache(tup);
            break;
        }

        Assert(*typmod == -1);
        typid = typTup->typbasetype;
        *typmod = typTup->typtypmod;

        ReleaseSysCache(tup);
    }

    return typid;
}

void getTypeBinaryInputInfo ( Oid  type,
Oid typReceive,
Oid typIOParam 
)

Definition at line 2512 of file lsyscache.c.

References elog, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, ObjectIdGetDatum, OidIsValid, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by BeginCopyFrom(), domain_state_setup(), exec_bind_message(), parse_fcall_arguments(), parse_fcall_arguments_20(), and record_recv().

{
    HeapTuple   typeTuple;
    Form_pg_type pt;

    typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
    if (!HeapTupleIsValid(typeTuple))
        elog(ERROR, "cache lookup failed for type %u", type);
    pt = (Form_pg_type) GETSTRUCT(typeTuple);

    if (!pt->typisdefined)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("type %s is only a shell",
                        format_type_be(type))));
    if (!OidIsValid(pt->typreceive))
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_FUNCTION),
                 errmsg("no binary input function available for type %s",
                        format_type_be(type))));

    *typReceive = pt->typreceive;
    *typIOParam = getTypeIOParam(typeTuple);

    ReleaseSysCache(typeTuple);
}

void getTypeBinaryOutputInfo ( Oid  type,
Oid typSend,
bool typIsVarlena 
)

Definition at line 2545 of file lsyscache.c.

References elog, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OidIsValid, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by CopyTo(), printtup_prepare_info(), record_send(), and SendFunctionResult().

{
    HeapTuple   typeTuple;
    Form_pg_type pt;

    typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
    if (!HeapTupleIsValid(typeTuple))
        elog(ERROR, "cache lookup failed for type %u", type);
    pt = (Form_pg_type) GETSTRUCT(typeTuple);

    if (!pt->typisdefined)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("type %s is only a shell",
                        format_type_be(type))));
    if (!OidIsValid(pt->typsend))
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_FUNCTION),
                 errmsg("no binary output function available for type %s",
                        format_type_be(type))));

    *typSend = pt->typsend;
    *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);

    ReleaseSysCache(typeTuple);
}

void getTypeInputInfo ( Oid  type,
Oid typInput,
Oid typIOParam 
)
Oid getTypeIOParam ( HeapTuple  typeTuple  ) 

Definition at line 1921 of file lsyscache.c.

References GETSTRUCT, HeapTupleGetOid, and OidIsValid.

Referenced by build_datatype(), compile_plperl_function(), compile_pltcl_function(), do_compile(), get_typdefault(), get_type_io_data(), getTypeBinaryInputInfo(), getTypeInputInfo(), pltcl_trigger_handler(), PLy_input_datum_func2(), PLy_output_datum_func2(), and stringTypeDatum().

{
    Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);

    /*
     * Array types get their typelem as parameter; everybody else gets their
     * own type OID as parameter.
     */
    if (OidIsValid(typeStruct->typelem))
        return typeStruct->typelem;
    else
        return HeapTupleGetOid(typeTuple);
}

void getTypeOutputInfo ( Oid  type,
Oid typOutput,
bool typIsVarlena 
)

Definition at line 2479 of file lsyscache.c.

References elog, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OidIsValid, ReleaseSysCache(), SearchSysCache1, and TYPEOID.

Referenced by BuildIndexValueDescription(), composite_to_json(), concat_internal(), contain_leaky_functions_walker(), contain_mutable_functions_walker(), contain_volatile_functions_walker(), convert_value_to_string(), CopyTo(), cost_qual_eval_walker(), debugtup(), deparseConst(), errdetail_params(), eval_const_expressions_mutator(), ExecBuildSlotValueDescription(), ExecInitExpr(), get_const_expr(), hstore_from_record(), json_agg_transfn(), map_sql_value_to_xml_value(), plperl_hash_from_tuple(), plperl_sv_to_literal(), postgresBeginForeignModify(), postgresBeginForeignScan(), print_expr(), printtup_prepare_info(), record_out(), SendFunctionResult(), SPI_getvalue(), text_format(), and to_json().

{
    HeapTuple   typeTuple;
    Form_pg_type pt;

    typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
    if (!HeapTupleIsValid(typeTuple))
        elog(ERROR, "cache lookup failed for type %u", type);
    pt = (Form_pg_type) GETSTRUCT(typeTuple);

    if (!pt->typisdefined)
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_OBJECT),
                 errmsg("type %s is only a shell",
                        format_type_be(type))));
    if (!OidIsValid(pt->typoutput))
        ereport(ERROR,
                (errcode(ERRCODE_UNDEFINED_FUNCTION),
                 errmsg("no output function available for type %s",
                        format_type_be(type))));

    *typOutput = pt->typoutput;
    *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);

    ReleaseSysCache(typeTuple);
}

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1219 of file lsyscache.c.

References ARRAY_EQ_OP, GETSTRUCT, TypeCacheEntry::hash_proc, HeapTupleIsValid, lookup_type_cache(), ObjectIdGetDatum, OPEROID, ReleaseSysCache(), SearchSysCache1, and TYPECACHE_HASH_PROC.

Referenced by addTargetToSortList(), check_hashjoinable(), create_unique_path(), generate_join_implied_equalities_normal(), and hash_ok_operator().

{
    bool        result = false;
    HeapTuple   tp;
    TypeCacheEntry *typentry;

    /* As in op_mergejoinable, let the typcache handle the hard cases */
    /* Eventually we'll need a similar case for record_eq ... */
    if (opno == ARRAY_EQ_OP)
    {
        typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
        if (typentry->hash_proc == F_HASH_ARRAY)
            result = true;
    }
    else
    {
        /* For all other operators, rely on pg_operator.oprcanhash */
        tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
        if (HeapTupleIsValid(tp))
        {
            Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);

            result = optup->oprcanhash;
            ReleaseSysCache(tp);
        }
    }
    return result;
}

bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)
void op_input_types ( Oid  opno,
Oid lefttype,
Oid righttype 
)

Definition at line 1140 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1.

Referenced by CheckIndexCompatible(), initialize_mergeclause_eclasses(), process_equivalence(), reconsider_full_join_clause(), reconsider_outer_join_clause(), and ri_HashCompareOp().

{
    HeapTuple   tp;
    Form_pg_operator optup;

    tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
    if (!HeapTupleIsValid(tp))  /* shouldn't happen */
        elog(ERROR, "cache lookup failed for operator %u", opno);
    optup = (Form_pg_operator) GETSTRUCT(tp);
    *lefttype = optup->oprleft;
    *righttype = optup->oprright;
    ReleaseSysCache(tp);
}

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1168 of file lsyscache.c.

References ARRAY_EQ_OP, TypeCacheEntry::cmp_proc, GETSTRUCT, HeapTupleIsValid, lookup_type_cache(), ObjectIdGetDatum, OPEROID, RECORD_EQ_OP, ReleaseSysCache(), SearchSysCache1, and TYPECACHE_CMP_PROC.

Referenced by check_mergejoinable(), and create_unique_path().

{
    bool        result = false;
    HeapTuple   tp;
    TypeCacheEntry *typentry;

    /*
     * For array_eq or record_eq, we can sort if the element or field types
     * are all sortable.  We could implement all the checks for that here, but
     * the typcache already does that and caches the results too, so let's
     * rely on the typcache.
     */
    if (opno == ARRAY_EQ_OP)
    {
        typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
        if (typentry->cmp_proc == F_BTARRAYCMP)
            result = true;
    }
    else if (opno == RECORD_EQ_OP)
    {
        typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
        if (typentry->cmp_proc == F_BTRECORDCMP)
            result = true;
    }
    else
    {
        /* For all other operators, rely on pg_operator.oprcanmerge */
        tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno));
        if (HeapTupleIsValid(tp))
        {
            Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);

            result = optup->oprcanmerge;
            ReleaseSysCache(tp);
        }
    }
    return result;
}

bool op_strict ( Oid  opno  ) 

Definition at line 1254 of file lsyscache.c.

References elog, ERROR, func_strict(), get_opcode(), and InvalidOid.

Referenced by ExecHashTableCreate(), predicate_implied_by_simple_clause(), predicate_refuted_by_simple_clause(), and reconsider_outer_join_clause().

{
    RegProcedure funcid = get_opcode(opno);

    if (funcid == (RegProcedure) InvalidOid)
        elog(ERROR, "operator %u does not exist", opno);

    return func_strict((Oid) funcid);
}

char op_volatile ( Oid  opno  ) 

Definition at line 1270 of file lsyscache.c.

References elog, ERROR, func_volatile(), get_opcode(), and InvalidOid.

Referenced by contain_mutable_functions_walker(), contain_volatile_functions_walker(), and get_btree_test_op().

{
    RegProcedure funcid = get_opcode(opno);

    if (funcid == (RegProcedure) InvalidOid)
        elog(ERROR, "operator %u does not exist", opno);

    return func_volatile((Oid) funcid);
}

bool type_is_collatable ( Oid  typid  ) 
bool type_is_enum ( Oid  typid  ) 
bool type_is_range ( Oid  typid  ) 

Definition at line 2292 of file lsyscache.c.

References get_typtype(), and TYPTYPE_RANGE.

Referenced by IsBinaryCoercible().

{
    return (get_typtype(typid) == TYPTYPE_RANGE);
}

bool type_is_rowtype ( Oid  typid  ) 

Variable Documentation

Definition at line 46 of file lsyscache.c.

Referenced by get_attavgwidth().