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)
 
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)
 
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)
 
void get_type_category_preferred (Oid typid, char *typcategory, bool *typispreferred)
 
Oid get_typ_typrelid (Oid typid)
 
Oid get_element_type (Oid typid)
 
Oid get_array_type (Oid typid)
 
Oid get_promoted_array_type (Oid typid)
 
Oid get_base_element_type (Oid typid)
 
void getTypeInputInfo (Oid type, Oid *typInput, Oid *typIOParam)
 
void getTypeOutputInfo (Oid type, Oid *typOutput, bool *typIsVarlena)
 
void getTypeBinaryInputInfo (Oid type, Oid *typReceive, Oid *typIOParam)
 
void getTypeBinaryOutputInfo (Oid type, Oid *typSend, bool *typIsVarlena)
 
Oid get_typmodin (Oid typid)
 
Oid get_typcollation (Oid typid)
 
bool type_is_collatable (Oid typid)
 
Oid getBaseType (Oid typid)
 
Oid getBaseTypeAndTypmod (Oid typid, int32 *typmod)
 
int32 get_typavgwidth (Oid typid, int32 typmod)
 
int32 get_attavgwidth (Oid relid, AttrNumber attnum)
 
bool get_attstatsslot (AttStatsSlot *sslot, HeapTuple statstuple, int reqkind, Oid reqop, int flags)
 
void free_attstatsslot (AttStatsSlot *sslot)
 
char * get_namespace_name (Oid nspid)
 
char * get_namespace_name_or_temp (Oid nspid)
 
Oid get_range_subtype (Oid rangeOid)
 
Oid get_range_collation (Oid rangeOid)
 
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 191 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 195 of file lsyscache.h.

Referenced by ATExecSetStorage(), and ExecIndexBuildScanKeys().

Typedef Documentation

◆ AttStatsSlot

typedef struct AttStatsSlot AttStatsSlot

◆ get_attavgwidth_hook_type

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

Definition at line 62 of file lsyscache.h.

◆ IOFuncSelector

◆ OpBtreeInterpretation

Enumeration Type Documentation

◆ IOFuncSelector

Enumerator
IOFunc_input 
IOFunc_output 
IOFunc_receive 
IOFunc_send 

Definition at line 30 of file lsyscache.h.

Function Documentation

◆ 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:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
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:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
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 3169 of file lsyscache.c.

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

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

3170 {
3171  /* The values[] array was separately palloc'd by deconstruct_array */
3172  if (sslot->values)
3173  pfree(sslot->values);
3174  /* The numbers[] array points into numbers_arr, do not pfree it */
3175  /* Free the detoasted array objects, if any */
3176  if (sslot->values_arr)
3177  pfree(sslot->values_arr);
3178  if (sslot->numbers_arr)
3179  pfree(sslot->numbers_arr);
3180 }
void pfree(void *pointer)
Definition: mcxt.c:1057
void * values_arr
Definition: lsyscache.h:57
Datum * values
Definition: lsyscache.h:50
void * numbers_arr
Definition: lsyscache.h:58

◆ func_parallel()

char func_parallel ( Oid  funcid)

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

1712 {
1713  HeapTuple tp;
1714  char result;
1715 
1716  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1717  if (!HeapTupleIsValid(tp))
1718  elog(ERROR, "cache lookup failed for function %u", funcid);
1719 
1720  result = ((Form_pg_proc) GETSTRUCT(tp))->proparallel;
1721  ReleaseSysCache(tp);
1722  return result;
1723 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ func_strict()

bool func_strict ( Oid  funcid)

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

1674 {
1675  HeapTuple tp;
1676  bool result;
1677 
1678  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1679  if (!HeapTupleIsValid(tp))
1680  elog(ERROR, "cache lookup failed for function %u", funcid);
1681 
1682  result = ((Form_pg_proc) GETSTRUCT(tp))->proisstrict;
1683  ReleaseSysCache(tp);
1684  return result;
1685 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ func_volatile()

char func_volatile ( Oid  funcid)

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

1693 {
1694  HeapTuple tp;
1695  char result;
1696 
1697  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1698  if (!HeapTupleIsValid(tp))
1699  elog(ERROR, "cache lookup failed for function %u", funcid);
1700 
1701  result = ((Form_pg_proc) GETSTRUCT(tp))->provolatile;
1702  ReleaseSysCache(tp);
1703  return result;
1704 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_array_type()

Oid get_array_type ( Oid  typid)

Definition at line 2664 of file lsyscache.c.

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

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

2665 {
2666  HeapTuple tp;
2667  Oid result = InvalidOid;
2668 
2670  if (HeapTupleIsValid(tp))
2671  {
2672  result = ((Form_pg_type) GETSTRUCT(tp))->typarray;
2673  ReleaseSysCache(tp);
2674  }
2675  return result;
2676 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_attavgwidth()

int32 get_attavgwidth ( Oid  relid,
AttrNumber  attnum 
)

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

2981 {
2982  HeapTuple tp;
2983  int32 stawidth;
2984 
2986  {
2987  stawidth = (*get_attavgwidth_hook) (relid, attnum);
2988  if (stawidth > 0)
2989  return stawidth;
2990  }
2992  ObjectIdGetDatum(relid),
2994  BoolGetDatum(false));
2995  if (HeapTupleIsValid(tp))
2996  {
2997  stawidth = ((Form_pg_statistic) GETSTRUCT(tp))->stawidth;
2998  ReleaseSysCache(tp);
2999  if (stawidth > 0)
3000  return stawidth;
3001  }
3002  return 0;
3003 }
get_attavgwidth_hook_type get_attavgwidth_hook
Definition: lsyscache.c:51
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:134
signed int int32
Definition: c.h:363
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1138
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define BoolGetDatum(X)
Definition: postgres.h:402
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_attgenerated()

char get_attgenerated ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 886 of file lsyscache.c.

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

Referenced by ATExecAlterColumnType(), and check_nested_generated_walker().

887 {
888  HeapTuple tp;
889  Form_pg_attribute att_tup;
890  char result;
891 
892  tp = SearchSysCache2(ATTNUM,
893  ObjectIdGetDatum(relid),
895  if (!HeapTupleIsValid(tp))
896  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
897  attnum, relid);
898  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
899  result = att_tup->attgenerated;
900  ReleaseSysCache(tp);
901  return result;
902 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127
#define elog(elevel,...)
Definition: elog.h:214

◆ 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(), conversion_error_callback(), 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:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127
#define elog(elevel,...)
Definition: elog.h:214
#define NameStr(name)
Definition: c.h:623

◆ 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:655
NameData attname
Definition: pg_attribute.h:40
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1257
#define InvalidAttrNumber
Definition: attnum.h:23
int16 AttrNumber
Definition: attnum.h:21

◆ get_attoptions()

Datum get_attoptions ( Oid  relid,
int16  attnum 
)

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

969 {
970  HeapTuple tuple;
971  Datum attopts;
972  Datum result;
973  bool isnull;
974 
975  tuple = SearchSysCache2(ATTNUM,
976  ObjectIdGetDatum(relid),
978 
979  if (!HeapTupleIsValid(tuple))
980  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
981  attnum, relid);
982 
983  attopts = SysCacheGetAttr(ATTNAME, tuple, Anum_pg_attribute_attoptions,
984  &isnull);
985 
986  if (isnull)
987  result = (Datum) 0;
988  else
989  result = datumCopy(attopts, false, -1); /* text[] */
990 
991  ReleaseSysCache(tuple);
992 
993  return result;
994 }
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
Datum datumCopy(Datum value, bool typByVal, int typLen)
Definition: datum.c:131
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127
#define elog(elevel,...)
Definition: elog.h:214

◆ get_attstatsslot()

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

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

3054 {
3055  Form_pg_statistic stats = (Form_pg_statistic) GETSTRUCT(statstuple);
3056  int i;
3057  Datum val;
3058  bool isnull;
3059  ArrayType *statarray;
3060  Oid arrayelemtype;
3061  int narrayelem;
3062  HeapTuple typeTuple;
3063  Form_pg_type typeForm;
3064 
3065  /* initialize *sslot properly */
3066  memset(sslot, 0, sizeof(AttStatsSlot));
3067 
3068  for (i = 0; i < STATISTIC_NUM_SLOTS; i++)
3069  {
3070  if ((&stats->stakind1)[i] == reqkind &&
3071  (reqop == InvalidOid || (&stats->staop1)[i] == reqop))
3072  break;
3073  }
3074  if (i >= STATISTIC_NUM_SLOTS)
3075  return false; /* not there */
3076 
3077  sslot->staop = (&stats->staop1)[i];
3078  sslot->stacoll = (&stats->stacoll1)[i];
3079 
3080  if (flags & ATTSTATSSLOT_VALUES)
3081  {
3082  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3083  Anum_pg_statistic_stavalues1 + i,
3084  &isnull);
3085  if (isnull)
3086  elog(ERROR, "stavalues is null");
3087 
3088  /*
3089  * Detoast the array if needed, and in any case make a copy that's
3090  * under control of this AttStatsSlot.
3091  */
3092  statarray = DatumGetArrayTypePCopy(val);
3093 
3094  /*
3095  * Extract the actual array element type, and pass it back in case the
3096  * caller needs it.
3097  */
3098  sslot->valuetype = arrayelemtype = ARR_ELEMTYPE(statarray);
3099 
3100  /* Need info about element type */
3101  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(arrayelemtype));
3102  if (!HeapTupleIsValid(typeTuple))
3103  elog(ERROR, "cache lookup failed for type %u", arrayelemtype);
3104  typeForm = (Form_pg_type) GETSTRUCT(typeTuple);
3105 
3106  /* Deconstruct array into Datum elements; NULLs not expected */
3107  deconstruct_array(statarray,
3108  arrayelemtype,
3109  typeForm->typlen,
3110  typeForm->typbyval,
3111  typeForm->typalign,
3112  &sslot->values, NULL, &sslot->nvalues);
3113 
3114  /*
3115  * If the element type is pass-by-reference, we now have a bunch of
3116  * Datums that are pointers into the statarray, so we need to keep
3117  * that until free_attstatsslot. Otherwise, all the useful info is in
3118  * sslot->values[], so we can free the array object immediately.
3119  */
3120  if (!typeForm->typbyval)
3121  sslot->values_arr = statarray;
3122  else
3123  pfree(statarray);
3124 
3125  ReleaseSysCache(typeTuple);
3126  }
3127 
3128  if (flags & ATTSTATSSLOT_NUMBERS)
3129  {
3130  val = SysCacheGetAttr(STATRELATTINH, statstuple,
3131  Anum_pg_statistic_stanumbers1 + i,
3132  &isnull);
3133  if (isnull)
3134  elog(ERROR, "stanumbers is null");
3135 
3136  /*
3137  * Detoast the array if needed, and in any case make a copy that's
3138  * under control of this AttStatsSlot.
3139  */
3140  statarray = DatumGetArrayTypePCopy(val);
3141 
3142  /*
3143  * We expect the array to be a 1-D float4 array; verify that. We don't
3144  * need to use deconstruct_array() since the array data is just going
3145  * to look like a C array of float4 values.
3146  */
3147  narrayelem = ARR_DIMS(statarray)[0];
3148  if (ARR_NDIM(statarray) != 1 || narrayelem <= 0 ||
3149  ARR_HASNULL(statarray) ||
3150  ARR_ELEMTYPE(statarray) != FLOAT4OID)
3151  elog(ERROR, "stanumbers is not a 1-D float4 array");
3152 
3153  /* Give caller a pointer directly into the statarray */
3154  sslot->numbers = (float4 *) ARR_DATA_PTR(statarray);
3155  sslot->nnumbers = narrayelem;
3156 
3157  /* We'll free the statarray in free_attstatsslot */
3158  sslot->numbers_arr = statarray;
3159  }
3160 
3161  return true;
3162 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ATTSTATSSLOT_VALUES
Definition: lsyscache.h:39
int nnumbers
Definition: lsyscache.h:54
unsigned int Oid
Definition: postgres_ext.h:31
FormData_pg_statistic * Form_pg_statistic
Definition: pg_statistic.h:134
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ATTSTATSSLOT_NUMBERS
Definition: lsyscache.h:40
void * values_arr
Definition: lsyscache.h:57
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ARR_DIMS(a)
Definition: array.h:282
#define ARR_DATA_PTR(a)
Definition: array.h:310
float4 * numbers
Definition: lsyscache.h:53
#define ARR_HASNULL(a)
Definition: array.h:279
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
float float4
Definition: c.h:498
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
#define DatumGetArrayTypePCopy(X)
Definition: array.h:250
#define InvalidOid
Definition: postgres_ext.h:36
#define STATISTIC_NUM_SLOTS
Definition: pg_statistic.h:126
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
Datum * values
Definition: lsyscache.h:50
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define ARR_NDIM(a)
Definition: array.h:278
void deconstruct_array(ArrayType *array, Oid elmtype, int elmlen, bool elmbyval, char elmalign, Datum **elemsp, bool **nullsp, int *nelemsp)
Definition: arrayfuncs.c:3483
#define elog(elevel,...)
Definition: elog.h:214
int i
void * numbers_arr
Definition: lsyscache.h:58
Oid valuetype
Definition: lsyscache.h:49
#define ARR_ELEMTYPE(a)
Definition: array.h:280
long val
Definition: informix.c:664

◆ get_atttype()

Oid get_atttype ( Oid  relid,
AttrNumber  attnum 
)

Definition at line 911 of file lsyscache.c.

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

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

912 {
913  HeapTuple tp;
914 
915  tp = SearchSysCache2(ATTNUM,
916  ObjectIdGetDatum(relid),
918  if (HeapTupleIsValid(tp))
919  {
921  Oid result;
922 
923  result = att_tup->atttypid;
924  ReleaseSysCache(tp);
925  return result;
926  }
927  else
928  return InvalidOid;
929 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127

◆ get_atttypetypmodcoll()

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

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

943 {
944  HeapTuple tp;
945  Form_pg_attribute att_tup;
946 
947  tp = SearchSysCache2(ATTNUM,
948  ObjectIdGetDatum(relid),
950  if (!HeapTupleIsValid(tp))
951  elog(ERROR, "cache lookup failed for attribute %d of relation %u",
952  attnum, relid);
953  att_tup = (Form_pg_attribute) GETSTRUCT(tp);
954 
955  *typid = att_tup->atttypid;
956  *typmod = att_tup->atttypmod;
957  *collid = att_tup->attcollation;
958  ReleaseSysCache(tp);
959 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127
#define elog(elevel,...)
Definition: elog.h:214

◆ get_base_element_type()

Oid get_base_element_type ( Oid  typid)

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

2710 {
2711  /*
2712  * We loop to find the bottom base type in a stack of domains.
2713  */
2714  for (;;)
2715  {
2716  HeapTuple tup;
2717  Form_pg_type typTup;
2718 
2719  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2720  if (!HeapTupleIsValid(tup))
2721  break;
2722  typTup = (Form_pg_type) GETSTRUCT(tup);
2723  if (typTup->typtype != TYPTYPE_DOMAIN)
2724  {
2725  /* Not a domain, so stop descending */
2726  Oid result;
2727 
2728  /* This test must match get_element_type */
2729  if (typTup->typlen == -1)
2730  result = typTup->typelem;
2731  else
2732  result = InvalidOid;
2733  ReleaseSysCache(tup);
2734  return result;
2735  }
2736 
2737  typid = typTup->typbasetype;
2738  ReleaseSysCache(tup);
2739  }
2740 
2741  /* Like get_element_type, silently return InvalidOid for bogus input */
2742  return InvalidOid;
2743 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_cast_oid()

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

Definition at line 1005 of file lsyscache.c.

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

Referenced by get_object_address().

1006 {
1007  Oid oid;
1008 
1009  oid = GetSysCacheOid2(CASTSOURCETARGET, Anum_pg_cast_oid,
1010  ObjectIdGetDatum(sourcetypeid),
1011  ObjectIdGetDatum(targettypeid));
1012  if (!OidIsValid(oid) && !missing_ok)
1013  ereport(ERROR,
1014  (errcode(ERRCODE_UNDEFINED_OBJECT),
1015  errmsg("cast from type %s to type %s does not exist",
1016  format_type_be(sourcetypeid),
1017  format_type_be(targettypeid))));
1018  return oid;
1019 }
int errcode(int sqlerrcode)
Definition: elog.c:610
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:652
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
#define ereport(elevel,...)
Definition: elog.h:144
#define GetSysCacheOid2(cacheId, oidcol, key1, key2)
Definition: syscache.h:194
int errmsg(const char *fmt,...)
Definition: elog.c:821

◆ get_collation_isdeterministic()

bool get_collation_isdeterministic ( Oid  colloid)

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

1053 {
1054  HeapTuple tp;
1055  Form_pg_collation colltup;
1056  bool result;
1057 
1058  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1059  if (!HeapTupleIsValid(tp))
1060  elog(ERROR, "cache lookup failed for collation %u", colloid);
1061  colltup = (Form_pg_collation) GETSTRUCT(tp);
1062  result = colltup->collisdeterministic;
1063  ReleaseSysCache(tp);
1064  return result;
1065 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
#define elog(elevel,...)
Definition: elog.h:214

◆ get_collation_name()

char* get_collation_name ( Oid  colloid)

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

1034 {
1035  HeapTuple tp;
1036 
1037  tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(colloid));
1038  if (HeapTupleIsValid(tp))
1039  {
1041  char *result;
1042 
1043  result = pstrdup(NameStr(colltup->collname));
1044  ReleaseSysCache(tp);
1045  return result;
1046  }
1047  else
1048  return NULL;
1049 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_collation * Form_pg_collation
Definition: pg_collation.h:51
#define NameStr(name)
Definition: c.h:623

◆ get_commutator()

Oid get_commutator ( Oid  opno)

Definition at line 1421 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(), networkjoinsel(), operator_predicate_proof(), rangesel(), scalarineqsel_wrapper(), and targetIsInSortList().

1422 {
1423  HeapTuple tp;
1424 
1426  if (HeapTupleIsValid(tp))
1427  {
1429  Oid result;
1430 
1431  result = optup->oprcom;
1432  ReleaseSysCache(tp);
1433  return result;
1434  }
1435  else
1436  return InvalidOid;
1437 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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:655
#define OidIsValid(objectId)
Definition: c.h:652
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#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:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#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_name()

char* get_constraint_name ( Oid  conoid)

Definition at line 1079 of file lsyscache.c.

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

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

1080 {
1081  HeapTuple tp;
1082 
1084  if (HeapTupleIsValid(tp))
1085  {
1087  char *result;
1088 
1089  result = pstrdup(NameStr(contup->conname));
1090  ReleaseSysCache(tp);
1091  return result;
1092  }
1093  else
1094  return NULL;
1095 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_constraint * Form_pg_constraint
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:623

◆ get_element_type()

Oid get_element_type ( Oid  typid)

Definition at line 2636 of file lsyscache.c.

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

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

2637 {
2638  HeapTuple tp;
2639 
2641  if (HeapTupleIsValid(tp))
2642  {
2643  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2644  Oid result;
2645 
2646  if (typtup->typlen == -1)
2647  result = typtup->typelem;
2648  else
2649  result = InvalidOid;
2650  ReleaseSysCache(tp);
2651  return result;
2652  }
2653  else
2654  return InvalidOid;
2655 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ 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:362
#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 1749 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().

1750 {
1751  HeapTuple tp;
1752  bool result;
1753 
1754  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1755  if (!HeapTupleIsValid(tp))
1756  elog(ERROR, "cache lookup failed for function %u", funcid);
1757 
1758  result = ((Form_pg_proc) GETSTRUCT(tp))->proleakproof;
1759  ReleaseSysCache(tp);
1760  return result;
1761 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_func_name()

char* get_func_name ( Oid  funcid)

Definition at line 1520 of file lsyscache.c.

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

Referenced by AlterOpFamilyAdd(), DefineOpClass(), ExecBuildGroupingEqual(), 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().

1521 {
1522  HeapTuple tp;
1523 
1524  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1525  if (HeapTupleIsValid(tp))
1526  {
1527  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1528  char *result;
1529 
1530  result = pstrdup(NameStr(functup->proname));
1531  ReleaseSysCache(tp);
1532  return result;
1533  }
1534  else
1535  return NULL;
1536 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:623

◆ get_func_namespace()

Oid get_func_namespace ( Oid  funcid)

Definition at line 1544 of file lsyscache.c.

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

Referenced by sepgsql_proc_drop(), and unaccent_dict().

1545 {
1546  HeapTuple tp;
1547 
1548  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1549  if (HeapTupleIsValid(tp))
1550  {
1551  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1552  Oid result;
1553 
1554  result = functup->pronamespace;
1555  ReleaseSysCache(tp);
1556  return result;
1557  }
1558  else
1559  return InvalidOid;
1560 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#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 1586 of file lsyscache.c.

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

1587 {
1588  HeapTuple tp;
1589  int result;
1590 
1591  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1592  if (!HeapTupleIsValid(tp))
1593  elog(ERROR, "cache lookup failed for function %u", funcid);
1594 
1595  result = ((Form_pg_proc) GETSTRUCT(tp))->pronargs;
1596  ReleaseSysCache(tp);
1597  return result;
1598 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int16 pronargs
Definition: pg_proc.h:81
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_func_prokind()

char get_func_prokind ( Oid  funcid)

Definition at line 1730 of file lsyscache.c.

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

Referenced by LookupFuncWithArgs(), and RemoveObjects().

1731 {
1732  HeapTuple tp;
1733  char result;
1734 
1735  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1736  if (!HeapTupleIsValid(tp))
1737  elog(ERROR, "cache lookup failed for function %u", funcid);
1738 
1739  result = ((Form_pg_proc) GETSTRUCT(tp))->prokind;
1740  ReleaseSysCache(tp);
1741  return result;
1742 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_func_retset()

bool get_func_retset ( Oid  funcid)

Definition at line 1654 of file lsyscache.c.

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

Referenced by make_op(), and make_scalar_array_op().

1655 {
1656  HeapTuple tp;
1657  bool result;
1658 
1659  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1660  if (!HeapTupleIsValid(tp))
1661  elog(ERROR, "cache lookup failed for function %u", funcid);
1662 
1663  result = ((Form_pg_proc) GETSTRUCT(tp))->proretset;
1664  ReleaseSysCache(tp);
1665  return result;
1666 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_func_rettype()

Oid get_func_rettype ( Oid  funcid)

Definition at line 1567 of file lsyscache.c.

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

Referenced by CreateConversionCommand(), CreateEventTrigger(), CreateProceduralLanguage(), CreateTrigger(), DefineOperator(), findRangeCanonicalFunction(), findRangeSubtypeDiffFunction(), findTypeAnalyzeFunction(), findTypeInputFunction(), findTypeOutputFunction(), findTypeReceiveFunction(), findTypeSendFunction(), 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().

1568 {
1569  HeapTuple tp;
1570  Oid result;
1571 
1572  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1573  if (!HeapTupleIsValid(tp))
1574  elog(ERROR, "cache lookup failed for function %u", funcid);
1575 
1576  result = ((Form_pg_proc) GETSTRUCT(tp))->prorettype;
1577  ReleaseSysCache(tp);
1578  return result;
1579 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_func_signature()

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

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

1609 {
1610  HeapTuple tp;
1611  Form_pg_proc procstruct;
1612  Oid result;
1613 
1614  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1615  if (!HeapTupleIsValid(tp))
1616  elog(ERROR, "cache lookup failed for function %u", funcid);
1617 
1618  procstruct = (Form_pg_proc) GETSTRUCT(tp);
1619 
1620  result = procstruct->prorettype;
1621  *nargs = (int) procstruct->pronargs;
1622  Assert(*nargs == procstruct->proargtypes.dim1);
1623  *argtypes = (Oid *) palloc(*nargs * sizeof(Oid));
1624  memcpy(*argtypes, procstruct->proargtypes.values, *nargs * sizeof(Oid));
1625 
1626  ReleaseSysCache(tp);
1627  return result;
1628 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:746
void * palloc(Size size)
Definition: mcxt.c:950
#define elog(elevel,...)
Definition: elog.h:214

◆ get_func_support()

RegProcedure get_func_support ( Oid  funcid)

Definition at line 1770 of file lsyscache.c.

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

Referenced by function_selectivity(), and get_index_clause_from_support().

1771 {
1772  HeapTuple tp;
1773 
1774  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1775  if (HeapTupleIsValid(tp))
1776  {
1777  Form_pg_proc functup = (Form_pg_proc) GETSTRUCT(tp);
1778  RegProcedure result;
1779 
1780  result = functup->prosupport;
1781  ReleaseSysCache(tp);
1782  return result;
1783  }
1784  else
1785  return (RegProcedure) InvalidOid;
1786 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:519
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#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 1635 of file lsyscache.c.

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

Referenced by assign_hypothetical_collations(), and assign_ordered_set_collations().

1636 {
1637  HeapTuple tp;
1638  Oid result;
1639 
1640  tp = SearchSysCache1(PROCOID, ObjectIdGetDatum(funcid));
1641  if (!HeapTupleIsValid(tp))
1642  elog(ERROR, "cache lookup failed for function %u", funcid);
1643 
1644  result = ((Form_pg_proc) GETSTRUCT(tp))->provariadic;
1645  ReleaseSysCache(tp);
1646  return result;
1647 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
FormData_pg_proc * Form_pg_proc
Definition: pg_proc.h:133
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_index_column_opclass()

Oid get_index_column_opclass ( Oid  index_oid,
int  attno 
)

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

3288 {
3289  HeapTuple tuple;
3291  Datum datum;
3292  bool isnull;
3293  oidvector *indclass;
3294  Oid opclass;
3295 
3296  /* First we need to know the column's opclass. */
3297 
3298  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3299  if (!HeapTupleIsValid(tuple))
3300  return InvalidOid;
3301 
3302  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3303 
3304  /* caller is supposed to guarantee this */
3305  Assert(attno > 0 && attno <= rd_index->indnatts);
3306 
3307  /* Non-key attributes don't have an opclass */
3308  if (attno > rd_index->indnkeyatts)
3309  {
3310  ReleaseSysCache(tuple);
3311  return InvalidOid;
3312  }
3313 
3314  datum = SysCacheGetAttr(INDEXRELID, tuple,
3315  Anum_pg_index_indclass, &isnull);
3316  Assert(!isnull);
3317 
3318  indclass = ((oidvector *) DatumGetPointer(datum));
3319 
3320  Assert(attno <= indclass->dim1);
3321  opclass = indclass->values[attno - 1];
3322 
3323  ReleaseSysCache(tuple);
3324 
3325  return opclass;
3326 }
Definition: c.h:602
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Oid values[FLEXIBLE_ARRAY_MEMBER]
Definition: c.h:610
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:746
#define DatumGetPointer(X)
Definition: postgres.h:549
#define PG_USED_FOR_ASSERTS_ONLY
Definition: c.h:122

◆ get_index_isclustered()

bool get_index_isclustered ( Oid  index_oid)

Definition at line 3380 of file lsyscache.c.

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

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

3381 {
3382  bool isclustered;
3383  HeapTuple tuple;
3384  Form_pg_index rd_index;
3385 
3386  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3387  if (!HeapTupleIsValid(tuple))
3388  elog(ERROR, "cache lookup failed for index %u", index_oid);
3389 
3390  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3391  isclustered = rd_index->indisclustered;
3392  ReleaseSysCache(tuple);
3393 
3394  return isclustered;
3395 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_index_isreplident()

bool get_index_isreplident ( Oid  index_oid)

Definition at line 3334 of file lsyscache.c.

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

Referenced by RememberReplicaIdentityForRebuilding().

3335 {
3336  HeapTuple tuple;
3337  Form_pg_index rd_index;
3338  bool result;
3339 
3340  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3341  if (!HeapTupleIsValid(tuple))
3342  return false;
3343 
3344  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3345  result = rd_index->indisreplident;
3346  ReleaseSysCache(tuple);
3347 
3348  return result;
3349 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_index_isvalid()

bool get_index_isvalid ( Oid  index_oid)

Definition at line 3357 of file lsyscache.c.

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

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

3358 {
3359  bool isvalid;
3360  HeapTuple tuple;
3361  Form_pg_index rd_index;
3362 
3363  tuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(index_oid));
3364  if (!HeapTupleIsValid(tuple))
3365  elog(ERROR, "cache lookup failed for index %u", index_oid);
3366 
3367  rd_index = (Form_pg_index) GETSTRUCT(tuple);
3368  isvalid = rd_index->indisvalid;
3369  ReleaseSysCache(tuple);
3370 
3371  return isvalid;
3372 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
FormData_pg_index * Form_pg_index
Definition: pg_index.h:68
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214

◆ get_language_name()

char* get_language_name ( Oid  langoid,
bool  missing_ok 
)

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

1101 {
1102  HeapTuple tp;
1103 
1104  tp = SearchSysCache1(LANGOID, ObjectIdGetDatum(langoid));
1105  if (HeapTupleIsValid(tp))
1106  {
1108  char *result;
1109 
1110  result = pstrdup(NameStr(lantup->lanname));
1111  ReleaseSysCache(tp);
1112  return result;
1113  }
1114 
1115  if (!missing_ok)
1116  elog(ERROR, "cache lookup failed for language %u",
1117  langoid);
1118  return NULL;
1119 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_language * Form_pg_language
Definition: pg_language.h:65
#define elog(elevel,...)
Definition: elog.h:214
#define NameStr(name)
Definition: c.h:623

◆ 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:655
List * lappend_oid(List *list, Oid datum)
Definition: list.c:357
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
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_namespace_name()

char* get_namespace_name ( Oid  nspid)

Definition at line 3191 of file lsyscache.c.

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

Referenced by acquire_inherited_sample_rows(), add_cast_to(), 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_byrelname(), currtid_byreloid(), 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(), ExecBRUpdateTriggers(), ExecRefreshMatView(), execute_extension_script(), ExplainTargetRel(), fetch_statentries_for_relation(), format_operator_extended(), format_procedure_extended(), generate_collation_name(), generate_function_name(), generate_operator_clause(), generate_operator_name(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedIndexStmt(), generateSerialExtraStmts(), get_collation(), get_namespace_name_or_temp(), get_opclass(), get_opclass_name(), get_other_operator(), getObjectDescription(), getOpFamilyDescription(), getRelationDescription(), GetTempNamespaceBackendId(), HandleFunctionRequest(), heap_create(), 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(), parallel_vacuum_main(), perform_work_item(), pg_decode_change(), pg_decode_truncate(), pg_event_trigger_ddl_commands(), pg_get_functiondef(), pg_get_statisticsobj_worker(), pg_identify_object(), pg_newlocale_from_collation(), plpgsql_fulfill_promise(), postgresExplainForeignScan(), 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().

3192 {
3193  HeapTuple tp;
3194 
3196  if (HeapTupleIsValid(tp))
3197  {
3199  char *result;
3200 
3201  result = pstrdup(NameStr(nsptup->nspname));
3202  ReleaseSysCache(tp);
3203  return result;
3204  }
3205  else
3206  return NULL;
3207 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
FormData_pg_namespace * Form_pg_namespace
Definition: pg_namespace.h:52
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define NameStr(name)
Definition: c.h:623

◆ get_namespace_name_or_temp()

char* get_namespace_name_or_temp ( Oid  nspid)

Definition at line 3215 of file lsyscache.c.

References get_namespace_name(), and isTempNamespace().

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

3216 {
3217  if (isTempNamespace(nspid))
3218  return "pg_temp";
3219  else
3220  return get_namespace_name(nspid);
3221 }
char * get_namespace_name(Oid nspid)
Definition: lsyscache.c:3191
bool isTempNamespace(Oid namespaceId)
Definition: namespace.c:3156

◆ get_negator()

Oid get_negator ( Oid  opno)

Definition at line 1445 of file lsyscache.c.

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

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

1446 {
1447  HeapTuple tp;
1448 
1450  if (HeapTupleIsValid(tp))
1451  {
1453  Oid result;
1454 
1455  result = optup->oprnegate;
1456  ReleaseSysCache(tp);
1457  return result;
1458  }
1459  else
1460  return InvalidOid;
1461 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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:655
uint16 StrategyNumber
Definition: stratnum.h:22
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:652
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
List * lappend(List *list, void *datum)
Definition: list.c:321
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#define Assert(condition)
Definition: c.h:746
void * palloc(Size size)
Definition: mcxt.c:950
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:1445
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 ExecHashTableCreate(), 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:655
#define OidIsValid(objectId)
Definition: c.h:652
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define HTEqualStrategyNumber
Definition: stratnum.h:41
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define HASHSTANDARD_PROC
Definition: hash.h:353
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#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:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1138
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88
#define elog(elevel,...)
Definition: elog.h:214

◆ 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:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1138
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
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:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1138
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define CharGetDatum(X)
Definition: postgres.h:416
FormData_pg_amop * Form_pg_amop
Definition: pg_amop.h:88

◆ get_op_rettype()

Oid get_op_rettype ( Oid  opno)

Definition at line 1250 of file lsyscache.c.

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

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

1251 {
1252  HeapTuple tp;
1253 
1255  if (HeapTupleIsValid(tp))
1256  {
1258  Oid result;
1259 
1260  result = optup->oprresult;
1261  ReleaseSysCache(tp);
1262  return result;
1263  }
1264  else
1265  return InvalidOid;
1266 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1129 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().

1130 {
1131  HeapTuple tp;
1132  Form_pg_opclass cla_tup;
1133  Oid result;
1134 
1135  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1136  if (!HeapTupleIsValid(tp))
1137  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1138  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1139 
1140  result = cla_tup->opcfamily;
1141  ReleaseSysCache(tp);
1142  return result;
1143 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214
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 1151 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().

1152 {
1153  HeapTuple tp;
1154  Form_pg_opclass cla_tup;
1155  Oid result;
1156 
1157  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1158  if (!HeapTupleIsValid(tp))
1159  elog(ERROR, "cache lookup failed for opclass %u", opclass);
1160  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1161 
1162  result = cla_tup->opcintype;
1163  ReleaseSysCache(tp);
1164  return result;
1165 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define elog(elevel,...)
Definition: elog.h:214
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 1174 of file lsyscache.c.

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

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

1175 {
1176  HeapTuple tp;
1177  Form_pg_opclass cla_tup;
1178 
1179  tp = SearchSysCache1(CLAOID, ObjectIdGetDatum(opclass));
1180  if (!HeapTupleIsValid(tp))
1181  return false;
1182 
1183  cla_tup = (Form_pg_opclass) GETSTRUCT(tp);
1184 
1185  *opfamily = cla_tup->opcfamily;
1186  *opcintype = cla_tup->opcintype;
1187 
1188  ReleaseSysCache(tp);
1189 
1190  return true;
1191 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1202 of file lsyscache.c.

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

Referenced by _bt_compare_scankey_args(), _bt_find_extreme_element(), AlterOpFamilyAdd(), build_pertrans_for_aggref(), build_replindex_scan_key(), BuildSpeculativeIndexInfo(), check_functions_in_node(), ComputeIndexAttrs(), contain_leaked_vars_walker(), cost_qual_eval_walker(), DefineOpClass(), eqjoinsel(), 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(), 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().

1203 {
1204  HeapTuple tp;
1205 
1207  if (HeapTupleIsValid(tp))
1208  {
1210  RegProcedure result;
1211 
1212  result = optup->oprcode;
1213  ReleaseSysCache(tp);
1214  return result;
1215  }
1216  else
1217  return (RegProcedure) InvalidOid;
1218 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:519
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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:655
#define Int16GetDatum(X)
Definition: postgres.h:451
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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:655
FormData_pg_amproc * Form_pg_amproc
Definition: pg_amproc.h:68
regproc RegProcedure
Definition: c.h:519
#define Int16GetDatum(X)
Definition: postgres.h:451
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1149
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ get_opname()

char* get_opname ( Oid  opno)

Definition at line 1227 of file lsyscache.c.

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

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

1228 {
1229  HeapTuple tp;
1230 
1232  if (HeapTupleIsValid(tp))
1233  {
1235  char *result;
1236 
1237  result = pstrdup(NameStr(optup->oprname));
1238  ReleaseSysCache(tp);
1239  return result;
1240  }
1241  else
1242  return NULL;
1243 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_operator * Form_pg_operator
Definition: pg_operator.h:83
#define NameStr(name)
Definition: c.h:623

◆ get_oprjoin()

RegProcedure get_oprjoin ( Oid  opno)

Definition at line 1493 of file lsyscache.c.

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

Referenced by join_selectivity(), and scalararraysel().

1494 {
1495  HeapTuple tp;
1496 
1498  if (HeapTupleIsValid(tp))
1499  {
1501  RegProcedure result;
1502 
1503  result = optup->oprjoin;
1504  ReleaseSysCache(tp);
1505  return result;
1506  }
1507  else
1508  return (RegProcedure) InvalidOid;
1509 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:519
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1469 of file lsyscache.c.

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

Referenced by clauselist_selectivity_simple(), dependency_is_compatible_clause(), restriction_selectivity(), scalararraysel(), and statext_is_compatible_clause_internal().

1470 {
1471  HeapTuple tp;
1472 
1474  if (HeapTupleIsValid(tp))
1475  {
1477  RegProcedure result;
1478 
1479  result = optup->oprrest;
1480  ReleaseSysCache(tp);
1481  return result;
1482  }
1483  else
1484  return (RegProcedure) InvalidOid;
1485 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
regproc RegProcedure
Definition: c.h:519
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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:655
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:652
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype, int16 strategy)
Definition: lsyscache.c:164
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#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:655
CatCTup * members[FLEXIBLE_ARRAY_MEMBER]
Definition: catcache.h:178
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define SearchSysCacheList1(cacheId, key1)
Definition: syscache.h:210
#define ReleaseSysCacheList(x)
Definition: syscache.h:217
#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 2688 of file lsyscache.c.

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

Referenced by build_subplan(), and exprType().

2689 {
2690  Oid array_type = get_array_type(typid);
2691 
2692  if (OidIsValid(array_type))
2693  return array_type;
2694  if (OidIsValid(get_element_type(typid)))
2695  return typid;
2696  return InvalidOid;
2697 }
Oid get_element_type(Oid typid)
Definition: lsyscache.c:2636
Oid get_array_type(Oid typid)
Definition: lsyscache.c:2664
unsigned int Oid
Definition: postgres_ext.h:31
#define OidIsValid(objectId)
Definition: c.h:652
#define InvalidOid
Definition: postgres_ext.h:36

◆ get_range_collation()

Oid get_range_collation ( Oid  rangeOid)

Definition at line 3258 of file lsyscache.c.

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

Referenced by CheckAttributeType().

3259 {
3260  HeapTuple tp;
3261 
3262  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3263  if (HeapTupleIsValid(tp))
3264  {
3265  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3266  Oid result;
3267 
3268  result = rngtup->rngcollation;
3269  ReleaseSysCache(tp);
3270  return result;
3271  }
3272  else
3273  return InvalidOid;
3274 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:55
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 3232 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().

3233 {
3234  HeapTuple tp;
3235 
3236  tp = SearchSysCache1(RANGETYPE, ObjectIdGetDatum(rangeOid));
3237  if (HeapTupleIsValid(tp))
3238  {
3239  Form_pg_range rngtup = (Form_pg_range) GETSTRUCT(tp);
3240  Oid result;
3241 
3242  result = rngtup->rngsubtype;
3243  ReleaseSysCache(tp);
3244  return result;
3245  }
3246  else
3247  return InvalidOid;
3248 }
FormData_pg_range * Form_pg_range
Definition: pg_range.h:55
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1840 of file lsyscache.c.

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

Referenced by adjust_appendrel_attrs_mutator(), adjust_inherited_tlist(), AlterSubscription_refresh(), AlterTableNamespace(), ApplyWorkerMain(), ATExecChangeOwner(), check_enable_rls(), check_new_partition_bound(), conversion_error_callback(), convert_column_name(), CreateTrigger(), 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(), 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(), RenameConstraintById(), satisfies_hash_partition(), set_rtable_names(), show_modifytable_info(), table_to_xml_internal(), and transformAlterTableStmt().

1841 {
1842  HeapTuple tp;
1843 
1844  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1845  if (HeapTupleIsValid(tp))
1846  {
1847  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1848  char *result;
1849 
1850  result = pstrdup(NameStr(reltup->relname));
1851  ReleaseSysCache(tp);
1852  return result;
1853  }
1854  else
1855  return NULL;
1856 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char * pstrdup(const char *in)
Definition: mcxt.c:1187
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
#define NameStr(name)
Definition: c.h:623

◆ get_rel_namespace()

Oid get_rel_namespace ( Oid  relid)

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

1865 {
1866  HeapTuple tp;
1867 
1868  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1869  if (HeapTupleIsValid(tp))
1870  {
1871  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1872  Oid result;
1873 
1874  result = reltup->relnamespace;
1875  ReleaseSysCache(tp);
1876  return result;
1877  }
1878  else
1879  return InvalidOid;
1880 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1990 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().

1991 {
1992  HeapTuple tp;
1993  Form_pg_class reltup;
1994  char result;
1995 
1996  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1997  if (!HeapTupleIsValid(tp))
1998  elog(ERROR, "cache lookup failed for relation %u", relid);
1999  reltup = (Form_pg_class) GETSTRUCT(tp);
2000  result = reltup->relpersistence;
2001  ReleaseSysCache(tp);
2002 
2003  return result;
2004 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
#define elog(elevel,...)
Definition: elog.h:214

◆ get_rel_relispartition()

bool get_rel_relispartition ( Oid  relid)

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

1940 {
1941  HeapTuple tp;
1942 
1943  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1944  if (HeapTupleIsValid(tp))
1945  {
1946  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1947  bool result;
1948 
1949  result = reltup->relispartition;
1950  ReleaseSysCache(tp);
1951  return result;
1952  }
1953  else
1954  return false;
1955 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1915 of file lsyscache.c.

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

Referenced by AlterSubscription_refresh(), AlterTableMoveAll(), AlterTypeNamespaceInternal(), AlterTypeOwner(), ATExecAlterColumnType(), ATExecChangeOwner(), check_rel_can_be_partition(), check_relation_privileges(), CreateSubscription(), CreateTrigger(), doDeletion(), EnableDisableRule(), exec_object_restorecon(), ExecCheckRTPerms(), get_constraint_index(), 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().

1916 {
1917  HeapTuple tp;
1918 
1919  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1920  if (HeapTupleIsValid(tp))
1921  {
1922  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1923  char result;
1924 
1925  result = reltup->relkind;
1926  ReleaseSysCache(tp);
1927  return result;
1928  }
1929  else
1930  return '\0';
1931 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1966 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().

1967 {
1968  HeapTuple tp;
1969 
1970  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1971  if (HeapTupleIsValid(tp))
1972  {
1973  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1974  Oid result;
1975 
1976  result = reltup->reltablespace;
1977  ReleaseSysCache(tp);
1978  return result;
1979  }
1980  else
1981  return InvalidOid;
1982 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 1891 of file lsyscache.c.

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

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

1892 {
1893  HeapTuple tp;
1894 
1895  tp = SearchSysCache1(RELOID, ObjectIdGetDatum(relid));
1896  if (HeapTupleIsValid(tp))
1897  {
1898  Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp);
1899  Oid result;
1900 
1901  result = reltup->reltype;
1902  ReleaseSysCache(tp);
1903  return result;
1904  }
1905  else
1906  return InvalidOid;
1907 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#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 2010 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().

2011 {
2012  HeapTuple tup;
2013 
2014  if (!list_member_oid(trftypes, typid))
2015  return InvalidOid;
2016 
2017  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2018  if (HeapTupleIsValid(tup))
2019  {
2020  Oid funcid;
2021 
2022  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trffromsql;
2023  ReleaseSysCache(tup);
2024  return funcid;
2025  }
2026  else
2027  return InvalidOid;
2028 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
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:1164
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127

◆ get_transform_tosql()

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

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

2032 {
2033  HeapTuple tup;
2034 
2035  if (!list_member_oid(trftypes, typid))
2036  return InvalidOid;
2037 
2038  tup = SearchSysCache2(TRFTYPELANG, typid, langid);
2039  if (HeapTupleIsValid(tup))
2040  {
2041  Oid funcid;
2042 
2043  funcid = ((Form_pg_transform) GETSTRUCT(tup))->trftosql;
2044  ReleaseSysCache(tup);
2045  return funcid;
2046  }
2047  else
2048  return InvalidOid;
2049 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
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:1164
#define InvalidOid
Definition: postgres_ext.h:36
bool list_member_oid(const List *list, Oid datum)
Definition: list.c:674
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1127

◆ get_typ_typrelid()

Oid get_typ_typrelid ( Oid  typid)

Definition at line 2609 of file lsyscache.c.

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

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

2610 {
2611  HeapTuple tp;
2612 
2614  if (HeapTupleIsValid(tp))
2615  {
2616  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2617  Oid result;
2618 
2619  result = typtup->typrelid;
2620  ReleaseSysCache(tp);
2621  return result;
2622  }
2623  else
2624  return InvalidOid;
2625 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typavgwidth()

int32 get_typavgwidth ( Oid  typid,
int32  typmod 
)

Definition at line 2466 of file lsyscache.c.

References get_typlen(), and type_maximum_size().

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

2467 {
2468  int typlen = get_typlen(typid);
2469  int32 maxwidth;
2470 
2471  /*
2472  * Easy if it's a fixed-width type
2473  */
2474  if (typlen > 0)
2475  return typlen;
2476 
2477  /*
2478  * type_maximum_size knows the encoding of typmod for some datatypes;
2479  * don't duplicate that knowledge here.
2480  */
2481  maxwidth = type_maximum_size(typid, typmod);
2482  if (maxwidth > 0)
2483  {
2484  /*
2485  * For BPCHAR, the max width is also the only width. Otherwise we
2486  * need to guess about the typical data width given the max. A sliding
2487  * scale for percentage of max width seems reasonable.
2488  */
2489  if (typid == BPCHAROID)
2490  return maxwidth;
2491  if (maxwidth <= 32)
2492  return maxwidth; /* assume full width */
2493  if (maxwidth < 1000)
2494  return 32 + (maxwidth - 32) / 2; /* assume 50% */
2495 
2496  /*
2497  * Beyond 1000, assume we're looking at something like
2498  * "varchar(10000)" where the limit isn't actually reached often, and
2499  * use a fixed estimate.
2500  */
2501  return 32 + (1000 - 32) / 2;
2502  }
2503 
2504  /*
2505  * Oops, we have no idea ... wild guess time.
2506  */
2507  return 32;
2508 }
signed int int32
Definition: c.h:363
int32 type_maximum_size(Oid type_oid, int32 typemod)
Definition: format_type.c:408
int16 get_typlen(Oid typid)
Definition: lsyscache.c:2085

◆ get_typbyval()

bool get_typbyval ( Oid  typid)

Definition at line 2110 of file lsyscache.c.

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

Referenced by get_agg_clause_costs_walker().

2111 {
2112  HeapTuple tp;
2113 
2115  if (HeapTupleIsValid(tp))
2116  {
2117  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2118  bool result;
2119 
2120  result = typtup->typbyval;
2121  ReleaseSysCache(tp);
2122  return result;
2123  }
2124  else
2125  return false;
2126 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typcollation()

Oid get_typcollation ( Oid  typid)

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

2934 {
2935  HeapTuple tp;
2936 
2938  if (HeapTupleIsValid(tp))
2939  {
2940  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2941  Oid result;
2942 
2943  result = typtup->typcollation;
2944  ReleaseSysCache(tp);
2945  return result;
2946  }
2947  else
2948  return InvalidOid;
2949 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typdefault()

Node* get_typdefault ( Oid  typid)

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

2337 {
2338  HeapTuple typeTuple;
2340  Datum datum;
2341  bool isNull;
2342  Node *expr;
2343 
2344  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2345  if (!HeapTupleIsValid(typeTuple))
2346  elog(ERROR, "cache lookup failed for type %u", typid);
2347  type = (Form_pg_type) GETSTRUCT(typeTuple);
2348 
2349  /*
2350  * typdefault and typdefaultbin are potentially null, so don't try to
2351  * access 'em as struct fields. Must do it the hard way with
2352  * SysCacheGetAttr.
2353  */
2354  datum = SysCacheGetAttr(TYPEOID,
2355  typeTuple,
2356  Anum_pg_type_typdefaultbin,
2357  &isNull);
2358 
2359  if (!isNull)
2360  {
2361  /* We have an expression default */
2362  expr = stringToNode(TextDatumGetCString(datum));
2363  }
2364  else
2365  {
2366  /* Perhaps we have a plain literal default */
2367  datum = SysCacheGetAttr(TYPEOID,
2368  typeTuple,
2369  Anum_pg_type_typdefault,
2370  &isNull);
2371 
2372  if (!isNull)
2373  {
2374  char *strDefaultVal;
2375 
2376  /* Convert text datum to C string */
2377  strDefaultVal = TextDatumGetCString(datum);
2378  /* Convert C string to a value of the given type */
2379  datum = OidInputFunctionCall(type->typinput, strDefaultVal,
2380  getTypeIOParam(typeTuple), -1);
2381  /* Build a Const node containing the value */
2382  expr = (Node *) makeConst(typid,
2383  -1,
2384  type->typcollation,
2385  type->typlen,
2386  datum,
2387  false,
2388  type->typbyval);
2389  pfree(strDefaultVal);
2390  }
2391  else
2392  {
2393  /* No default */
2394  expr = NULL;
2395  }
2396  }
2397 
2398  ReleaseSysCache(typeTuple);
2399 
2400  return expr;
2401 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
Definition: nodes.h:528
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:1057
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
#define TextDatumGetCString(d)
Definition: builtins.h:87
uintptr_t Datum
Definition: postgres.h:367
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1377
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define elog(elevel,...)
Definition: elog.h:214
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2191
Datum OidInputFunctionCall(Oid functionId, char *str, Oid typioparam, int32 typmod)
Definition: fmgr.c:1648

◆ get_type_category_preferred()

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

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

2589 {
2590  HeapTuple tp;
2591  Form_pg_type typtup;
2592 
2594  if (!HeapTupleIsValid(tp))
2595  elog(ERROR, "cache lookup failed for type %u", typid);
2596  typtup = (Form_pg_type) GETSTRUCT(tp);
2597  *typcategory = typtup->typcategory;
2598  *typispreferred = typtup->typispreferred;
2599  ReleaseSysCache(tp);
2600 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define elog(elevel,...)
Definition: elog.h:214

◆ 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 2213 of file lsyscache.c.

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

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

2221 {
2222  HeapTuple typeTuple;
2223  Form_pg_type typeStruct;
2224 
2225  /*
2226  * In bootstrap mode, pass it off to bootstrap.c. This hack allows us to
2227  * use array_in and array_out during bootstrap.
2228  */
2230  {
2231  Oid typinput;
2232  Oid typoutput;
2233 
2234  boot_get_type_io_data(typid,
2235  typlen,
2236  typbyval,
2237  typalign,
2238  typdelim,
2239  typioparam,
2240  &typinput,
2241  &typoutput);
2242  switch (which_func)
2243  {
2244  case IOFunc_input:
2245  *func = typinput;
2246  break;
2247  case IOFunc_output:
2248  *func = typoutput;
2249  break;
2250  default:
2251  elog(ERROR, "binary I/O not supported during bootstrap");
2252  break;
2253  }
2254  return;
2255  }
2256 
2257  typeTuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2258  if (!HeapTupleIsValid(typeTuple))
2259  elog(ERROR, "cache lookup failed for type %u", typid);
2260  typeStruct = (Form_pg_type) GETSTRUCT(typeTuple);
2261 
2262  *typlen = typeStruct->typlen;
2263  *typbyval = typeStruct->typbyval;
2264  *typalign = typeStruct->typalign;
2265  *typdelim = typeStruct->typdelim;
2266  *typioparam = getTypeIOParam(typeTuple);
2267  switch (which_func)
2268  {
2269  case IOFunc_input:
2270  *func = typeStruct->typinput;
2271  break;
2272  case IOFunc_output:
2273  *func = typeStruct->typoutput;
2274  break;
2275  case IOFunc_receive:
2276  *func = typeStruct->typreceive;
2277  break;
2278  case IOFunc_send:
2279  *func = typeStruct->typsend;
2280  break;
2281  }
2282  ReleaseSysCache(typeTuple);
2283 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
char typalign
Definition: pg_type.h:170
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:393
#define elog(elevel,...)
Definition: elog.h:214
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2191
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:971

◆ get_typisdefined()

bool get_typisdefined ( Oid  typid)

Definition at line 2061 of file lsyscache.c.

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

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

2062 {
2063  HeapTuple tp;
2064 
2066  if (HeapTupleIsValid(tp))
2067  {
2068  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2069  bool result;
2070 
2071  result = typtup->typisdefined;
2072  ReleaseSysCache(tp);
2073  return result;
2074  }
2075  else
2076  return false;
2077 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typlen()

int16 get_typlen ( Oid  typid)

Definition at line 2085 of file lsyscache.c.

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

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

2086 {
2087  HeapTuple tp;
2088 
2090  if (HeapTupleIsValid(tp))
2091  {
2092  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2093  int16 result;
2094 
2095  result = typtup->typlen;
2096  ReleaseSysCache(tp);
2097  return result;
2098  }
2099  else
2100  return 0;
2101 }
signed short int16
Definition: c.h:362
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typlenbyval()

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

Definition at line 2139 of file lsyscache.c.

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

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

2140 {
2141  HeapTuple tp;
2142  Form_pg_type typtup;
2143 
2145  if (!HeapTupleIsValid(tp))
2146  elog(ERROR, "cache lookup failed for type %u", typid);
2147  typtup = (Form_pg_type) GETSTRUCT(tp);
2148  *typlen = typtup->typlen;
2149  *typbyval = typtup->typbyval;
2150  ReleaseSysCache(tp);
2151 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define elog(elevel,...)
Definition: elog.h:214

◆ get_typlenbyvalalign()

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

Definition at line 2159 of file lsyscache.c.

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

Referenced by _bt_preprocess_array_keys(), array_create_iterator(), array_fill_internal(), array_map(), array_position_common(), array_positions(), array_to_json_internal(), array_to_jsonb_internal(), array_unnest(), arrayconst_startup_fn(), CreateCast(), DefineRange(), exec_assign_value(), ExecEvalScalarArrayOp(), ExecIndexEvalArrayKeys(), ExecInitExprRec(), ExecInitSubscriptingRef(), 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(), and text_format().

2161 {
2162  HeapTuple tp;
2163  Form_pg_type typtup;
2164 
2166  if (!HeapTupleIsValid(tp))
2167  elog(ERROR, "cache lookup failed for type %u", typid);
2168  typtup = (Form_pg_type) GETSTRUCT(tp);
2169  *typlen = typtup->typlen;
2170  *typbyval = typtup->typbyval;
2171  *typalign = typtup->typalign;
2172  ReleaseSysCache(tp);
2173 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
char typalign
Definition: pg_type.h:170
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define elog(elevel,...)
Definition: elog.h:214

◆ get_typmodin()

Oid get_typmodin ( Oid  typid)

Definition at line 2883 of file lsyscache.c.

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

2884 {
2885  HeapTuple tp;
2886 
2888  if (HeapTupleIsValid(tp))
2889  {
2890  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2891  Oid result;
2892 
2893  result = typtup->typmodin;
2894  ReleaseSysCache(tp);
2895  return result;
2896  }
2897  else
2898  return InvalidOid;
2899 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
unsigned int Oid
Definition: postgres_ext.h:31
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typstorage()

char get_typstorage ( Oid  typid)

Definition at line 2307 of file lsyscache.c.

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

2308 {
2309  HeapTuple tp;
2310 
2312  if (HeapTupleIsValid(tp))
2313  {
2314  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2315  char result;
2316 
2317  result = typtup->typstorage;
2318  ReleaseSysCache(tp);
2319  return result;
2320  }
2321  else
2322  return TYPSTORAGE_PLAIN;
2323 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ get_typtype()

char get_typtype ( Oid  typid)

Definition at line 2517 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_range(), and type_is_rowtype().

2518 {
2519  HeapTuple tp;
2520 
2522  if (HeapTupleIsValid(tp))
2523  {
2524  Form_pg_type typtup = (Form_pg_type) GETSTRUCT(tp);
2525  char result;
2526 
2527  result = typtup->typtype;
2528  ReleaseSysCache(tp);
2529  return result;
2530  }
2531  else
2532  return '\0';
2533 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255

◆ getBaseType()

◆ getBaseTypeAndTypmod()

Oid getBaseTypeAndTypmod ( Oid  typid,
int32 typmod 
)

Definition at line 2426 of file lsyscache.c.

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

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

2427 {
2428  /*
2429  * We loop to find the bottom base type in a stack of domains.
2430  */
2431  for (;;)
2432  {
2433  HeapTuple tup;
2434  Form_pg_type typTup;
2435 
2436  tup = SearchSysCache1(TYPEOID, ObjectIdGetDatum(typid));
2437  if (!HeapTupleIsValid(tup))
2438  elog(ERROR, "cache lookup failed for type %u", typid);
2439  typTup = (Form_pg_type) GETSTRUCT(tup);
2440  if (typTup->typtype != TYPTYPE_DOMAIN)
2441  {
2442  /* Not a domain, so done */
2443  ReleaseSysCache(tup);
2444  break;
2445  }
2446 
2447  Assert(*typmod == -1);
2448  typid = typTup->typbasetype;
2449  *typmod = typTup->typtypmod;
2450 
2451  ReleaseSysCache(tup);
2452  }
2453 
2454  return typid;
2455 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:746
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
#define elog(elevel,...)
Definition: elog.h:214

◆ getTypeBinaryInputInfo()

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

Definition at line 2817 of file lsyscache.c.

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

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

2818 {
2819  HeapTuple typeTuple;
2820  Form_pg_type pt;
2821 
2823  if (!HeapTupleIsValid(typeTuple))
2824  elog(ERROR, "cache lookup failed for type %u", type);
2825  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2826 
2827  if (!pt->typisdefined)
2828  ereport(ERROR,
2829  (errcode(ERRCODE_UNDEFINED_OBJECT),
2830  errmsg("type %s is only a shell",
2831  format_type_be(type))));
2832  if (!OidIsValid(pt->typreceive))
2833  ereport(ERROR,
2834  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2835  errmsg("no binary input function available for type %s",
2836  format_type_be(type))));
2837 
2838  *typReceive = pt->typreceive;
2839  *typIOParam = getTypeIOParam(typeTuple);
2840 
2841  ReleaseSysCache(typeTuple);
2842 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:610
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
#define OidIsValid(objectId)
Definition: c.h:652
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define ereport(elevel,...)
Definition: elog.h:144
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define elog(elevel,...)
Definition: elog.h:214
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2191

◆ getTypeBinaryOutputInfo()

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

Definition at line 2850 of file lsyscache.c.

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

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

2851 {
2852  HeapTuple typeTuple;
2853  Form_pg_type pt;
2854 
2856  if (!HeapTupleIsValid(typeTuple))
2857  elog(ERROR, "cache lookup failed for type %u", type);
2858  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2859 
2860  if (!pt->typisdefined)
2861  ereport(ERROR,
2862  (errcode(ERRCODE_UNDEFINED_OBJECT),
2863  errmsg("type %s is only a shell",
2864  format_type_be(type))));
2865  if (!OidIsValid(pt->typsend))
2866  ereport(ERROR,
2867  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2868  errmsg("no binary output function available for type %s",
2869  format_type_be(type))));
2870 
2871  *typSend = pt->typsend;
2872  *typIsVarlena = (!pt->typbyval) && (pt->typlen == -1);
2873 
2874  ReleaseSysCache(typeTuple);
2875 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:610
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
#define OidIsValid(objectId)
Definition: c.h:652
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define ereport(elevel,...)
Definition: elog.h:144
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define elog(elevel,...)
Definition: elog.h:214

◆ getTypeInputInfo()

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

Definition at line 2751 of file lsyscache.c.

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

Referenced by _sv_to_datum_finfo(), BeginCopyFrom(), check_functions_in_node(), cost_qual_eval_walker(), DefineAggregate(), domain_state_setup(), eval_const_expressions_mutator(), exec_bind_message(), ExecInitExprRec(), ExecInitTableFuncScan(), GetAggInitVal(), hstore_populate_record(), parse_fcall_arguments(), plperl_spi_prepare(), pltcl_SPI_prepare(), PLy_output_setup_func(), prepare_column_cache(), record_in(), slot_modify_data(), slot_store_data(), and TupleDescGetAttInMetadata().

2752 {
2753  HeapTuple typeTuple;
2754  Form_pg_type pt;
2755 
2757  if (!HeapTupleIsValid(typeTuple))
2758  elog(ERROR, "cache lookup failed for type %u", type);
2759  pt = (Form_pg_type) GETSTRUCT(typeTuple);
2760 
2761  if (!pt->typisdefined)
2762  ereport(ERROR,
2763  (errcode(ERRCODE_UNDEFINED_OBJECT),
2764  errmsg("type %s is only a shell",
2765  format_type_be(type))));
2766  if (!OidIsValid(pt->typinput))
2767  ereport(ERROR,
2768  (errcode(ERRCODE_UNDEFINED_FUNCTION),
2769  errmsg("no input function available for type %s",
2770  format_type_be(type))));
2771 
2772  *typInput = pt->typinput;
2773  *typIOParam = getTypeIOParam(typeTuple);
2774 
2775  ReleaseSysCache(typeTuple);
2776 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
int errcode(int sqlerrcode)
Definition: elog.c:610
char * format_type_be(Oid type_oid)
Definition: format_type.c:339
#define OidIsValid(objectId)
Definition: c.h:652
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1116
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define ereport(elevel,...)
Definition: elog.h:144
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
FormData_pg_type * Form_pg_type
Definition: pg_type.h:255
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define elog(elevel,...)
Definition: elog.h:214
Oid getTypeIOParam(HeapTuple typeTuple)
Definition: lsyscache.c:2191

◆ getTypeIOParam()

Oid getTypeIOParam ( HeapTuple