#include "postgres.h"
#include "access/hash.h"
#include "access/htup_details.h"
#include "access/nbtree.h"
#include "bootstrap/bootstrap.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_range.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_type.h"
#include "miscadmin.h"
#include "nodes/makefuncs.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/catcache.h"
#include "utils/datum.h"
#include "utils/fmgroids.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
#include "utils/typcache.h"
Go to the source code of this file.
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; }
Definition at line 2857 of file lsyscache.c.
References DatumGetPointer, get_typbyval(), i, and pfree().
Referenced by booltestsel(), btcostestimate(), calc_arraycontsel(), 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().
{ if (values) { if (!get_typbyval(atttype)) { int i; for (i = 0; i < nvalues; i++) pfree(DatumGetPointer(values[i])); } pfree(values); } if (numbers) pfree(numbers); }
Definition at line 1519 of file lsyscache.c.
References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.
Referenced by contain_nonstrict_functions_walker(), find_nonnullable_rels_walker(), find_nonnullable_vars_walker(), hash_ok_operator(), is_strict_saop(), op_strict(), predicate_implied_by_simple_clause(), and predicate_refuted_by_simple_clause().
{ 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))->proisstrict; ReleaseSysCache(tp); return result; }
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; }
Definition at line 2380 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by AlterTypeNamespace_oid(), AlterTypeOwner(), build_subplan(), enforce_generic_type_consistency(), exprType(), find_composite_type_dependencies(), LookupTypeName(), make_scalar_array_op(), moveArrayTypeName(), ParseFuncOrColumn(), RenameType(), resolve_generic_type(), transformAExprIn(), and transformArrayExpr().
{ HeapTuple tp; Oid result = InvalidOid; tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { result = ((Form_pg_type) GETSTRUCT(tp))->typarray; ReleaseSysCache(tp); } return result; }
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 | |||
) |
Definition at line 873 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ReleaseSysCache(), and SearchSysCacheAttName().
Referenced by ATExecColumnDefault(), convert_column_name(), expand_col_privileges(), fixup_inherited_columns(), get_object_address_attribute(), LookupTypeName(), pg_get_serial_sequence(), ProcedureCreate(), process_owned_by(), and transformAssignmentIndirection().
{ HeapTuple tp; tp = SearchSysCacheAttName(relid, attname); if (HeapTupleIsValid(tp)) { Form_pg_attribute att_tup = (Form_pg_attribute) GETSTRUCT(tp); AttrNumber result; result = att_tup->attnum; ReleaseSysCache(tp); return result; } else return InvalidAttrNumber; }
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; }
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; }
Definition at line 1286 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1.
Referenced by adjust_rowcompare_for_index(), btcostestimate(), btree_predicate_proof(), CommuteOpExpr(), CommuteRowCompareExpr(), ComputeIndexAttrs(), convert_EXISTS_to_ANY(), create_unique_path(), eqjoinsel(), gincost_opexpr(), is_indexable_operator(), match_clause_to_ordering_op(), match_rowcompare_to_indexcol(), and targetIsInSortList().
{ HeapTuple tp; tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); Oid result; result = optup->oprcom; ReleaseSysCache(tp); return result; } else return InvalidOid; }
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; }
Definition at line 2352 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by aclcheck_error_type(), AlterTypeNamespace_oid(), array_push(), check_generic_type_consistency(), CheckAttributeType(), concat_internal(), CreateCast(), enforce_generic_type_consistency(), examine_parameter_list(), exec_assign_value(), exec_stmt_foreach_a(), ExecInitExpr(), find_coercion_pathway(), is_complex_array(), moveArrayTypeName(), plperl_array_to_datum(), PLy_input_datum_func2(), PLy_output_datum_func2(), PLySequence_ToArray(), ProcedureCreate(), resolve_generic_type(), text_format(), transformArrayExpr(), and transformExprRecurse().
{ HeapTuple tp; tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); Oid result; if (typtup->typlen == -1) result = typtup->typelem; else result = InvalidOid; ReleaseSysCache(tp); return result; } else return InvalidOid; }
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; }
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; }
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 | ) |
Definition at line 1385 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, PROCOID, pstrdup(), ReleaseSysCache(), and SearchSysCache1.
Referenced by AlterOpFamilyAdd(), DefineOpClass(), ExecEvalArrayCoerceExpr(), ExecInitAgg(), ExecInitWindowAgg(), ExplainTargetRel(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), HandleFunctionRequest(), init_fcache(), initialize_peragg(), lookup_agg_function(), and print_expr().
{ HeapTuple tp; tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (HeapTupleIsValid(tp)) { Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp); char *result; result = pstrdup(NameStr(functup->proname)); ReleaseSysCache(tp); return result; } else return NULL; }
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; }
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; }
Definition at line 1432 of file lsyscache.c.
References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), and SearchSysCache1.
Referenced by CreateConversionCommand(), CreateEventTrigger(), CreateProceduralLanguage(), CreateTrigger(), DefineOperator(), DefineType(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeAnalyzeFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), get_ts_parser_func(), get_ts_template_func(), lookup_fdw_handler_func(), and OperatorCreate().
{ HeapTuple tp; Oid result; tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid)); if (!HeapTupleIsValid(tp)) elog(ERROR, "cache lookup failed for function %u", funcid); result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype; ReleaseSysCache(tp); return result; }
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; }
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; }
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; }
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; }
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); }
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; }
Definition at line 76 of file lsyscache.c.
References AMOP_SEARCH, AMOPOPID, CharGetDatum, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache3.
Referenced by adjust_rowcompare_for_index(), btcostestimate(), ComputeIndexAttrs(), get_actual_variable_range(), match_rowcompare_to_indexcol(), and RelationGetExclusionInfo().
{ HeapTuple tp; Form_pg_amop amop_tup; int result; tp = SearchSysCache3(AMOPOPID, ObjectIdGetDatum(opno), CharGetDatum(AMOP_SEARCH), ObjectIdGetDatum(opfamily)); if (!HeapTupleIsValid(tp)) return 0; amop_tup = (Form_pg_amop) GETSTRUCT(tp); result = amop_tup->amopstrategy; ReleaseSysCache(tp); return result; }
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; }
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 | ) |
Definition at line 1090 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), and SearchSysCache1.
Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), AlterOpFamilyAdd(), ComputeIndexAttrs(), contain_leaky_functions_walker(), cost_qual_eval_walker(), DefineOpClass(), eqjoinsel_inner(), eqjoinsel_semi(), ExecInitAgg(), ExecInitSubPlan(), execTuplesHashPrepare(), execTuplesMatchPrepare(), get_expr_result_type(), get_variable_range(), lookup_type_cache(), ltreeparentsel(), op_strict(), op_volatile(), OperatorLookup(), patternsel(), prefix_quals(), prefix_selectivity(), RelationGetExclusionInfo(), ri_HashCompareOp(), scalarineqsel(), set_opfuncid(), set_sa_opfuncid(), std_typanalyze(), and var_eq_const().
{ HeapTuple tp; tp = SearchSysCache1(OPEROID, ObjectIdGetDatum(opno)); if (HeapTupleIsValid(tp)) { Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp); RegProcedure result; result = optup->oprcode; ReleaseSysCache(tp); return result; } else return (RegProcedure) InvalidOid; }
Definition at line 159 of file lsyscache.c.
References AMOPSTRATEGY, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache4.
Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), adjust_rowcompare_for_index(), ATAddForeignKeyConstraint(), btcostestimate(), get_btree_test_op(), get_compatible_hash_operators(), get_equality_op_for_ordering_op(), get_ordering_op_for_equality_op(), get_relation_info(), lookup_type_cache(), make_pathkey_from_sortinfo(), mergejoinscansel(), network_prefix_quals(), patternsel(), prefix_quals(), prefix_selectivity(), prepare_sort_from_pathkeys(), and select_equality_operator().
{ HeapTuple tp; Form_pg_amop amop_tup; Oid result; tp = SearchSysCache4(AMOPSTRATEGY, ObjectIdGetDatum(opfamily), ObjectIdGetDatum(lefttype), ObjectIdGetDatum(righttype), Int16GetDatum(strategy)); if (!HeapTupleIsValid(tp)) return InvalidOid; amop_tup = (Form_pg_amop) GETSTRUCT(tp); result = amop_tup->amopopr; ReleaseSysCache(tp); return result; }
Definition at line 796 of file lsyscache.c.
References AMPROCNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache4.
Referenced by _bt_first(), _bt_sort_array_elements(), _hash_datum2hashkey_type(), ExecIndexBuildScanKeys(), ExecInitExpr(), get_op_hash_functions(), get_sort_function_for_ordering_op(), gincost_pattern(), load_rangetype_info(), lookup_type_cache(), and MJExamineQuals().
{ HeapTuple tp; Form_pg_amproc amproc_tup; RegProcedure result; tp = SearchSysCache4(AMPROCNUM, ObjectIdGetDatum(opfamily), ObjectIdGetDatum(lefttype), ObjectIdGetDatum(righttype), Int16GetDatum(procnum)); if (!HeapTupleIsValid(tp)) return InvalidOid; amproc_tup = (Form_pg_amproc) GETSTRUCT(tp); result = amproc_tup->amproc; ReleaseSysCache(tp); return result; }
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; }
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; }
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; }
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 | ) |
Definition at line 1661 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), RELOID, and SearchSysCache1.
Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_tlist(), AlterTableNamespace(), ATExecChangeOwner(), convert_column_name(), CreateTrigger(), do_autovacuum(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), execCurrentOf(), expand_col_privileges(), explain_get_index_name(), ExplainTargetRel(), get_relation_constraint_oid(), get_relation_name(), get_rewrite_oid(), get_rte_attribute_type(), get_trigger_oid(), gincost_pattern(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_name_id(), heap_truncate_check_FKs(), InsertRule(), LockTableRecurse(), map_sql_schema_to_xmlschema_types(), pg_extension_config_dump(), pg_get_expr(), pg_get_expr_ext(), ReindexDatabase(), RenameConstraintById(), set_rtable_names(), and table_to_xml_internal().
{ HeapTuple tp; tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); char *result; result = pstrdup(NameStr(reltup->relname)); ReleaseSysCache(tp); return result; } else return NULL; }
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 | ) |
Definition at line 1736 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, and SearchSysCache1.
Referenced by AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), check_relation_privileges(), doDeletion(), exec_object_restorecon(), get_constraint_index(), getOwnedSequences(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_id(), has_sequence_privilege_name_name(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), RangeVarCallbackForLockTable(), RangeVarCallbackForReindexIndex(), RangeVarCallbackOwnsTable(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), and sepgsql_relation_setattr().
{ HeapTuple tp; tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); if (HeapTupleIsValid(tp)) { Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); char result; result = reltup->relkind; ReleaseSysCache(tp); return result; } else return '\0'; }
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; }
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; }
Definition at line 1618 of file lsyscache.c.
References GetSysCacheOid2, ObjectIdGetDatum, PointerGetDatum, and RELNAMENSP.
Referenced by AlterRelationNamespaceInternal(), ATExecClusterOn(), ChooseRelationName(), cluster(), heap_create_with_catalog(), index_create(), RangeVarGetAndCheckCreationNamespace(), RangeVarGetRelidExtended(), refnameRangeTblEntry(), RelationIsVisible(), RelnameGetRelid(), RenameRelationInternal(), and transformIndexConstraint().
{ return GetSysCacheOid2(RELNAMENSP, PointerGetDatum(relname), ObjectIdGetDatum(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; }
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; }
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; }
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; }
Definition at line 2628 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by assign_collations_walker(), ATExecAddColumn(), check_sql_fn_retval(), DefineRange(), domainAddConstraint(), fixed_paramref_hook(), get_collation(), get_const_collation(), get_from_clause_coldeflist(), GetColumnDefCollation(), resolve_polymorphic_tupdesc(), sql_fn_make_param(), transformAssignmentSubscripts(), type_is_collatable(), variable_coerce_param_hook(), and variable_paramref_hook().
{ HeapTuple tp; tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); Oid result; result = typtup->typcollation; ReleaseSysCache(tp); return result; } else return InvalidOid; }
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; }
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); }
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; }
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; }
Definition at line 1869 of file lsyscache.c.
References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by copyParamList(), eval_const_expressions_mutator(), evaluate_expr(), exec_eval_using_params(), exec_stmt_block(), ExecInitAgg(), ExecInitWindowAgg(), ExecWindowAgg(), fillTypeDesc(), get_actual_variable_range(), get_variable_range(), init_sql_fcache(), initialize_peragg(), makeNullConst(), scalararraysel(), and tuplesort_begin_datum().
{ 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); *typlen = typtup->typlen; *typbyval = typtup->typbyval; ReleaseSysCache(tp); }
Definition at line 1889 of file lsyscache.c.
References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by _bt_preprocess_array_keys(), accumArrayResult(), array_create_iterator(), array_fill_internal(), array_map(), array_push(), array_unnest(), arrayconst_startup_fn(), create_singleton_array(), CreateCast(), DefineRange(), exec_assign_value(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitExpr(), get_text_array_contents(), ginarrayextract(), gincost_scalararrayopexpr(), ginqueryarrayextract(), map_sql_value_to_xml_value(), scalararraysel(), and text_format().
{ 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); *typlen = typtup->typlen; *typbyval = typtup->typbyval; *typalign = typtup->typalign; ReleaseSysCache(tp); }
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 | ) |
Definition at line 2247 of file lsyscache.c.
References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by AlterTypeNamespace(), check_sql_fn_retval(), CheckAttributeType(), CreateCast(), DefineAggregate(), DefineRange(), DefineType(), fmgr_sql_validator(), get_rels_with_domain(), get_type_func_class(), inline_set_returning_function(), map_sql_type_to_xmlschema_type(), plperl_validator(), plpgsql_validator(), PLyObject_ToBool(), PLyObject_ToBytea(), type_is_enum(), type_is_range(), and type_is_rowtype().
{ HeapTuple tp; tp = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid)); if (HeapTupleIsValid(tp)) { Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp); char result; result = typtup->typtype; ReleaseSysCache(tp); return result; } else return '\0'; }
Definition at line 2139 of file lsyscache.c.
References getBaseTypeAndTypmod().
Referenced by ATAddForeignKeyConstraint(), binary_oper_exact(), check_generic_type_consistency(), CheckAttributeType(), coerce_type(), enforce_generic_type_consistency(), ExecInitExpr(), find_coercion_pathway(), func_select_candidate(), GetDefaultOpClass(), is_expected_type(), is_text_type(), IsBinaryCoercible(), map_sql_typecoll_to_xmlschema_types(), map_sql_value_to_xml_value(), PLy_input_datum_func2(), PLy_output_datum_func2(), resolve_generic_type(), and select_common_type().
{ int32 typmod = -1; return getBaseTypeAndTypmod(typid, &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; }
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); }
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); }
Definition at line 2446 of file lsyscache.c.
References elog, ereport, errcode(), errmsg(), ERROR, format_type_be(), GETSTRUCT, getTypeIOParam(), HeapTupleIsValid, ObjectIdGetDatum, OidIsValid, ReleaseSysCache(), SearchSysCache1, and TYPEOID.
Referenced by _sv_to_datum_finfo(), BeginCopyFrom(), contain_leaky_functions_walker(), contain_mutable_functions_walker(), contain_volatile_functions_walker(), cost_qual_eval_walker(), DefineAggregate(), domain_state_setup(), eval_const_expressions_mutator(), exec_bind_message(), exec_simple_cast_value(), ExecInitExpr(), GetAggInitVal(), hstore_populate_record(), json_populate_record(), parse_fcall_arguments(), plperl_spi_prepare(), plpgsql_compile_inline(), pltcl_SPI_prepare(), populate_recordset_object_end(), record_in(), and TupleDescGetAttInMetadata().
{ 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->typinput)) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_FUNCTION), errmsg("no input function available for type %s", format_type_be(type)))); *typInput = pt->typinput; *typIOParam = getTypeIOParam(typeTuple); ReleaseSysCache(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); }
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); }
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; }
Definition at line 59 of file lsyscache.c.
References AMOP_SEARCH, AMOPOPID, CharGetDatum, ObjectIdGetDatum, and SearchSysCacheExists3.
Referenced by equality_ops_are_compatible(), expand_indexqual_opclause(), is_indexable_operator(), and relation_has_unique_index_for().
{ return SearchSysCacheExists3(AMOPOPID, ObjectIdGetDatum(opno), CharGetDatum(AMOP_SEARCH), ObjectIdGetDatum(opfamily)); }
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); }
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; }
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); }
Definition at line 2653 of file lsyscache.c.
References get_typcollation(), and OidIsValid.
Referenced by CheckAttributeType(), ComputeIndexAttrs(), DefineRange(), DefineVirtualRelation(), intorel_startup(), pg_collation_for(), and transformCollateClause().
{ return OidIsValid(get_typcollation(typid)); }
Definition at line 2282 of file lsyscache.c.
References get_typtype(), and TYPTYPE_ENUM.
Referenced by check_generic_type_consistency(), enforce_generic_type_consistency(), IsBinaryCoercible(), and resolve_polymorphic_tupdesc().
{ return (get_typtype(typid) == TYPTYPE_ENUM); }
Definition at line 2292 of file lsyscache.c.
References get_typtype(), and TYPTYPE_RANGE.
Referenced by IsBinaryCoercible().
{ return (get_typtype(typid) == TYPTYPE_RANGE); }
Definition at line 2272 of file lsyscache.c.
References get_typtype(), RECORDOID, and TYPTYPE_COMPOSITE.
Referenced by eval_const_expressions_mutator(), exec_assign_value(), exec_stmt_return(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), find_minmax_aggs_walker(), get_relation_constraints(), hstore_populate_record(), init_sql_fcache(), json_populate_record(), json_populate_recordset(), makeWholeRowVar(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), plperl_sv_to_datum(), PLy_output_datum_func2(), and transformExprRecurse().
{ return (typid == RECORDOID || get_typtype(typid) == TYPTYPE_COMPOSITE); }
Definition at line 46 of file lsyscache.c.
Referenced by get_attavgwidth().