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) != TYPSTORAGE_PLAIN)
 

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)
 
bool comparison_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, bool missing_ok)
 
AttrNumber get_attnum (Oid relid, const char *attname)
 
int get_attstattarget (Oid relid, AttrNumber attnum)
 
char get_attgenerated (Oid relid, AttrNumber attnum)
 
Oid get_atttype (Oid relid, AttrNumber attnum)
 
void get_atttypetypmodcoll (Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
 
Datum get_attoptions (Oid relid, int16 attnum)
 
Oid get_cast_oid (Oid sourcetypeid, Oid targettypeid, bool missing_ok)
 
char * get_collation_name (Oid colloid)
 
bool get_collation_isdeterministic (Oid colloid)
 
char * get_constraint_name (Oid conoid)
 
Oid get_constraint_index (Oid conoid)
 
char * get_language_name (Oid langoid, bool missing_ok)
 
Oid get_opclass_family (Oid opclass)
 
Oid get_opclass_input_type (Oid opclass)
 
bool get_opclass_opfamily_and_input_type (Oid opclass, Oid *opfamily, Oid *opcintype)
 
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)
 
char get_func_prokind (Oid funcid)
 
bool get_func_leakproof (Oid funcid)
 
RegProcedure get_func_support (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)
 
bool get_rel_relispartition (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)
 
bool type_is_multirange (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)
 
RegProcedure get_typsubscript (Oid typid, Oid *typelemp)
 
const struct SubscriptRoutinesgetSubscriptingRoutines (Oid typid, Oid *typelemp)
 
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)
 
Oid get_range_collation (Oid rangeOid)
 
Oid get_range_multirange (Oid rangeOid)
 
Oid get_multirange_range (Oid multirangeOid)
 
Oid get_index_column_opclass (Oid index_oid, int attno)
 
bool get_index_isreplident (Oid index_oid)
 
bool get_index_isvalid (Oid index_oid)
 
bool get_index_isclustered (Oid index_oid)
 

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)

Definition at line 202 of file lsyscache.h.

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

◆ type_is_array_domain

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

◆ TypeIsToastable

#define TypeIsToastable (   typid)    (get_typstorage(typid) != TYPSTORAGE_PLAIN)

Definition at line 206 of file lsyscache.h.

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

Typedef Documentation

◆ AttStatsSlot

typedef struct AttStatsSlot AttStatsSlot

◆ get_attavgwidth_hook_type

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

Definition at line 65 of file lsyscache.h.

◆ IOFuncSelector

◆ OpBtreeInterpretation

Enumeration Type Documentation

◆ IOFuncSelector

Enumerator
IOFunc_input 
IOFunc_output 
IOFunc_receive 
IOFunc_send 

Definition at line 33 of file lsyscache.h.

Function Documentation

◆ comparison_ops_are_compatible()

bool comparison_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 747 of file lsyscache.c.

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

Referenced by ineq_histogram_selectivity().

748 {
749  bool result;
750  CatCList *catlist;
751  int i;
752 
753  /* Easy if they're the same operator */
754  if (opno1 == opno2)
755  return true;
756 
757  /*
758  * We search through all the pg_amop entries for opno1.
759  */
760  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
761 
762  result = false;
763  for (i = 0; i < catlist->n_members; i++)
764  {
765  HeapTuple op_tuple = &catlist->members[i]->tuple;
766  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
767 
768  if (op_form->amopmethod == BTREE_AM_OID)
769  {
770  if (op_in_opfamily(opno2, op_form->amopfamily))
771  {
772  result = true;
773  break;
774  }
775  }
776  }
777 
778  ReleaseSysCacheList(catlist);
779 
780  return result;
781 }
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:64
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ equality_ops_are_compatible()

bool equality_ops_are_compatible ( Oid  opno1,
Oid  opno2 
)

Definition at line 696 of file lsyscache.c.

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

Referenced by query_is_distinct_for().

697 {
698  bool result;
699  CatCList *catlist;
700  int i;
701 
702  /* Easy if they're the same operator */
703  if (opno1 == opno2)
704  return true;
705 
706  /*
707  * We search through all the pg_amop entries for opno1.
708  */
709  catlist = SearchSysCacheList1(AMOPOPID, ObjectIdGetDatum(opno1));
710 
711  result = false;
712  for (i = 0; i < catlist->n_members; i++)
713  {
714  HeapTuple op_tuple = &catlist->members[i]->tuple;
715  Form_pg_amop op_form = (Form_pg_amop) GETSTRUCT(op_tuple);
716 
717  /* must be btree or hash */
718  if (op_form->amopmethod == BTREE_AM_OID ||
719  op_form->amopmethod == HASH_AM_OID)
720  {
721  if (op_in_opfamily(opno2, op_form->amopfamily))
722  {
723  result = true;
724  break;
725  }
726  }
727  }
728 
729  ReleaseSysCacheList(catlist);
730 
731  return result;
732 }
bool op_in_opfamily(Oid opno, Oid opfamily)
Definition: lsyscache.c:64
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121

◆ free_attstatsslot()

void free_attstatsslot ( AttStatsSlot sslot)

Definition at line 3294 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_multirangesel(), calc_rangesel(), eqjoinsel(), 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().

3295 {
3296  /* The values[] array was separately palloc'd by deconstruct_array */
3297  if (sslot->values)
3298  pfree(sslot->values);
3299  /* The numbers[] array points into numbers_arr, do not pfree it */
3300  /* Free the detoasted array objects, if any */
3301  if (sslot->values_arr)
3302  pfree(sslot->values_arr);
3303  if (sslot->numbers_arr)
3304  pfree(sslot->numbers_arr);
3305 }
void pfree(void *pointer)
Definition: mcxt.c:1169
void * values_arr
Definition: lsyscache.h:60
Datum * values
Definition: lsyscache.h:53
void * numbers_arr
Definition: lsyscache.h:61

◆ func_parallel()

char func_parallel ( Oid  funcid)

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

1771 {
1772  HeapTuple tp;
1773  char result;
1774 
1775  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1776  if (!HeapTupleIsValid(tp))
1777  elog(ERROR, "cache lookup failed for function %u", funcid);
1778 
1779  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1780  ReleaseSysCache(tp);
1781  return result;
1782 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ func_strict()

bool func_strict ( Oid  funcid)

Definition at line 1732 of file lsyscache.c.

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

Referenced by AggregateCreate(), clause_is_strict_for(), contain_nonstrict_functions_checker(), find_nonnullable_rels_walker(), find_nonnullable_vars_walker(), hash_ok_operator(), is_strict_saop(), op_strict(), and process_equivalence().

1733 {
1734  HeapTuple tp;
1735  bool result;
1736 
1737  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1738  if (!HeapTupleIsValid(tp))
1739  elog(ERROR, "cache lookup failed for function %u", funcid);
1740 
1741  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1742  ReleaseSysCache(tp);
1743  return result;
1744 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ func_volatile()

char func_volatile ( Oid  funcid)

Definition at line 1751 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(), ece_function_is_safe(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeInputFunction(), findTypeOutputFunction(), findTypeReceiveFunction(), findTypeSendFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), and op_volatile().

1752 {
1753  HeapTuple tp;
1754  char result;
1755 
1756  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1757  if (!HeapTupleIsValid(tp))
1758  elog(ERROR, "cache lookup failed for function %u", funcid);
1759 
1760  result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
1761  ReleaseSysCache(tp);
1762  return result;
1763 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2734 of file lsyscache.c.

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

Referenced by AlterTypeNamespace_oid(), enforce_generic_type_consistency(), get_promoted_array_type(), initArrayResultAny(), LookupTypeNameExtended(), make_partition_op_expr(), make_scalar_array_op(), moveArrayTypeName(), ParseFuncOrColumn(), resolve_anyarray_from_others(), transformAExprIn(), and transformArrayExpr().

2735 {
2736  HeapTuple tp;
2737  Oid result = InvalidOid;
2738 
2740  if (HeapTupleIsValid(tp))
2741  {
2742  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2743  ReleaseSysCache(tp);
2744  }
2745  return result;
2746 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 3105 of file lsyscache.c.

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

Referenced by get_rel_data_width(), and set_rel_width().

3106 {
3107  HeapTuple tp;
3108  int32 stawidth;
3109 
3111  {
3112  stawidth = (*get_attavgwidth_hook) (relid, attnum);
3113  if (stawidth > 0)
3114  return stawidth;
3115  }
3117  ObjectIdGetDatum(relid),
3119  BoolGetDatum(false));
3120  if (HeapTupleIsValid(tp))
3121  {
3122  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
3123  ReleaseSysCache(tp);
3124  if (stawidth > 0)
3125  return stawidth;
3126  }
3127  return 0;
3128 }
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:51
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define Int16GetDatum(X)
Definition: postgres.h:495
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:135
signed int int32
Definition: c.h:429
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define BoolGetDatum(X)
Definition: postgres.h:446
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 913 of file lsyscache.c.

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

Referenced by ATExecAlterColumnType(), and check_nested_generated_walker().

914 {
915  HeapTuple tp;
916  Form_pg_attribute att_tup;
917  char result;
918 
919  tp = SearchSysCache2(ATTNUM,
920  ObjectIdGetDatum(relid),
922  if (!HeapTupleIsValid(tp))
923  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
924  attnum, relid);
925  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
926  result = att_tup->attgenerated;
927  ReleaseSysCache(tp);
928  return result;
929 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:232

◆ get_attname()

char* get_attname ( Oid  relid,
AttrNumber  attnum,
bool  missing_ok 
)

Definition at line 825 of file lsyscache.c.

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

Referenced by AddRelationNewConstraints(), ATExecAlterColumnType(), check_nested_generated_walker(), ComputePartitionAttrs(), decompile_column_index_array(), deparseColumnRef(), errtablecol(), fixup_inherited_columns(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_insert_query_def(), get_rte_attribute_name(), get_update_query_targetlist_def(), getObjectDescription(), getObjectIdentityParts(), pg_get_constraintdef_worker(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_triggerdef_worker(), processIndirection(), transformPartitionBound(), and transformPartitionRangeBounds().

826 {
827  HeapTuple tp;
828 
829  tp = SearchSysCache2(ATTNUM,
831  if (HeapTupleIsValid(tp))
832  {
834  char *result;
835 
836  result = pstrdup(NameStr(att_tup->attname));
837  ReleaseSysCache(tp);
838  return result;
839  }
840 
841  if (!missing_ok)
842  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
843  attnum, relid);
844  return NULL;
845 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:232
#define NameStr(name)
Definition: c.h:681

◆ get_attnum()

AttrNumber get_attnum ( Oid  relid,
const char *  attname 
)

Definition at line 856 of file lsyscache.c.

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

Referenced by ATExecColumnDefault(), ATExecDropNotNull(), expand_col_privileges(), fixup_inherited_columns(), get_object_address_attrdef(), get_object_address_attribute(), LookupTypeNameExtended(), pg_get_serial_sequence(), process_owned_by(), transformAlterTableStmt(), and transformAssignmentIndirection().

857 {
858  HeapTuple tp;
859 
860  tp = SearchSysCacheAttName(relid, attname);
861  if (HeapTupleIsValid(tp))
862  {
864  AttrNumber result;
865 
866  result = att_tup->attnum;
867  ReleaseSysCache(tp);
868  return result;
869  }
870  else
871  return InvalidAttrNumber;
872 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
NameData attname
Definition: pg_attribute.h:41
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1268
#define InvalidAttrNumber
Definition: attnum.h:23
int16 AttrNumber
Definition: attnum.h:21

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

Definition at line 995 of file lsyscache.c.

References ATTNAME, ATTNUM, datumCopy(), elog, ERROR, HeapTupleIsValid, Int16GetDatum, ObjectIdGetDatum, ReleaseSysCache(), SearchSysCache2(), and SysCacheGetAttr().

Referenced by generateClonedIndexStmt(), pg_get_indexdef_worker(), RelationGetIndexAttOptions(), RelationGetIndexRawAttOptions(), and transformIndexConstraint().

996 {
997  HeapTuple tuple;
998  Datum attopts;
999  Datum result;
1000  bool isnull;
1001 
1002  tuple = SearchSysCache2(ATTNUM,
1003  ObjectIdGetDatum(relid),
1005 
1006  if (!HeapTupleIsValid(tuple))
1007  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
1008  attnum, relid);
1009 
1010  attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
1011  &isnull);
1012 
1013  if (isnull)
1014  result = (Datum) 0;
1015  else
1016  result = datumCopy(attopts, false, -1); /* text[] */
1017 
1018  ReleaseSysCache(tuple);
1019 
1020  return result;
1021 }
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:131
uintptr_t Datum
Definition: postgres.h:411
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:232

◆ get_attstatsslot()

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

Definition at line 3177 of file lsyscache.c.

References ARR_DATA_PTR, ARR_DIMS, ARR_ELEMTYPE, ARR_HASNULL, ARR_NDIM, ATTSTATSSLOT_NUMBERS, ATTSTATSSLOT_VALUES, DatumGetArrayTypePCopy, deconstruct_array(), elog, ERROR, GETSTRUCT, HeapTupleIsValid, i, InvalidOid, AttStatsSlot::nnumbers, AttStatsSlot::numbers, AttStatsSlot::numbers_arr, AttStatsSlot::nvalues, ObjectIdGetDatum, pfree(), ReleaseSysCache(), SearchSysCache1(), AttStatsSlot::stacoll, 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_multirangesel(), calc_rangesel(), eqjoinsel(), 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().

3179 {
3180  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3181  int i;
3182  Datum val;
3183  bool isnull;
3184  ArrayType *statarray;
3185  Oid arrayelemtype;
3186  int narrayelem;
3187  HeapTuple typeTuple;
3188  Form_pg_type typeForm;
3189 
3190  /* initialize *sslot properly */
3191  memset(sslot, 0, sizeof(AttStatsSlot));
3192 
3193  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3194  {
3195  if ((&stats->stakind1)[i] == reqkind &&
3196  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3197  break;
3198  }
3199  if (i >= STATISTIC_NUM_SLOTS)
3200  return false; /* not there */
3201 
3202  sslot->staop = (&stats->staop1)[i];
3203  sslot->stacoll = (&stats->stacoll1)[i];
3204 
3205  if (flags & ATTSTATSSLOT_VALUES)
3206  {
3207  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3208  Anum_pg_statistic_stavalues1 + i,
3209  &isnull);
3210  if (isnull)
3211  elog(ERROR, "stavalues is null");
3212 
3213  /*
3214  * Detoast the array if needed, and in any case make a copy that's
3215  * under control of this AttStatsSlot.
3216  */
3217  statarray = DatumGetArrayTypePCopy(val);
3218 
3219  /*
3220  * Extract the actual array element type, and pass it back in case the
3221  * caller needs it.
3222  */
3223  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3224 
3225  /* Need info about element type */
3226  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3227  if (!HeapTupleIsValid(typeTuple))
3228  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3229  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3230 
3231  /* Deconstruct array into Datum elements; NULLs not expected */
3232  deconstruct_array(statarray,
3233  arrayelemtype,
3234  typeForm->typlen,
3235  typeForm->typbyval,
3236  typeForm->typalign,
3237  &sslot->values, NULL, &sslot->nvalues);
3238 
3239  /*
3240  * If the element type is pass-by-reference, we now have a bunch of
3241  * Datums that are pointers into the statarray, so we need to keep
3242  * that until free_attstatsslot. Otherwise, all the useful info is in
3243  * sslot->values[], so we can free the array object immediately.
3244  */
3245  if (!typeForm->typbyval)
3246  sslot->values_arr = statarray;
3247  else
3248  pfree(statarray);
3249 
3250  ReleaseSysCache(typeTuple);
3251  }
3252 
3253  if (flags & ATTSTATSSLOT_NUMBERS)
3254  {
3255  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3256  Anum_pg_statistic_stanumbers1 + i,
3257  &isnull);
3258  if (isnull)
3259  elog(ERROR, "stanumbers is null");
3260 
3261  /*
3262  * Detoast the array if needed, and in any case make a copy that's
3263  * under control of this AttStatsSlot.
3264  */
3265  statarray = DatumGetArrayTypePCopy(val);
3266 
3267  /*
3268  * We expect the array to be a 1-D float4 array; verify that. We don't
3269  * need to use deconstruct_array() since the array data is just going
3270  * to look like a C array of float4 values.
3271  */
3272  narrayelem = ARR_DIMS(statarray)[0];
3273  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3274  ARR_HASNULL(statarray) ||
3275  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3276  elog(ERROR, "stanumbers is not a 1-D float4 array");
3277 
3278  /* Give caller a pointer directly into the statarray */
3279  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3280  sslot->nnumbers = narrayelem;
3281 
3282  /* We'll free the statarray in free_attstatsslot */
3283  sslot->numbers_arr = statarray;
3284  }
3285 
3286  return true;
3287 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:42
int nnumbers
Definition: lsyscache.h:57
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:135
void pfree(void *pointer)
Definition: mcxt.c:1169
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:43
void * values_arr
Definition: lsyscache.h:60
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
#define ARR_DIMS(a)
Definition: array.h:287
#define ARR_DATA_PTR(a)
Definition: array.h:315
float4 * numbers
Definition: lsyscache.h:56
#define ARR_HASNULL(a)
Definition: array.h:284
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
float float4
Definition: c.h:564
uintptr_t Datum
Definition: postgres.h:411
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
#define DatumGetArrayTypePCopy(X)
Definition: array.h:255
#define InvalidOid
Definition: postgres_ext.h:36
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:127
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Datum * values
Definition: lsyscache.h:53
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define ARR_NDIM(a)
Definition: array.h:283
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3490
#define elog(elevel,...)
Definition: elog.h:232
int i
void * numbers_arr
Definition: lsyscache.h:61
Oid valuetype
Definition: lsyscache.h:52
#define ARR_ELEMTYPE(a)
Definition: array.h:285
long val
Definition: informix.c:664

◆ get_attstattarget()

int get_attstattarget ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 883 of file lsyscache.c.

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

Referenced by index_concurrently_swap().

884 {
885  HeapTuple tp;
886  Form_pg_attribute att_tup;
887  int result;
888 
889  tp = SearchSysCache2(ATTNUM,
890  ObjectIdGetDatum(relid),
892  if (!HeapTupleIsValid(tp))
893  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
894  attnum, relid);
895  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
896  result = att_tup->attstattarget;
897  ReleaseSysCache(tp);
898  return result;
899 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:232

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 938 of file lsyscache.c.

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

Referenced by generateClonedIndexStmt(), GetIndexInputType(), LookupTypeNameExtended(), and transformAlterTableStmt().

939 {
940  HeapTuple tp;
941 
942  tp = SearchSysCache2(ATTNUM,
943  ObjectIdGetDatum(relid),
945  if (HeapTupleIsValid(tp))
946  {
948  Oid result;
949 
950  result = att_tup->atttypid;
951  ReleaseSysCache(tp);
952  return result;
953  }
954  else
955  return InvalidOid;
956 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define Int16GetDatum(X)
Definition: postgres.h:495
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ get_atttypetypmodcoll()

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

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

970 {
971  HeapTuple tp;
972  Form_pg_attribute att_tup;
973 
974  tp = SearchSysCache2(ATTNUM,
975  ObjectIdGetDatum(relid),
977  if (!HeapTupleIsValid(tp))
978  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
979  attnum, relid);
980  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
981 
982  *typid = att_tup->atttypid;
983  *typmod = att_tup->atttypmod;
984  *collid = att_tup->attcollation;
985  ReleaseSysCache(tp);
986 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:83
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
#define elog(elevel,...)
Definition: elog.h:232

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

Definition at line 2779 of file lsyscache.c.

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

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().

2780 {
2781  /*
2782  * We loop to find the bottom base type in a stack of domains.
2783  */
2784  for (;;)
2785  {
2786  HeapTuple tup;
2787  Form_pg_type typTup;
2788 
2789  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2790  if (!HeapTupleIsValid(tup))
2791  break;
2792  typTup = (Form_pg_type) GETSTRUCT(tup);
2793  if (typTup->typtype != TYPTYPE_DOMAIN)
2794  {
2795  /* Not a domain, so stop descending */
2796  Oid result;
2797 
2798  /* This test must match get_element_type */
2799  if (IsTrueArrayType(typTup))
2800  result = typTup->typelem;
2801  else
2802  result = InvalidOid;
2803  ReleaseSysCache(tup);
2804  return result;
2805  }
2806 
2807  typid = typTup->typbasetype;
2808  ReleaseSysCache(tup);
2809  }
2810 
2811  /* Like get_element_type, silently return InvalidOid for bogus input */
2812  return InvalidOid;
2813 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_cast_oid()

Oid get_cast_oid ( Oid  sourcetypeid,
Oid  targettypeid,
bool  missing_ok 
)

Definition at line 1032 of file lsyscache.c.

References CASTSOURCETARGET, ereport, errcode(), errmsg(), ERROR, format_type_be(), GetSysCacheOid2, ObjectIdGetDatum, and OidIsValid.

Referenced by get_object_address().

1033 {
1034  Oid oid;
1035 
1036  oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1037  ObjectIdGetDatum(sourcetypeid),
1038  ObjectIdGetDatum(targettypeid));
1039  if (!OidIsValid(oid) && !missing_ok)
1040  ereport(ERROR,
1041  (errcode(ERRCODE_UNDEFINED_OBJECT),
1042  errmsg("cast from type %s to type %s does not exist",
1043  format_type_be(sourcetypeid),
1044  format_type_be(targettypeid))));
1045  return oid;
1046 }
int errcode(int sqlerrcode)
Definition: elog.c:698
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:710
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
#define ereport(elevel,...)
Definition: elog.h:157
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition: syscache.h:195
int errmsg(const char *fmt,...)
Definition: elog.c:909

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

Definition at line 1079 of file lsyscache.c.

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

Referenced by btvarstrequalimage(), index_create(), match_pattern_prefix(), RI_FKey_cascade_del(), RI_FKey_cascade_upd(), ri_restrict(), and ri_set().

1080 {
1081  HeapTuple tp;
1082  Form_pg_collation colltup;
1083  bool result;
1084 
1085  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1086  if (!HeapTupleIsValid(tp))
1087  elog(ERROR, "cache lookup failed for collation %u", colloid);
1088  colltup = (Form_pg_collation) GETSTRUCT(tp);
1089  result = colltup->collisdeterministic;
1090  ReleaseSysCache(tp);
1091  return result;
1092 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:56
#define elog(elevel,...)
Definition: elog.h:232

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

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

1061 {
1062  HeapTuple tp;
1063 
1064  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1065  if (HeapTupleIsValid(tp))
1066  {
1068  char *result;
1069 
1070  result = pstrdup(NameStr(colltup->collname));
1071  ReleaseSysCache(tp);
1072  return result;
1073  }
1074  else
1075  return NULL;
1076 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:56
#define NameStr(name)
Definition: c.h:681

◆ get_commutator()

Oid get_commutator ( Oid  opno)

Definition at line 1480 of file lsyscache.c.

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

Referenced by CommuteOpExpr(), compute_semijoin_info(), ComputeIndexAttrs(), convert_EXISTS_to_ANY(), eqjoinsel(), expand_indexqual_rowcompare(), match_clause_to_ordering_op(), match_clause_to_partition_key(), match_foreign_keys_to_quals(), match_opclause_to_indexcol(), match_rowcompare_to_indexcol(), multirangesel(), networkjoinsel(), operator_predicate_proof(), rangesel(), scalarineqsel_wrapper(), and targetIsInSortList().

1481 {
1482  HeapTuple tp;
1483 
1485  if (HeapTupleIsValid(tp))
1486  {
1488  Oid result;
1489 
1490  result = optup->oprcom;
1491  ReleaseSysCache(tp);
1492  return result;
1493  }
1494  else
1495  return InvalidOid;
1496 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_compatible_hash_operators()

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

Definition at line 408 of file lsyscache.c.

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

Referenced by create_unique_plan(), and ExecInitSubPlan().

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

◆ get_constraint_index()

Oid get_constraint_index ( Oid  conoid)

Definition at line 1133 of file lsyscache.c.

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

Referenced by ATPostAlterTypeParse(), infer_arbiter_indexes(), and RememberConstraintForRebuilding().

1134 {
1135  HeapTuple tp;
1136 
1138  if (HeapTupleIsValid(tp))
1139  {
1141  Oid result;
1142 
1143  result = contup->conindid;
1144  ReleaseSysCache(tp);
1145  return result;
1146  }
1147  else
1148  return InvalidOid;
1149 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_constraint_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 1106 of file lsyscache.c.

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

Referenced by addFkRecurseReferencing(), get_insert_query_def(), and report_triggers().

1107 {
1108  HeapTuple tp;
1109 
1111  if (HeapTupleIsValid(tp))
1112  {
1114  char *result;
1115 
1116  result = pstrdup(NameStr(contup->conname));
1117  ReleaseSysCache(tp);
1118  return result;
1119  }
1120  else
1121  return NULL;
1122 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:681

◆ get_element_type()

Oid get_element_type ( Oid  typid)

Definition at line 2706 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_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_anyelement_from_others(), transformArrayExpr(), and transformTypeCast().

2707 {
2708  HeapTuple tp;
2709 
2711  if (HeapTupleIsValid(tp))
2712  {
2713  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2714  Oid result;
2715 
2716  if (IsTrueArrayType(typtup))
2717  result = typtup->typelem;
2718  else
2719  result = InvalidOid;
2720  ReleaseSysCache(tp);
2721  return result;
2722  }
2723  else
2724  return InvalidOid;
2725 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_equality_op_for_ordering_op()

Oid get_equality_op_for_ordering_op ( Oid  opno,
bool reverse 
)

Definition at line 265 of file lsyscache.c.

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

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

266 {
267  Oid result = InvalidOid;
268  Oid opfamily;
269  Oid opcintype;
270  int16 strategy;
271 
272  /* Find the operator in pg_amop */
274  &opfamily, &opcintype, &strategy))
275  {
276  /* Found a suitable opfamily, get matching equality operator */
277  result = get_opfamily_member(opfamily,
278  opcintype,
279  opcintype,
281  if (reverse)
282  *reverse = (strategy == BTGreaterStrategyNumber);
283  }
284 
285  return result;
286 }
signed short int16
Definition: c.h:428
#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:164
#define InvalidOid
Definition: postgres_ext.h:36
bool get_ordering_op_properties(Oid opno, Oid *opfamily, Oid *opcintype, int16 *strategy)
Definition: lsyscache.c:205
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_func_leakproof()

bool get_func_leakproof ( Oid  funcid)

Definition at line 1808 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(), statext_is_compatible_clause_internal(), and statistic_proc_security_check().

1809 {
1810  HeapTuple tp;
1811  bool result;
1812 
1813  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1814  if (!HeapTupleIsValid(tp))
1815  elog(ERROR, "cache lookup failed for function %u", funcid);
1816 
1817  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1818  ReleaseSysCache(tp);
1819  return result;
1820 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_func_name()

char* get_func_name ( Oid  funcid)

Definition at line 1579 of file lsyscache.c.

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

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

1580 {
1581  HeapTuple tp;
1582 
1583  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1584  if (HeapTupleIsValid(tp))
1585  {
1586  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1587  char *result;
1588 
1589  result = pstrdup(NameStr(functup->proname));
1590  ReleaseSysCache(tp);
1591  return result;
1592  }
1593  else
1594  return NULL;
1595 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:681

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1603 of file lsyscache.c.

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

Referenced by sepgsql_proc_drop(), and unaccent_dict().

1604 {
1605  HeapTuple tp;
1606 
1607  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1608  if (HeapTupleIsValid(tp))
1609  {
1610  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1611  Oid result;
1612 
1613  result = functup->pronamespace;
1614  ReleaseSysCache(tp);
1615  return result;
1616  }
1617  else
1618  return InvalidOid;
1619 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_func_nargs()

int get_func_nargs ( Oid  funcid)

Definition at line 1645 of file lsyscache.c.

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

1646 {
1647  HeapTuple tp;
1648  int result;
1649 
1650  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1651  if (!HeapTupleIsValid(tp))
1652  elog(ERROR, "cache lookup failed for function %u", funcid);
1653 
1654  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1655  ReleaseSysCache(tp);
1656  return result;
1657 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
int16 pronargs
Definition: pg_proc.h:81
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1789 of file lsyscache.c.

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

Referenced by LookupFuncNameInternal(), LookupFuncWithArgs(), and RemoveObjects().

1790 {
1791  HeapTuple tp;
1792  char result;
1793 
1794  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1795  if (!HeapTupleIsValid(tp))
1796  elog(ERROR, "cache lookup failed for function %u", funcid);
1797 
1798  result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1799  ReleaseSysCache(tp);
1800  return result;
1801 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1713 of file lsyscache.c.

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

Referenced by make_op(), and make_scalar_array_op().

1714 {
1715  HeapTuple tp;
1716  bool result;
1717 
1718  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1719  if (!HeapTupleIsValid(tp))
1720  elog(ERROR, "cache lookup failed for function %u", funcid);
1721 
1722  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1723  ReleaseSysCache(tp);
1724  return result;
1725 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_func_rettype()

Oid get_func_rettype ( Oid  funcid)

Definition at line 1626 of file lsyscache.c.

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

Referenced by CreateConversionCommand(), CreateEventTrigger(), CreateProceduralLanguage(), CreateTriggerFiringOn(), DefineOperator(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeAnalyzeFunction(), findTypeInputFunction(), findTypeOutputFunction(), findTypeReceiveFunction(), findTypeSendFunction(), findTypeSubscriptingFunction(), findTypeTypmodinFunction(), findTypeTypmodoutFunction(), get_ts_parser_func(), get_ts_template_func(), gistrescan(), interpret_func_support(), lookup_am_handler_func(), lookup_fdw_handler_func(), OperatorCreate(), spgrescan(), transformRangeTableSample(), ValidateJoinEstimator(), and ValidateRestrictionEstimator().

1627 {
1628  HeapTuple tp;
1629  Oid result;
1630 
1631  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1632  if (!HeapTupleIsValid(tp))
1633  elog(ERROR, "cache lookup failed for function %u", funcid);
1634 
1635  result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
1636  ReleaseSysCache(tp);
1637  return result;
1638 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_func_signature()

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

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

1668 {
1669  HeapTuple tp;
1670  Form_pg_proc procstruct;
1671  Oid result;
1672 
1673  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1674  if (!HeapTupleIsValid(tp))
1675  elog(ERROR, "cache lookup failed for function %u", funcid);
1676 
1677  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1678 
1679  result = procstruct->prorettype;
1680  *nargs = (int) procstruct->pronargs;
1681  Assert(*nargs == procstruct->proargtypes.dim1);
1682  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1683  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1684 
1685  ReleaseSysCache(tp);
1686  return result;
1687 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:804
void * palloc(Size size)
Definition: mcxt.c:1062
#define elog(elevel,...)
Definition: elog.h:232

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1829 of file lsyscache.c.

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

Referenced by function_selectivity(), and get_index_clause_from_support().

1830 {
1831  HeapTuple tp;
1832 
1833  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1834  if (HeapTupleIsValid(tp))
1835  {
1836  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1837  RegProcedure result;
1838 
1839  result = functup->prosupport;
1840  ReleaseSysCache(tp);
1841  return result;
1842  }
1843  else
1844  return (RegProcedure) InvalidOid;
1845 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
regproc RegProcedure
Definition: c.h:585
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_func_variadictype()

Oid get_func_variadictype ( Oid  funcid)

Definition at line 1694 of file lsyscache.c.

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

1695 {
1696  HeapTuple tp;
1697  Oid result;
1698 
1699  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1700  if (!HeapTupleIsValid(tp))
1701  elog(ERROR, "cache lookup failed for function %u", funcid);
1702 
1703  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1704  ReleaseSysCache(tp);
1705  return result;
1706 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:136
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

Definition at line 3462 of file lsyscache.c.

References Assert, DatumGetPointer, GETSTRUCT, HeapTupleIsValid, INDEXRELID, InvalidOid, ObjectIdGetDatum, PG_USED_FOR_ASSERTS_ONLY, ReleaseSysCache(), SearchSysCache1(), SysCacheGetAttr(), and oidvector::values.

Referenced by gistproperty(), and spgproperty().

3463 {
3464  HeapTuple tuple;
3466  Datum datum;
3467  bool isnull;
3468  oidvector *indclass;
3469  Oid opclass;
3470 
3471  /* First we need to know the column's opclass. */
3472 
3473  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3474  if (!HeapTupleIsValid(tuple))
3475  return InvalidOid;
3476 
3477  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3478 
3479  /* caller is supposed to guarantee this */
3480  Assert(attno > 0 && attno <= rd_index->indnatts);
3481 
3482  /* Non-key attributes don't have an opclass */
3483  if (attno > rd_index->indnkeyatts)
3484  {
3485  ReleaseSysCache(tuple);
3486  return InvalidOid;
3487  }
3488 
3489  datum = SysCacheGetAttr(INDEXRELID, tuple,
3490  Anum_pg_index_indclass, &isnull);
3491  Assert(!isnull);
3492 
3493  indclass = ((oidvector *) DatumGetPointer(datum));
3494 
3495  Assert(attno <= indclass->dim1);
3496  opclass = indclass->values[attno - 1];
3497 
3498  ReleaseSysCache(tuple);
3499 
3500  return opclass;
3501 }
Definition: c.h:660
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:668
FormData_pg_index * Form_pg_index
Definition: pg_index.h:69
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
uintptr_t Datum
Definition: postgres.h:411
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:804
#define DatumGetPointer(X)
Definition: postgres.h:593
#define PG_USED_FOR_ASSERTS_ONLY
Definition: c.h:155

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3555 of file lsyscache.c.

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

Referenced by cluster(), cluster_rel(), mark_index_clustered(), and RememberClusterOnForRebuilding().

3556 {
3557  bool isclustered;
3558  HeapTuple tuple;
3559  Form_pg_index rd_index;
3560 
3561  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3562  if (!HeapTupleIsValid(tuple))
3563  elog(ERROR, "cache lookup failed for index %u", index_oid);
3564 
3565  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3566  isclustered = rd_index->indisclustered;
3567  ReleaseSysCache(tuple);
3568 
3569  return isclustered;
3570 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
FormData_pg_index * Form_pg_index
Definition: pg_index.h:69
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3509 of file lsyscache.c.

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

Referenced by RememberReplicaIdentityForRebuilding().

3510 {
3511  HeapTuple tuple;
3512  Form_pg_index rd_index;
3513  bool result;
3514 
3515  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3516  if (!HeapTupleIsValid(tuple))
3517  return false;
3518 
3519  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3520  result = rd_index->indisreplident;
3521  ReleaseSysCache(tuple);
3522 
3523  return result;
3524 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
FormData_pg_index * Form_pg_index
Definition: pg_index.h:69
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3532 of file lsyscache.c.

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

Referenced by reindex_index(), reindex_relation(), and ReindexRelationConcurrently().

3533 {
3534  bool isvalid;
3535  HeapTuple tuple;
3536  Form_pg_index rd_index;
3537 
3538  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3539  if (!HeapTupleIsValid(tuple))
3540  elog(ERROR, "cache lookup failed for index %u", index_oid);
3541 
3542  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3543  isvalid = rd_index->indisvalid;
3544  ReleaseSysCache(tuple);
3545 
3546  return isvalid;
3547 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
FormData_pg_index * Form_pg_index
Definition: pg_index.h:69
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

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

1155 {
1156  HeapTuple tp;
1157 
1158  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1159  if (HeapTupleIsValid(tp))
1160  {
1162  char *result;
1163 
1164  result = pstrdup(NameStr(lantup->lanname));
1165  ReleaseSysCache(tp);
1166  return result;
1167  }
1168 
1169  if (!missing_ok)
1170  elog(ERROR, "cache lookup failed for language %u",
1171  langoid);
1172  return NULL;
1173 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
#define elog(elevel,...)
Definition: elog.h:232
#define NameStr(name)
Definition: c.h:681

◆ get_mergejoin_opfamilies()

List* get_mergejoin_opfamilies ( Oid  opno)

Definition at line 364 of file lsyscache.c.

References AMOPOPID, BTEqualStrategyNumber, 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().

365 {
366  List *result = NIL;
367  CatCList *catlist;
368  int i;
369 
370  /*
371  * Search pg_amop to see if the target operator is registered as the "="
372  * operator of any btree opfamily.
373  */
375 
376  for (i = 0; i < catlist->n_members; i++)
377  {
378  HeapTuple tuple = &catlist->members[i]->tuple;
379  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
380 
381  /* must be btree equality */
382  if (aform->amopmethod == BTREE_AM_OID &&
383  aform->amopstrategy == BTEqualStrategyNumber)
384  result = lappend_oid(result, aform->amopfamily);
385  }
386 
387  ReleaseSysCacheList(catlist);
388 
389  return result;
390 }
#define NIL
Definition: pg_list.h:65
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
List * lappend_oid(List *list, Oid datum)
Definition: list.c:372
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
int i
HeapTupleData tuple
Definition: catcache.h:121
Definition: pg_list.h:50
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ get_multirange_range()

Oid get_multirange_range ( Oid  multirangeOid)

Definition at line 3433 of file lsyscache.c.

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

Referenced by check_generic_type_consistency(), enforce_generic_type_consistency(), load_multirangetype_info(), resolve_anyelement_from_others(), and resolve_anyrange_from_others().

3434 {
3435  HeapTuple tp;
3436 
3437  tp = SearchSysCache1(RANGEMULTIRANGE, ObjectIdGetDatum(multirangeOid));
3438  if (HeapTupleIsValid(tp))
3439  {
3440  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3441  Oid result;
3442 
3443  result = rngtup->rngtypid;
3444  ReleaseSysCache(tp);
3445  return result;
3446  }
3447  else
3448  return InvalidOid;
3449 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3316 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(), ATParseTransformCmd(), BuildRelationExtStatistics(), check_TSCurrentConfig(), compute_return_type(), copy_table(), copy_table_data(), CreateConversionCommand(), CreateExtensionInternal(), CreateFunction(), current_schema(), current_schemas(), currtid_internal(), 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(), ExecBRInsertTriggers(), ExecRefreshMatView(), execute_extension_script(), fetch_statentries_for_relation(), format_operator_extended(), format_procedure_extended(), generate_operator_clause(), generate_relation_name(), generateClonedIndexStmt(), generateSerialExtraStmts(), get_collation(), get_namespace_name_or_temp(), get_opclass(), get_other_operator(), getObjectDescription(), getOpFamilyDescription(), getRelationDescription(), GetTempNamespaceBackendId(), HandleFunctionRequest(), heap_create(), heap_vacuum_rel(), isAnyTempNamespace(), IsThereCollationInNamespace(), IsThereFunctionInNamespace(), IsThereOpClassInNamespace(), IsThereOpFamilyInNamespace(), 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(), MarkInheritDetached(), parallel_vacuum_main(), perform_work_item(), pg_decode_change(), pg_decode_truncate(), pg_identify_object(), pg_newlocale_from_collation(), plpgsql_fulfill_promise(), quoteRelationName(), RangeVarCallbackForAlterRelation(), RangeVarGetAndCheckCreationNamespace(), RebuildConstraintComment(), refresh_by_match_merge(), regclassout(), regcollationout(), regconfigout(), regdictionaryout(), regnamespaceout(), regoperout(), regprocout(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), report_namespace_conflict(), ri_GenerateQualCollation(), schema_to_xml_internal(), sepgsql_proc_post_create(), sepgsql_relation_post_create(), SPI_getnspname(), transformAlterTableStmt(), transformCreateStmt(), and unaccent_dict().

3317 {
3318  HeapTuple tp;
3319 
3321  if (HeapTupleIsValid(tp))
3322  {
3324  char *result;
3325 
3326  result = pstrdup(NameStr(nsptup->nspname));
3327  ReleaseSysCache(tp);
3328  return result;
3329  }
3330  else
3331  return NULL;
3332 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:681

◆ get_namespace_name_or_temp()

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1504 of file lsyscache.c.

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

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

1505 {
1506  HeapTuple tp;
1507 
1509  if (HeapTupleIsValid(tp))
1510  {
1512  Oid result;
1513 
1514  result = optup->oprnegate;
1515  ReleaseSysCache(tp);
1516  return result;
1517  }
1518  else
1519  return InvalidOid;
1520 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_op_btree_interpretation()

List* get_op_btree_interpretation ( Oid  opno)

Definition at line 599 of file lsyscache.c.

References AMOPOPID, Assert, BTEqualStrategyNumber, 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().

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

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

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

510 {
511  bool result = false;
512  CatCList *catlist;
513  int i;
514 
515  /* Ensure output args are initialized on failure */
516  if (lhs_procno)
517  *lhs_procno = InvalidOid;
518  if (rhs_procno)
519  *rhs_procno = InvalidOid;
520 
521  /*
522  * Search pg_amop to see if the target operator is registered as the "="
523  * operator of any hash opfamily. If the operator is registered in
524  * multiple opfamilies, assume we can use any one.
525  */
527 
528  for (i = 0; i < catlist->n_members; i++)
529  {
530  HeapTuple tuple = &catlist->members[i]->tuple;
531  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
532 
533  if (aform->amopmethod == HASH_AM_OID &&
534  aform->amopstrategy == HTEqualStrategyNumber)
535  {
536  /*
537  * Get the matching support function(s). Failure probably
538  * shouldn't happen --- it implies a bogus opfamily --- but
539  * continue looking if so.
540  */
541  if (lhs_procno)
542  {
543  *lhs_procno = get_opfamily_proc(aform->amopfamily,
544  aform->amoplefttype,
545  aform->amoplefttype,
547  if (!OidIsValid(*lhs_procno))
548  continue;
549  /* Matching LHS found, done if caller doesn't want RHS */
550  if (!rhs_procno)
551  {
552  result = true;
553  break;
554  }
555  /* Only one lookup needed if given operator is single-type */
556  if (aform->amoplefttype == aform->amoprighttype)
557  {
558  *rhs_procno = *lhs_procno;
559  result = true;
560  break;
561  }
562  }
563  if (rhs_procno)
564  {
565  *rhs_procno = get_opfamily_proc(aform->amopfamily,
566  aform->amoprighttype,
567  aform->amoprighttype,
569  if (!OidIsValid(*rhs_procno))
570  {
571  /* Forget any LHS function from this opfamily */
572  if (lhs_procno)
573  *lhs_procno = InvalidOid;
574  continue;
575  }
576  /* Matching RHS found, so done */
577  result = true;
578  break;
579  }
580  }
581  }
582 
583  ReleaseSysCacheList(catlist);
584 
585  return result;
586 }
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define OidIsValid(objectId)
Definition: c.h:710
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define HTEqualStrategyNumber
Definition: stratnum.h:41
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define HASHSTANDARD_PROC
Definition: hash.h:353
#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:794
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
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 134 of file lsyscache.c.

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

Referenced by ExecIndexBuildScanKeys(), ExecInitExprRec(), expand_indexqual_rowcompare(), gen_prune_steps_from_opexps(), gincost_pattern(), match_clause_to_partition_key(), mergejoinscansel(), and MJExamineQuals().

138 {
139  HeapTuple tp;
140  Form_pg_amop amop_tup;
141 
143  ObjectIdGetDatum(opno),
144  CharGetDatum(ordering_op ? AMOP_ORDER : AMOP_SEARCH),
145  ObjectIdGetDatum(opfamily));
146  if (!HeapTupleIsValid(tp))
147  elog(ERROR, "operator %u is not a member of opfamily %u",
148  opno, opfamily);
149  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
150  *strategy = amop_tup->amopstrategy;
151  *lefttype = amop_tup->amoplefttype;
152  *righttype = amop_tup->amoprighttype;
153  ReleaseSysCache(tp);
154 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:460
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
#define elog(elevel,...)
Definition: elog.h:232

◆ get_op_opfamily_sortfamily()

Oid get_op_opfamily_sortfamily ( Oid  opno,
Oid  opfamily 
)

Definition at line 106 of file lsyscache.c.

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

Referenced by match_clause_to_ordering_op().

107 {
108  HeapTuple tp;
109  Form_pg_amop amop_tup;
110  Oid result;
111 
113  ObjectIdGetDatum(opno),
114  CharGetDatum(AMOP_ORDER),
115  ObjectIdGetDatum(opfamily));
116  if (!HeapTupleIsValid(tp))
117  return InvalidOid;
118  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
119  result = amop_tup->amopsortfamily;
120  ReleaseSysCache(tp);
121  return result;
122 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:460
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_opfamily_strategy()

int get_op_opfamily_strategy ( Oid  opno,
Oid  opfamily 
)

Definition at line 81 of file lsyscache.c.

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

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

82 {
83  HeapTuple tp;
84  Form_pg_amop amop_tup;
85  int result;
86 
88  ObjectIdGetDatum(opno),
89  CharGetDatum(AMOP_SEARCH),
90  ObjectIdGetDatum(opfamily));
91  if (!HeapTupleIsValid(tp))
92  return 0;
93  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
94  result = amop_tup->amopstrategy;
95  ReleaseSysCache(tp);
96  return result;
97 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:460
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1304 of file lsyscache.c.

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

Referenced by gistvalidate(), spgproperty(), and spgvalidate().

1305 {
1306  HeapTuple tp;
1307 
1309  if (HeapTupleIsValid(tp))
1310  {
1312  Oid result;
1313 
1314  result = optup->oprresult;
1315  ReleaseSysCache(tp);
1316  return result;
1317  }
1318  else
1319  return InvalidOid;
1320 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_opclass_family()

Oid get_opclass_family ( Oid  opclass)

Definition at line 1183 of file lsyscache.c.

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

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

1184 {
1185  HeapTuple tp;
1186  Form_pg_opclass cla_tup;
1187  Oid result;
1188 
1189  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1190  if (!HeapTupleIsValid(tp))
1191  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1192  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1193 
1194  result = cla_tup->opcfamily;
1195  ReleaseSysCache(tp);
1196  return result;
1197 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opclass_input_type()

Oid get_opclass_input_type ( Oid  opclass)

Definition at line 1205 of file lsyscache.c.

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

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

1206 {
1207  HeapTuple tp;
1208  Form_pg_opclass cla_tup;
1209  Oid result;
1210 
1211  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1212  if (!HeapTupleIsValid(tp))
1213  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1214  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1215 
1216  result = cla_tup->opcintype;
1217  ReleaseSysCache(tp);
1218  return result;
1219 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:232
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opclass_opfamily_and_input_type()

bool get_opclass_opfamily_and_input_type ( Oid  opclass,
Oid opfamily,
Oid opcintype 
)

Definition at line 1228 of file lsyscache.c.

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

Referenced by DefineIndex(), gistproperty(), and spgproperty().

1229 {
1230  HeapTuple tp;
1231  Form_pg_opclass cla_tup;
1232 
1233  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1234  if (!HeapTupleIsValid(tp))
1235  return false;
1236 
1237  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1238 
1239  *opfamily = cla_tup->opcfamily;
1240  *opcintype = cla_tup->opcintype;
1241 
1242  ReleaseSysCache(tp);
1243 
1244  return true;
1245 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_opclass * Form_pg_opclass
Definition: pg_opclass.h:83

◆ get_opcode()

RegProcedure get_opcode ( Oid  opno)

Definition at line 1256 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(), convert_saop_to_hashed_saop_walker(), cost_qual_eval_walker(), DefineOpClass(), eqjoinsel(), ExecInitMemoize(), ExecInitSubPlan(), execTuplesHashPrepare(), execTuplesMatchPrepare(), generic_restriction_selectivity(), get_expr_result_type(), get_variable_range(), inclusion_get_strategy_procinfo(), inet_mcv_join_sel(), lookup_type_cache(), make_partition_op_expr(), match_pattern_prefix(), mcv_get_match_bitmap(), minmax_get_strategy_procinfo(), minmax_multi_get_strategy_procinfo(), mode_final(), networkjoinsel_semi(), networksel(), op_strict(), op_volatile(), OperatorLookup(), patternsel_common(), prefix_selectivity(), preparePresortedCols(), RelationGetExclusionInfo(), ri_HashCompareOp(), scalarineqsel(), select_equality_operator(), set_opfuncid(), set_sa_opfuncid(), statext_is_compatible_clause_internal(), std_typanalyze(), and var_eq_const().

1257 {
1258  HeapTuple tp;
1259 
1261  if (HeapTupleIsValid(tp))
1262  {
1264  RegProcedure result;
1265 
1266  result = optup->oprcode;
1267  ReleaseSysCache(tp);
1268  return result;
1269  }
1270  else
1271  return (RegProcedure) InvalidOid;
1272 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
regproc RegProcedure
Definition: c.h:585
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_opfamily_member()

Oid get_opfamily_member ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  strategy 
)

Definition at line 164 of file lsyscache.c.

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

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), ATAddForeignKeyConstraint(), btcostestimate(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), create_indexscan_plan(), DefineIndex(), expand_indexqual_rowcompare(), 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(), match_network_subset(), mergejoinscansel(), prepare_sort_from_pathkeys(), refresh_by_match_merge(), and select_equality_operator().

166 {
167  HeapTuple tp;
168  Form_pg_amop amop_tup;
169  Oid result;
170 
172  ObjectIdGetDatum(opfamily),
173  ObjectIdGetDatum(lefttype),
174  ObjectIdGetDatum(righttype),
175  Int16GetDatum(strategy));
176  if (!HeapTupleIsValid(tp))
177  return InvalidOid;
178  amop_tup = (Form_pg_amop) GETSTRUCT(tp);
179  result = amop_tup->amopopr;
180  ReleaseSysCache(tp);
181  return result;
182 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define Int16GetDatum(X)
Definition: postgres.h:495
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1160
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_opfamily_proc()

Oid get_opfamily_proc ( Oid  opfamily,
Oid  lefttype,
Oid  righttype,
int16  procnum 
)

Definition at line 794 of file lsyscache.c.

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

Referenced by _bt_allequalimage(), _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(), match_clause_to_partition_key(), MJExamineQuals(), PrepareSortSupportFromGistIndexRel(), and RelationBuildPartitionKey().

795 {
796  HeapTuple tp;
797  Form_pg_amproc amproc_tup;
798  RegProcedure result;
799 
801  ObjectIdGetDatum(opfamily),
802  ObjectIdGetDatum(lefttype),
803  ObjectIdGetDatum(righttype),
804  Int16GetDatum(procnum));
805  if (!HeapTupleIsValid(tp))
806  return InvalidOid;
807  amproc_tup = (Form_pg_amproc) GETSTRUCT(tp);
808  result = amproc_tup->amproc;
809  ReleaseSysCache(tp);
810  return result;
811 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:68
regproc RegProcedure
Definition: c.h:585
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1160
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1281 of file lsyscache.c.

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

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

1282 {
1283  HeapTuple tp;
1284 
1286  if (HeapTupleIsValid(tp))
1287  {
1289  char *result;
1290 
1291  result = pstrdup(NameStr(optup->oprname));
1292  ReleaseSysCache(tp);
1293  return result;
1294  }
1295  else
1296  return NULL;
1297 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83
#define NameStr(name)
Definition: c.h:681

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1552 of file lsyscache.c.

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

Referenced by join_selectivity(), and scalararraysel().

1553 {
1554  HeapTuple tp;
1555 
1557  if (HeapTupleIsValid(tp))
1558  {
1560  RegProcedure result;
1561 
1562  result = optup->oprjoin;
1563  ReleaseSysCache(tp);
1564  return result;
1565  }
1566  else
1567  return (RegProcedure) InvalidOid;
1568 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
regproc RegProcedure
Definition: c.h:585
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_oprrest()

RegProcedure get_oprrest ( Oid  opno)

Definition at line 1528 of file lsyscache.c.

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

Referenced by clauselist_selectivity_ext(), dependency_is_compatible_clause(), dependency_is_compatible_expression(), restriction_selectivity(), scalararraysel(), and statext_is_compatible_clause_internal().

1529 {
1530  HeapTuple tp;
1531 
1533  if (HeapTupleIsValid(tp))
1534  {
1536  RegProcedure result;
1537 
1538  result = optup->oprrest;
1539  ReleaseSysCache(tp);
1540  return result;
1541  }
1542  else
1543  return (RegProcedure) InvalidOid;
1544 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
regproc RegProcedure
Definition: c.h:585
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83

◆ get_ordering_op_for_equality_op()

Oid get_ordering_op_for_equality_op ( Oid  opno,
bool  use_lhs_type 
)

Definition at line 303 of file lsyscache.c.

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

Referenced by create_unique_plan().

304 {
305  Oid result = InvalidOid;
306  CatCList *catlist;
307  int i;
308 
309  /*
310  * Search pg_amop to see if the target operator is registered as the "="
311  * operator of any btree opfamily.
312  */
314 
315  for (i = 0; i < catlist->n_members; i++)
316  {
317  HeapTuple tuple = &catlist->members[i]->tuple;
318  Form_pg_amop aform = (Form_pg_amop) GETSTRUCT(tuple);
319 
320  /* must be btree */
321  if (aform->amopmethod != BTREE_AM_OID)
322  continue;
323 
324  if (aform->amopstrategy == BTEqualStrategyNumber)
325  {
326  /* Found a suitable opfamily, get matching ordering operator */
327  Oid typid;
328 
329  typid = use_lhs_type ? aform->amoplefttype : aform->amoprighttype;
330  result = get_opfamily_member(aform->amopfamily,
331  typid, typid,
333  if (OidIsValid(result))
334  break;
335  /* failure probably shouldn't happen, but keep looking if so */
336  }
337  }
338 
339  ReleaseSysCacheList(catlist);
340 
341  return result;
342 }
int n_members
Definition: catcache.h:176
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:710
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:211
#define ReleaseSysCacheList(x)
Definition: syscache.h:218
#define InvalidOid
Definition: postgres_ext.h:36
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
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 205 of file lsyscache.c.

References AMOPOPID, BTGreaterStrategyNumber, BTLessStrategyNumber, 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(), PrepareSortSupportFromOrderingOp(), and transformWindowDefinitions().

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

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

Referenced by build_subplan(), and exprType().

2759 {
2760  Oid array_type = get_array_type(typid);
2761 
2762  if (OidIsValid(array_type))
2763  return array_type;
2764  if (OidIsValid(get_element_type(typid)))
2765  return typid;
2766  return InvalidOid;
2767 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2706
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2734
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:710
#define InvalidOid
Definition: postgres_ext.h:36

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3383 of file lsyscache.c.

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

Referenced by CheckAttributeType().

3384 {
3385  HeapTuple tp;
3386 
3387  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3388  if (HeapTupleIsValid(tp))
3389  {
3390  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3391  Oid result;
3392 
3393  result = rngtup->rngcollation;
3394  ReleaseSysCache(tp);
3395  return result;
3396  }
3397  else
3398  return InvalidOid;
3399 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_range_multirange()

Oid get_range_multirange ( Oid  rangeOid)

Definition at line 3408 of file lsyscache.c.

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

Referenced by enforce_generic_type_consistency(), and resolve_anymultirange_from_others().

3409 {
3410  HeapTuple tp;
3411 
3412  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3413  if (HeapTupleIsValid(tp))
3414  {
3415  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3416  Oid result;
3417 
3418  result = rngtup->rngmultitypid;
3419  ReleaseSysCache(tp);
3420  return result;
3421  }
3422  else
3423  return InvalidOid;
3424 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_range_subtype()

Oid get_range_subtype ( Oid  rangeOid)

Definition at line 3357 of file lsyscache.c.

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

Referenced by check_generic_type_consistency(), CheckAttributeType(), enforce_generic_type_consistency(), and resolve_anyelement_from_others().

3358 {
3359  HeapTuple tp;
3360 
3361  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3362  if (HeapTupleIsValid(tp))
3363  {
3364  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3365  Oid result;
3366 
3367  result = rngtup->rngsubtype;
3368  ReleaseSysCache(tp);
3369  return result;
3370  }
3371  else
3372  return InvalidOid;
3373 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:58
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_rel_name()

char* get_rel_name ( Oid  relid)

Definition at line 1899 of file lsyscache.c.

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_attnums(), AlterSubscription_refresh(), AlterTableNamespace(), ApplyWorkerMain(), ATExecAlterConstraint(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), convert_column_name(), CreateTriggerFiringOn(), DefineRelation(), do_autovacuum(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), execCurrentOf(), expand_col_privileges(), explain_get_index_name(), ExplainTargetRel(), get_relation_constraint_attnos(), get_relation_constraint_oid(), get_relation_name(), get_relation_policy_oid(), get_rewrite_oid(), get_trigger_oid(), gincost_pattern(), has_sequence_privilege_id(), has_sequence_privilege_id_id(), has_sequence_privilege_name_id(), heap_truncate_check_FKs(), InsertRule(), LockTableRecurse(), LockViewRecurse_walker(), makeWholeRowVar(), map_sql_schema_to_xmlschema_types(), MarkInheritDetached(), perform_work_item(), pg_attribute_noreturn(), pg_decode_change(), pg_extension_config_dump(), pg_get_expr(), pg_get_expr_ext(), pg_prewarm(), pg_sequence_parameters(), postgresExplainForeignScan(), process_owned_by(), reindex_index(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), RememberClusterOnForRebuilding(), RememberReplicaIdentityForRebuilding(), RemoveSubscriptionRel(), RenameConstraintById(), renametrig(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), table_to_xml_internal(), and transformAlterTableStmt().

1900 {
1901  HeapTuple tp;
1902 
1903  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1904  if (HeapTupleIsValid(tp))
1905  {
1906  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1907  char *result;
1908 
1909  result = pstrdup(NameStr(reltup->relname));
1910  ReleaseSysCache(tp);
1911  return result;
1912  }
1913  else
1914  return NULL;
1915 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char * pstrdup(const char *in)
Definition: mcxt.c:1299
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
#define NameStr(name)
Definition: c.h:681

◆ get_rel_namespace()

Oid get_rel_namespace ( Oid  relid)

Definition at line 1923 of file lsyscache.c.

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

Referenced by AlterSubscription_refresh(), do_autovacuum(), exec_object_restorecon(), ExecCheckXactReadOnly(), perform_work_item(), pg_decode_change(), reindex_relation(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), sepgsql_relation_drop(), and transformAlterTableStmt().

1924 {
1925  HeapTuple tp;
1926 
1927  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1928  if (HeapTupleIsValid(tp))
1929  {
1930  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1931  Oid result;
1932 
1933  result = reltup->relnamespace;
1934  ReleaseSysCache(tp);
1935  return result;
1936  }
1937  else
1938  return InvalidOid;
1939 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_persistence()

char get_rel_persistence ( Oid  relid)

Definition at line 2049 of file lsyscache.c.

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

Referenced by DefineIndex(), index_drop(), RangeVarCallbackForLockTable(), ReindexIndex(), ReindexMultipleInternal(), ReindexTable(), RemoveRelations(), and set_rel_consider_parallel().

2050 {
2051  HeapTuple tp;
2052  Form_pg_class reltup;
2053  char result;
2054 
2055  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2056  if (!HeapTupleIsValid(tp))
2057  elog(ERROR, "cache lookup failed for relation %u", relid);
2058  reltup = (Form_pg_class) GETSTRUCT(tp);
2059  result = reltup->relpersistence;
2060  ReleaseSysCache(tp);
2061 
2062  return result;
2063 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
#define elog(elevel,...)
Definition: elog.h:232

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

Definition at line 1998 of file lsyscache.c.

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

Referenced by check_rel_can_be_partition(), get_partition_qual_relid(), get_rel_sync_entry(), and index_concurrently_swap().

1999 {
2000  HeapTuple tp;
2001 
2002  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2003  if (HeapTupleIsValid(tp))
2004  {
2005  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2006  bool result;
2007 
2008  result = reltup->relispartition;
2009  ReleaseSysCache(tp);
2010  return result;
2011  }
2012  else
2013  return false;
2014 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_relkind()

char get_rel_relkind ( Oid  relid)

Definition at line 1974 of file lsyscache.c.

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

Referenced by AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), ATExecAlterConstrRecurse(), ATExecChangeOwner(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTriggerFiringOn(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), get_object_type(), get_rel_sync_entry(), getOwnedSequences_internal(), GetPublicationRelations(), 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(), LockTableCommand(), pg_get_serial_sequence(), pg_get_triggerdef_worker(), pg_partition_tree(), ProcessUtilitySlow(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForLockTable(), RangeVarCallbackForPolicy(), RangeVarCallbackForReindexIndex(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), RangeVarCallbackOwnsTable(), RangeVarGetAndCheckCreationNamespace(), ReindexIndex(), ReindexMultipleInternal(), ReindexPartitions(), ReindexRelationConcurrently(), ReindexTable(), RelationBuildPartitionDesc(), RemoveRelations(), renameatt_check(), RenameType(), sepgsql_attribute_drop(), sepgsql_attribute_post_create(), sepgsql_attribute_relabel(), sepgsql_attribute_setattr(), sepgsql_relation_drop(), sepgsql_relation_relabel(), sepgsql_relation_setattr(), and sepgsql_relation_truncate().

1975 {
1976  HeapTuple tp;
1977 
1978  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1979  if (HeapTupleIsValid(tp))
1980  {
1981  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1982  char result;
1983 
1984  result = reltup->relkind;
1985  ReleaseSysCache(tp);
1986  return result;
1987  }
1988  else
1989  return '\0';
1990 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_tablespace()

Oid get_rel_tablespace ( Oid  relid)

Definition at line 2025 of file lsyscache.c.

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

Referenced by DefineRelation(), pg_get_constraintdef_worker(), and pg_get_indexdef_worker().

2026 {
2027  HeapTuple tp;
2028 
2029  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
2030  if (HeapTupleIsValid(tp))
2031  {
2032  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
2033  Oid result;
2034 
2035  result = reltup->reltablespace;
2036  ReleaseSysCache(tp);
2037  return result;
2038  }
2039  else
2040  return InvalidOid;
2041 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_rel_type_id()

Oid get_rel_type_id ( Oid  relid)

Definition at line 1950 of file lsyscache.c.

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

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

1951 {
1952  HeapTuple tp;
1953 
1954  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1955  if (HeapTupleIsValid(tp))
1956  {
1957  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1958  Oid result;
1959 
1960  result = reltup->reltype;
1961  ReleaseSysCache(tp);
1962  return result;
1963  }
1964  else
1965  return InvalidOid;
1966 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153

◆ get_relname_relid()

◆ get_transform_fromsql()

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

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

2070 {
2071  HeapTuple tup;
2072 
2073  if (!list_member_oid(trftypes, typid))
2074  return InvalidOid;
2075 
2076  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2077  if (HeapTupleIsValid(tup))
2078  {
2079  Oid funcid;
2080 
2081  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2082  ReleaseSysCache(tup);
2083  return funcid;
2084  }
2085  else
2086  return InvalidOid;
2087 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:689
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ get_transform_tosql()

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

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

2091 {
2092  HeapTuple tup;
2093 
2094  if (!list_member_oid(trftypes, typid))
2095  return InvalidOid;
2096 
2097  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2098  if (HeapTupleIsValid(tup))
2099  {
2100  Oid funcid;
2101 
2102  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2103  ReleaseSysCache(tup);
2104  return funcid;
2105  }
2106  else
2107  return InvalidOid;
2108 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_transform * Form_pg_transform
Definition: pg_transform.h:43
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:689
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2678 of file lsyscache.c.

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

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

2679 {
2680  HeapTuple tp;
2681 
2683  if (HeapTupleIsValid(tp))
2684  {
2685  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2686  Oid result;
2687 
2688  result = typtup->typrelid;
2689  ReleaseSysCache(tp);
2690  return result;
2691  }
2692  else
2693  return InvalidOid;
2694 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2525 of file lsyscache.c.

References get_typlen(), and type_maximum_size().

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

2526 {
2527  int typlen = get_typlen(typid);
2528  int32 maxwidth;
2529 
2530  /*
2531  * Easy if it's a fixed-width type
2532  */
2533  if (typlen > 0)
2534  return typlen;
2535 
2536  /*
2537  * type_maximum_size knows the encoding of typmod for some datatypes;
2538  * don't duplicate that knowledge here.
2539  */
2540  maxwidth = type_maximum_size(typid, typmod);
2541  if (maxwidth > 0)
2542  {
2543  /*
2544  * For BPCHAR, the max width is also the only width. Otherwise we
2545  * need to guess about the typical data width given the max. A sliding
2546  * scale for percentage of max width seems reasonable.
2547  */
2548  if (typid == BPCHAROID)
2549  return maxwidth;
2550  if (maxwidth <= 32)
2551  return maxwidth; /* assume full width */
2552  if (maxwidth < 1000)
2553  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2554 
2555  /*
2556  * Beyond 1000, assume we're looking at something like
2557  * "varchar(10000)" where the limit isn't actually reached often, and
2558  * use a fixed estimate.
2559  */
2560  return 32 + (1000 - 32) / 2;
2561  }
2562 
2563  /*
2564  * Oops, we have no idea ... wild guess time.
2565  */
2566  return 32;
2567 }
signed int int32
Definition: c.h:429
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:408
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2144

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 2169 of file lsyscache.c.

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

Referenced by range_deserialize(), and range_serialize().

2170 {
2171  HeapTuple tp;
2172 
2174  if (HeapTupleIsValid(tp))
2175  {
2176  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2177  bool result;
2178 
2179  result = typtup->typbyval;
2180  ReleaseSysCache(tp);
2181  return result;
2182  }
2183  else
2184  return false;
2185 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typcollation()

Oid get_typcollation ( Oid  typid)

Definition at line 3003 of file lsyscache.c.

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

Referenced by assign_collations_walker(), ATExecAddColumn(), DefineRange(), domainAddConstraint(), fixed_paramref_hook(), get_cast_hashentry(), get_collation(), get_const_collation(), get_from_clause_coldeflist(), GetColumnDefCollation(), paramlist_param_ref(), resolve_polymorphic_tupdesc(), show_sortorder_options(), sql_fn_make_param(), transformAssignmentSubscripts(), transformRangeTableFunc(), type_is_collatable(), variable_coerce_param_hook(), and variable_paramref_hook().

3004 {
3005  HeapTuple tp;
3006 
3008  if (HeapTupleIsValid(tp))
3009  {
3010  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
3011  Oid result;
3012 
3013  result = typtup->typcollation;
3014  ReleaseSysCache(tp);
3015  return result;
3016  }
3017  else
3018  return InvalidOid;
3019 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

Definition at line 2395 of file lsyscache.c.

References 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().

2396 {
2397  HeapTuple typeTuple;
2399  Datum datum;
2400  bool isNull;
2401  Node *expr;
2402 
2403  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2404  if (!HeapTupleIsValid(typeTuple))
2405  elog(ERROR, "cache lookup failed for type %u", typid);
2406  type = (Form_pg_type) GETSTRUCT(typeTuple);
2407 
2408  /*
2409  * typdefault and typdefaultbin are potentially null, so don't try to
2410  * access 'em as struct fields. Must do it the hard way with
2411  * SysCacheGetAttr.
2412  */
2413  datum = SysCacheGetAttr(TYPEOID,
2414  typeTuple,
2415  Anum_pg_type_typdefaultbin,
2416  &isNull);
2417 
2418  if (!isNull)
2419  {
2420  /* We have an expression default */
2421  expr = stringToNode(TextDatumGetCString(datum));
2422  }
2423  else
2424  {
2425  /* Perhaps we have a plain literal default */
2426  datum = SysCacheGetAttr(TYPEOID,
2427  typeTuple,
2428  Anum_pg_type_typdefault,
2429  &isNull);
2430 
2431  if (!isNull)
2432  {
2433  char *strDefaultVal;
2434 
2435  /* Convert text datum to C string */
2436  strDefaultVal = TextDatumGetCString(datum);
2437  /* Convert C string to a value of the given type */
2438  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2439  getTypeIOParam(typeTuple), -1);
2440  /* Build a Const node containing the value */
2441  expr = (Node *) makeConst(typid,
2442  -1,
2443  type->typcollation,
2444  type->typlen,
2445  datum,
2446  false,
2447  type->typbyval);
2448  pfree(strDefaultVal);
2449  }
2450  else
2451  {
2452  /* No default */
2453  expr = NULL;
2454  }
2455  }
2456 
2457  ReleaseSysCache(typeTuple);
2458 
2459  return expr;
2460 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
Definition: nodes.h:539
void * stringToNode(const char *str)
Definition: read.c:89
Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)
Definition: makefuncs.c:299
void pfree(void *pointer)
Definition: mcxt.c:1169
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
#define TextDatumGetCString(d)
Definition: builtins.h:83
uintptr_t Datum
Definition: postgres.h:411
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:232
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2250
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1644

◆ get_type_category_preferred()

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

Definition at line 2657 of file lsyscache.c.

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

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

2658 {
2659  HeapTuple tp;
2660  Form_pg_type typtup;
2661 
2663  if (!HeapTupleIsValid(tp))
2664  elog(ERROR, "cache lookup failed for type %u", typid);
2665  typtup = (Form_pg_type) GETSTRUCT(tp);
2666  *typcategory = typtup->typcategory;
2667  *typispreferred = typtup->typispreferred;
2668  ReleaseSysCache(tp);
2669 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:232

◆ 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 2272 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_multirange_io_data(), get_range_io_data(), and plperl_ref_from_pg_array().

2280 {
2281  HeapTuple typeTuple;
2282  Form_pg_type typeStruct;
2283 
2284  /*
2285  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2286  * use array_in and array_out during bootstrap.
2287  */
2289  {
2290  Oid typinput;
2291  Oid typoutput;
2292 
2293  boot_get_type_io_data(typid,
2294  typlen,
2295  typbyval,
2296  typalign,
2297  typdelim,
2298  typioparam,
2299  &typinput,
2300  &typoutput);
2301  switch (which_func)
2302  {
2303  case IOFunc_input:
2304  *func = typinput;
2305  break;
2306  case IOFunc_output:
2307  *func = typoutput;
2308  break;
2309  default:
2310  elog(ERROR, "binary I/O not supported during bootstrap");
2311  break;
2312  }
2313  return;
2314  }
2315 
2316  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2317  if (!HeapTupleIsValid(typeTuple))
2318  elog(ERROR, "cache lookup failed for type %u", typid);
2319  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2320 
2321  *typlen = typeStruct->typlen;
2322  *typbyval = typeStruct->typbyval;
2323  *typalign = typeStruct->typalign;
2324  *typdelim = typeStruct->typdelim;
2325  *typioparam = getTypeIOParam(typeTuple);
2326  switch (which_func)
2327  {
2328  case IOFunc_input:
2329  *func = typeStruct->typinput;
2330  break;
2331  case IOFunc_output:
2332  *func = typeStruct->typoutput;
2333  break;
2334  case IOFunc_receive:
2335  *func = typeStruct->typreceive;
2336  break;
2337  case IOFunc_send:
2338  *func = typeStruct->typsend;
2339  break;
2340  }
2341  ReleaseSysCache(typeTuple);
2342 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
char typalign
Definition: pg_type.h:176
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:406
#define elog(elevel,...)
Definition: elog.h:232
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2250
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:991

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 2120 of file lsyscache.c.

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

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

2121 {
2122  HeapTuple tp;
2123 
2125  if (HeapTupleIsValid(tp))
2126  {
2127  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2128  bool result;
2129 
2130  result = typtup->typisdefined;
2131  ReleaseSysCache(tp);
2132  return result;
2133  }
2134  else
2135  return false;
2136 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2144 of file lsyscache.c.

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

Referenced by array_exec_setup(), build_sorted_items(), DefineType(), ExecBuildProjectionInfo(), ExecInitCoerceToDomain(), ExecInitExprRec(), get_typavgwidth(), pg_column_compression(), pg_column_size(), range_deserialize(), and range_serialize().

2145 {
2146  HeapTuple tp;
2147 
2149  if (HeapTupleIsValid(tp))
2150  {
2151  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2152  int16 result;
2153 
2154  result = typtup->typlen;
2155  ReleaseSysCache(tp);
2156  return result;
2157  }
2158  else
2159  return 0;
2160 }
signed short int16
Definition: c.h:428
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typlenbyval()

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

Definition at line 2198 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(), get_actual_variable_range(), get_variable_range(), init_sql_fcache(), initialize_peragg(), makeNullConst(), preprocess_aggref(), scalararraysel(), SerializeParamExecParams(), SerializeParamList(), and tuplesort_begin_datum().

2199 {
2200  HeapTuple tp;
2201  Form_pg_type typtup;
2202 
2204  if (!HeapTupleIsValid(tp))
2205  elog(ERROR, "cache lookup failed for type %u", typid);
2206  typtup = (Form_pg_type) GETSTRUCT(tp);
2207  *typlen = typtup->typlen;
2208  *typbyval = typtup->typbyval;
2209  ReleaseSysCache(tp);
2210 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:232

◆ get_typlenbyvalalign()

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

Definition at line 2218 of file lsyscache.c.

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

Referenced by _bt_preprocess_array_keys(), array_create_iterator(), array_exec_setup(), 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(), ExecEvalHashedScalarArrayOp(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitExprRec(), expand_array(), extract_variadic_args(), get_text_array_contents(), ginarrayextract(), gincost_scalararrayopexpr(), ginqueryarrayextract(), initArrayResult(), map_sql_value_to_xml_value(), match_clause_to_partition_key(), mcv_get_match_bitmap(), ordered_set_startup(), RelationBuildPartitionKey(), satisfies_hash_partition(), scalararraysel(), text_format(), and trim_array().

2220 {
2221  HeapTuple tp;
2222  Form_pg_type typtup;
2223 
2225  if (!HeapTupleIsValid(tp))
2226  elog(ERROR, "cache lookup failed for type %u", typid);
2227  typtup = (Form_pg_type) GETSTRUCT(tp);
2228  *typlen = typtup->typlen;
2229  *typbyval = typtup->typbyval;
2230  *typalign = typtup->typalign;
2231  ReleaseSysCache(tp);
2232 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
char typalign
Definition: pg_type.h:176
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261
#define elog(elevel,...)
Definition: elog.h:232

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2953 of file lsyscache.c.

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

2954 {
2955  HeapTuple tp;
2956 
2958  if (HeapTupleIsValid(tp))
2959  {
2960  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2961  Oid result;
2962 
2963  result = typtup->typmodin;
2964  ReleaseSysCache(tp);
2965  return result;
2966  }
2967  else
2968  return InvalidOid;
2969 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2366 of file lsyscache.c.

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

2367 {
2368  HeapTuple tp;
2369 
2371  if (HeapTupleIsValid(tp))
2372  {
2373  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2374  char result;
2375 
2376  result = typtup->typstorage;
2377  ReleaseSysCache(tp);
2378  return result;
2379  }
2380  else
2381  return TYPSTORAGE_PLAIN;
2382 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typsubscript()

RegProcedure get_typsubscript ( Oid  typid,
Oid typelemp 
)

Definition at line 3044 of file lsyscache.c.

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

Referenced by exec_check_rw_parameter(), and getSubscriptingRoutines().

3045 {
3046  HeapTuple tp;
3047 
3049  if (HeapTupleIsValid(tp))
3050  {
3051  Form_pg_type typform = (Form_pg_type) GETSTRUCT(tp);
3052  RegProcedure handler = typform->typsubscript;
3053 
3054  if (typelemp)
3055  *typelemp = typform->typelem;
3056  ReleaseSysCache(tp);
3057  return handler;
3058  }
3059  else
3060  {
3061  if (typelemp)
3062  *typelemp = InvalidOid;
3063  return InvalidOid;
3064  }
3065 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
regproc RegProcedure
Definition: c.h:585
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2576 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(), map_sql_type_to_xmlschema_type(), plperl_validator(), plpgsql_validator(), prepare_column_cache(), type_is_enum(), type_is_multirange(), type_is_range(), and type_is_rowtype().

2577 {
2578  HeapTuple tp;
2579 
2581  if (HeapTupleIsValid(tp))
2582  {
2583  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2584  char result;
2585 
2586  result = typtup->typtype;
2587  ReleaseSysCache(tp);
2588  return result;
2589  }
2590  else
2591  return '\0';
2592 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:261

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)