PostgreSQL Source Code  git master
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
 
struct  AttStatsSlot
 

Macros

#define ATTSTATSSLOT_VALUES   0x01
 
#define ATTSTATSSLOT_NUMBERS   0x02
 
#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 struct AttStatsSlot AttStatsSlot
 
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)
 
char get_attidentity (Oid relid, AttrNumber attnum)
 
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_isagg (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 (AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
 
void free_attstatsslot (AttStatsSlot *sslot)
 
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

◆ ATTSTATSSLOT_NUMBERS

◆ ATTSTATSSLOT_VALUES

◆ type_is_array

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

◆ type_is_array_domain

#define type_is_array_domain (   typid)    (get_base_element_type(typid) != InvalidOid)

◆ TypeIsToastable

#define TypeIsToastable (   typid)    (get_typstorage(typid) != 'p')

Definition at line 185 of file lsyscache.h.

Referenced by ATExecSetStorage(), and ExecIndexBuildScanKeys().

Typedef Documentation

◆ AttStatsSlot

◆ get_attavgwidth_hook_type

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

Definition at line 61 of file lsyscache.h.

◆ IOFuncSelector

◆ OpBtreeInterpretation

Enumeration Type Documentation

◆ IOFuncSelector

Enumerator
IOFunc_input 
IOFunc_output 
IOFunc_receive 
IOFunc_send 

Definition at line 30 of file lsyscache.h.

Function Documentation

◆ equality_ops_are_compatible()

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, 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:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define BTREE_AM_OID
Definition: pg_am.h:70
#define HASH_AM_OID
Definition: pg_am.h:73
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:209
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3044 of file lsyscache.c.

References AttStatsSlot::numbers_arr, pfree(), AttStatsSlot::values, and AttStatsSlot::values_arr.

Referenced by _int_matchsel(), booltestsel(), brincostestimate(), btcostestimate(), calc_arraycontsel(), calc_hist_selectivity(), calc_rangesel(), eqjoinsel_inner(), eqjoinsel_semi(), estimate_hash_bucket_stats(), 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().

3045 {
3046  /* The values[] array was separately palloc'd by deconstruct_array */
3047  if (sslot->values)
3048  pfree(sslot->values);
3049  /* The numbers[] array points into numbers_arr, do not pfree it */
3050  /* Free the detoasted array objects, if any */
3051  if (sslot->values_arr)
3052  pfree(sslot->values_arr);
3053  if (sslot->numbers_arr)
3054  pfree(sslot->numbers_arr);
3055 }
void pfree(void *pointer)
Definition: mcxt.c:936
void * values_arr
Definition: lsyscache.h:56
Datum * values
Definition: lsyscache.h:49
void * numbers_arr
Definition: lsyscache.h:57

◆ func_parallel()

char func_parallel ( Oid  funcid)

Definition at line 1603 of file lsyscache.c.

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

Referenced by max_parallel_hazard_checker(), and set_rel_consider_parallel().

1604 {
1605  HeapTuple tp;
1606  char result;
1607 
1608  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1609  if (!HeapTupleIsValid(tp))
1610  elog(ERROR, "cache lookup failed for function %u", funcid);
1611 
1612  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1613  ReleaseSysCache(tp);
1614  return result;
1615 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1565 of file lsyscache.c.

References elog, ERROR, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, PROCOID, ReleaseSysCache(), 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(), predicate_refuted_by_simple_clause(), and process_equivalence().

1566 {
1567  HeapTuple tp;
1568  bool result;
1569 
1570  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1571  if (!HeapTupleIsValid(tp))
1572  elog(ERROR, "cache lookup failed for function %u", funcid);
1573 
1574  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1575  ReleaseSysCache(tp);
1576  return result;
1577 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ func_volatile()

char func_volatile ( Oid  funcid)

Definition at line 1584 of file lsyscache.c.

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

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

1585 {
1586  HeapTuple tp;
1587  char result;
1588 
1589  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1590  if (!HeapTupleIsValid(tp))
1591  elog(ERROR, "cache lookup failed for function %u", funcid);
1592 
1593  result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
1594  ReleaseSysCache(tp);
1595  return result;
1596 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2545 of file lsyscache.c.

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

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

2546 {
2547  HeapTuple tp;
2548  Oid result = InvalidOid;
2549 
2551  if (HeapTupleIsValid(tp))
2552  {
2553  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2554  ReleaseSysCache(tp);
2555  }
2556  return result;
2557 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

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

2862 {
2863  HeapTuple tp;
2864  int32 stawidth;
2865 
2867  {
2868  stawidth = (*get_attavgwidth_hook) (relid, attnum);
2869  if (stawidth > 0)
2870  return stawidth;
2871  }
2873  ObjectIdGetDatum(relid),
2874  Int16GetDatum(attnum),
2875  BoolGetDatum(false));
2876  if (HeapTupleIsValid(tp))
2877  {
2878  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
2879  ReleaseSysCache(tp);
2880  if (stawidth > 0)
2881  return stawidth;
2882  }
2883  return 0;
2884 }
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:50
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define Int16GetDatum(X)
Definition: postgres.h:457
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:129
signed int int32
Definition: c.h:294
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1134
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define BoolGetDatum(X)
Definition: postgres.h:408
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_attidentity()

char get_attidentity ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 851 of file lsyscache.c.

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

Referenced by ATExecColumnDefault(), ATExecDropNotNull(), and transformAlterTableStmt().

852 {
853  HeapTuple tp;
854 
855  tp = SearchSysCache2(ATTNUM,
856  ObjectIdGetDatum(relid),
857  Int16GetDatum(attnum));
858  if (HeapTupleIsValid(tp))
859  {
861  char result;
862 
863  result = att_tup->attidentity;
864  ReleaseSysCache(tp);
865  return result;
866  }
867  else
868  return '\0';
869 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define Int16GetDatum(X)
Definition: postgres.h:457
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123

◆ get_attname()

char* get_attname ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 774 of file lsyscache.c.

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

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

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:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define Int16GetDatum(X)
Definition: postgres.h:457
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123
#define NameStr(name)
Definition: c.h:557

◆ get_attnum()

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 821 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidAttrNumber, ReleaseSysCache(), 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(), transformAlterTableStmt(), and transformAssignmentIndirection().

822 {
823  HeapTuple tp;
824 
825  tp = SearchSysCacheAttName(relid, attname);
826  if (HeapTupleIsValid(tp))
827  {
829  AttrNumber result;
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:661
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1248
#define InvalidAttrNumber
Definition: attnum.h:23
int16 AttrNumber
Definition: attnum.h:21

◆ get_attstatsslot()

bool get_attstatsslot ( AttStatsSlot sslot,
HeapTuple  statstuple,
int  reqkind,
Oid  reqop,
int  flags 
)

Definition at line 2928 of file lsyscache.c.

References Anum_pg_statistic_stanumbers1, Anum_pg_statistic_stavalues1, ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, DatumGetArrayTypePCopy, deconstruct_array(), elog, ERROR, FLOAT4OID, GETSTRUCT, HeapTupleIsValid, i, InvalidOid, AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::numbers_arr, AttStatsSlot::nvalues, ObjectIdGetDatum, pfree(), ReleaseSysCache(), SearchSysCache1(), AttStatsSlot::staop, STATISTIC_NUM_SLOTS, STATRELATTINH, SysCacheGetAttr(), TYPEOID, val, AttStatsSlot::values, AttStatsSlot::values_arr, and AttStatsSlot::valuetype.

Referenced by _int_matchsel(), booltestsel(), brincostestimate(), btcostestimate(), calc_arraycontsel(), calc_hist_selectivity(), calc_rangesel(), eqjoinsel_inner(), eqjoinsel_semi(), estimate_hash_bucket_stats(), 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().

2930 {
2931  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
2932  int i;
2933  Datum val;
2934  bool isnull;
2935  ArrayType *statarray;
2936  Oid arrayelemtype;
2937  int narrayelem;
2938  HeapTuple typeTuple;
2939  Form_pg_type typeForm;
2940 
2941  /* initialize *sslot properly */
2942  memset(sslot, 0, sizeof(AttStatsSlot));
2943 
2944  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
2945  {
2946  if ((&stats->stakind1)[i] == reqkind &&
2947  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
2948  break;
2949  }
2950  if (i >= STATISTIC_NUM_SLOTS)
2951  return false; /* not there */
2952 
2953  sslot->staop = (&stats->staop1)[i];
2954 
2955  if (flags & ATTSTATSSLOT_VALUES)
2956  {
2957  val = SysCacheGetAttr(STATRELATTINH, statstuple,
2959  &isnull);
2960  if (isnull)
2961  elog(ERROR, "stavalues is null");
2962 
2963  /*
2964  * Detoast the array if needed, and in any case make a copy that's
2965  * under control of this AttStatsSlot.
2966  */
2967  statarray = DatumGetArrayTypePCopy(val);
2968 
2969  /*
2970  * Extract the actual array element type, and pass it back in case the
2971  * caller needs it.
2972  */
2973  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
2974 
2975  /* Need info about element type */
2976  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
2977  if (!HeapTupleIsValid(typeTuple))
2978  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
2979  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
2980 
2981  /* Deconstruct array into Datum elements; NULLs not expected */
2982  deconstruct_array(statarray,
2983  arrayelemtype,
2984  typeForm->typlen,
2985  typeForm->typbyval,
2986  typeForm->typalign,
2987  &sslot->values, NULL, &sslot->nvalues);
2988 
2989  /*
2990  * If the element type is pass-by-reference, we now have a bunch of
2991  * Datums that are pointers into the statarray, so we need to keep
2992  * that until free_attstatsslot. Otherwise, all the useful info is in
2993  * sslot->values[], so we can free the array object immediately.
2994  */
2995  if (!typeForm->typbyval)
2996  sslot->values_arr = statarray;
2997  else
2998  pfree(statarray);
2999 
3000  ReleaseSysCache(typeTuple);
3001  }
3002 
3003  if (flags & ATTSTATSSLOT_NUMBERS)
3004  {
3005  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3007  &isnull);
3008  if (isnull)
3009  elog(ERROR, "stanumbers is null");
3010 
3011  /*
3012  * Detoast the array if needed, and in any case make a copy that's
3013  * under control of this AttStatsSlot.
3014  */
3015  statarray = DatumGetArrayTypePCopy(val);
3016 
3017  /*
3018  * We expect the array to be a 1-D float4 array; verify that. We don't
3019  * need to use deconstruct_array() since the array data is just going
3020  * to look like a C array of float4 values.
3021  */
3022  narrayelem = ARR_DIMS(statarray)[0];
3023  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3024  ARR_HASNULL(statarray) ||
3025  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3026  elog(ERROR, "stanumbers is not a 1-D float4 array");
3027 
3028  /* Give caller a pointer directly into the statarray */
3029  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3030  sslot->nnumbers = narrayelem;
3031 
3032  /* We'll free the statarray in free_attstatsslot */
3033  sslot->numbers_arr = statarray;
3034  }
3035 
3036  return true;
3037 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:39
#define Anum_pg_statistic_stavalues1
Definition: pg_statistic.h:157
int nnumbers
Definition: lsyscache.h:53
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
void pfree(void *pointer)
Definition: mcxt.c:936
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:40
void * values_arr
Definition: lsyscache.h:56
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ARR_DIMS(a)
Definition: array.h:279
#define ARR_DATA_PTR(a)
Definition: array.h:307
float4 * numbers
Definition: lsyscache.h:52
#define ARR_HASNULL(a)
Definition: array.h:276
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
float float4
Definition: c.h:438
#define FLOAT4OID
Definition: pg_type.h:416
uintptr_t Datum
Definition: postgres.h:372
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1368
#define DatumGetArrayTypePCopy(X)
Definition: array.h:247
#define InvalidOid
Definition: postgres_ext.h:36
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:121
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
Datum * values
Definition: lsyscache.h:49
#define Anum_pg_statistic_stanumbers1
Definition: pg_statistic.h:152
#define ARR_NDIM(a)
Definition: array.h:275
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3449
int i
void * numbers_arr
Definition: lsyscache.h:57
#define elog
Definition: elog.h:219
Oid valuetype
Definition: lsyscache.h:48
#define ARR_ELEMTYPE(a)
Definition: array.h:277
long val
Definition: informix.c:689

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 878 of file lsyscache.c.

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

Referenced by generateClonedIndexStmt(), LookupTypeName(), and transformAlterTableStmt().

879 {
880  HeapTuple tp;
881 
882  tp = SearchSysCache2(ATTNUM,
883  ObjectIdGetDatum(relid),
884  Int16GetDatum(attnum));
885  if (HeapTupleIsValid(tp))
886  {
888  Oid result;
889 
890  result = att_tup->atttypid;
891  ReleaseSysCache(tp);
892  return result;
893  }
894  else
895  return InvalidOid;
896 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define Int16GetDatum(X)
Definition: postgres.h:457
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:187
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123

◆ get_atttypetypmodcoll()

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

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

937 {
938  HeapTuple tp;
939  Form_pg_attribute att_tup;
940 
941  tp = SearchSysCache2(ATTNUM,
942  ObjectIdGetDatum(relid),
943  Int16GetDatum(attnum));
944  if (!HeapTupleIsValid(tp))
945  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
946  attnum, relid);
947  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
948 
949  *typid = att_tup->atttypid;
950  *typmod = att_tup->atttypmod;
951  *collid = att_tup->attcollation;
952  ReleaseSysCache(tp);
953 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#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:187
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123
#define elog
Definition: elog.h:219

◆ get_atttypmod()

int32 get_atttypmod ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 905 of file lsyscache.c.

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

906 {
907  HeapTuple tp;
908 
909  tp = SearchSysCache2(ATTNUM,
910  ObjectIdGetDatum(relid),
911  Int16GetDatum(attnum));
912  if (HeapTupleIsValid(tp))
913  {
915  int32 result;
916 
917  result = att_tup->atttypmod;
918  ReleaseSysCache(tp);
919  return result;
920  }
921  else
922  return -1;
923 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define Int16GetDatum(X)
Definition: postgres.h:457
signed int int32
Definition: c.h:294
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:187
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2590 of file lsyscache.c.

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

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

2591 {
2592  /*
2593  * We loop to find the bottom base type in a stack of domains.
2594  */
2595  for (;;)
2596  {
2597  HeapTuple tup;
2598  Form_pg_type typTup;
2599 
2600  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2601  if (!HeapTupleIsValid(tup))
2602  break;
2603  typTup = (Form_pg_type) GETSTRUCT(tup);
2604  if (typTup->typtype != TYPTYPE_DOMAIN)
2605  {
2606  /* Not a domain, so stop descending */
2607  Oid result;
2608 
2609  /* This test must match get_element_type */
2610  if (typTup->typlen == -1)
2611  result = typTup->typelem;
2612  else
2613  result = InvalidOid;
2614  ReleaseSysCache(tup);
2615  return result;
2616  }
2617 
2618  typid = typTup->typbasetype;
2619  ReleaseSysCache(tup);
2620  }
2621 
2622  /* Like get_element_type, silently return InvalidOid for bogus input */
2623  return InvalidOid;
2624 }
#define TYPTYPE_DOMAIN
Definition: pg_type.h:722
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

Definition at line 967 of file lsyscache.c.

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

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

968 {
969  HeapTuple tp;
970 
971  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
972  if (HeapTupleIsValid(tp))
973  {
975  char *result;
976 
977  result = pstrdup(NameStr(colltup->collname));
978  ReleaseSysCache(tp);
979  return result;
980  }
981  else
982  return NULL;
983 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:52
#define NameStr(name)
Definition: c.h:557

◆ get_commutator()

Oid get_commutator ( Oid  opno)

Definition at line 1313 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), 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(), scalarineqsel_wrapper(), and targetIsInSortList().

1314 {
1315  HeapTuple tp;
1316 
1318  if (HeapTupleIsValid(tp))
1319  {
1321  Oid result;
1322 
1323  result = optup->oprcom;
1324  ReleaseSysCache(tp);
1325  return result;
1326  }
1327  else
1328  return InvalidOid;
1329 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_compatible_hash_operators()

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, 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:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define HTEqualStrategyNumber
Definition: hash.h:336
#define OidIsValid(objectId)
Definition: c.h:586
#define HASH_AM_OID
Definition: pg_am.h:73
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#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:209
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#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:121

◆ get_constraint_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 997 of file lsyscache.c.

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

Referenced by get_insert_query_def(), and report_triggers().

998 {
999  HeapTuple tp;
1000 
1002  if (HeapTupleIsValid(tp))
1003  {
1005  char *result;
1006 
1007  result = pstrdup(NameStr(contup->conname));
1008  ReleaseSysCache(tp);
1009  return result;
1010  }
1011  else
1012  return NULL;
1013 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NameStr(name)
Definition: c.h:557

◆ get_element_type()

Oid get_element_type ( Oid  typid)

Definition at line 2517 of file lsyscache.c.

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

Referenced by aclcheck_error_type(), AlterTypeNamespace_oid(), build_coercion_expression(), 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().

2518 {
2519  HeapTuple tp;
2520 
2522  if (HeapTupleIsValid(tp))
2523  {
2524  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2525  Oid result;
2526 
2527  if (typtup->typlen == -1)
2528  result = typtup->typelem;
2529  else
2530  result = InvalidOid;
2531  ReleaseSysCache(tp);
2532  return result;
2533  }
2534  else
2535  return InvalidOid;
2536 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_equality_op_for_ordering_op()

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(), and InvalidOid.

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

265 {
266  Oid result = InvalidOid;
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:293
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
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

◆ get_func_cost()

float4 get_func_cost ( Oid  funcid)

Definition at line 1660 of file lsyscache.c.

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

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

1661 {
1662  HeapTuple tp;
1663  float4 result;
1664 
1665  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1666  if (!HeapTupleIsValid(tp))
1667  elog(ERROR, "cache lookup failed for function %u", funcid);
1668 
1669  result = ((Form_pg_proc) GETSTRUCT(tp))->procost;
1670  ReleaseSysCache(tp);
1671  return result;
1672 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
float float4
Definition: c.h:438
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_isagg()

bool get_func_isagg ( Oid  funcid)

Definition at line 1622 of file lsyscache.c.

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

Referenced by LookupFuncWithArgs(), and RemoveObjects().

1623 {
1624  HeapTuple tp;
1625  bool result;
1626 
1627  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1628  if (!HeapTupleIsValid(tp))
1629  elog(ERROR, "cache lookup failed for function %u", funcid);
1630 
1631  result = ((Form_pg_proc) GETSTRUCT(tp))->proisagg;
1632  ReleaseSysCache(tp);
1633  return result;
1634 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1641 of file lsyscache.c.

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

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

1642 {
1643  HeapTuple tp;
1644  bool result;
1645 
1646  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1647  if (!HeapTupleIsValid(tp))
1648  elog(ERROR, "cache lookup failed for function %u", funcid);
1649 
1650  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1651  ReleaseSysCache(tp);
1652  return result;
1653 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_name()

char* get_func_name ( Oid  funcid)

Definition at line 1412 of file lsyscache.c.

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

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

1413 {
1414  HeapTuple tp;
1415 
1416  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1417  if (HeapTupleIsValid(tp))
1418  {
1419  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1420  char *result;
1421 
1422  result = pstrdup(NameStr(functup->proname));
1423  ReleaseSysCache(tp);
1424  return result;
1425  }
1426  else
1427  return NULL;
1428 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NameStr(name)
Definition: c.h:557

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1436 of file lsyscache.c.

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

Referenced by sepgsql_proc_drop().

1437 {
1438  HeapTuple tp;
1439 
1440  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1441  if (HeapTupleIsValid(tp))
1442  {
1443  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1444  Oid result;
1445 
1446  result = functup->pronamespace;
1447  ReleaseSysCache(tp);
1448  return result;
1449  }
1450  else
1451  return InvalidOid;
1452 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
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

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1478 of file lsyscache.c.

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

1479 {
1480  HeapTuple tp;
1481  int result;
1482 
1483  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1484  if (!HeapTupleIsValid(tp))
1485  elog(ERROR, "cache lookup failed for function %u", funcid);
1486 
1487  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1488  ReleaseSysCache(tp);
1489  return result;
1490 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1546 of file lsyscache.c.

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

Referenced by make_op(), and make_scalar_array_op().

1547 {
1548  HeapTuple tp;
1549  bool result;
1550 
1551  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1552  if (!HeapTupleIsValid(tp))
1553  elog(ERROR, "cache lookup failed for function %u", funcid);
1554 
1555  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1556  ReleaseSysCache(tp);
1557  return result;
1558 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_rettype()

Oid get_func_rettype ( Oid  funcid)

Definition at line 1459 of file lsyscache.c.

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

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

1460 {
1461  HeapTuple tp;
1462  Oid result;
1463 
1464  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1465  if (!HeapTupleIsValid(tp))
1466  elog(ERROR, "cache lookup failed for function %u", funcid);
1467 
1468  result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
1469  ReleaseSysCache(tp);
1470  return result;
1471 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_rows()

float4 get_func_rows ( Oid  funcid)

Definition at line 1679 of file lsyscache.c.

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

Referenced by expression_returns_set_rows().

1680 {
1681  HeapTuple tp;
1682  float4 result;
1683 
1684  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1685  if (!HeapTupleIsValid(tp))
1686  elog(ERROR, "cache lookup failed for function %u", funcid);
1687 
1688  result = ((Form_pg_proc) GETSTRUCT(tp))->prorows;
1689  ReleaseSysCache(tp);
1690  return result;
1691 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
float float4
Definition: c.h:438
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_func_signature()

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

Definition at line 1500 of file lsyscache.c.

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

Referenced by plperl_call_perl_func(), and resolve_aggregate_transtype().

1501 {
1502  HeapTuple tp;
1503  Form_pg_proc procstruct;
1504  Oid result;
1505 
1506  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1507  if (!HeapTupleIsValid(tp))
1508  elog(ERROR, "cache lookup failed for function %u", funcid);
1509 
1510  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1511 
1512  result = procstruct->prorettype;
1513  *nargs = (int) procstruct->pronargs;
1514  Assert(*nargs == procstruct->proargtypes.dim1);
1515  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1516  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1517 
1518  ReleaseSysCache(tp);
1519  return result;
1520 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define Assert(condition)
Definition: c.h:680
void * palloc(Size size)
Definition: mcxt.c:835
#define elog
Definition: elog.h:219

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1527 of file lsyscache.c.

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

1528 {
1529  HeapTuple tp;
1530  Oid result;
1531 
1532  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1533  if (!HeapTupleIsValid(tp))
1534  elog(ERROR, "cache lookup failed for function %u", funcid);
1535 
1536  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1537  ReleaseSysCache(tp);
1538  return result;
1539 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

Definition at line 1018 of file lsyscache.c.

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

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

1019 {
1020  HeapTuple tp;
1021 
1022  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1023  if (HeapTupleIsValid(tp))
1024  {
1026  char *result;
1027 
1028  result = pstrdup(NameStr(lantup->lanname));
1029  ReleaseSysCache(tp);
1030  return result;
1031  }
1032 
1033  if (!missing_ok)
1034  elog(ERROR, "cache lookup failed for language %u",
1035  langoid);
1036  return NULL;
1037 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_language * Form_pg_language
Definition: pg_language.h:51
#define NameStr(name)
Definition: c.h:557
#define elog
Definition: elog.h:219

◆ get_mergejoin_opfamilies()

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, 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:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define BTREE_AM_OID
Definition: pg_am.h:70
List * lappend_oid(List *list, Oid datum)
Definition: list.c:164
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:209
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:121
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3066 of file lsyscache.c.

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

Referenced by acquire_inherited_sample_rows(), AlterExtensionNamespace(), AlterObjectNamespace_internal(), AlterObjectOwner_internal(), AlterObjectRename_internal(), AlterRelationNamespaceInternal(), AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), appendFunctionName(), ApplyExtensionUpdates(), ATExecChangeOwner(), BuildRelationExtStatistics(), 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(), fetch_statentries_for_relation(), format_operator_internal(), format_procedure_internal(), generate_collation_name(), generate_function_name(), generate_operator_name(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedIndexStmt(), generateSerialExtraStmts(), 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(), 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(), perform_work_item(), pg_decode_change(), pg_event_trigger_ddl_commands(), pg_get_functiondef(), pg_get_statisticsobj_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(), transformAlterTableStmt(), and transformCreateStmt().

3067 {
3068  HeapTuple tp;
3069 
3071  if (HeapTupleIsValid(tp))
3072  {
3074  char *result;
3075 
3076  result = pstrdup(NameStr(nsptup->nspname));
3077  ReleaseSysCache(tp);
3078  return result;
3079  }
3080  else
3081  return NULL;
3082 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:51
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define NameStr(name)
Definition: c.h:557

◆ get_namespace_name_or_temp()

char* get_namespace_name_or_temp ( Oid  nspid)

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

3091 {
3092  if (isTempNamespace(nspid))
3093  return "pg_temp";
3094  else
3095  return get_namespace_name(nspid);
3096 }
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3066
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3118

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1337 of file lsyscache.c.

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

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

1338 {
1339  HeapTuple tp;
1340 
1342  if (HeapTupleIsValid(tp))
1343  {
1345  Oid result;
1346 
1347  result = optup->oprnegate;
1348  ReleaseSysCache(tp);
1349  return result;
1350  }
1351  else
1352  return InvalidOid;
1353 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_op_btree_interpretation()

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, 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:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define BTREE_AM_OID
Definition: pg_am.h:70
uint16 StrategyNumber
Definition: stratnum.h:22
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:586
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:209
List * lappend(List *list, void *datum)
Definition: list.c:128
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define Assert(condition)
Definition: c.h:680
void * palloc(Size size)
Definition: mcxt.c:835
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:77
int i
HeapTupleData tuple
Definition: catcache.h:121
Oid get_negator(Oid opno)
Definition: lsyscache.c:1337
Definition: pg_list.h:45
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_op_hash_functions()

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, HASHSTANDARD_PROC, HTEqualStrategyNumber, i, InvalidOid, catclist::members, catclist::n_members, ObjectIdGetDatum, OidIsValid, ReleaseSysCacheList, 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,
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,
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:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define HTEqualStrategyNumber
Definition: hash.h:336
#define OidIsValid(objectId)
Definition: c.h:586
#define HASH_AM_OID
Definition: pg_am.h:73
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:209
#define HASHSTANDARD_PROC
Definition: hash.h:351
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#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
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ get_op_opfamily_properties()

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:661
#define AMOP_SEARCH
Definition: pg_amop.h:69
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1134
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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 AMOP_ORDER
Definition: pg_amop.h:70
#define elog
Definition: elog.h:219

◆ get_op_opfamily_sortfamily()

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(), 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:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1134
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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 AMOP_ORDER
Definition: pg_amop.h:70

◆ get_op_opfamily_strategy()

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(), 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:661
#define AMOP_SEARCH
Definition: pg_amop.h:69
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1134
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1142 of file lsyscache.c.

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

Referenced by gistvalidate().

1143 {
1144  HeapTuple tp;
1145 
1147  if (HeapTupleIsValid(tp))
1148  {
1150  Oid result;
1151 
1152  result = optup->oprresult;
1153  ReleaseSysCache(tp);
1154  return result;
1155  }
1156  else
1157  return InvalidOid;
1158 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1047 of file lsyscache.c.

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

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

1048 {
1049  HeapTuple tp;
1050  Form_pg_opclass cla_tup;
1051  Oid result;
1052 
1053  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1054  if (!HeapTupleIsValid(tp))
1055  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1056  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1057 
1058  result = cla_tup->opcfamily;
1059  ReleaseSysCache(tp);
1060  return result;
1061 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:68

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1069 of file lsyscache.c.

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

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

1070 {
1071  HeapTuple tp;
1072  Form_pg_opclass cla_tup;
1073  Oid result;
1074 
1075  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1076  if (!HeapTupleIsValid(tp))
1077  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1078  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1079 
1080  result = cla_tup->opcintype;
1081  ReleaseSysCache(tp);
1082  return result;
1083 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:68

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1094 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, OPEROID, ReleaseSysCache(), 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_variable_range(), hypothetical_dense_rank_final(), inclusion_get_strategy_procinfo(), inet_mcv_join_sel(), lookup_type_cache(), ltreeparentsel(), make_partition_op_expr(), 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().

1095 {
1096  HeapTuple tp;
1097 
1099  if (HeapTupleIsValid(tp))
1100  {
1102  RegProcedure result;
1103 
1104  result = optup->oprcode;
1105  ReleaseSysCache(tp);
1106  return result;
1107  }
1108  else
1109  return (RegProcedure) InvalidOid;
1110 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
regproc RegProcedure
Definition: c.h:453
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_opfamily_member()

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(), 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:661
#define Int16GetDatum(X)
Definition: postgres.h:457
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1145
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_opfamily_proc()

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(), 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;
748  RegProcedure result;
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:661
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:59
regproc RegProcedure
Definition: c.h:453
#define Int16GetDatum(X)
Definition: postgres.h:457
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1145
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1119 of file lsyscache.c.

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

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

1120 {
1121  HeapTuple tp;
1122 
1124  if (HeapTupleIsValid(tp))
1125  {
1127  char *result;
1128 
1129  result = pstrdup(NameStr(optup->oprname));
1130  ReleaseSysCache(tp);
1131  return result;
1132  }
1133  else
1134  return NULL;
1135 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:57
#define NameStr(name)
Definition: c.h:557

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1385 of file lsyscache.c.

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

Referenced by join_selectivity(), and scalararraysel().

1386 {
1387  HeapTuple tp;
1388 
1390  if (HeapTupleIsValid(tp))
1391  {
1393  RegProcedure result;
1394 
1395  result = optup->oprjoin;
1396  ReleaseSysCache(tp);
1397  return result;
1398  }
1399  else
1400  return (RegProcedure) InvalidOid;
1401 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
regproc RegProcedure
Definition: c.h:453
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1361 of file lsyscache.c.

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

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

1362 {
1363  HeapTuple tp;
1364 
1366  if (HeapTupleIsValid(tp))
1367  {
1369  RegProcedure result;
1370 
1371  result = optup->oprrest;
1372  ReleaseSysCache(tp);
1373  return result;
1374  }
1375  else
1376  return (RegProcedure) InvalidOid;
1377 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
regproc RegProcedure
Definition: c.h:453
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_ordering_op_for_equality_op()

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, SearchSysCacheList1, and catctup::tuple.

Referenced by create_unique_plan().

303 {
304  Oid result = InvalidOid;
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:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define BTREE_AM_OID
Definition: pg_am.h:70
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:586
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#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:209
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#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:121
#define BTLessStrategyNumber
Definition: stratnum.h:29
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_ordering_op_properties()

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, 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:176
#define BTGreaterStrategyNumber
Definition: stratnum.h:33
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define BTREE_AM_OID
Definition: pg_am.h:70
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:209
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#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:121
#define BTLessStrategyNumber
Definition: stratnum.h:29

◆ get_promoted_array_type()

Oid get_promoted_array_type ( Oid  typid)

Definition at line 2569 of file lsyscache.c.

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

Referenced by build_subplan(), and exprType().

2570 {
2571  Oid array_type = get_array_type(typid);
2572 
2573  if (OidIsValid(array_type))
2574  return array_type;
2575  if (OidIsValid(get_element_type(typid)))
2576  return typid;
2577  return InvalidOid;
2578 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2517
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2545
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:586
#define InvalidOid
Definition: postgres_ext.h:36

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3107 of file lsyscache.c.

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

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

3108 {
3109  HeapTuple tp;
3110 
3111  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3112  if (HeapTupleIsValid(tp))
3113  {
3114  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3115  Oid result;
3116 
3117  result = rngtup->rngsubtype;
3118  ReleaseSysCache(tp);
3119  return result;
3120  }
3121  else
3122  return InvalidOid;
3123 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:49
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_rel_name()

char* get_rel_name ( Oid  relid)

Definition at line 1745 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, NameStr, ObjectIdGetDatum, pstrdup(), ReleaseSysCache(), RELOID, 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_rel_sync_entry(), get_relation_constraint_attnos(), 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(), perform_work_item(), pg_attribute_noreturn(), pg_extension_config_dump(), pg_get_expr(), pg_get_expr_ext(), pg_prewarm(), pg_sequence_parameters(), postgresGetForeignRelSize(), process_owned_by(), reindex_index(), ReindexMultipleTables(), RenameConstraintById(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), table_to_xml_internal(), and transformAlterTableStmt().

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  char *result;
1754 
1755  result = pstrdup(NameStr(reltup->relname));
1756  ReleaseSysCache(tp);
1757  return result;
1758  }
1759  else
1760  return NULL;
1761 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
char * pstrdup(const char *in)
Definition: mcxt.c:1063
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define NameStr(name)
Definition: c.h:557

◆ get_rel_namespace()

Oid get_rel_namespace ( Oid  relid)

Definition at line 1769 of file lsyscache.c.

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

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

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  Oid result;
1778 
1779  result = reltup->relnamespace;
1780  ReleaseSysCache(tp);
1781  return result;
1782  }
1783  else
1784  return InvalidOid;
1785 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 1871 of file lsyscache.c.

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

Referenced by set_rel_consider_parallel().

1872 {
1873  HeapTuple tp;
1874  Form_pg_class reltup;
1875  char result;
1876 
1877  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1878  if (!HeapTupleIsValid(tp))
1879  elog(ERROR, "cache lookup failed for relation %u", relid);
1880  reltup = (Form_pg_class) GETSTRUCT(tp);
1881  result = reltup->relpersistence;
1882  ReleaseSysCache(tp);
1883 
1884  return result;
1885 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95
#define elog
Definition: elog.h:219

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 1820 of file lsyscache.c.

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

Referenced by AlterSubscription_refresh(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), check_relation_privileges(), CreateSubscription(), doDeletion(), exec_object_restorecon(), get_constraint_index(), get_partition_dispatch_recurse(), get_rel_sync_entry(), getOwnedSequences(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_id_name(), has_sequence_privilege_name(), has_sequence_privilege_name_id(), has_sequence_privilege_name_name(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), RangeVarCallbackForLockTable(), RangeVarCallbackForReindexIndex(), RangeVarCallbackOwnsTable(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), and sepgsql_relation_setattr().

1821 {
1822  HeapTuple tp;
1823 
1824  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1825  if (HeapTupleIsValid(tp))
1826  {
1827  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1828  char result;
1829 
1830  result = reltup->relkind;
1831  ReleaseSysCache(tp);
1832  return result;
1833  }
1834  else
1835  return '\0';
1836 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_class * Form_pg_class
Definition: pg_class.h:95

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 1847 of file lsyscache.c.

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

Referenced by pg_get_constraintdef_worker(), and pg_get_indexdef_worker().

1848 {
1849  HeapTuple tp;
1850 
1851  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1852  if (HeapTupleIsValid(tp))
1853  {
1854  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1855  Oid result;
1856 
1857  result = reltup->reltablespace;
1858  ReleaseSysCache(tp);
1859  return result;
1860  }
1861  else
1862  return InvalidOid;
1863 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 1796 of file lsyscache.c.

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

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

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->reltype;
1807  ReleaseSysCache(tp);
1808  return result;
1809  }
1810  else
1811  return InvalidOid;
1812 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#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

◆ get_relid_attribute_name()

char* get_relid_attribute_name ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 801 of file lsyscache.c.

References elog, ERROR, and get_attname().

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_statisticsobj_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 elog
Definition: elog.h:219

◆ get_relname_relid()

◆ get_transform_fromsql()

Oid get_transform_fromsql ( Oid  typid,
Oid  langid,
List trftypes 
)

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

1892 {
1893  HeapTuple tup;
1894 
1895  if (!list_member_oid(trftypes, typid))
1896  return InvalidOid;
1897 
1898  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
1899  if (HeapTupleIsValid(tup))
1900  {
1901  Oid funcid;
1902 
1903  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
1904  ReleaseSysCache(tup);
1905  return funcid;
1906  }
1907  else
1908  return InvalidOid;
1909 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
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:1160
#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
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123

◆ get_transform_tosql()

Oid get_transform_tosql ( Oid  typid,
Oid  langid,
List trftypes 
)

Definition at line 1912 of file lsyscache.c.

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

Referenced by plperl_sv_to_datum(), and PLy_output_setup_func().

1913 {
1914  HeapTuple tup;
1915 
1916  if (!list_member_oid(trftypes, typid))
1917  return InvalidOid;
1918 
1919  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
1920  if (HeapTupleIsValid(tup))
1921  {
1922  Oid funcid;
1923 
1924  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
1925  ReleaseSysCache(tup);
1926  return funcid;
1927  }
1928  else
1929  return InvalidOid;
1930 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
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:1160
#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
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1123

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2490 of file lsyscache.c.

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

Referenced by ATPostAlterTypeCleanup(), CheckAttributeType(), find_expr_references_walker(), and processIndirection().

2491 {
2492  HeapTuple tp;
2493 
2495  if (HeapTupleIsValid(tp))
2496  {
2497  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2498  Oid result;
2499 
2500  result = typtup->typrelid;
2501  ReleaseSysCache(tp);
2502  return result;
2503  }
2504  else
2505  return InvalidOid;
2506 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

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

2348 {
2349  int typlen = get_typlen(typid);
2350  int32 maxwidth;
2351 
2352  /*
2353  * Easy if it's a fixed-width type
2354  */
2355  if (typlen > 0)
2356  return typlen;
2357 
2358  /*
2359  * type_maximum_size knows the encoding of typmod for some datatypes;
2360  * don't duplicate that knowledge here.
2361  */
2362  maxwidth = type_maximum_size(typid, typmod);
2363  if (maxwidth > 0)
2364  {
2365  /*
2366  * For BPCHAR, the max width is also the only width. Otherwise we
2367  * need to guess about the typical data width given the max. A sliding
2368  * scale for percentage of max width seems reasonable.
2369  */
2370  if (typid == BPCHAROID)
2371  return maxwidth;
2372  if (maxwidth <= 32)
2373  return maxwidth; /* assume full width */
2374  if (maxwidth < 1000)
2375  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2376 
2377  /*
2378  * Beyond 1000, assume we're looking at something like
2379  * "varchar(10000)" where the limit isn't actually reached often, and
2380  * use a fixed estimate.
2381  */
2382  return 32 + (1000 - 32) / 2;
2383  }
2384 
2385  /*
2386  * Oops, we have no idea ... wild guess time.
2387  */
2388  return 32;
2389 }
#define BPCHAROID
Definition: pg_type.h:504
signed int int32
Definition: c.h:294
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:389
int16 get_typlen(Oid typid)
Definition: lsyscache.c:1966

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 1991 of file lsyscache.c.

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

Referenced by get_agg_clause_costs_walker().

1992 {
1993  HeapTuple tp;
1994 
1996  if (HeapTupleIsValid(tp))
1997  {
1998  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1999  bool result;
2000 
2001  result = typtup->typbyval;
2002  ReleaseSysCache(tp);
2003  return result;
2004  }
2005  else
2006  return false;
2007 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typcollation()

Oid get_typcollation ( Oid  typid)

Definition at line 2814 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, InvalidOid, ObjectIdGetDatum, ReleaseSysCache(), 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().

2815 {
2816  HeapTuple tp;
2817 
2819  if (HeapTupleIsValid(tp))
2820  {
2821  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2822  Oid result;
2823 
2824  result = typtup->typcollation;
2825  ReleaseSysCache(tp);
2826  return result;
2827  }
2828  else
2829  return InvalidOid;
2830 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2217 of file lsyscache.c.

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

Referenced by build_column_default().

2218 {
2219  HeapTuple typeTuple;
2221  Datum datum;
2222  bool isNull;
2223  Node *expr;
2224 
2225  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2226  if (!HeapTupleIsValid(typeTuple))
2227  elog(ERROR, "cache lookup failed for type %u", typid);
2228  type = (Form_pg_type) GETSTRUCT(typeTuple);
2229 
2230  /*
2231  * typdefault and typdefaultbin are potentially null, so don't try to
2232  * access 'em as struct fields. Must do it the hard way with
2233  * SysCacheGetAttr.
2234  */
2235  datum = SysCacheGetAttr(TYPEOID,
2236  typeTuple,
2238  &isNull);
2239 
2240  if (!isNull)
2241  {
2242  /* We have an expression default */
2243  expr = stringToNode(TextDatumGetCString(datum));
2244  }
2245  else
2246  {
2247  /* Perhaps we have a plain literal default */
2248  datum = SysCacheGetAttr(TYPEOID,
2249  typeTuple,
2251  &isNull);
2252 
2253  if (!isNull)
2254  {
2255  char *strDefaultVal;
2256 
2257  /* Convert text datum to C string */
2258  strDefaultVal = TextDatumGetCString(datum);
2259  /* Convert C string to a value of the given type */
2260  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2261  getTypeIOParam(typeTuple), -1);
2262  /* Build a Const node containing the value */
2263  expr = (Node *) makeConst(typid,
2264  -1,
2265  type->typcollation,
2266  type->typlen,
2267  datum,
2268  false,
2269  type->typbyval);
2270  pfree(strDefaultVal);
2271  }
2272  else
2273  {
2274  /* No default */
2275  expr = NULL;
2276  }
2277  }
2278 
2279  ReleaseSysCache(typeTuple);
2280 
2281  return expr;
2282 }
#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:661
Definition: nodes.h:512
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:298
void pfree(void *pointer)
Definition: mcxt.c:936
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
#define TextDatumGetCString(d)
Definition: builtins.h:92
uintptr_t Datum
Definition: postgres.h:372
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1368
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2072
#define elog
Definition: elog.h:219
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1733
#define Anum_pg_type_typdefault
Definition: pg_type.h:268

◆ get_type_category_preferred()

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

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

2470 {
2471  HeapTuple tp;
2472  Form_pg_type typtup;
2473 
2475  if (!HeapTupleIsValid(tp))
2476  elog(ERROR, "cache lookup failed for type %u", typid);
2477  typtup = (Form_pg_type) GETSTRUCT(tp);
2478  *typcategory = typtup->typcategory;
2479  *typispreferred = typtup->typispreferred;
2480  ReleaseSysCache(tp);
2481 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_type_io_data()

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 2094 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(), and plperl_ref_from_pg_array().

2102 {
2103  HeapTuple typeTuple;
2104  Form_pg_type typeStruct;
2105 
2106  /*
2107  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2108  * use array_in and array_out during bootstrap.
2109  */
2111  {
2112  Oid typinput;
2113  Oid typoutput;
2114 
2115  boot_get_type_io_data(typid,
2116  typlen,
2117  typbyval,
2118  typalign,
2119  typdelim,
2120  typioparam,
2121  &typinput,
2122  &typoutput);
2123  switch (which_func)
2124  {
2125  case IOFunc_input:
2126  *func = typinput;
2127  break;
2128  case IOFunc_output:
2129  *func = typoutput;
2130  break;
2131  default:
2132  elog(ERROR, "binary I/O not supported during bootstrap");
2133  break;
2134  }
2135  return;
2136  }
2137 
2138  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2139  if (!HeapTupleIsValid(typeTuple))
2140  elog(ERROR, "cache lookup failed for type %u", typid);
2141  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2142 
2143  *typlen = typeStruct->typlen;
2144  *typbyval = typeStruct->typbyval;
2145  *typalign = typeStruct->typalign;
2146  *typdelim = typeStruct->typdelim;
2147  *typioparam = getTypeIOParam(typeTuple);
2148  switch (which_func)
2149  {
2150  case IOFunc_input:
2151  *func = typeStruct->typinput;
2152  break;
2153  case IOFunc_output:
2154  *func = typeStruct->typoutput;
2155  break;
2156  case IOFunc_receive:
2157  *func = typeStruct->typreceive;
2158  break;
2159  case IOFunc_send:
2160  *func = typeStruct->typsend;
2161  break;
2162  }
2163  ReleaseSysCache(typeTuple);
2164 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:367
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2072
#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:957

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 1942 of file lsyscache.c.

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

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

1943 {
1944  HeapTuple tp;
1945 
1947  if (HeapTupleIsValid(tp))
1948  {
1949  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1950  bool result;
1951 
1952  result = typtup->typisdefined;
1953  ReleaseSysCache(tp);
1954  return result;
1955  }
1956  else
1957  return false;
1958 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 1966 of file lsyscache.c.

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

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

1967 {
1968  HeapTuple tp;
1969 
1971  if (HeapTupleIsValid(tp))
1972  {
1973  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
1974  int16 result;
1975 
1976  result = typtup->typlen;
1977  ReleaseSysCache(tp);
1978  return result;
1979  }
1980  else
1981  return 0;
1982 }
signed short int16
Definition: c.h:293
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typlenbyval()

void get_typlenbyval ( Oid  typid,
int16 typlen,
bool typbyval 
)

Definition at line 2020 of file lsyscache.c.

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

Referenced by build_pertrans_for_aggref(), copyParamList(), EstimateParamExecSpace(), 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(), SerializeParamExecParams(), SerializeParamList(), and tuplesort_begin_datum().

2021 {
2022  HeapTuple tp;
2023  Form_pg_type typtup;
2024 
2026  if (!HeapTupleIsValid(tp))
2027  elog(ERROR, "cache lookup failed for type %u", typid);
2028  typtup = (Form_pg_type) GETSTRUCT(tp);
2029  *typlen = typtup->typlen;
2030  *typbyval = typtup->typbyval;
2031  ReleaseSysCache(tp);
2032 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_typlenbyvalalign()

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

Definition at line 2040 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(), CreateCast(), DefineRange(), exec_assign_value(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitArrayRef(), ExecInitExprRec(), expand_array(), extract_variadic_args(), get_text_array_contents(), ginarrayextract(), gincost_scalararrayopexpr(), ginqueryarrayextract(), initArrayResult(), map_sql_value_to_xml_value(), ordered_set_startup(), RelationBuildPartitionKey(), satisfies_hash_partition(), scalararraysel(), and text_format().

2042 {
2043  HeapTuple tp;
2044  Form_pg_type typtup;
2045 
2047  if (!HeapTupleIsValid(tp))
2048  elog(ERROR, "cache lookup failed for type %u", typid);
2049  typtup = (Form_pg_type) GETSTRUCT(tp);
2050  *typlen = typtup->typlen;
2051  *typbyval = typtup->typbyval;
2052  *typalign = typtup->typalign;
2053  ReleaseSysCache(tp);
2054 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define elog
Definition: elog.h:219

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2764 of file lsyscache.c.

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

2765 {
2766  HeapTuple tp;
2767 
2769  if (HeapTupleIsValid(tp))
2770  {
2771  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2772  Oid result;
2773 
2774  result = typtup->typmodin;
2775  ReleaseSysCache(tp);
2776  return result;
2777  }
2778  else
2779  return InvalidOid;
2780 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2188 of file lsyscache.c.

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

2189 {
2190  HeapTuple tp;
2191 
2193  if (HeapTupleIsValid(tp))
2194  {
2195  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2196  char result;
2197 
2198  result = typtup->typstorage;
2199  ReleaseSysCache(tp);
2200  return result;
2201  }
2202  else
2203  return 'p';
2204 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2398 of file lsyscache.c.

References GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), 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(), prepare_column_cache(), type_is_enum(), type_is_range(), and type_is_rowtype().

2399 {
2400  HeapTuple tp;
2401 
2403  if (HeapTupleIsValid(tp))
2404  {
2405  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2406  char result;
2407 
2408  result = typtup->typtype;
2409  ReleaseSysCache(tp);
2410  return result;
2411  }
2412  else
2413  return '\0';
2414 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2307 of file lsyscache.c.

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

Referenced by ATExecAddColumn(), build_coercion_expression(), cache_record_field_properties(), coerce_record_to_complex(), coerce_to_domain(), coerce_type(), exec_assign_value(), getBaseType(), lookup_type_cache(), map_sql_type_to_xmlschema_type(), prepare_column_cache(), SendRowDescriptionCols_2(), SendRowDescriptionCols_3(), transformArrayType(), transformAssignmentIndirection(), and transformTypeCast().

2308 {
2309  /*
2310  * We loop to find the bottom base type in a stack of domains.
2311  */
2312  for (;;)
2313  {
2314  HeapTuple tup;
2315  Form_pg_type typTup;
2316 
2317  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2318  if (!HeapTupleIsValid(tup))
2319  elog(ERROR, "cache lookup failed for type %u", typid);
2320  typTup = (Form_pg_type) GETSTRUCT(tup);
2321  if (typTup->typtype != TYPTYPE_DOMAIN)
2322  {
2323  /* Not a domain, so done */
2324  ReleaseSysCache(tup);
2325  break;
2326  }
2327 
2328  Assert(*typmod == -1);
2329  typid = typTup->typbasetype;
2330  *typmod = typTup->typtypmod;
2331 
2332  ReleaseSysCache(tup);
2333  }
2334 
2335  return typid;
2336 }
#define TYPTYPE_DOMAIN
Definition: pg_type.h:722
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
#define Assert(condition)
Definition: c.h:680
#define elog
Definition: elog.h:219

◆ getTypeBinaryInputInfo()

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

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

2699 {
2700  HeapTuple typeTuple;
2701  Form_pg_type pt;
2702 
2704  if (!HeapTupleIsValid(typeTuple))
2705  elog(ERROR, "cache lookup failed for type %u", type);
2706  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2707 
2708  if (!pt->typisdefined)
2709  ereport(ERROR,
2710  (errcode(ERRCODE_UNDEFINED_OBJECT),
2711  errmsg("type %s is only a shell",
2712  format_type_be(type))));
2713  if (!OidIsValid(pt->typreceive))
2714  ereport(ERROR,
2715  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2716  errmsg("no binary input function available for type %s",
2717  format_type_be(type))));
2718 
2719  *typReceive = pt->typreceive;
2720  *typIOParam = getTypeIOParam(typeTuple);
2721 
2722  ReleaseSysCache(typeTuple);
2723 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
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:586
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2072
#define elog
Definition: elog.h:219

◆ getTypeBinaryOutputInfo()

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

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

2732 {
2733  HeapTuple typeTuple;
2734  Form_pg_type pt;
2735 
2737  if (!HeapTupleIsValid(typeTuple))
2738  elog(ERROR, "cache lookup failed for type %u", type);
2739  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2740 
2741  if (!pt->typisdefined)
2742  ereport(ERROR,
2743  (errcode(ERRCODE_UNDEFINED_OBJECT),
2744  errmsg("type %s is only a shell",
2745  format_type_be(type))));
2746  if (!OidIsValid(pt->typsend))
2747  ereport(ERROR,
2748  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2749  errmsg("no binary output function available for type %s",
2750  format_type_be(type))));
2751 
2752  *typSend = pt->typsend;
2753  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2754 
2755  ReleaseSysCache(typeTuple);
2756 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
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:586
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define elog
Definition: elog.h:219

◆ getTypeInputInfo()

void getTypeInputInfo ( Oid  type,
Oid typInput,
Oid typIOParam 
)

Definition at line 2632 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(), parse_fcall_arguments(), plperl_spi_prepare(), pltcl_SPI_prepare(), PLy_output_setup_func(), prepare_column_cache(), record_in(), slot_modify_cstrings(), slot_store_cstrings(), and TupleDescGetAttInMetadata().

2633 {
2634  HeapTuple typeTuple;
2635  Form_pg_type pt;
2636 
2638  if (!HeapTupleIsValid(typeTuple))
2639  elog(ERROR, "cache lookup failed for type %u", type);
2640  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2641 
2642  if (!pt->typisdefined)
2643  ereport(ERROR,
2644  (errcode(ERRCODE_UNDEFINED_OBJECT),
2645  errmsg("type %s is only a shell",
2646  format_type_be(type))));
2647  if (!OidIsValid(pt->typinput))
2648  ereport(ERROR,
2649  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2650  errmsg("no input function available for type %s",
2651  format_type_be(type))));
2652 
2653  *typInput = pt->typinput;
2654  *typIOParam = getTypeIOParam(typeTuple);
2655 
2656  ReleaseSysCache(typeTuple);
2657 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
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:586
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2072
#define elog
Definition: elog.h:219

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple  typeTuple)

Definition at line 2072 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(), and stringTypeDatum().

2073 {
2074  Form_pg_type typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2075 
2076  /*
2077  * Array types get their typelem as parameter; everybody else gets their
2078  * own type OID as parameter.
2079  */
2080  if (OidIsValid(typeStruct->typelem))
2081  return typeStruct->typelem;
2082  else
2083  return HeapTupleGetOid(typeTuple);
2084 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
FormData_pg_type * Form_pg_type
Definition: pg_type.h:233
#define OidIsValid(objectId)
Definition: c.h:586
#define HeapTupleGetOid(tuple)
Definition: htup_details.h:700

◆ getTypeOutputInfo()

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

Definition at line 2665 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(), build_concat_foutcache(), BuildIndexValueDescription(), check_functions_in_node(), 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(), PLy_input_setup_func(), postgresBeginForeignModify(), prepare_query_params(), print_expr(), printtup_prepare_info(), record_out(), SendFunctionResult(), set_limit(), SPI_getvalue(), text_format(), and tuple_to_stringinfo().

2666 {
2667  HeapTuple typeTuple;
2668  Form_pg_type pt;
2669 
2671  if (!HeapTupleIsValid(typeTuple))
2672  elog(ERROR, "cache lookup failed for type %u", type);
2673  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2674 
2675  if (!pt->typisdefined)
2676  ereport(ERROR,
2677  (errcode(ERRCODE_UNDEFINED_OBJECT),
2678  errmsg("type %s is only a shell",
2679  format_type_be(type))));
2680  if (!OidIsValid(pt->typoutput))
2681  ereport(ERROR,
2682  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2683  errmsg("no output function available for type %s",
2684  format_type_be(type))));
2685 
2686  *typOutput = pt->typoutput;
2687  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2688 
2689  ReleaseSysCache(typeTuple);
2690 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
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:586
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
#define ereport(elevel, rest)
Definition: elog.h:122
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define elog
Definition: elog.h:219

◆ op_hashjoinable()

bool op_hashjoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1246 of file lsyscache.c.

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

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

1247 {
1248  bool result = false;
1249  HeapTuple tp;
1250  TypeCacheEntry *typentry;
1251 
1252  /* As in op_mergejoinable, let the typcache handle the hard cases */
1253  /* Eventually we'll need a similar case for record_eq ... */
1254  if (opno == ARRAY_EQ_OP)
1255  {
1256  typentry = lookup_type_cache(inputtype, TYPECACHE_HASH_PROC);
1257  if (typentry->hash_proc == F_HASH_ARRAY)
1258  result = true;
1259  }
1260  else
1261  {
1262  /* For all other operators, rely on pg_operator.oprcanhash */
1264  if (HeapTupleIsValid(tp))
1265  {
1267 
1268  result = optup->oprcanhash;
1269  ReleaseSysCache(tp);
1270  }
1271  }
1272  return result;
1273 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:311
#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:128

◆ op_in_opfamily()

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(), have_partkey_equi_join(), 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:186
#define CharGetDatum(X)
Definition: postgres.h:422

◆ op_input_types()

void op_input_types ( Oid  opno,
Oid lefttype,
Oid righttype 
)

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

1168 {
1169  HeapTuple tp;
1170  Form_pg_operator optup;
1171 
1173  if (!HeapTupleIsValid(tp)) /* shouldn't happen */
1174  elog(ERROR, "cache lookup failed for operator %u", opno);
1175  optup = (Form_pg_operator) GETSTRUCT(tp);
1176  *lefttype = optup->oprleft;
1177  *righttype = optup->oprright;
1178  ReleaseSysCache(tp);
1179 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
#define HeapTupleIsValid(tuple)
Definition: htup.h:77
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:57
#define elog
Definition: elog.h:219

◆ op_mergejoinable()

bool op_mergejoinable ( Oid  opno,
Oid  inputtype 
)

Definition at line 1195 of file lsyscache.c.

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

Referenced by check_mergejoinable(), and compute_semijoin_info().

1196 {
1197  bool result = false;
1198  HeapTuple tp;
1199  TypeCacheEntry *typentry;
1200 
1201  /*
1202  * For array_eq or record_eq, we can sort if the element or field types
1203  * are all sortable. We could implement all the checks for that here, but
1204  * the typcache already does that and caches the results too, so let's
1205  * rely on the typcache.
1206  */
1207  if (opno == ARRAY_EQ_OP)
1208  {
1209  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1210  if (typentry->cmp_proc == F_BTARRAYCMP)
1211  result = true;
1212  }
1213  else if (opno == RECORD_EQ_OP)
1214  {
1215  typentry = lookup_type_cache(inputtype, TYPECACHE_CMP_PROC);
1216  if (typentry->cmp_proc == F_BTRECORDCMP)
1217  result = true;
1218  }
1219  else
1220  {
1221  /* For all other operators, rely on pg_operator.oprcanmerge */
1223  if (HeapTupleIsValid(tp))
1224  {
1226 
1227  result = optup->oprcanmerge;
1228  ReleaseSysCache(tp);
1229  }
1230  }
1231  return result;
1232 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:661
#define RECORD_EQ_OP
Definition: pg_operator.h:1720
#define ObjectIdGetDatum(X)
Definition: postgres.h:513
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1112
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1160
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
Definition: typcache.c:311
#define TYPECACHE_CMP_PROC
Definition: typcache.h:127
#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

◆ op_strict()

bool op_strict ( Oid  opno)

Definition at line 1281 of file lsyscache.c.

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

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

1282 {
1283  RegProcedure funcid = get_opcode(opno);
1284 
1285  if (funcid == (RegProcedure) InvalidOid)
1286  elog(ERROR, "operator %u does not exist", opno);
1287 
1288  return func_strict((Oid) funcid);
1289 }
regproc RegProcedure
Definition: c.h:453
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:1094
bool func_strict(Oid funcid)
Definition: lsyscache.c:1565
#define elog
Definition: elog.h:219

◆ op_volatile()

char op_volatile ( Oid  opno)

Definition at line 1297 of file lsyscache.c.

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

Referenced by lookup_proof_cache().

1298 {
1299  RegProcedure funcid = get_opcode(opno);
1300 
1301  if (funcid == (RegProcedure) InvalidOid)
1302  elog(ERROR, "operator %u does not exist", opno);
1303 
1304  return func_volatile((Oid) funcid);
1305 }
regproc RegProcedure
Definition: c.h:453
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:1094
char func_volatile(Oid funcid)
Definition: lsyscache.c:1584
#define elog
Definition: elog.h:219

◆ type_is_collatable()

bool type_is_collatable ( Oid  typid)

◆ type_is_enum()

bool type_is_enum ( Oid  typid)

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

2448 {
2449  return (get_typtype(typid) == TYPTYPE_ENUM);
2450 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2398
#define TYPTYPE_ENUM
Definition: pg_type.h:723

◆ type_is_range()

bool type_is_range ( Oid  typid)

Definition at line 2457 of file lsyscache.c.

References get_typtype(), and TYPTYPE_RANGE.

Referenced by IsBinaryCoercible().

2458 {
2459  return (get_typtype(typid) == TYPTYPE_RANGE);
2460 }
char get_typtype(Oid typid)
Definition: lsyscache.c:2398
#define TYPTYPE_RANGE
Definition: pg_type.h:725

◆ type_is_rowtype()

bool type_is_rowtype ( Oid  typid)

Definition at line 2424 of file lsyscache.c.

References get_typtype(), getBaseType(), RECORDOID, TYPTYPE_COMPOSITE, and TYPTYPE_DOMAIN.

Referenced by compile_plperl_function(), compile_pltcl_function(), deparseNullTest(), exec_assign_value(), exec_stmt_return(), exec_stmt_return_next(), ExecMakeTableFunctionResult(), find_minmax_aggs_walker(), get_rule_expr(), hstore_populate_record(), init_sql_fcache(), json_categorize_type(), jsonb_categorize_type(), makeWholeRowVar(), plperl_hash_from_tuple(), plperl_ref_from_pg_array(), plperl_sv_to_datum(), and transformExprRecurse().

2425 {
2426  if (typid == RECORDOID)
2427  return true; /* easy case */
2428  switch (get_typtype(typid))
2429  {
2430  case TYPTYPE_COMPOSITE:
2431  return true;
2432  case TYPTYPE_DOMAIN:
2433  if (get_typtype(getBaseType(typid)) == TYPTYPE_COMPOSITE)
2434  return true;
2435  break;
2436  default:
2437  break;
2438  }
2439  return false;
2440 }
#define TYPTYPE_DOMAIN
Definition: pg_type.h:722
#define TYPTYPE_COMPOSITE
Definition: pg_type.h:721
char get_typtype(Oid typid)
Definition: lsyscache.c:2398
#define RECORDOID
Definition: pg_type.h:680
Oid getBaseType(Oid typid)
Definition: lsyscache.c:2290

Variable Documentation

◆ get_attavgwidth_hook

PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook

Definition at line 50 of file lsyscache.c.

Referenced by get_attavgwidth().