codekingpro/portable-devtools
116k
1/*-------------------------------------------------------------------------2 *3 * lsyscache.h4 * Convenience routines for common queries in the system catalog cache.5 *6 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group7 * Portions Copyright (c) 1994, Regents of the University of California8 *9 * src/include/utils/lsyscache.h10 *11 *-------------------------------------------------------------------------12 */13#ifndef LSYSCACHE_H14#define LSYSCACHE_H15 16#include "access/attnum.h"17#include "access/htup.h"18#include "nodes/pg_list.h"19 20/* avoid including subscripting.h here */21struct SubscriptRoutines;22 23/* Result list element for get_op_btree_interpretation */24typedef struct OpBtreeInterpretation25{26 Oid opfamily_id; /* btree opfamily containing operator */27 int strategy; /* its strategy number */28 Oid oplefttype; /* declared left input datatype */29 Oid oprighttype; /* declared right input datatype */30} OpBtreeInterpretation;31 32/* I/O function selector for get_type_io_data */33typedef enum IOFuncSelector34{35 IOFunc_input,36 IOFunc_output,37 IOFunc_receive,38 IOFunc_send39} IOFuncSelector;40 41/* Flag bits for get_attstatsslot */42#define ATTSTATSSLOT_VALUES 0x0143#define ATTSTATSSLOT_NUMBERS 0x0244 45/* Result struct for get_attstatsslot */46typedef struct AttStatsSlot47{48 /* Always filled: */49 Oid staop; /* Actual staop for the found slot */50 Oid stacoll; /* Actual collation for the found slot */51 /* Filled if ATTSTATSSLOT_VALUES is specified: */52 Oid valuetype; /* Actual datatype of the values */53 Datum *values; /* slot's "values" array, or NULL if none */54 int nvalues; /* length of values[], or 0 */55 /* Filled if ATTSTATSSLOT_NUMBERS is specified: */56 float4 *numbers; /* slot's "numbers" array, or NULL if none */57 int nnumbers; /* length of numbers[], or 0 */58 59 /* Remaining fields are private to get_attstatsslot/free_attstatsslot */60 void *values_arr; /* palloc'd values array, if any */61 void *numbers_arr; /* palloc'd numbers array, if any */62} AttStatsSlot;63 64/* Hook for plugins to get control in get_attavgwidth() */65typedef int32 (*get_attavgwidth_hook_type) (Oid relid, AttrNumber attnum);66extern PGDLLIMPORT get_attavgwidth_hook_type get_attavgwidth_hook;67 68extern bool op_in_opfamily(Oid opno, Oid opfamily);69extern int get_op_opfamily_strategy(Oid opno, Oid opfamily);70extern Oid get_op_opfamily_sortfamily(Oid opno, Oid opfamily);71extern void get_op_opfamily_properties(Oid opno, Oid opfamily, bool ordering_op,72 int *strategy,73 Oid *lefttype,74 Oid *righttype);75extern Oid get_opfamily_member(Oid opfamily, Oid lefttype, Oid righttype,76 int16 strategy);77extern bool get_ordering_op_properties(Oid opno,78 Oid *opfamily, Oid *opcintype, int16 *strategy);79extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);80extern Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);81extern List *get_mergejoin_opfamilies(Oid opno);82extern bool get_compatible_hash_operators(Oid opno,83 Oid *lhs_opno, Oid *rhs_opno);84extern bool get_op_hash_functions(Oid opno,85 RegProcedure *lhs_procno, RegProcedure *rhs_procno);86extern List *get_op_btree_interpretation(Oid opno);87extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);88extern bool comparison_ops_are_compatible(Oid opno1, Oid opno2);89extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,90 int16 procnum);91extern char *get_attname(Oid relid, AttrNumber attnum, bool missing_ok);92extern AttrNumber get_attnum(Oid relid, const char *attname);93extern int get_attstattarget(Oid relid, AttrNumber attnum);94extern char get_attgenerated(Oid relid, AttrNumber attnum);95extern Oid get_atttype(Oid relid, AttrNumber attnum);96extern void get_atttypetypmodcoll(Oid relid, AttrNumber attnum,97 Oid *typid, int32 *typmod, Oid *collid);98extern Datum get_attoptions(Oid relid, int16 attnum);99extern Oid get_cast_oid(Oid sourcetypeid, Oid targettypeid, bool missing_ok);100extern char *get_collation_name(Oid colloid);101extern bool get_collation_isdeterministic(Oid colloid);102extern char *get_constraint_name(Oid conoid);103extern Oid get_constraint_index(Oid conoid);104extern char *get_language_name(Oid langoid, bool missing_ok);105extern Oid get_opclass_family(Oid opclass);106extern Oid get_opclass_input_type(Oid opclass);107extern bool get_opclass_opfamily_and_input_type(Oid opclass,108 Oid *opfamily, Oid *opcintype);109extern RegProcedure get_opcode(Oid opno);110extern char *get_opname(Oid opno);111extern Oid get_op_rettype(Oid opno);112extern void op_input_types(Oid opno, Oid *lefttype, Oid *righttype);113extern bool op_mergejoinable(Oid opno, Oid inputtype);114extern bool op_hashjoinable(Oid opno, Oid inputtype);115extern bool op_strict(Oid opno);116extern char op_volatile(Oid opno);117extern Oid get_commutator(Oid opno);118extern Oid get_negator(Oid opno);119extern RegProcedure get_oprrest(Oid opno);120extern RegProcedure get_oprjoin(Oid opno);121extern char *get_func_name(Oid funcid);122extern Oid get_func_namespace(Oid funcid);123extern Oid get_func_rettype(Oid funcid);124extern int get_func_nargs(Oid funcid);125extern Oid get_func_signature(Oid funcid, Oid **argtypes, int *nargs);126extern Oid get_func_variadictype(Oid funcid);127extern bool get_func_retset(Oid funcid);128extern bool func_strict(Oid funcid);129extern char func_volatile(Oid funcid);130extern char func_parallel(Oid funcid);131extern char get_func_prokind(Oid funcid);132extern bool get_func_leakproof(Oid funcid);133extern RegProcedure get_func_support(Oid funcid);134extern Oid get_relname_relid(const char *relname, Oid relnamespace);135extern char *get_rel_name(Oid relid);136extern Oid get_rel_namespace(Oid relid);137extern Oid get_rel_type_id(Oid relid);138extern char get_rel_relkind(Oid relid);139extern bool get_rel_relispartition(Oid relid);140extern Oid get_rel_tablespace(Oid relid);141extern char get_rel_persistence(Oid relid);142extern Oid get_transform_fromsql(Oid typid, Oid langid, List *trftypes);143extern Oid get_transform_tosql(Oid typid, Oid langid, List *trftypes);144extern bool get_typisdefined(Oid typid);145extern int16 get_typlen(Oid typid);146extern bool get_typbyval(Oid typid);147extern void get_typlenbyval(Oid typid, int16 *typlen, bool *typbyval);148extern void get_typlenbyvalalign(Oid typid, int16 *typlen, bool *typbyval,149 char *typalign);150extern Oid getTypeIOParam(HeapTuple typeTuple);151extern void get_type_io_data(Oid typid,152 IOFuncSelector which_func,153 int16 *typlen,154 bool *typbyval,155 char *typalign,156 char *typdelim,157 Oid *typioparam,158 Oid *func);159extern char get_typstorage(Oid typid);160extern Node *get_typdefault(Oid typid);161extern char get_typtype(Oid typid);162extern bool type_is_rowtype(Oid typid);163extern bool type_is_enum(Oid typid);164extern bool type_is_range(Oid typid);165extern bool type_is_multirange(Oid typid);166extern void get_type_category_preferred(Oid typid,167 char *typcategory,168 bool *typispreferred);169extern Oid get_typ_typrelid(Oid typid);170extern Oid get_element_type(Oid typid);171extern Oid get_array_type(Oid typid);172extern Oid get_promoted_array_type(Oid typid);173extern Oid get_base_element_type(Oid typid);174extern void getTypeInputInfo(Oid type, Oid *typInput, Oid *typIOParam);175extern void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena);176extern void getTypeBinaryInputInfo(Oid type, Oid *typReceive, Oid *typIOParam);177extern void getTypeBinaryOutputInfo(Oid type, Oid *typSend, bool *typIsVarlena);178extern Oid get_typmodin(Oid typid);179extern Oid get_typcollation(Oid typid);180extern bool type_is_collatable(Oid typid);181extern RegProcedure get_typsubscript(Oid typid, Oid *typelemp);182extern const struct SubscriptRoutines *getSubscriptingRoutines(Oid typid,183 Oid *typelemp);184extern Oid getBaseType(Oid typid);185extern Oid getBaseTypeAndTypmod(Oid typid, int32 *typmod);186extern int32 get_typavgwidth(Oid typid, int32 typmod);187extern int32 get_attavgwidth(Oid relid, AttrNumber attnum);188extern bool get_attstatsslot(AttStatsSlot *sslot, HeapTuple statstuple,189 int reqkind, Oid reqop, int flags);190extern void free_attstatsslot(AttStatsSlot *sslot);191extern char *get_namespace_name(Oid nspid);192extern char *get_namespace_name_or_temp(Oid nspid);193extern Oid get_range_subtype(Oid rangeOid);194extern Oid get_range_collation(Oid rangeOid);195extern Oid get_range_multirange(Oid rangeOid);196extern Oid get_multirange_range(Oid multirangeOid);197extern Oid get_index_column_opclass(Oid index_oid, int attno);198extern bool get_index_isreplident(Oid index_oid);199extern bool get_index_isvalid(Oid index_oid);200extern bool get_index_isclustered(Oid index_oid);201extern Oid get_publication_oid(const char *pubname, bool missing_ok);202extern char *get_publication_name(Oid pubid, bool missing_ok);203extern Oid get_subscription_oid(const char *subname, bool missing_ok);204extern char *get_subscription_name(Oid subid, bool missing_ok);205 206#define type_is_array(typid) (get_element_type(typid) != InvalidOid)207/* type_is_array_domain accepts both plain arrays and domains over arrays */208#define type_is_array_domain(typid) (get_base_element_type(typid) != InvalidOid)209 210#define TypeIsToastable(typid) (get_typstorage(typid) != TYPSTORAGE_PLAIN)211 212#endif /* LSYSCACHE_H */213 