PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
lsyscache.h File Reference
#include "access/attnum.h"
#include "access/htup.h"
#include "nodes/pg_list.h"
Include dependency graph for lsyscache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  OpBtreeInterpretation
 

Macros

#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)
 
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)
 
char * get_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
RegProcedure get_opcode (Oid opno)
 
char * get_opname (Oid opno)
 
Oid get_op_rettype (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)
 
Oid get_func_variadictype (Oid funcid)
 
bool get_func_retset (Oid funcid)
 
bool func_strict (Oid funcid)
 
char func_volatile (Oid funcid)
 
char func_parallel (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)
 
char get_rel_persistence (Oid relid)
 
Oid get_transform_fromsql (Oid typid, Oid langid, List *trftypes)
 
Oid get_transform_tosql (Oid typid, Oid langid, List *trftypes)
 
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_promoted_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)
 
char * get_namespace_name_or_temp (Oid nspid)
 
Oid get_range_subtype (Oid rangeOid)
 

Variables

PGDLLIMPORT
get_attavgwidth_hook_type 
get_attavgwidth_hook
 

Macro Definition Documentation

#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')

Definition at line 167 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.

Function Documentation

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 695 of file lsyscache.c.

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

Referenced by query_is_distinct_for().

696 {
697  bool result;
698  CatCList *catlist;
699  int i;
700 
701  /* Easy if they're the same operator */
702  if (opno1 == opno2)
703  return true;
704 
705  /*
706  * We search through all the pg_amop entries for opno1.
707  */
708  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
709 
710  result = false;
711  for (i = 0; i < catlist->n_members; i++)
712  {
713  HeapTuple op_tuple = &catlist->members[i]->tuple;
714  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
715 
716  /* must be btree or hash */
717  if (op_form->amopmethod == BTREE_AM_OID ||
718  op_form->amopmethod == HASH_AM_OID)
719  {
720  if (op_in_opfamily(opno2, op_form->amopfamily))
721  {
722  result = true;
723  break;
724  }
725  }
726  }
727 
728  ReleaseSysCacheList(catlist);
729 
730  return result;
731 }
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:63
int n_members
Definition: catcache.h:154
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define BTREE_AM_OID
Definition: pg_am.h:70
return result
Definition: formatting.c:1618
#define HASH_AM_OID
Definition: pg_am.h:73
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:116
void free_attstatsslot ( Oid  atttype,
Datum values,
int  nvalues,
float4 numbers,
int  nnumbers 
)

Definition at line 2978 of file lsyscache.c.

References DatumGetPointer, get_typbyval(), i, and pfree().

Referenced by _int_matchsel(), booltestsel(), btcostestimate(), calc_arraycontsel(), eqjoinsel_inner(), eqjoinsel_semi(), estimate_hash_bucketsize(), ExecHashBuildSkewHash(), get_variable_range(), histogram_selectivity(), ineq_histogram_selectivity(), mcv_selectivity(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), scalararraysel_containment(), tsquerysel(), var_eq_const(), and var_eq_non_const().

2981 {
2982  if (values)
2983  {
2984  if (!get_typbyval(atttype))
2985  {
2986  int i;
2987 
2988  for (i = 0; i < nvalues; i++)
2990  }
2991  pfree(values);
2992  }
2993  if (numbers)
2994  pfree(numbers);
2995 }
bool get_typbyval(Oid typid)
Definition: lsyscache.c:1940
void pfree(void *pointer)
Definition: mcxt.c:950
#define DatumGetPointer(X)
Definition: postgres.h:555
static Datum values[MAXATTR]
Definition: bootstrap.c:162
int i
char func_parallel ( Oid  funcid)

Definition at line 1571 of file lsyscache.c.

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

1572 {
1573  HeapTuple tp;
1574  char result;
1575 
1576  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1577  if (!HeapTupleIsValid(tp))
1578  elog(ERROR, "cache lookup failed for function %u", funcid);
1579 
1580  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1581  ReleaseSysCache(tp);
1582  return result;
1583 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
bool func_strict ( Oid  funcid)

Definition at line 1533 of file lsyscache.c.

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

Referenced by AggregateCreate(), contain_nonstrict_functions_checker(), 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().

1534 {
1535  HeapTuple tp;
1536  bool result;
1537 
1538  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1539  if (!HeapTupleIsValid(tp))
1540  elog(ERROR, "cache lookup failed for function %u", funcid);
1541 
1542  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1543  ReleaseSysCache(tp);
1544  return result;
1545 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
char func_volatile ( Oid  funcid)

Definition at line 1552 of file lsyscache.c.

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

Referenced by contain_mutable_functions_checker(), contain_volatile_functions_checker(), contain_volatile_functions_not_nextval_checker(), DefineType(), eval_const_expressions_mutator(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), and op_volatile().

1553 {
1554  HeapTuple tp;
1555  char result;
1556 
1557  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1558  if (!HeapTupleIsValid(tp))
1559  elog(ERROR, "cache lookup failed for function %u", funcid);
1560 
1561  result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
1562  ReleaseSysCache(tp);
1563  return result;
1564 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
Oid get_array_type ( Oid  typid)

Definition at line 2480 of file lsyscache.c.

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

Referenced by AlterTypeNamespace_oid(), AlterTypeOwner(), enforce_generic_type_consistency(), find_composite_type_dependencies(), get_promoted_array_type(), get_qual_for_list(), initArrayResultAny(), LookupTypeName(), make_scalar_array_op(), moveArrayTypeName(), ParseFuncOrColumn(), RenameType(), resolve_generic_type(), transformAExprIn(), and transformArrayExpr().

2481 {
2482  HeapTuple tp;
2483  Oid result = InvalidOid;
2484 
2486  if (HeapTupleIsValid(tp))
2487  {
2488  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2489  ReleaseSysCache(tp);
2490  }
2491  return result;
2492 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 2796 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().

2797 {
2798  HeapTuple tp;
2799  int32 stawidth;
2800 
2802  {
2803  stawidth = (*get_attavgwidth_hook) (relid, attnum);
2804  if (stawidth > 0)
2805  return stawidth;
2806  }
2808  ObjectIdGetDatum(relid),
2809  Int16GetDatum(attnum),
2810  BoolGetDatum(false));
2811  if (HeapTupleIsValid(tp))
2812  {
2813  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
2814  ReleaseSysCache(tp);
2815  if (stawidth > 0)
2816  return stawidth;
2817  }
2818  return 0;
2819 }
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:50
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define Int16GetDatum(X)
Definition: postgres.h:457
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:129
signed int int32
Definition: c.h:256
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define BoolGetDatum(X)
Definition: postgres.h:408
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define SearchSysCache3(cacheId, key1, key2, key3)
Definition: syscache.h:156
char* get_attname ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 774 of file lsyscache.c.

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

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

775 {
776  HeapTuple tp;
777 
778  tp = SearchSysCache2(ATTNUM,
779  ObjectIdGetDatum(relid),
780  Int16GetDatum(attnum));
781  if (HeapTupleIsValid(tp))
782  {
784  char *result;
785 
786  result = pstrdup(NameStr(att_tup->attname));
787  ReleaseSysCache(tp);
788  return result;
789  }
790  else
791  return NULL;
792 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
#define Int16GetDatum(X)
Definition: postgres.h:457
return result
Definition: formatting.c:1618
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
#define NameStr(name)
Definition: c.h:499
#define SearchSysCache2(cacheId, key1, key2)
Definition: syscache.h:154
AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 821 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidAttrNumber, ReleaseSysCache(), result, and SearchSysCacheAttName().

Referenced by ATExecColumnDefault(), ATExecDropNotNull(), convert_column_name(), expand_col_privileges(), fixup_inherited_columns(), get_object_address_attrdef(), get_object_address_attribute(), LookupTypeName(), pg_get_serial_sequence(), ProcedureCreate(), process_owned_by(), and transformAssignmentIndirection().

822 {
823  HeapTuple tp;
824 
825  tp = SearchSysCacheAttName(relid, attname);
826  if (HeapTupleIsValid(tp))
827  {
830 
831  result = att_tup->attnum;
832  ReleaseSysCache(tp);
833  return result;
834  }
835  else
836  return InvalidAttrNumber;
837 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1204
#define InvalidAttrNumber
Definition: attnum.h:23
int16 AttrNumber
Definition: attnum.h:21
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 2854 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, STATISTIC_NUM_SLOTS, STATRELATTINH, SysCacheGetAttr(), TYPEOID, and val.

Referenced by _int_matchsel(), 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(), networkjoinsel_inner(), networkjoinsel_semi(), networksel(), scalararraysel_containment(), tsquerysel(), var_eq_const(), and var_eq_non_const().

2860 {
2861  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
2862  int i,
2863  j;
2864  Datum val;
2865  bool isnull;
2866  ArrayType *statarray;
2867  Oid arrayelemtype;
2868  int narrayelem;
2869  HeapTuple typeTuple;
2870  Form_pg_type typeForm;
2871 
2872  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
2873  {
2874  if ((&stats->stakind1)[i] == reqkind &&
2875  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
2876  break;
2877  }
2878  if (i >= STATISTIC_NUM_SLOTS)
2879  return false; /* not there */
2880 
2881  if (actualop)
2882  *actualop = (&stats->staop1)[i];
2883 
2884  if (values)
2885  {
2886  val = SysCacheGetAttr(STATRELATTINH, statstuple,
2888  &isnull);
2889  if (isnull)
2890  elog(ERROR, "stavalues is null");
2891  statarray = DatumGetArrayTypeP(val);
2892 
2893  /*
2894  * Need to get info about the array element type. We look at the
2895  * actual element type embedded in the array, which might be only
2896  * binary-compatible with the passed-in atttype. The info we extract
2897  * here should be the same either way, but deconstruct_array is picky
2898  * about having an exact type OID match.
2899  */
2900  arrayelemtype = ARR_ELEMTYPE(statarray);
2901  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
2902  if (!HeapTupleIsValid(typeTuple))
2903  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
2904  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
2905 
2906  /* Deconstruct array into Datum elements; NULLs not expected */
2907  deconstruct_array(statarray,
2908  arrayelemtype,
2909  typeForm->typlen,
2910  typeForm->typbyval,
2911  typeForm->typalign,
2912  values, NULL, nvalues);
2913 
2914  /*
2915  * If the element type is pass-by-reference, we now have a bunch of
2916  * Datums that are pointers into the syscache value. Copy them to
2917  * avoid problems if syscache decides to drop the entry.
2918  */
2919  if (!typeForm->typbyval)
2920  {
2921  for (j = 0; j < *nvalues; j++)
2922  {
2923  (*values)[j] = datumCopy((*values)[j],
2924  typeForm->typbyval,
2925  typeForm->typlen);
2926  }
2927  }
2928 
2929  ReleaseSysCache(typeTuple);
2930 
2931  /*
2932  * Free statarray if it's a detoasted copy.
2933  */
2934  if ((Pointer) statarray != DatumGetPointer(val))
2935  pfree(statarray);
2936  }
2937 
2938  if (numbers)
2939  {
2940  val = SysCacheGetAttr(STATRELATTINH, statstuple,
2942  &isnull);
2943  if (isnull)
2944  elog(ERROR, "stanumbers is null");
2945  statarray = DatumGetArrayTypeP(val);
2946 
2947  /*
2948  * We expect the array to be a 1-D float4 array; verify that. We don't
2949  * need to use deconstruct_array() since the array data is just going
2950  * to look like a C array of float4 values.
2951  */
2952  narrayelem = ARR_DIMS(statarray)[0];
2953  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
2954  ARR_HASNULL(statarray) ||
2955  ARR_ELEMTYPE(statarray) != FLOAT4OID)
2956  elog(ERROR, "stanumbers is not a 1-D float4 array");
2957  *numbers = (float4 *) palloc(narrayelem * sizeof(float4));
2958  memcpy(*numbers, ARR_DATA_PTR(statarray), narrayelem * sizeof(float4));
2959  *nnumbers = narrayelem;
2960 
2961  /*
2962  * Free statarray if it's a detoasted copy.
2963  */
2964  if ((Pointer) statarray != DatumGetPointer(val))
2965  pfree(statarray);
2966  }
2967 
2968  return true;
2969 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define Anum_pg_statistic_stavalues1
Definition: pg_statistic.h:157
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:129
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
void pfree(void *pointer)
Definition: mcxt.c:950
char * Pointer
Definition: c.h:245
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ARR_DIMS(a)
Definition: array.h:275
#define ARR_DATA_PTR(a)
Definition: array.h:303
#define ARR_HASNULL(a)
Definition: array.h:272
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:128
float float4
Definition: c.h:380
#define FLOAT4OID
Definition: pg_type.h:412
uintptr_t Datum
Definition: postgres.h:372
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1278
#define InvalidOid
Definition: postgres_ext.h:36
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:121
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
#define Anum_pg_statistic_stanumbers1
Definition: pg_statistic.h:152
#define ARR_NDIM(a)
Definition: array.h:271
#define DatumGetPointer(X)
Definition: postgres.h:555
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3475
static Datum values[MAXATTR]
Definition: bootstrap.c:162
void * palloc(Size size)
Definition: mcxt.c:849
int i
#define elog
Definition: elog.h:219
#define ARR_ELEMTYPE(a)
Definition: array.h:273
long val
Definition: informix.c:689
#define DatumGetArrayTypeP(X)
Definition: array.h:242
Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 846 of file lsyscache.c.

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

Referenced by generateClonedIndexStmt(), and LookupTypeName().

847 {
848  HeapTuple tp;
849 
850  tp = SearchSysCache2(ATTNUM,
851  ObjectIdGetDatum(relid),
852  Int16GetDatum(attnum));
853  if (HeapTupleIsValid(tp))
854  {
856  Oid result;
857 
858  result = att_tup->atttypid;
859  ReleaseSysCache(tp);
860  return result;
861  }
862  else
863  return InvalidOid;
864 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define Int16GetDatum(X)
Definition: postgres.h:457
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define SearchSysCache2(cacheId, key1, key2)
Definition: syscache.h:154
void get_atttypetypmodcoll ( Oid  relid,
AttrNumber  attnum,
Oid typid,
int32 typmod,
Oid collid 
)

Definition at line 903 of file lsyscache.c.

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

Referenced by pg_get_indexdef_worker(), pg_get_partkeydef_worker(), and transformAssignmentIndirection().

905 {
906  HeapTuple tp;
907  Form_pg_attribute att_tup;
908 
909  tp = SearchSysCache2(ATTNUM,
910  ObjectIdGetDatum(relid),
911  Int16GetDatum(attnum));
912  if (!HeapTupleIsValid(tp))
913  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
914  attnum, relid);
915  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
916 
917  *typid = att_tup->atttypid;
918  *typmod = att_tup->atttypmod;
919  *collid = att_tup->attcollation;
920  ReleaseSysCache(tp);
921 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define Int16GetDatum(X)
Definition: postgres.h:457
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
#define SearchSysCache2(cacheId, key1, key2)
Definition: syscache.h:154
int32 get_atttypmod ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 873 of file lsyscache.c.

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

874 {
875  HeapTuple tp;
876 
877  tp = SearchSysCache2(ATTNUM,
878  ObjectIdGetDatum(relid),
879  Int16GetDatum(attnum));
880  if (HeapTupleIsValid(tp))
881  {
883  int32 result;
884 
885  result = att_tup->atttypmod;
886  ReleaseSysCache(tp);
887  return result;
888  }
889  else
890  return -1;
891 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define Int16GetDatum(X)
Definition: postgres.h:457
return result
Definition: formatting.c:1618
signed int int32
Definition: c.h:256
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:184
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define SearchSysCache2(cacheId, key1, key2)
Definition: syscache.h:154
Oid get_base_element_type ( Oid  typid)

Definition at line 2525 of file lsyscache.c.

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

Referenced by array_typanalyze(), arraycontsel(), build_datatype(), cache_array_element_properties(), concat_internal(), ConstructTupleDescriptor(), count_nulls(), CreateFunction(), find_coercion_pathway(), get_call_expr_argtype(), get_rule_expr(), make_scalar_array_op(), ParseFuncOrColumn(), plperl_hash_from_tuple(), PLy_input_datum_func2(), PLy_output_datum_func2(), PLySequence_ToArray(), scalararraysel(), and text_format().

2526 {
2527  /*
2528  * We loop to find the bottom base type in a stack of domains.
2529  */
2530  for (;;)
2531  {
2532  HeapTuple tup;
2533  Form_pg_type typTup;
2534 
2535  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2536  if (!HeapTupleIsValid(tup))
2537  break;
2538  typTup = (Form_pg_type) GETSTRUCT(tup);
2539  if (typTup->typtype != TYPTYPE_DOMAIN)
2540  {
2541  /* Not a domain, so stop descending */
2542  Oid result;
2543 
2544  /* This test must match get_element_type */
2545  if (typTup->typlen == -1)
2546  result = typTup->typelem;
2547  else
2548  result = InvalidOid;
2549  ReleaseSysCache(tup);
2550  return result;
2551  }
2552 
2553  typid = typTup->typbasetype;
2554  ReleaseSysCache(tup);
2555  }
2556 
2557  /* Like get_element_type, silently return InvalidOid for bogus input */
2558  return InvalidOid;
2559 }
#define TYPTYPE_DOMAIN
Definition: pg_type.h:718
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char* get_collation_name ( Oid  colloid)

Definition at line 935 of file lsyscache.c.

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

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

936 {
937  HeapTuple tp;
938 
939  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
940  if (HeapTupleIsValid(tp))
941  {
943  char *result;
944 
945  result = pstrdup(NameStr(colltup->collname));
946  ReleaseSysCache(tp);
947  return result;
948  }
949  else
950  return NULL;
951 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
#define NameStr(name)
Definition: c.h:499
Oid get_commutator ( Oid  opno)

Definition at line 1281 of file lsyscache.c.

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

Referenced by adjust_rowcompare_for_index(), CommuteOpExpr(), CommuteRowCompareExpr(), compute_semijoin_info(), ComputeIndexAttrs(), convert_EXISTS_to_ANY(), eqjoinsel(), gincost_opexpr(), is_indexable_operator(), match_clause_to_ordering_op(), match_foreign_keys_to_quals(), match_rowcompare_to_indexcol(), networkjoinsel(), operator_predicate_proof(), rangesel(), scalargtsel(), scalarltsel(), and targetIsInSortList().

1282 {
1283  HeapTuple tp;
1284 
1286  if (HeapTupleIsValid(tp))
1287  {
1289  Oid result;
1290 
1291  result = optup->oprcom;
1292  ReleaseSysCache(tp);
1293  return result;
1294  }
1295  else
1296  return InvalidOid;
1297 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
bool get_compatible_hash_operators ( Oid  opno,
Oid lhs_opno,
Oid rhs_opno 
)

Definition at line 407 of file lsyscache.c.

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

Referenced by create_unique_plan(), and ExecInitSubPlan().

409 {
410  bool result = false;
411  CatCList *catlist;
412  int i;
413 
414  /* Ensure output args are initialized on failure */
415  if (lhs_opno)
416  *lhs_opno = InvalidOid;
417  if (rhs_opno)
418  *rhs_opno = InvalidOid;
419 
420  /*
421  * Search pg_amop to see if the target operator is registered as the "="
422  * operator of any hash opfamily. If the operator is registered in
423  * multiple opfamilies, assume we can use any one.
424  */
426 
427  for (i = 0; i < catlist->n_members; i++)
428  {
429  HeapTuple tuple = &catlist->members[i]->tuple;
430  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
431 
432  if (aform->amopmethod == HASH_AM_OID &&
433  aform->amopstrategy == HTEqualStrategyNumber)
434  {
435  /* No extra lookup needed if given operator is single-type */
436  if (aform->amoplefttype == aform->amoprighttype)
437  {
438  if (lhs_opno)
439  *lhs_opno = opno;
440  if (rhs_opno)
441  *rhs_opno = opno;
442  result = true;
443  break;
444  }
445 
446  /*
447  * Get the matching single-type operator(s). Failure probably
448  * shouldn't happen --- it implies a bogus opfamily --- but
449  * continue looking if so.
450  */
451  if (lhs_opno)
452  {
453  *lhs_opno = get_opfamily_member(aform->amopfamily,
454  aform->amoplefttype,
455  aform->amoplefttype,
457  if (!OidIsValid(*lhs_opno))
458  continue;
459  /* Matching LHS found, done if caller doesn't want RHS */
460  if (!rhs_opno)
461  {
462  result = true;
463  break;
464  }
465  }
466  if (rhs_opno)
467  {
468  *rhs_opno = get_opfamily_member(aform->amopfamily,
469  aform->amoprighttype,
470  aform->amoprighttype,
472  if (!OidIsValid(*rhs_opno))
473  {
474  /* Forget any LHS operator from this opfamily */
475  if (lhs_opno)
476  *lhs_opno = InvalidOid;
477  continue;
478  }
479  /* Matching RHS found, so done */
480  result = true;
481  break;
482  }
483  }
484  }
485 
486  ReleaseSysCacheList(catlist);
487 
488  return result;
489 }
int n_members
Definition: catcache.h:154
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define HTEqualStrategyNumber
Definition: hash.h:273
return result
Definition: formatting.c:1618
#define OidIsValid(objectId)
Definition: c.h:538
#define HASH_AM_OID
Definition: pg_am.h:73
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:116
char* get_constraint_name ( Oid  conoid)

Definition at line 965 of file lsyscache.c.

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

Referenced by get_insert_query_def(), and report_triggers().

966 {
967  HeapTuple tp;
968 
970  if (HeapTupleIsValid(tp))
971  {
973  char *result;
974 
975  result = pstrdup(NameStr(contup->conname));
976  ReleaseSysCache(tp);
977  return result;
978  }
979  else
980  return NULL;
981 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
#define NameStr(name)
Definition: c.h:499
Oid get_element_type ( Oid  typid)

Definition at line 2452 of file lsyscache.c.

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

Referenced by aclcheck_error_type(), AlterTypeNamespace_oid(), check_generic_type_consistency(), CheckAttributeType(), CreateCast(), enforce_generic_type_consistency(), exec_assign_value(), exec_stmt_foreach_a(), ExecInitExprRec(), fetch_array_arg_replace_nulls(), find_coercion_pathway(), get_promoted_array_type(), initArrayResultAny(), initArrayResultArr(), interpret_function_parameter_list(), is_complex_array(), json_categorize_type(), jsonb_categorize_type(), moveArrayTypeName(), plperl_array_to_datum(), ProcedureCreate(), resolve_generic_type(), transformArrayExpr(), and transformTypeCast().

2453 {
2454  HeapTuple tp;
2455 
2457  if (HeapTupleIsValid(tp))
2458  {
2459  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2460  Oid result;
2461 
2462  if (typtup->typlen == -1)
2463  result = typtup->typelem;
2464  else
2465  result = InvalidOid;
2466  ReleaseSysCache(tp);
2467  return result;
2468  }
2469  else
2470  return InvalidOid;
2471 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 264 of file lsyscache.c.

References BTEqualStrategyNumber, BTGreaterStrategyNumber, get_opfamily_member(), get_ordering_op_properties(), InvalidOid, and result.

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

265 {
267  Oid opfamily;
268  Oid opcintype;
269  int16 strategy;
270 
271  /* Find the operator in pg_amop */
273  &opfamily, &opcintype, &strategy))
274  {
275  /* Found a suitable opfamily, get matching equality operator */
276  result = get_opfamily_member(opfamily,
277  opcintype,
278  opcintype,
280  if (reverse)
281  *reverse = (strategy == BTGreaterStrategyNumber);
282  }
283 
284  return result;
285 }
signed short int16
Definition: c.h:255
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
#define InvalidOid
Definition: postgres_ext.h:36
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:204
#define BTEqualStrategyNumber
Definition: stratnum.h:31
float4 get_func_cost ( Oid  funcid)

Definition at line 1609 of file lsyscache.c.

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

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

1610 {
1611  HeapTuple tp;
1612  float4 result;
1613 
1614  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1615  if (!HeapTupleIsValid(tp))
1616  elog(ERROR, "cache lookup failed for function %u", funcid);
1617 
1618  result = ((Form_pg_proc) GETSTRUCT(tp))->procost;
1619  ReleaseSysCache(tp);
1620  return result;
1621 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
float float4
Definition: c.h:380
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
bool get_func_leakproof ( Oid  funcid)

Definition at line 1590 of file lsyscache.c.

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

Referenced by contain_leaked_vars_checker(), contain_leaked_vars_walker(), and select_equality_operator().

1591 {
1592  HeapTuple tp;
1593  bool result;
1594 
1595  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1596  if (!HeapTupleIsValid(tp))
1597  elog(ERROR, "cache lookup failed for function %u", funcid);
1598 
1599  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1600  ReleaseSysCache(tp);
1601  return result;
1602 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
char* get_func_name ( Oid  funcid)

Definition at line 1380 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, NULL, ObjectIdGetDatum, PROCOID, pstrdup(), ReleaseSysCache(), result, and SearchSysCache1.

Referenced by AlterOpFamilyAdd(), DefineOpClass(), ExecInitAgg(), ExecInitExprRec(), ExecInitFunc(), ExecInitWindowAgg(), ExplainTargetRel(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), HandleFunctionRequest(), init_sexpr(), initialize_peragg(), lookup_agg_function(), print_expr(), and show_tablesample().

1381 {
1382  HeapTuple tp;
1383 
1384  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1385  if (HeapTupleIsValid(tp))
1386  {
1387  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1388  char *result;
1389 
1390  result = pstrdup(NameStr(functup->proname));
1391  ReleaseSysCache(tp);
1392  return result;
1393  }
1394  else
1395  return NULL;
1396 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
#define NameStr(name)
Definition: c.h:499
Oid get_func_namespace ( Oid  funcid)

Definition at line 1404 of file lsyscache.c.

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

Referenced by sepgsql_proc_drop().

1405 {
1406  HeapTuple tp;
1407 
1408  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1409  if (HeapTupleIsValid(tp))
1410  {
1411  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1412  Oid result;
1413 
1414  result = functup->pronamespace;
1415  ReleaseSysCache(tp);
1416  return result;
1417  }
1418  else
1419  return InvalidOid;
1420 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int get_func_nargs ( Oid  funcid)

Definition at line 1446 of file lsyscache.c.

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

1447 {
1448  HeapTuple tp;
1449  int result;
1450 
1451  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1452  if (!HeapTupleIsValid(tp))
1453  elog(ERROR, "cache lookup failed for function %u", funcid);
1454 
1455  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1456  ReleaseSysCache(tp);
1457  return result;
1458 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
bool get_func_retset ( Oid  funcid)

Definition at line 1514 of file lsyscache.c.

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

Referenced by make_op(), and make_scalar_array_op().

1515 {
1516  HeapTuple tp;
1517  bool result;
1518 
1519  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1520  if (!HeapTupleIsValid(tp))
1521  elog(ERROR, "cache lookup failed for function %u", funcid);
1522 
1523  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1524  ReleaseSysCache(tp);
1525  return result;
1526 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
Oid get_func_rettype ( Oid  funcid)

Definition at line 1427 of file lsyscache.c.

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

Referenced by CreateConversionCommand(), CreateEventTrigger(), CreateProceduralLanguage(), CreateTrigger(), DefineOperator(), DefineType(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeAnalyzeFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), get_ts_parser_func(), get_ts_template_func(), gistrescan(), lookup_fdw_handler_func(), lookup_index_am_handler_func(), OperatorCreate(), transformRangeTableSample(), ValidateJoinEstimator(), and ValidateRestrictionEstimator().

1428 {
1429  HeapTuple tp;
1430  Oid result;
1431 
1432  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1433  if (!HeapTupleIsValid(tp))
1434  elog(ERROR, "cache lookup failed for function %u", funcid);
1435 
1436  result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
1437  ReleaseSysCache(tp);
1438  return result;
1439 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
float4 get_func_rows ( Oid  funcid)

Definition at line 1628 of file lsyscache.c.

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

Referenced by expression_returns_set_rows().

1629 {
1630  HeapTuple tp;
1631  float4 result;
1632 
1633  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1634  if (!HeapTupleIsValid(tp))
1635  elog(ERROR, "cache lookup failed for function %u", funcid);
1636 
1637  result = ((Form_pg_proc) GETSTRUCT(tp))->prorows;
1638  ReleaseSysCache(tp);
1639  return result;
1640 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
float float4
Definition: c.h:380
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
Oid get_func_signature ( Oid  funcid,
Oid **  argtypes,
int *  nargs 
)

Definition at line 1468 of file lsyscache.c.

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

Referenced by plperl_call_perl_func(), and resolve_aggregate_transtype().

1469 {
1470  HeapTuple tp;
1471  Form_pg_proc procstruct;
1472  Oid result;
1473 
1474  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1475  if (!HeapTupleIsValid(tp))
1476  elog(ERROR, "cache lookup failed for function %u", funcid);
1477 
1478  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1479 
1480  result = procstruct->prorettype;
1481  *nargs = (int) procstruct->pronargs;
1482  Assert(*nargs == procstruct->proargtypes.dim1);
1483  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1484  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1485 
1486  ReleaseSysCache(tp);
1487  return result;
1488 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define Assert(condition)
Definition: c.h:675
void * palloc(Size size)
Definition: mcxt.c:849
#define elog
Definition: elog.h:219
Oid get_func_variadictype ( Oid  funcid)

Definition at line 1495 of file lsyscache.c.

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

1496 {
1497  HeapTuple tp;
1498  Oid result;
1499 
1500  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1501  if (!HeapTupleIsValid(tp))
1502  elog(ERROR, "cache lookup failed for function %u", funcid);
1503 
1504  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1505  ReleaseSysCache(tp);
1506  return result;
1507 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 986 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, LANGOID, NameStr, NULL, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), result, and SearchSysCache1.

Referenced by get_transform_oid(), getObjectDescription(), getObjectIdentityParts(), and pg_get_functiondef().

987 {
988  HeapTuple tp;
989 
990  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
991  if (HeapTupleIsValid(tp))
992  {
994  char *result;
995 
996  result = pstrdup(NameStr(lantup->lanname));
997  ReleaseSysCache(tp);
998  return result;
999  }
1000 
1001  if (!missing_ok)
1002  elog(ERROR, "cache lookup failed for language %u",
1003  langoid);
1004  return NULL;
1005 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
FormData_pg_language * Form_pg_language
Definition: pg_language.h:51
#define NameStr(name)
Definition: c.h:499
#define elog
Definition: elog.h:219
List* get_mergejoin_opfamilies ( Oid  opno)

Definition at line 363 of file lsyscache.c.

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

Referenced by check_mergejoinable(), compute_semijoin_info(), make_pathkey_from_sortinfo(), and match_eclasses_to_foreign_key_col().

364 {
365  List *result = NIL;
366  CatCList *catlist;
367  int i;
368 
369  /*
370  * Search pg_amop to see if the target operator is registered as the "="
371  * operator of any btree opfamily.
372  */
374 
375  for (i = 0; i < catlist->n_members; i++)
376  {
377  HeapTuple tuple = &catlist->members[i]->tuple;
378  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
379 
380  /* must be btree equality */
381  if (aform->amopmethod == BTREE_AM_OID &&
382  aform->amopstrategy == BTEqualStrategyNumber)
383  result = lappend_oid(result, aform->amopfamily);
384  }
385 
386  ReleaseSysCacheList(catlist);
387 
388  return result;
389 }
#define NIL
Definition: pg_list.h:69
int n_members
Definition: catcache.h:154
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define BTREE_AM_OID
Definition: pg_am.h:70
return result
Definition: formatting.c:1618
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:116
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31
char* get_namespace_name ( Oid  nspid)

Definition at line 3006 of file lsyscache.c.

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

Referenced by acquire_inherited_sample_rows(), AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterRelationNamespaceInternal(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), appendFunctionName(), ApplyExtensionUpdates(), ATExecChangeOwner(), check_TSCurrentConfig(), compute_return_type(), copy_heap_data(), copy_table(), CreateConversionCommand(), CreateExtensionInternal(), CreateFunction(), current_schema(), current_schemas(), DefineAggregate(), DefineCollation(), DefineDomain(), DefineEnum(), DefineIndex(), DefineOpClass(), DefineOperator(), DefineOpFamily(), DefineRange(), DefineTSConfiguration(), DefineTSDictionary(), DefineType(), deparseOperatorName(), deparseRelation(), do_analyze_rel(), do_autovacuum(), DoCopy(), errdatatype(), errtable(), EventTriggerSQLDropAddObject(), exec_object_restorecon(), ExecAlterExtensionContentsStmt(), ExecRefreshMatView(), execute_extension_script(), ExplainTargetRel(), format_operator_internal(), format_procedure_internal(), generate_collation_name(), generate_function_name(), generate_operator_name(), generate_qualified_relation_name(), generate_relation_name(), generateClonedIndexStmt(), get_collation(), get_namespace_name_or_temp(), get_opclass(), get_opclass_name(), get_other_operator(), getObjectDescription(), getOpFamilyDescription(), getRelationDescription(), GetTempNamespaceBackendId(), HandleFunctionRequest(), heap_create(), isAnyTempNamespace(), IsThereCollationInNamespace(), IsThereFunctionInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), lazy_scan_heap(), lazy_vacuum_rel(), logicalrep_write_namespace(), lookup_var_attr_stats(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), mv_GenerateOper(), pg_decode_change(), pg_event_trigger_ddl_commands(), pg_get_functiondef(), pg_get_statisticsext_worker(), pg_identify_object(), pg_newlocale_from_collation(), plpgsql_exec_trigger(), postgresGetForeignRelSize(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), RebuildConstraintComment(), refresh_by_match_merge(), regclassout(), regconfigout(), regdictionaryout(), regnamespaceout(), regoperout(), regprocout(), ReindexMultipleTables(), 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().

3007 {
3008  HeapTuple tp;
3009 
3011  if (HeapTupleIsValid(tp))
3012  {
3014  char *result;
3015 
3016  result = pstrdup(NameStr(nsptup->nspname));
3017  ReleaseSysCache(tp);
3018  return result;
3019  }
3020  else
3021  return NULL;
3022 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:51
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
#define NameStr(name)
Definition: c.h:499
char* get_namespace_name_or_temp ( Oid  nspid)

Definition at line 3030 of file lsyscache.c.

References get_namespace_name(), and isTempNamespace().

Referenced by format_operator_parts(), format_procedure_parts(), format_type_internal(), getObjectIdentityParts(), getOpFamilyIdentity(), and getRelationIdentity().

3031 {
3032  if (isTempNamespace(nspid))
3033  return "pg_temp";
3034  else
3035  return get_namespace_name(nspid);
3036 }
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3006
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3008
Oid get_negator ( Oid  opno)

Definition at line 1305 of file lsyscache.c.

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

Referenced by get_op_btree_interpretation(), lookup_proof_cache(), negate_clause(), neqjoinsel(), neqsel(), operator_same_subexprs_proof(), patternsel(), and scalararraysel().

1306 {
1307  HeapTuple tp;
1308 
1310  if (HeapTupleIsValid(tp))
1311  {
1313  Oid result;
1314 
1315  result = optup->oprnegate;
1316  ReleaseSysCache(tp);
1317  return result;
1318  }
1319  else
1320  return InvalidOid;
1321 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
List* get_op_btree_interpretation ( Oid  opno)

Definition at line 598 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, result, ROWCOMPARE_NE, SearchSysCacheList1, OpBtreeInterpretation::strategy, and catctup::tuple.

Referenced by lookup_proof_cache(), and make_row_comparison_op().

599 {
600  List *result = NIL;
601  OpBtreeInterpretation *thisresult;
602  CatCList *catlist;
603  int i;
604 
605  /*
606  * Find all the pg_amop entries containing the operator.
607  */
609 
610  for (i = 0; i < catlist->n_members; i++)
611  {
612  HeapTuple op_tuple = &catlist->members[i]->tuple;
613  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
614  StrategyNumber op_strategy;
615 
616  /* must be btree */
617  if (op_form->amopmethod != BTREE_AM_OID)
618  continue;
619 
620  /* Get the operator's btree strategy number */
621  op_strategy = (StrategyNumber) op_form->amopstrategy;
622  Assert(op_strategy >= 1 && op_strategy <= 5);
623 
624  thisresult = (OpBtreeInterpretation *)
625  palloc(sizeof(OpBtreeInterpretation));
626  thisresult->opfamily_id = op_form->amopfamily;
627  thisresult->strategy = op_strategy;
628  thisresult->oplefttype = op_form->amoplefttype;
629  thisresult->oprighttype = op_form->amoprighttype;
630  result = lappend(result, thisresult);
631  }
632 
633  ReleaseSysCacheList(catlist);
634 
635  /*
636  * If we didn't find any btree opfamily containing the operator, perhaps
637  * it is a <> operator. See if it has a negator that is in an opfamily.
638  */
639  if (result == NIL)
640  {
641  Oid op_negator = get_negator(opno);
642 
643  if (OidIsValid(op_negator))
644  {
645  catlist = SearchSysCacheList1(AMOPOPID,
646  ObjectIdGetDatum(op_negator));
647 
648  for (i = 0; i < catlist->n_members; i++)
649  {
650  HeapTuple op_tuple = &catlist->members[i]->tuple;
651  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
652  StrategyNumber op_strategy;
653 
654  /* must be btree */
655  if (op_form->amopmethod != BTREE_AM_OID)
656  continue;
657 
658  /* Get the operator's btree strategy number */
659  op_strategy = (StrategyNumber) op_form->amopstrategy;
660  Assert(op_strategy >= 1 && op_strategy <= 5);
661 
662  /* Only consider negators that are = */
663  if (op_strategy != BTEqualStrategyNumber)
664  continue;
665 
666  /* OK, report it with "strategy" ROWCOMPARE_NE */
667  thisresult = (OpBtreeInterpretation *)
668  palloc(sizeof(OpBtreeInterpretation));
669  thisresult->opfamily_id = op_form->amopfamily;
670  thisresult->strategy = ROWCOMPARE_NE;
671  thisresult->oplefttype = op_form->amoplefttype;
672  thisresult->oprighttype = op_form->amoprighttype;
673  result = lappend(result, thisresult);
674  }
675 
676  ReleaseSysCacheList(catlist);
677  }
678  }
679 
680  return result;
681 }
#define NIL
Definition: pg_list.h:69
int n_members
Definition: catcache.h:154
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define BTREE_AM_OID
Definition: pg_am.h:70
uint16 StrategyNumber
Definition: stratnum.h:22
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:538
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
List * lappend(List *list, void *datum)
Definition: list.c:128
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
#define Assert(condition)
Definition: c.h:675
void * palloc(Size size)
Definition: mcxt.c:849
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:116
Oid get_negator(Oid opno)
Definition: lsyscache.c:1305
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31
bool get_op_hash_functions ( Oid  opno,
RegProcedure lhs_procno,
RegProcedure rhs_procno 
)

Definition at line 507 of file lsyscache.c.

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

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

509 {
510  bool result = false;
511  CatCList *catlist;
512  int i;
513 
514  /* Ensure output args are initialized on failure */
515  if (lhs_procno)
516  *lhs_procno = InvalidOid;
517  if (rhs_procno)
518  *rhs_procno = InvalidOid;
519 
520  /*
521  * Search pg_amop to see if the target operator is registered as the "="
522  * operator of any hash opfamily. If the operator is registered in
523  * multiple opfamilies, assume we can use any one.
524  */
526 
527  for (i = 0; i < catlist->n_members; i++)
528  {
529  HeapTuple tuple = &catlist->members[i]->tuple;
530  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
531 
532  if (aform->amopmethod == HASH_AM_OID &&
533  aform->amopstrategy == HTEqualStrategyNumber)
534  {
535  /*
536  * Get the matching support function(s). Failure probably
537  * shouldn't happen --- it implies a bogus opfamily --- but
538  * continue looking if so.
539  */
540  if (lhs_procno)
541  {
542  *lhs_procno = get_opfamily_proc(aform->amopfamily,
543  aform->amoplefttype,
544  aform->amoplefttype,
545  HASHPROC);
546  if (!OidIsValid(*lhs_procno))
547  continue;
548  /* Matching LHS found, done if caller doesn't want RHS */
549  if (!rhs_procno)
550  {
551  result = true;
552  break;
553  }
554  /* Only one lookup needed if given operator is single-type */
555  if (aform->amoplefttype == aform->amoprighttype)
556  {
557  *rhs_procno = *lhs_procno;
558  result = true;
559  break;
560  }
561  }
562  if (rhs_procno)
563  {
564  *rhs_procno = get_opfamily_proc(aform->amopfamily,
565  aform->amoprighttype,
566  aform->amoprighttype,
567  HASHPROC);
568  if (!OidIsValid(*rhs_procno))
569  {
570  /* Forget any LHS function from this opfamily */
571  if (lhs_procno)
572  *lhs_procno = InvalidOid;
573  continue;
574  }
575  /* Matching RHS found, so done */
576  result = true;
577  break;
578  }
579  }
580  }
581 
582  ReleaseSysCacheList(catlist);
583 
584  return result;
585 }
int n_members
Definition: catcache.h:154
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define HTEqualStrategyNumber
Definition: hash.h:273
return result
Definition: formatting.c:1618
#define OidIsValid(objectId)
Definition: c.h:538
#define HASH_AM_OID
Definition: pg_am.h:73
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
#define InvalidOid
Definition: postgres_ext.h:36
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition: lsyscache.c:744
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
#define HASHPROC
Definition: hash.h:281
int i
HeapTupleData tuple
Definition: catcache.h:116
void get_op_opfamily_properties ( Oid  opno,
Oid  opfamily,
bool  ordering_op,
int *  strategy,
Oid lefttype,
Oid righttype 
)

Definition at line 133 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(), ExecInitExprRec(), gincost_pattern(), mergejoinscansel(), and MJExamineQuals().

137 {
138  HeapTuple tp;
139  Form_pg_amop amop_tup;
140 
142  ObjectIdGetDatum(opno),
143  CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
144  ObjectIdGetDatum(opfamily));
145  if (!HeapTupleIsValid(tp))
146  elog(ERROR, "operator %u is not a member of opfamily %u",
147  opno, opfamily);
148  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
149  *strategy = amop_tup->amopstrategy;
150  *lefttype = amop_tup->amoplefttype;
151  *righttype = amop_tup->amoprighttype;
152  ReleaseSysCache(tp);
153 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define AMOP_SEARCH
Definition: pg_amop.h:69
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define CharGetDatum(X)
Definition: postgres.h:422
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
#define SearchSysCache3(cacheId, key1, key2, key3)
Definition: syscache.h:156
#define AMOP_ORDER
Definition: pg_amop.h:70
#define elog
Definition: elog.h:219
Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 105 of file lsyscache.c.

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

Referenced by match_clause_to_ordering_op().

106 {
107  HeapTuple tp;
108  Form_pg_amop amop_tup;
109  Oid result;
110 
112  ObjectIdGetDatum(opno),
114  ObjectIdGetDatum(opfamily));
115  if (!HeapTupleIsValid(tp))
116  return InvalidOid;
117  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
118  result = amop_tup->amopsortfamily;
119  ReleaseSysCache(tp);
120  return result;
121 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define CharGetDatum(X)
Definition: postgres.h:422
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
#define SearchSysCache3(cacheId, key1, key2, key3)
Definition: syscache.h:156
#define AMOP_ORDER
Definition: pg_amop.h:70
int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 80 of file lsyscache.c.

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

Referenced by adjust_rowcompare_for_index(), btcostestimate(), ComputeIndexAttrs(), get_actual_variable_range(), match_rowcompare_to_indexcol(), and RelationGetExclusionInfo().

81 {
82  HeapTuple tp;
83  Form_pg_amop amop_tup;
84  int result;
85 
87  ObjectIdGetDatum(opno),
89  ObjectIdGetDatum(opfamily));
90  if (!HeapTupleIsValid(tp))
91  return 0;
92  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
93  result = amop_tup->amopstrategy;
94  ReleaseSysCache(tp);
95  return result;
96 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define AMOP_SEARCH
Definition: pg_amop.h:69
return result
Definition: formatting.c:1618
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define CharGetDatum(X)
Definition: postgres.h:422
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
#define SearchSysCache3(cacheId, key1, key2, key3)
Definition: syscache.h:156
Oid get_op_rettype ( Oid  opno)

Definition at line 1110 of file lsyscache.c.

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

Referenced by gistvalidate().

1111 {
1112  HeapTuple tp;
1113 
1115  if (HeapTupleIsValid(tp))
1116  {
1118  Oid result;
1119 
1120  result = optup->oprresult;
1121  ReleaseSysCache(tp);
1122  return result;
1123  }
1124  else
1125  return InvalidOid;
1126 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
Oid get_opclass_family ( Oid  opclass)

Definition at line 1015 of file lsyscache.c.

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

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

1016 {
1017  HeapTuple tp;
1018  Form_pg_opclass cla_tup;
1019  Oid result;
1020 
1021  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1022  if (!HeapTupleIsValid(tp))
1023  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1024  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1025 
1026  result = cla_tup->opcfamily;
1027  ReleaseSysCache(tp);
1028  return result;
1029 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:68
Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1037 of file lsyscache.c.

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

Referenced by build_replindex_scan_key(), CheckIndexCompatible(), findRangeSubOpclass(), get_rule_expr(), infer_collation_opclass_match(), load_rangetype_info(), and lookup_type_cache().

1038 {
1039  HeapTuple tp;
1040  Form_pg_opclass cla_tup;
1041  Oid result;
1042 
1043  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1044  if (!HeapTupleIsValid(tp))
1045  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1046  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1047 
1048  result = cla_tup->opcintype;
1049  ReleaseSysCache(tp);
1050  return result;
1051 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:68
RegProcedure get_opcode ( Oid  opno)

Definition at line 1062 of file lsyscache.c.

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

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), AlterOpFamilyAdd(), build_pertrans_for_aggref(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), check_functions_in_node(), ComputeIndexAttrs(), contain_leaked_vars_walker(), cost_qual_eval_walker(), DefineOpClass(), eqjoinsel_inner(), eqjoinsel_semi(), ExecInitSubPlan(), execTuplesHashPrepare(), execTuplesMatchPrepare(), get_expr_result_type(), get_qual_for_list(), get_variable_range(), hypothetical_dense_rank_final(), inclusion_get_strategy_procinfo(), inet_mcv_join_sel(), lookup_type_cache(), ltreeparentsel(), minmax_get_strategy_procinfo(), mode_final(), networkjoinsel_semi(), networksel(), op_strict(), op_volatile(), OperatorLookup(), patternsel(), prefix_quals(), prefix_selectivity(), RelationGetExclusionInfo(), ri_HashCompareOp(), scalarineqsel(), select_equality_operator(), set_opfuncid(), set_sa_opfuncid(), std_typanalyze(), and var_eq_const().

1063 {
1064  HeapTuple tp;
1065 
1067  if (HeapTupleIsValid(tp))
1068  {
1071 
1072  result = optup->oprcode;
1073  ReleaseSysCache(tp);
1074  return result;
1075  }
1076  else
1077  return (RegProcedure) InvalidOid;
1078 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
regproc RegProcedure
Definition: c.h:395
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
Oid get_opfamily_member ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  strategy 
)

Definition at line 163 of file lsyscache.c.

References AMOPSTRATEGY, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), result, and SearchSysCache4.

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), adjust_rowcompare_for_index(), ATAddForeignKeyConstraint(), btcostestimate(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), create_indexscan_plan(), get_compatible_hash_operators(), get_equality_op_for_ordering_op(), get_ordering_op_for_equality_op(), get_partition_operator(), get_relation_info(), lookup_proof_cache(), lookup_type_cache(), make_pathkey_from_sortinfo(), make_unique_from_pathkeys(), mergejoinscansel(), network_prefix_quals(), patternsel(), prefix_quals(), prefix_selectivity(), prepare_sort_from_pathkeys(), and select_equality_operator().

165 {
166  HeapTuple tp;
167  Form_pg_amop amop_tup;
168  Oid result;
169 
171  ObjectIdGetDatum(opfamily),
172  ObjectIdGetDatum(lefttype),
173  ObjectIdGetDatum(righttype),
174  Int16GetDatum(strategy));
175  if (!HeapTupleIsValid(tp))
176  return InvalidOid;
177  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
178  result = amop_tup->amopopr;
179  ReleaseSysCache(tp);
180  return result;
181 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define SearchSysCache4(cacheId, key1, key2, key3, key4)
Definition: syscache.h:158
#define Int16GetDatum(X)
Definition: postgres.h:457
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
Oid get_opfamily_proc ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  procnum 
)

Definition at line 744 of file lsyscache.c.

References AMPROCNUM, GETSTRUCT, HeapTupleIsValid, Int16GetDatum, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), result, and SearchSysCache4.

Referenced by _bt_first(), _bt_sort_array_elements(), _hash_datum2hashkey_type(), ExecIndexBuildScanKeys(), ExecInitExprRec(), FinishSortSupportFunction(), get_op_hash_functions(), gincost_pattern(), gistvalidate(), load_rangetype_info(), lookup_type_cache(), MJExamineQuals(), and RelationBuildPartitionKey().

745 {
746  HeapTuple tp;
747  Form_pg_amproc amproc_tup;
749 
751  ObjectIdGetDatum(opfamily),
752  ObjectIdGetDatum(lefttype),
753  ObjectIdGetDatum(righttype),
754  Int16GetDatum(procnum));
755  if (!HeapTupleIsValid(tp))
756  return InvalidOid;
757  amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
758  result = amproc_tup->amproc;
759  ReleaseSysCache(tp);
760  return result;
761 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:59
#define SearchSysCache4(cacheId, key1, key2, key3, key4)
Definition: syscache.h:158
regproc RegProcedure
Definition: c.h:395
#define Int16GetDatum(X)
Definition: postgres.h:457
return result
Definition: formatting.c:1618
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char* get_opname ( Oid  opno)

Definition at line 1087 of file lsyscache.c.

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

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

1088 {
1089  HeapTuple tp;
1090 
1092  if (HeapTupleIsValid(tp))
1093  {
1095  char *result;
1096 
1097  result = pstrdup(NameStr(optup->oprname));
1098  ReleaseSysCache(tp);
1099  return result;
1100  }
1101  else
1102  return NULL;
1103 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
#define NameStr(name)
Definition: c.h:499
RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1353 of file lsyscache.c.

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

Referenced by join_selectivity(), and scalararraysel().

1354 {
1355  HeapTuple tp;
1356 
1358  if (HeapTupleIsValid(tp))
1359  {
1362 
1363  result = optup->oprjoin;
1364  ReleaseSysCache(tp);
1365  return result;
1366  }
1367  else
1368  return (RegProcedure) InvalidOid;
1369 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
regproc RegProcedure
Definition: c.h:395
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
RegProcedure get_oprrest ( Oid  opno)

Definition at line 1329 of file lsyscache.c.

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

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

1330 {
1331  HeapTuple tp;
1332 
1334  if (HeapTupleIsValid(tp))
1335  {
1338 
1339  result = optup->oprrest;
1340  ReleaseSysCache(tp);
1341  return result;
1342  }
1343  else
1344  return (RegProcedure) InvalidOid;
1345 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
regproc RegProcedure
Definition: c.h:395
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 302 of file lsyscache.c.

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

Referenced by create_unique_plan().

303 {
305  CatCList *catlist;
306  int i;
307 
308  /*
309  * Search pg_amop to see if the target operator is registered as the "="
310  * operator of any btree opfamily.
311  */
313 
314  for (i = 0; i < catlist->n_members; i++)
315  {
316  HeapTuple tuple = &catlist->members[i]->tuple;
317  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
318 
319  /* must be btree */
320  if (aform->amopmethod != BTREE_AM_OID)
321  continue;
322 
323  if (aform->amopstrategy == BTEqualStrategyNumber)
324  {
325  /* Found a suitable opfamily, get matching ordering operator */
326  Oid typid;
327 
328  typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
329  result = get_opfamily_member(aform->amopfamily,
330  typid, typid,
332  if (OidIsValid(result))
333  break;
334  /* failure probably shouldn't happen, but keep looking if so */
335  }
336  }
337 
338  ReleaseSysCacheList(catlist);
339 
340  return result;
341 }
int n_members
Definition: catcache.h:154
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define BTREE_AM_OID
Definition: pg_am.h:70
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:538
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:163
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:116
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31
bool get_ordering_op_properties ( Oid  opno,
Oid opfamily,
Oid opcintype,
int16 strategy 
)

Definition at line 204 of file lsyscache.c.

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

Referenced by build_expression_pathkey(), get_equality_op_for_ordering_op(), get_relation_info(), make_pathkey_from_sortop(), and PrepareSortSupportFromOrderingOp().

206 {
207  bool result = false;
208  CatCList *catlist;
209  int i;
210 
211  /* ensure outputs are initialized on failure */
212  *opfamily = InvalidOid;
213  *opcintype = InvalidOid;
214  *strategy = 0;
215 
216  /*
217  * Search pg_amop to see if the target operator is registered as the "<"
218  * or ">" operator of any btree opfamily.
219  */
221 
222  for (i = 0; i < catlist->n_members; i++)
223  {
224  HeapTuple tuple = &catlist->members[i]->tuple;
225  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
226 
227  /* must be btree */
228  if (aform->amopmethod != BTREE_AM_OID)
229  continue;
230 
231  if (aform->amopstrategy == BTLessStrategyNumber ||
232  aform->amopstrategy == BTGreaterStrategyNumber)
233  {
234  /* Found it ... should have consistent input types */
235  if (aform->amoplefttype == aform->amoprighttype)
236  {
237  /* Found a suitable opfamily, return info */
238  *opfamily = aform->amopfamily;
239  *opcintype = aform->amoplefttype;
240  *strategy = aform->amopstrategy;
241  result = true;
242  break;
243  }
244  }
245  }
246 
247  ReleaseSysCacheList(catlist);
248 
249  return result;
250 }
int n_members
Definition: catcache.h:154
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define BTREE_AM_OID
Definition: pg_am.h:70
return result
Definition: formatting.c:1618
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:155
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:197
#define ReleaseSysCacheList(x)
Definition: syscache.h:206
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:116
#define BTLessStrategyNumber
Definition: stratnum.h:29
Oid get_promoted_array_type ( Oid  typid)

Definition at line 2504 of file lsyscache.c.

References get_array_type(), get_element_type(), InvalidOid, and OidIsValid.

Referenced by build_subplan(), and exprType().

2505 {
2506  Oid array_type = get_array_type(typid);
2507 
2508  if (OidIsValid(array_type))
2509  return array_type;
2510  if (OidIsValid(get_element_type(typid)))
2511  return typid;
2512  return InvalidOid;
2513 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2452
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2480
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:538
#define InvalidOid
Definition: postgres_ext.h:36
Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3047 of file lsyscache.c.

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

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

3048 {
3049  HeapTuple tp;
3050 
3051  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3052  if (HeapTupleIsValid(tp))
3053  {
3054  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3055  Oid result;
3056 
3057  result = rngtup->rngsubtype;
3058  ReleaseSysCache(tp);
3059  return result;
3060  }
3061  else
3062  return InvalidOid;
3063 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:49
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char* get_rel_name ( Oid  relid)

Definition at line 1694 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, NULL, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), RELOID, result, and SearchSysCache1.

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_tlist(), AlterSubscription_refresh(), AlterTableNamespace(), ApplyWorkerMain(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), conversion_error_callback(), 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_relation_policy_oid(), get_rewrite_oid(), get_rte_attribute_type(), get_trigger_oid(), getObjectDescription(), getObjectIdentityParts(), 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(), pg_prewarm(), pg_sequence_parameters(), postgresGetForeignRelSize(), reindex_index(), ReindexMultipleTables(), RenameConstraintById(), set_rtable_names(), show_modifytable_info(), and table_to_xml_internal().

1695 {
1696  HeapTuple tp;
1697 
1698  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1699  if (HeapTupleIsValid(tp))
1700  {
1701  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1702  char *result;
1703 
1704  result = pstrdup(NameStr(reltup->relname));
1705  ReleaseSysCache(tp);
1706  return result;
1707  }
1708  else
1709  return NULL;
1710 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
char * pstrdup(const char *in)
Definition: mcxt.c:1077
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define NameStr(name)
Definition: c.h:499
Oid get_rel_namespace ( Oid  relid)

Definition at line 1718 of file lsyscache.c.

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

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

1719 {
1720  HeapTuple tp;
1721 
1722  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1723  if (HeapTupleIsValid(tp))
1724  {
1725  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1726  Oid result;
1727 
1728  result = reltup->relnamespace;
1729  ReleaseSysCache(tp);
1730  return result;
1731  }
1732  else
1733  return InvalidOid;
1734 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
char get_rel_persistence ( Oid  relid)

Definition at line 1820 of file lsyscache.c.

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

Referenced by set_rel_consider_parallel().

1821 {
1822  HeapTuple tp;
1823  Form_pg_class reltup;
1824  char result;
1825 
1826  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1827  if (!HeapTupleIsValid(tp))
1828  elog(ERROR, "cache lookup failed for relation %u", relid);
1829  reltup = (Form_pg_class) GETSTRUCT(tp);
1830  result = reltup->relpersistence;
1831  ReleaseSysCache(tp);
1832 
1833  return result;
1834 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define elog
Definition: elog.h:219
char get_rel_relkind ( Oid  relid)

Definition at line 1769 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), RELOID, result, 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(), RelationGetPartitionDispatchInfo(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), and sepgsql_relation_setattr().

1770 {
1771  HeapTuple tp;
1772 
1773  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1774  if (HeapTupleIsValid(tp))
1775  {
1776  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1777  char result;
1778 
1779  result = reltup->relkind;
1780  ReleaseSysCache(tp);
1781  return result;
1782  }
1783  else
1784  return '\0';
1785 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
Oid get_rel_tablespace ( Oid  relid)

Definition at line 1796 of file lsyscache.c.

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

Referenced by pg_get_constraintdef_worker(), and pg_get_indexdef_worker().

1797 {
1798  HeapTuple tp;
1799 
1800  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1801  if (HeapTupleIsValid(tp))
1802  {
1803  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1804  Oid result;
1805 
1806  result = reltup->reltablespace;
1807  ReleaseSysCache(tp);
1808  return result;
1809  }
1810  else
1811  return InvalidOid;
1812 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
Oid get_rel_type_id ( Oid  relid)

Definition at line 1745 of file lsyscache.c.

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

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

1746 {
1747  HeapTuple tp;
1748 
1749  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1750  if (HeapTupleIsValid(tp))
1751  {
1752  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1753  Oid result;
1754 
1755  result = reltup->reltype;
1756  ReleaseSysCache(tp);
1757  return result;
1758  }
1759  else
1760  return InvalidOid;
1761 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
char* get_relid_attribute_name ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 801 of file lsyscache.c.

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

Referenced by conversion_error_callback(), decompile_column_index_array(), deparseColumnRef(), errtablecol(), generateClonedIndexStmt(), get_insert_query_def(), get_rte_attribute_name(), get_update_query_targetlist_def(), getObjectDescription(), getObjectIdentityParts(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsext_worker(), pg_get_triggerdef_worker(), processIndirection(), and transformPartitionBound().

802 {
803  char *attname;
804 
805  attname = get_attname(relid, attnum);
806  if (attname == NULL)
807  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
808  attnum, relid);
809  return attname;
810 }
char * get_attname(Oid relid, AttrNumber attnum)
Definition: lsyscache.c:774
#define ERROR
Definition: elog.h:43
#define NULL
Definition: c.h:229
#define elog
Definition: elog.h:219
Oid get_relname_relid ( const char *  relname,
Oid  relnamespace 
)
Oid get_transform_fromsql ( Oid  typid,
Oid  langid,
List trftypes 
)

Definition at line 1840 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, list_member_oid(), ReleaseSysCache(), SearchSysCache2, and TRFTYPELANG.

Referenced by plperl_call_perl_func(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), and PLy_input_datum_func2().

1841 {
1842  HeapTuple tup;
1843 
1844  if (!list_member_oid(trftypes, typid))
1845  return InvalidOid;
1846 
1847  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
1848  if (HeapTupleIsValid(tup))
1849  {
1850  Oid funcid;
1851 
1852  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
1853  ReleaseSysCache(tup);
1854  return funcid;
1855  }
1856  else
1857  return InvalidOid;
1858 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:35
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define SearchSysCache2(cacheId, key1, key2)
Definition: syscache.h:154
Oid get_transform_tosql ( Oid  typid,
Oid  langid,
List trftypes 
)

Definition at line 1861 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, list_member_oid(), ReleaseSysCache(), SearchSysCache2, and TRFTYPELANG.

Referenced by plperl_sv_to_datum(), and PLy_output_datum_func2().

1862 {
1863  HeapTuple tup;
1864 
1865  if (!list_member_oid(trftypes, typid))
1866  return InvalidOid;
1867 
1868  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
1869  if (HeapTupleIsValid(tup))
1870  {
1871  Oid funcid;
1872 
1873  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
1874  ReleaseSysCache(tup);
1875  return funcid;
1876  }
1877  else
1878  return InvalidOid;
1879 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:35
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:505
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define SearchSysCache2(cacheId, key1, key2)
Definition: syscache.h:154
Oid get_typ_typrelid ( Oid  typid)

Definition at line 2425 of file lsyscache.c.

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

Referenced by CheckAttributeType(), and processIndirection().

2426 {
2427  HeapTuple tp;
2428 
2430  if (HeapTupleIsValid(tp))
2431  {
2432  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2433  Oid result;
2434 
2435  result = typtup->typrelid;
2436  ReleaseSysCache(tp);
2437  return result;
2438  }
2439  else
2440  return InvalidOid;
2441 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2296 of file lsyscache.c.

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

Referenced by create_one_window_path(), find_placeholder_info(), get_agg_clause_costs_walker(), get_rel_data_width(), set_append_rel_size(), set_pathtarget_cost_width(), and set_rel_width().

2297 {
2298  int typlen = get_typlen(typid);
2299  int32 maxwidth;
2300 
2301  /*
2302  * Easy if it's a fixed-width type
2303  */
2304  if (typlen > 0)
2305  return typlen;
2306 
2307  /*
2308  * type_maximum_size knows the encoding of typmod for some datatypes;
2309  * don't duplicate that knowledge here.
2310  */
2311  maxwidth = type_maximum_size(typid, typmod);
2312  if (maxwidth > 0)
2313  {
2314  /*
2315  * For BPCHAR, the max width is also the only width. Otherwise we
2316  * need to guess about the typical data width given the max. A sliding
2317  * scale for percentage of max width seems reasonable.
2318  */
2319  if (typid == BPCHAROID)
2320  return maxwidth;
2321  if (maxwidth <= 32)
2322  return maxwidth; /* assume full width */
2323  if (maxwidth < 1000)
2324  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2325 
2326  /*
2327  * Beyond 1000, assume we're looking at something like
2328  * "varchar(10000)" where the limit isn't actually reached often, and
2329  * use a fixed estimate.
2330  */
2331  return 32 + (1000 - 32) / 2;
2332  }
2333 
2334  /*
2335  * Oops, we have no idea ... wild guess time.
2336  */
2337  return 32;
2338 }
#define BPCHAROID
Definition: pg_type.h:500
signed int int32
Definition: c.h:256
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:389
int16 get_typlen(Oid typid)
Definition: lsyscache.c:1915
bool get_typbyval ( Oid  typid)

Definition at line 1940 of file lsyscache.c.

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

Referenced by free_attstatsslot(), and get_agg_clause_costs_walker().

1941 {
1942  HeapTuple tp;
1943 
1945  if (HeapTupleIsValid(tp))
1946  {
1947  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1948  bool result;
1949 
1950  result = typtup->typbyval;
1951  ReleaseSysCache(tp);
1952  return result;
1953  }
1954  else
1955  return false;
1956 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
Oid get_typcollation ( Oid  typid)

Definition at line 2749 of file lsyscache.c.

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

Referenced by assign_collations_walker(), ATExecAddColumn(), check_sql_fn_retval(), DefineRange(), domainAddConstraint(), fixed_paramref_hook(), get_cast_hashentry(), 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().

2750 {
2751  HeapTuple tp;
2752 
2754  if (HeapTupleIsValid(tp))
2755  {
2756  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2757  Oid result;
2758 
2759  result = typtup->typcollation;
2760  ReleaseSysCache(tp);
2761  return result;
2762  }
2763  else
2764  return InvalidOid;
2765 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
Node* get_typdefault ( Oid  typid)

Definition at line 2166 of file lsyscache.c.

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

Referenced by build_column_default().

2167 {
2168  HeapTuple typeTuple;
2169  Form_pg_type type;
2170  Datum datum;
2171  bool isNull;
2172  Node *expr;
2173 
2174  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2175  if (!HeapTupleIsValid(typeTuple))
2176  elog(ERROR, "cache lookup failed for type %u", typid);
2177  type = (Form_pg_type) GETSTRUCT(typeTuple);
2178 
2179  /*
2180  * typdefault and typdefaultbin are potentially null, so don't try to
2181  * access 'em as struct fields. Must do it the hard way with
2182  * SysCacheGetAttr.
2183  */
2184  datum = SysCacheGetAttr(TYPEOID,
2185  typeTuple,
2187  &isNull);
2188 
2189  if (!isNull)
2190  {
2191  /* We have an expression default */
2192  expr = stringToNode(TextDatumGetCString(datum));
2193  }
2194  else
2195  {
2196  /* Perhaps we have a plain literal default */
2197  datum = SysCacheGetAttr(TYPEOID,
2198  typeTuple,
2200  &isNull);
2201 
2202  if (!isNull)
2203  {
2204  char *strDefaultVal;
2205 
2206  /* Convert text datum to C string */
2207  strDefaultVal = TextDatumGetCString(datum);
2208  /* Convert C string to a value of the given type */
2209  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2210  getTypeIOParam(typeTuple), -1);
2211  /* Build a Const node containing the value */
2212  expr = (Node *) makeConst(typid,
2213  -1,
2214  type->typcollation,
2215  type->typlen,
2216  datum,
2217  false,
2218  type->typbyval);
2219  pfree(strDefaultVal);
2220  }
2221  else
2222  {
2223  /* No default */
2224  expr = NULL;
2225  }
2226  }
2227 
2228  ReleaseSysCache(typeTuple);
2229 
2230  return expr;
2231 }
#define Anum_pg_type_typdefaultbin
Definition: pg_type.h:267
void * stringToNode(char *str)
Definition: read.c:38
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
Definition: nodes.h:506
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:296
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
void pfree(void *pointer)
Definition: mcxt.c:950
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define TextDatumGetCString(d)
Definition: builtins.h:92
uintptr_t Datum
Definition: postgres.h:372
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1278
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NULL
Definition: c.h:229
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2021
#define elog
Definition: elog.h:219
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:2047
#define Anum_pg_type_typdefault
Definition: pg_type.h:268
void get_type_category_preferred ( Oid  typid,
char *  typcategory,
bool typispreferred 
)

Definition at line 2404 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().

2405 {
2406  HeapTuple tp;
2407  Form_pg_type typtup;
2408 
2410  if (!HeapTupleIsValid(tp))
2411  elog(ERROR, "cache lookup failed for type %u", typid);
2412  typtup = (Form_pg_type) GETSTRUCT(tp);
2413  *typcategory = typtup->typcategory;
2414  *typispreferred = typtup->typispreferred;
2415  ReleaseSysCache(tp);
2416 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
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 2043 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_text_internal(), get_range_io_data(), plperl_ref_from_pg_array(), PLy_input_datum_func2(), and PLy_output_datum_func2().

2051 {
2052  HeapTuple typeTuple;
2053  Form_pg_type typeStruct;
2054 
2055  /*
2056  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2057  * use array_in and array_out during bootstrap.
2058  */
2060  {
2061  Oid typinput;
2062  Oid typoutput;
2063 
2064  boot_get_type_io_data(typid,
2065  typlen,
2066  typbyval,
2067  typalign,
2068  typdelim,
2069  typioparam,
2070  &typinput,
2071  &typoutput);
2072  switch (which_func)
2073  {
2074  case IOFunc_input:
2075  *func = typinput;
2076  break;
2077  case IOFunc_output:
2078  *func = typoutput;
2079  break;
2080  default:
2081  elog(ERROR, "binary I/O not supported during bootstrap");
2082  break;
2083  }
2084  return;
2085  }
2086 
2087  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2088  if (!HeapTupleIsValid(typeTuple))
2089  elog(ERROR, "cache lookup failed for type %u", typid);
2090  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2091 
2092  *typlen = typeStruct->typlen;
2093  *typbyval = typeStruct->typbyval;
2094  *typalign = typeStruct->typalign;
2095  *typdelim = typeStruct->typdelim;
2096  *typioparam = getTypeIOParam(typeTuple);
2097  switch (which_func)
2098  {
2099  case IOFunc_input:
2100  *func = typeStruct->typinput;
2101  break;
2102  case IOFunc_output:
2103  *func = typeStruct->typoutput;
2104  break;
2105  case IOFunc_receive:
2106  *func = typeStruct->typreceive;
2107  break;
2108  case IOFunc_send:
2109  *func = typeStruct->typsend;
2110  break;
2111  }
2112  ReleaseSysCache(typeTuple);
2113 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:365
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2021
#define elog
Definition: elog.h:219
void boot_get_type_io_data(Oid typid, int16 *typlen, bool *typbyval, char *typalign, char *typdelim, Oid *typioparam, Oid *typinput, Oid *typoutput)
Definition: bootstrap.c:936
bool get_typisdefined ( Oid  typid)

Definition at line 1891 of file lsyscache.c.

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

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

1892 {
1893  HeapTuple tp;
1894 
1896  if (HeapTupleIsValid(tp))
1897  {
1898  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1899  bool result;
1900 
1901  result = typtup->typisdefined;
1902  ReleaseSysCache(tp);
1903  return result;
1904  }
1905  else
1906  return false;
1907 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int16 get_typlen ( Oid  typid)

Definition at line 1915 of file lsyscache.c.

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

Referenced by exec_assign_value(), ExecBuildProjectionInfo(), ExecInitArrayRef(), ExecInitCoerceToDomain(), ExecInitExprRec(), get_typavgwidth(), and pg_column_size().

1916 {
1917  HeapTuple tp;
1918 
1920  if (HeapTupleIsValid(tp))
1921  {
1922  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1923  int16 result;
1924 
1925  result = typtup->typlen;
1926  ReleaseSysCache(tp);
1927  return result;
1928  }
1929  else
1930  return 0;
1931 }
signed short int16
Definition: c.h:255
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
void get_typlenbyval ( Oid  typid,
int16 typlen,
bool typbyval 
)

Definition at line 1969 of file lsyscache.c.

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

Referenced by build_pertrans_for_aggref(), copyParamList(), EstimateParamListSpace(), eval_const_expressions_mutator(), evaluate_expr(), exec_eval_using_params(), exec_stmt_block(), ExecInitAgg(), ExecInitIndexScan(), ExecInitWindowAgg(), ExecWindowAgg(), fillTypeDesc(), get_actual_variable_range(), get_variable_range(), init_sql_fcache(), initialize_peragg(), makeNullConst(), scalararraysel(), SerializeParamList(), and tuplesort_begin_datum().

1970 {
1971  HeapTuple tp;
1972  Form_pg_type typtup;
1973 
1975  if (!HeapTupleIsValid(tp))
1976  elog(ERROR, "cache lookup failed for type %u", typid);
1977  typtup = (Form_pg_type) GETSTRUCT(tp);
1978  *typlen = typtup->typlen;
1979  *typbyval = typtup->typbyval;
1980  ReleaseSysCache(tp);
1981 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
void get_typlenbyvalalign ( Oid  typid,
int16 typlen,
bool typbyval,
char *  typalign 
)

Definition at line 1989 of file lsyscache.c.

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

Referenced by _bt_preprocess_array_keys(), array_create_iterator(), array_fill_internal(), array_map(), array_position_common(), array_positions(), array_to_json_internal(), array_to_jsonb_internal(), array_unnest(), arrayconst_startup_fn(), BuildArrayRemapInfo(), create_singleton_array(), CreateCast(), DefineRange(), exec_assign_value(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitArrayRef(), ExecInitExprRec(), expand_array(), get_text_array_contents(), ginarrayextract(), gincost_scalararrayopexpr(), ginqueryarrayextract(), initArrayResult(), map_sql_value_to_xml_value(), ordered_set_startup(), RelationBuildPartitionKey(), scalararraysel(), and text_format().

1991 {
1992  HeapTuple tp;
1993  Form_pg_type typtup;
1994 
1996  if (!HeapTupleIsValid(tp))
1997  elog(ERROR, "cache lookup failed for type %u", typid);
1998  typtup = (Form_pg_type) GETSTRUCT(tp);
1999  *typlen = typtup->typlen;
2000  *typbyval = typtup->typbyval;
2001  *typalign = typtup->typalign;
2002  ReleaseSysCache(tp);
2003 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
Oid get_typmodin ( Oid  typid)

Definition at line 2699 of file lsyscache.c.

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

2700 {
2701  HeapTuple tp;
2702 
2704  if (HeapTupleIsValid(tp))
2705  {
2706  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2707  Oid result;
2708 
2709  result = typtup->typmodin;
2710  ReleaseSysCache(tp);
2711  return result;
2712  }
2713  else
2714  return InvalidOid;
2715 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char get_typstorage ( Oid  typid)

Definition at line 2137 of file lsyscache.c.

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

2138 {
2139  HeapTuple tp;
2140 
2142  if (HeapTupleIsValid(tp))
2143  {
2144  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2145  char result;
2146 
2147  result = typtup->typstorage;
2148  ReleaseSysCache(tp);
2149  return result;
2150  }
2151  else
2152  return 'p';
2153 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
char get_typtype ( Oid  typid)

Definition at line 2347 of file lsyscache.c.

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

Referenced by AlterTypeNamespace(), check_sql_fn_retval(), CheckAttributeType(), CreateCast(), CreateTransform(), 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(), PLySequence_ToArray(), type_is_enum(), type_is_range(), and type_is_rowtype().

2348 {
2349  HeapTuple tp;
2350 
2352  if (HeapTupleIsValid(tp))
2353  {
2354  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2355  char result;
2356 
2357  result = typtup->typtype;
2358  ReleaseSysCache(tp);
2359  return result;
2360  }
2361  else
2362  return '\0';
2363 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2256 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 transformTypeCast().

2257 {
2258  /*
2259  * We loop to find the bottom base type in a stack of domains.
2260  */
2261  for (;;)
2262  {
2263  HeapTuple tup;
2264  Form_pg_type typTup;
2265 
2266  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2267  if (!HeapTupleIsValid(tup))
2268  elog(ERROR, "cache lookup failed for type %u", typid);
2269  typTup = (Form_pg_type) GETSTRUCT(tup);
2270  if (typTup->typtype != TYPTYPE_DOMAIN)
2271  {
2272  /* Not a domain, so done */
2273  ReleaseSysCache(tup);
2274  break;
2275  }
2276 
2277  Assert(*typmod == -1);
2278  typid = typTup->typbasetype;
2279  *typmod = typTup->typtypmod;
2280 
2281  ReleaseSysCache(tup);
2282  }
2283 
2284  return typid;
2285 }
#define TYPTYPE_DOMAIN
Definition: pg_type.h:718
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define Assert(condition)
Definition: c.h:675
#define elog
Definition: elog.h:219
void getTypeBinaryInputInfo ( Oid  type,
Oid typReceive,
Oid typIOParam 
)

Definition at line 2633 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().

2634 {
2635  HeapTuple typeTuple;
2636  Form_pg_type pt;
2637 
2638  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2639  if (!HeapTupleIsValid(typeTuple))
2640  elog(ERROR, "cache lookup failed for type %u", type);
2641  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2642 
2643  if (!pt->typisdefined)
2644  ereport(ERROR,
2645  (errcode(ERRCODE_UNDEFINED_OBJECT),
2646  errmsg("type %s is only a shell",
2647  format_type_be(type))));
2648  if (!OidIsValid(pt->typreceive))
2649  ereport(ERROR,
2650  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2651  errmsg("no binary input function available for type %s",
2652  format_type_be(type))));
2653 
2654  *typReceive = pt->typreceive;
2655  *typIOParam = getTypeIOParam(typeTuple);
2656 
2657  ReleaseSysCache(typeTuple);
2658 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
int errcode(int sqlerrcode)
Definition: elog.c:575
char * format_type_be(Oid type_oid)
Definition: format_type.c:94
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define OidIsValid(objectId)
Definition: c.h:538
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2021
#define elog
Definition: elog.h:219
void getTypeBinaryOutputInfo ( Oid  type,
Oid typSend,
bool typIsVarlena 
)

Definition at line 2666 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().

2667 {
2668  HeapTuple typeTuple;
2669  Form_pg_type pt;
2670 
2671  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2672  if (!HeapTupleIsValid(typeTuple))
2673  elog(ERROR, "cache lookup failed for type %u", type);
2674  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2675 
2676  if (!pt->typisdefined)
2677  ereport(ERROR,
2678  (errcode(ERRCODE_UNDEFINED_OBJECT),
2679  errmsg("type %s is only a shell",
2680  format_type_be(type))));
2681  if (!OidIsValid(pt->typsend))
2682  ereport(ERROR,
2683  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2684  errmsg("no binary output function available for type %s",
2685  format_type_be(type))));
2686 
2687  *typSend = pt->typsend;
2688  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2689 
2690  ReleaseSysCache(typeTuple);
2691 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
int errcode(int sqlerrcode)
Definition: elog.c:575
char * format_type_be(Oid type_oid)
Definition: format_type.c:94
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define OidIsValid(objectId)
Definition: c.h:538
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define elog
Definition: elog.h:219
void getTypeInputInfo ( Oid  type,
Oid typInput,
Oid typIOParam 
)

Definition at line 2567 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(), check_functions_in_node(), cost_qual_eval_walker(), DefineAggregate(), domain_state_setup(), eval_const_expressions_mutator(), exec_bind_message(), ExecInitExprRec(), ExecInitTableFuncScan(), GetAggInitVal(), hstore_populate_record(), make_row_from_rec_and_jsonb(), parse_fcall_arguments(), plperl_spi_prepare(), pltcl_SPI_prepare(), populate_record_worker(), populate_recordset_object_end(), record_in(), slot_modify_cstrings(), slot_store_cstrings(), and TupleDescGetAttInMetadata().

2568 {
2569  HeapTuple typeTuple;
2570  Form_pg_type pt;
2571 
2572  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2573  if (!HeapTupleIsValid(typeTuple))
2574  elog(ERROR, "cache lookup failed for type %u", type);
2575  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2576 
2577  if (!pt->typisdefined)
2578  ereport(ERROR,
2579  (errcode(ERRCODE_UNDEFINED_OBJECT),
2580  errmsg("type %s is only a shell",
2581  format_type_be(type))));
2582  if (!OidIsValid(pt->typinput))
2583  ereport(ERROR,
2584  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2585  errmsg("no input function available for type %s",
2586  format_type_be(type))));
2587 
2588  *typInput = pt->typinput;
2589  *typIOParam = getTypeIOParam(typeTuple);
2590 
2591  ReleaseSysCache(typeTuple);
2592 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
int errcode(int sqlerrcode)
Definition: elog.c:575
char * format_type_be(Oid type_oid)
Definition: format_type.c:94
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define OidIsValid(objectId)
Definition: c.h:538
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2021
#define elog
Definition: elog.h:219
Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2021 of file lsyscache.c.

References GETSTRUCT, HeapTupleGetOid, and OidIsValid.

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

2022 {
2023  Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2024 
2025  /*
2026  * Array types get their typelem as parameter; everybody else gets their
2027  * own type OID as parameter.
2028  */
2029  if (OidIsValid(typeStruct->typelem))
2030  return typeStruct->typelem;
2031  else
2032  return HeapTupleGetOid(typeTuple);
2033 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define OidIsValid(objectId)
Definition: c.h:538
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:695
void getTypeOutputInfo ( Oid  type,
Oid typOutput,
bool typIsVarlena 
)

Definition at line 2600 of file lsyscache.c.

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

Referenced by brin_page_items(), BuildIndexValueDescription(), check_functions_in_node(), concat_internal(), convert_value_to_string(), CopyTo(), cost_qual_eval_walker(), debugtup(), deparseConst(), errdetail_params(), eval_const_expressions_mutator(), ExecBuildSlotPartitionKeyDescription(), ExecBuildSlotValueDescription(), ExecInitExprRec(), get_const_expr(), hstore_from_record(), json_categorize_type(), jsonb_categorize_type(), map_sql_value_to_xml_value(), plperl_hash_from_tuple(), plperl_sv_to_literal(), pltcl_build_tuple_argument(), pltcl_set_tuple_values(), postgresBeginForeignModify(), prepare_query_params(), print_expr(), printtup_prepare_info(), record_out(), SendFunctionResult(), set_limit(), SPI_getvalue(), text_format(), and tuple_to_stringinfo().

2601 {
2602  HeapTuple typeTuple;
2603  Form_pg_type pt;
2604 
2605  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(type));
2606  if (!HeapTupleIsValid(typeTuple))
2607  elog(ERROR, "cache lookup failed for type %u", type);
2608  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2609 
2610  if (!pt->typisdefined)
2611  ereport(ERROR,
2612  (errcode(ERRCODE_UNDEFINED_OBJECT),
2613  errmsg("type %s is only a shell",
2614  format_type_be(type))));
2615  if (!OidIsValid(pt->typoutput))
2616  ereport(ERROR,
2617  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2618  errmsg("no output function available for type %s",
2619  format_type_be(type))));
2620 
2621  *typOutput = pt->typoutput;
2622  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2623 
2624  ReleaseSysCache(typeTuple);
2625 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
int errcode(int sqlerrcode)
Definition: elog.c:575
char * format_type_be(Oid type_oid)
Definition: format_type.c:94
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define OidIsValid(objectId)
Definition: c.h:538
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define elog
Definition: elog.h:219
bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1214 of file lsyscache.c.

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

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

1215 {
1216  bool result = false;
1217  HeapTuple tp;
1218  TypeCacheEntry *typentry;
1219 
1220  /* As in op_mergejoinable, let the typcache handle the hard cases */
1221  /* Eventually we'll need a similar case for record_eq ... */
1222  if (opno == ARRAY_EQ_OP)
1223  {
1224  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1225  if (typentry->hash_proc == F_HASH_ARRAY)
1226  result = true;
1227  }
1228  else
1229  {
1230  /* For all other operators, rely on pg_operator.oprcanhash */
1232  if (HeapTupleIsValid(tp))
1233  {
1235 
1236  result = optup->oprcanhash;
1237  ReleaseSysCache(tp);
1238  }
1239  }
1240  return result;
1241 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:191
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define ARRAY_EQ_OP
Definition: pg_operator.h:776
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
#define TYPECACHE_HASH_PROC
Definition: typcache.h:114
bool op_in_opfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 63 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().

64 {
66  ObjectIdGetDatum(opno),
68  ObjectIdGetDatum(opfamily));
69 }
#define AMOP_SEARCH
Definition: pg_amop.h:69
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheExists3(cacheId, key1, key2, key3)
Definition: syscache.h:174
#define CharGetDatum(X)
Definition: postgres.h:422
void op_input_types ( Oid  opno,
Oid lefttype,
Oid righttype 
)

Definition at line 1135 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().

1136 {
1137  HeapTuple tp;
1138  Form_pg_operator optup;
1139 
1141  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1142  elog(ERROR, "cache lookup failed for operator %u", opno);
1143  optup = (Form_pg_operator) GETSTRUCT(tp);
1144  *lefttype = optup->oprleft;
1145  *righttype = optup->oprright;
1146  ReleaseSysCache(tp);
1147 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
#define elog
Definition: elog.h:219
bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1163 of file lsyscache.c.

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

Referenced by check_mergejoinable(), and compute_semijoin_info().

1164 {
1165  bool result = false;
1166  HeapTuple tp;
1167  TypeCacheEntry *typentry;
1168 
1169  /*
1170  * For array_eq or record_eq, we can sort if the element or field types
1171  * are all sortable. We could implement all the checks for that here, but
1172  * the typcache already does that and caches the results too, so let's
1173  * rely on the typcache.
1174  */
1175  if (opno == ARRAY_EQ_OP)
1176  {
1177  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1178  if (typentry->cmp_proc == F_BTARRAYCMP)
1179  result = true;
1180  }
1181  else if (opno == RECORD_EQ_OP)
1182  {
1183  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1184  if (typentry->cmp_proc == F_BTRECORDCMP)
1185  result = true;
1186  }
1187  else
1188  {
1189  /* For all other operators, rely on pg_operator.oprcanmerge */
1191  if (HeapTupleIsValid(tp))
1192  {
1194 
1195  result = optup->oprcanmerge;
1196  ReleaseSysCache(tp);
1197  }
1198  }
1199  return result;
1200 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:656
return result
Definition: formatting.c:1618
#define RECORD_EQ_OP
Definition: pg_operator.h:1720
#define SearchSysCache1(cacheId, key1)
Definition: syscache.h:152
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1116
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:191
#define TYPECACHE_CMP_PROC
Definition: typcache.h:113
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define ARRAY_EQ_OP
Definition: pg_operator.h:776
FormData_pg_operator* Form_pg_operator
Definition: pg_operator.h:57
bool op_strict ( Oid  opno)

Definition at line 1249 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().

1250 {
1251  RegProcedure funcid = get_opcode(opno);
1252 
1253  if (funcid == (RegProcedure) InvalidOid)
1254  elog(ERROR, "operator %u does not exist", opno);
1255 
1256  return func_strict((Oid) funcid);
1257 }
regproc RegProcedure
Definition: c.h:395
unsigned int Oid
Definition: postgres_ext.h:31
#define ERROR
Definition: elog.h:43
#define InvalidOid
Definition: postgres_ext.h:36
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1062
bool func_strict(Oid funcid)
Definition: lsyscache.c:1533
#define elog
Definition: elog.h:219
char op_volatile ( Oid  opno)

Definition at line 1265 of file lsyscache.c.

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

Referenced by lookup_proof_cache().

1266 {
1267  RegProcedure funcid = get_opcode(opno);
1268 
1269  if (funcid == (RegProcedure) InvalidOid)
1270  elog(ERROR, "operator %u does not exist", opno);
1271 
1272  return func_volatile((Oid) funcid);
1273 }
regproc RegProcedure
Definition: c.h:395
unsigned int Oid
Definition: postgres_ext.h:31
#define ERROR
Definition: elog.h:43
#define InvalidOid
Definition: postgres_ext.h:36
RegProcedure get_opcode(Oid opno)
Definition: lsyscache.c:1062
char func_volatile(Oid funcid)
Definition: lsyscache.c:1552
#define elog
Definition: elog.h:219
bool type_is_collatable ( Oid  typid)

Definition at line 2774 of file lsyscache.c.

References get_typcollation(), and OidIsValid.

Referenced by CheckAttributeType(), ComputeIndexAttrs(), ComputePartitionAttrs(), create_ctas_nodata(), DefineRange(), DefineVirtualRelation(), intorel_startup(), pg_collation_for(), transformCollateClause(), and transformRangeTableFunc().

2775 {
2776  return OidIsValid(get_typcollation(typid));
2777 }
#define OidIsValid(objectId)
Definition: c.h:538
Oid get_typcollation(Oid typid)
Definition: lsyscache.c:2749
bool type_is_enum ( Oid  typid)

Definition at line 2382 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().

2383 {
2384  return (get_typtype(typid) == TYPTYPE_ENUM);
2385 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2347
#define TYPTYPE_ENUM
Definition: pg_type.h:719
bool type_is_range ( Oid  typid)

Definition at line 2392 of file lsyscache.c.

References get_typtype(), and TYPTYPE_RANGE.

Referenced by IsBinaryCoercible().

2393 {
2394  return (get_typtype(typid) == TYPTYPE_RANGE);
2395 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2347
#define TYPTYPE_RANGE
Definition: pg_type.h:721

Variable Documentation

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook

Definition at line 50 of file lsyscache.c.

Referenced by get_attavgwidth().