PostgreSQL Source Code  git master
syscache.c File Reference
#include "postgres.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
#include "catalog/pg_aggregate.h"
#include "catalog/pg_am.h"
#include "catalog/pg_amop.h"
#include "catalog/pg_amproc.h"
#include "catalog/pg_auth_members.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_cast.h"
#include "catalog/pg_collation.h"
#include "catalog/pg_constraint.h"
#include "catalog/pg_conversion.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
#include "catalog/pg_default_acl.h"
#include "catalog/pg_depend.h"
#include "catalog/pg_description.h"
#include "catalog/pg_enum.h"
#include "catalog/pg_event_trigger.h"
#include "catalog/pg_foreign_data_wrapper.h"
#include "catalog/pg_foreign_server.h"
#include "catalog/pg_foreign_table.h"
#include "catalog/pg_language.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h"
#include "catalog/pg_opfamily.h"
#include "catalog/pg_partitioned_table.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_publication.h"
#include "catalog/pg_publication_rel.h"
#include "catalog/pg_range.h"
#include "catalog/pg_replication_origin.h"
#include "catalog/pg_rewrite.h"
#include "catalog/pg_seclabel.h"
#include "catalog/pg_sequence.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_statistic.h"
#include "catalog/pg_statistic_ext.h"
#include "catalog/pg_statistic_ext_data.h"
#include "catalog/pg_subscription.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_transform.h"
#include "catalog/pg_ts_config.h"
#include "catalog/pg_ts_config_map.h"
#include "catalog/pg_ts_dict.h"
#include "catalog/pg_ts_parser.h"
#include "catalog/pg_ts_template.h"
#include "catalog/pg_type.h"
#include "catalog/pg_user_mapping.h"
#include "lib/qunique.h"
#include "utils/catcache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
Include dependency graph for syscache.c:

Go to the source code of this file.

Data Structures

struct  cachedesc
 

Functions

static int oid_compare (const void *a, const void *b)
 
void InitCatalogCache (void)
 
void InitCatalogCachePhase2 (void)
 
HeapTuple SearchSysCache (int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
 
HeapTuple SearchSysCache1 (int cacheId, Datum key1)
 
HeapTuple SearchSysCache2 (int cacheId, Datum key1, Datum key2)
 
HeapTuple SearchSysCache3 (int cacheId, Datum key1, Datum key2, Datum key3)
 
HeapTuple SearchSysCache4 (int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
 
void ReleaseSysCache (HeapTuple tuple)
 
HeapTuple SearchSysCacheCopy (int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
 
bool SearchSysCacheExists (int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
 
Oid GetSysCacheOid (int cacheId, AttrNumber oidcol, Datum key1, Datum key2, Datum key3, Datum key4)
 
HeapTuple SearchSysCacheAttName (Oid relid, const char *attname)
 
HeapTuple SearchSysCacheCopyAttName (Oid relid, const char *attname)
 
bool SearchSysCacheExistsAttName (Oid relid, const char *attname)
 
HeapTuple SearchSysCacheAttNum (Oid relid, int16 attnum)
 
HeapTuple SearchSysCacheCopyAttNum (Oid relid, int16 attnum)
 
Datum SysCacheGetAttr (int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
 
uint32 GetSysCacheHashValue (int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
 
struct catclistSearchSysCacheList (int cacheId, int nkeys, Datum key1, Datum key2, Datum key3)
 
void SysCacheInvalidate (int cacheId, uint32 hashValue)
 
bool RelationInvalidatesSnapshotsOnly (Oid relid)
 
bool RelationHasSysCache (Oid relid)
 
bool RelationSupportsSysCache (Oid relid)
 

Variables

static const struct cachedesc cacheinfo []
 
static CatCacheSysCache [SysCacheSize]
 
static bool CacheInitialized = false
 
static Oid SysCacheRelationOid [SysCacheSize]
 
static int SysCacheRelationOidSize
 
static Oid SysCacheSupportingRelOid [SysCacheSize *2]
 
static int SysCacheSupportingRelOidSize
 

Function Documentation

◆ GetSysCacheHashValue()

uint32 GetSysCacheHashValue ( int  cacheId,
Datum  key1,
Datum  key2,
Datum  key3,
Datum  key4 
)

Definition at line 1423 of file syscache.c.

References elog, ERROR, GetCatCacheHashValue(), PointerIsValid, and SysCacheSize.

1428 {
1429  if (cacheId < 0 || cacheId >= SysCacheSize ||
1430  !PointerIsValid(SysCache[cacheId]))
1431  elog(ERROR, "invalid cache ID: %d", cacheId);
1432 
1433  return GetCatCacheHashValue(SysCache[cacheId], key1, key2, key3, key4);
1434 }
#define SysCacheSize
Definition: syscache.h:114
#define ERROR
Definition: elog.h:45
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define elog(elevel,...)
Definition: elog.h:228
uint32 GetCatCacheHashValue(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4)
Definition: catcache.c:1472
#define PointerIsValid(pointer)
Definition: c.h:686

◆ GetSysCacheOid()

Oid GetSysCacheOid ( int  cacheId,
AttrNumber  oidcol,
Datum  key1,
Datum  key2,
Datum  key3,
Datum  key4 
)

Definition at line 1236 of file syscache.c.

References Assert, heap_getattr, HeapTupleIsValid, InvalidOid, ReleaseSysCache(), and SearchSysCache().

1242 {
1243  HeapTuple tuple;
1244  bool isNull;
1245  Oid result;
1246 
1247  tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
1248  if (!HeapTupleIsValid(tuple))
1249  return InvalidOid;
1250  result = heap_getattr(tuple, oidcol,
1251  SysCache[cacheId]->cc_tupdesc,
1252  &isNull);
1253  Assert(!isNull); /* columns used as oids should never be NULL */
1254  ReleaseSysCache(tuple);
1255  return result;
1256 }
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1114
unsigned int Oid
Definition: postgres_ext.h:31
#define heap_getattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:762
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define InvalidOid
Definition: postgres_ext.h:36
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:792

◆ InitCatalogCache()

void InitCatalogCache ( void  )

Definition at line 1021 of file syscache.c.

References Assert, CacheInitialized, elog, ERROR, cachedesc::indoid, InitCatCache(), cachedesc::key, lengthof, cachedesc::nbuckets, cachedesc::nkeys, oid_compare(), pg_qsort(), PointerIsValid, qunique(), RelationInvalidatesSnapshotsOnly(), cachedesc::reloid, StaticAssertStmt, SysCacheRelationOid, SysCacheRelationOidSize, SysCacheSize, SysCacheSupportingRelOid, and SysCacheSupportingRelOidSize.

Referenced by InitPostgres().

1022 {
1023  int cacheId;
1024 
1026  "SysCacheSize does not match syscache.c's array");
1027 
1029 
1031 
1032  for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
1033  {
1034  SysCache[cacheId] = InitCatCache(cacheId,
1035  cacheinfo[cacheId].reloid,
1036  cacheinfo[cacheId].indoid,
1037  cacheinfo[cacheId].nkeys,
1038  cacheinfo[cacheId].key,
1039  cacheinfo[cacheId].nbuckets);
1040  if (!PointerIsValid(SysCache[cacheId]))
1041  elog(ERROR, "could not initialize cache %u (%d)",
1042  cacheinfo[cacheId].reloid, cacheId);
1043  /* Accumulate data for OID lists, too */
1045  cacheinfo[cacheId].reloid;
1047  cacheinfo[cacheId].reloid;
1049  cacheinfo[cacheId].indoid;
1050  /* see comments for RelationInvalidatesSnapshotsOnly */
1052  }
1053 
1056 
1057  /* Sort and de-dup OID arrays, so we can use binary search. */
1059  sizeof(Oid), oid_compare);
1062  oid_compare);
1063 
1065  sizeof(Oid), oid_compare);
1068  sizeof(Oid), oid_compare);
1069 
1070  CacheInitialized = true;
1071 }
static bool CacheInitialized
Definition: syscache.c:999
static int SysCacheSupportingRelOidSize
Definition: syscache.c:1007
static Oid SysCacheSupportingRelOid[SysCacheSize *2]
Definition: syscache.c:1006
static int SysCacheRelationOidSize
Definition: syscache.c:1003
#define lengthof(array)
Definition: c.h:722
unsigned int Oid
Definition: postgres_ext.h:31
static const struct cachedesc cacheinfo[]
Definition: syscache.c:123
Oid reloid
Definition: syscache.c:116
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:906
#define SysCacheSize
Definition: syscache.h:114
#define ERROR
Definition: elog.h:45
CatCache * InitCatCache(int id, Oid reloid, Oid indexoid, int nkeys, const int *key, int nbuckets)
Definition: catcache.c:763
Oid indoid
Definition: syscache.c:117
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
static Oid SysCacheRelationOid[SysCacheSize]
Definition: syscache.c:1002
#define Assert(condition)
Definition: c.h:792
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1484
void pg_qsort(void *base, size_t nel, size_t elsize, int(*cmp)(const void *, const void *))
Definition: qsort.c:113
static size_t qunique(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
Definition: qunique.h:21
static int oid_compare(const void *a, const void *b)
Definition: syscache.c:1557
#define elog(elevel,...)
Definition: elog.h:228
#define PointerIsValid(pointer)
Definition: c.h:686

◆ InitCatalogCachePhase2()

void InitCatalogCachePhase2 ( void  )

Definition at line 1086 of file syscache.c.

References Assert, CacheInitialized, InitCatCachePhase2(), and SysCacheSize.

Referenced by RelationCacheInitializePhase3().

1087 {
1088  int cacheId;
1089 
1091 
1092  for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
1093  InitCatCachePhase2(SysCache[cacheId], true);
1094 }
static bool CacheInitialized
Definition: syscache.c:999
#define SysCacheSize
Definition: syscache.h:114
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
void InitCatCachePhase2(CatCache *cache, bool touch_index)
Definition: catcache.c:1032

◆ oid_compare()

static int oid_compare ( const void *  a,
const void *  b 
)
static

Definition at line 1557 of file syscache.c.

Referenced by InitCatalogCache().

1558 {
1559  Oid oa = *((const Oid *) a);
1560  Oid ob = *((const Oid *) b);
1561 
1562  if (oa == ob)
1563  return 0;
1564  return (oa > ob) ? 1 : -1;
1565 }
unsigned int Oid
Definition: postgres_ext.h:31

◆ RelationHasSysCache()

bool RelationHasSysCache ( Oid  relid)

Definition at line 1507 of file syscache.c.

References SysCacheRelationOid, and SysCacheRelationOidSize.

Referenced by GetNonHistoricCatalogSnapshot().

1508 {
1509  int low = 0,
1510  high = SysCacheRelationOidSize - 1;
1511 
1512  while (low <= high)
1513  {
1514  int middle = low + (high - low) / 2;
1515 
1516  if (SysCacheRelationOid[middle] == relid)
1517  return true;
1518  if (SysCacheRelationOid[middle] < relid)
1519  low = middle + 1;
1520  else
1521  high = middle - 1;
1522  }
1523 
1524  return false;
1525 }
static int SysCacheRelationOidSize
Definition: syscache.c:1003
static Oid SysCacheRelationOid[SysCacheSize]
Definition: syscache.c:1002

◆ RelationInvalidatesSnapshotsOnly()

bool RelationInvalidatesSnapshotsOnly ( Oid  relid)

Definition at line 1484 of file syscache.c.

Referenced by CacheInvalidateHeapTuple(), GetNonHistoricCatalogSnapshot(), and InitCatalogCache().

1485 {
1486  switch (relid)
1487  {
1488  case DbRoleSettingRelationId:
1489  case DependRelationId:
1490  case SharedDependRelationId:
1491  case DescriptionRelationId:
1492  case SharedDescriptionRelationId:
1493  case SecLabelRelationId:
1494  case SharedSecLabelRelationId:
1495  return true;
1496  default:
1497  break;
1498  }
1499 
1500  return false;
1501 }

◆ RelationSupportsSysCache()

bool RelationSupportsSysCache ( Oid  relid)

Definition at line 1532 of file syscache.c.

References SysCacheSupportingRelOid, and SysCacheSupportingRelOidSize.

Referenced by RelationIdIsInInitFile().

1533 {
1534  int low = 0,
1535  high = SysCacheSupportingRelOidSize - 1;
1536 
1537  while (low <= high)
1538  {
1539  int middle = low + (high - low) / 2;
1540 
1541  if (SysCacheSupportingRelOid[middle] == relid)
1542  return true;
1543  if (SysCacheSupportingRelOid[middle] < relid)
1544  low = middle + 1;
1545  else
1546  high = middle - 1;
1547  }
1548 
1549  return false;
1550 }
static int SysCacheSupportingRelOidSize
Definition: syscache.c:1007
static Oid SysCacheSupportingRelOid[SysCacheSize *2]
Definition: syscache.c:1006

◆ ReleaseSysCache()

void ReleaseSysCache ( HeapTuple  tuple)

Definition at line 1175 of file syscache.c.

References ReleaseCatCache().

Referenced by aclitemout(), add_cast_to(), add_function_cost(), AddEnumLabel(), AddRoleMems(), AggregateCreate(), AlterDomainValidateConstraint(), AlterEnum(), AlterObjectRename_internal(), AlterOpFamily(), AlterRole(), AlterRoleSet(), AlterSchemaOwner(), AlterSchemaOwner_oid(), AlterStatistics(), AlterTSConfiguration(), AlterTSDictionary(), AlterType(), AlterTypeOwner(), AlterTypeOwner_oid(), AlterTypeRecurse(), amvalidate(), appendAggOrderBy(), appendFunctionName(), assignOperTypes(), assignProcTypes(), ATAddForeignKeyConstraint(), ATDetachCheckNoForeignKeyRefs(), ATExecAddColumn(), ATExecAddOf(), ATExecAlterColumnGenericOptions(), ATExecAlterColumnType(), ATExecChangeOwner(), ATExecCheckNotNull(), ATExecDetachPartition(), ATExecDropColumn(), ATExecDropNotNull(), ATExecSetOptions(), ATExecSetRelOptions(), ATPostAlterTypeCleanup(), ATPrepAlterColumnType(), ATPrepSetNotNull(), blvalidate(), brincostestimate(), brinvalidate(), btcostestimate(), btvalidate(), build_coercion_expression(), CacheInvalidateRelcacheByRelid(), call_pltcl_start_proc(), CallStmtResultDesc(), check_amop_signature(), check_amproc_signature(), check_enable_rls(), check_for_column_name_collision(), check_hash_func_signature(), check_object_ownership(), check_role(), check_session_authorization(), check_sql_fn_statements(), check_TSCurrentConfig(), CheckFunctionValidatorAccess(), CheckIndexCompatible(), CheckMyDatabase(), CloneFkReferenced(), CloneFkReferencing(), coerce_type(), CollationIsVisible(), column_privilege_check(), compatible_oper(), compatible_oper_opid(), compile_plperl_function(), compile_pltcl_function(), compute_return_type(), ComputeIndexAttrs(), ComputePartitionAttrs(), ConstraintSetParentConstraint(), ConstructTupleDescriptor(), ConversionIsVisible(), convert_column_name(), CreateCast(), CreateFunction(), CreateProceduralLanguage(), CreateRole(), CreateSchemaCommand(), CreateStatistics(), CreateTransform(), DefineCollation(), DefineDomain(), DefineIndex(), DefineOpClass(), DefineTSConfiguration(), DefineType(), DeleteRelationTuple(), DeleteSequenceTuple(), DelRoleMems(), deparseOpExpr(), deparseScalarArrayOpExpr(), do_autovacuum(), do_compile(), do_setval(), dropdb(), DropObjectById(), DropRole(), DropSubscription(), enum_cmp_internal(), enum_in(), enum_out(), enum_recv(), enum_send(), errdatatype(), eval_const_expressions_mutator(), examine_simple_variable(), examine_variable(), exec_stmt_call(), ExecGrant_Attribute(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecHashBuildSkewHash(), ExecInitAgg(), ExecuteCallStmt(), ExecuteDoStmt(), expand_all_col_privileges(), expand_vacuum_rel(), fetch_agg_sort_op(), fetch_fp_info(), find_coercion_pathway(), find_typmod_coercion_function(), fixup_whole_row_references(), flatten_reloptions(), fmgr_c_validator(), fmgr_info_cxt_security(), fmgr_info_other_lang(), fmgr_internal_validator(), fmgr_security_definer(), fmgr_sql_validator(), fmgr_symbol(), format_operator_extended(), format_operator_parts(), format_procedure_extended(), format_procedure_parts(), format_type_extended(), func_get_detail(), func_parallel(), func_strict(), func_volatile(), FuncNameAsType(), FunctionIsVisible(), generate_collation_name(), generate_function_name(), generate_operator_clause(), generate_operator_name(), generate_partition_qual(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_am_name(), get_am_type_oid(), get_array_type(), get_attavgwidth(), get_attgenerated(), get_attname(), get_attnum(), get_attoptions(), get_attribute_options(), get_attstatsslot(), get_atttype(), get_atttypetypmodcoll(), get_base_element_type(), get_collation(), get_collation_isdeterministic(), get_collation_name(), get_collation_version_for_oid(), get_commutator(), get_constraint_index(), get_constraint_name(), get_database_name(), get_db_info(), get_default_acl_internal(), get_default_partition_oid(), get_element_type(), get_func_leakproof(), get_func_name(), get_func_namespace(), get_func_nargs(), get_func_prokind(), get_func_result_name(), get_func_retset(), get_func_rettype(), get_func_signature(), get_func_support(), get_func_variadictype(), get_function_rows(), get_index_column_opclass(), get_index_isclustered(), get_index_isreplident(), get_index_isvalid(), get_language_name(), get_multirange_range(), get_namespace_name(), get_negator(), get_object_address_defacl(), get_object_address_opf_member(), get_object_address_type(), get_object_address_usermapping(), get_object_namespace(), get_op_opfamily_properties(), get_op_opfamily_sortfamily(), get_op_opfamily_strategy(), get_op_rettype(), get_opclass(), get_opclass_family(), get_opclass_input_type(), get_opclass_name(), get_opclass_oid(), get_opclass_opfamily_and_input_type(), get_opcode(), get_opfamily_member(), get_opfamily_oid(), get_opfamily_proc(), get_opname(), get_oprjoin(), get_oprrest(), get_publication_name(), get_qual_for_range(), get_range_collation(), get_range_multirange(), get_range_subtype(), get_rel_name(), get_rel_namespace(), get_rel_persistence(), get_rel_relispartition(), get_rel_relkind(), get_rel_tablespace(), get_rel_type_id(), get_relation_statistics(), get_relname_relid(), get_rewrite_oid(), get_role_password(), get_rolespec_name(), get_rte_attribute_is_dropped(), get_subscription_name(), get_tablespace(), get_transform_fromsql(), get_transform_tosql(), get_typ_typrelid(), get_typbyval(), get_typcollation(), get_typdefault(), get_type_category_preferred(), get_type_io_data(), get_typisdefined(), get_typlen(), get_typlenbyval(), get_typlenbyvalalign(), get_typmodin(), get_typstorage(), get_typsubscript(), get_typtype(), getBaseTypeAndTypmod(), GetFdwRoutineByServerId(), GetForeignColumnOptions(), GetForeignDataWrapperExtended(), GetForeignServerExtended(), GetForeignServerIdByRelId(), GetForeignTable(), GetIndexAmRoutineByAmId(), getObjectDescription(), getObjectIdentityParts(), getOpFamilyDescription(), getOpFamilyIdentity(), getProcedureTypeDescription(), GetPublication(), getRelationDescription(), getRelationIdentity(), GetRelationPublicationActions(), getRelationTypeDescription(), GetSubscription(), GetSubscriptionRelState(), GetSysCacheOid(), getTypeBinaryInputInfo(), getTypeBinaryOutputInfo(), GetTypeCollations(), getTypeInputInfo(), getTypeOutputInfo(), GetUserMapping(), GetUserNameFromId(), ginvalidate(), gistvalidate(), has_bypassrls_privilege(), has_createrole_privilege(), has_rolinherit(), has_rolreplication(), has_subclass(), hash_ok_operator(), hashvalidate(), have_createdb_privilege(), heap_drop_with_catalog(), inclusion_get_strategy_procinfo(), index_check_primary_key(), index_concurrently_create_copy(), index_create(), index_drop(), index_get_partition(), indexam_property(), IndexGetRelation(), IndexSupportsBackwardScan(), init_sql_fcache(), initialize_peragg(), InitializeSessionUserId(), inline_set_returning_function(), InsertRule(), internal_get_result_type(), interpret_function_parameter_list(), IsBinaryCoercible(), load_domaintype_info(), load_rangetype_info(), logicalrep_write_tuple(), logicalrep_write_typ(), lookup_collation(), lookup_collation_cache(), lookup_ts_config_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupTypeNameOid(), make_inh_translation_list(), make_new_heap(), make_op(), make_scalar_array_op(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), minmax_get_strategy_procinfo(), nextval_internal(), op_hashjoinable(), op_input_types(), op_mergejoinable(), OpclassIsVisible(), OperatorGet(), OperatorIsVisible(), OpernameGetOprid(), OpfamilyIsVisible(), ParseFuncOrColumn(), parseTypeString(), pg_attribute_aclcheck_all(), pg_attribute_aclmask(), pg_class_aclmask(), pg_class_ownercheck(), pg_collation_ownercheck(), pg_conversion_ownercheck(), pg_database_aclmask(), pg_database_ownercheck(), pg_event_trigger_ownercheck(), pg_foreign_data_wrapper_aclmask(), pg_foreign_data_wrapper_ownercheck(), pg_foreign_server_aclmask(), pg_foreign_server_ownercheck(), pg_get_constraintdef_worker(), pg_get_function_arg_default(), pg_get_function_arguments(), pg_get_function_identity_arguments(), pg_get_function_result(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_userbyid(), pg_language_aclmask(), pg_language_ownercheck(), pg_namespace_aclmask(), pg_namespace_ownercheck(), pg_newlocale_from_collation(), pg_nextoid(), pg_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_proc_aclmask(), pg_proc_ownercheck(), pg_publication_ownercheck(), pg_relation_filenode(), pg_relation_filepath(), pg_relation_is_publishable(), pg_sequence_parameters(), pg_statistics_object_ownercheck(), pg_subscription_ownercheck(), pg_tablespace_aclmask(), pg_tablespace_ownercheck(), pg_ts_config_ownercheck(), pg_ts_dict_ownercheck(), pg_type_aclmask(), pg_type_ownercheck(), plperl_validator(), plpgsql_build_datatype(), plpgsql_compile(), plpgsql_parse_cwordtype(), plpgsql_parse_wordtype(), plpgsql_validator(), plpython_validator(), plsample_func_handler(), PLy_procedure_create(), PLy_procedure_get(), prepare_column_cache(), preprocess_aggref(), print_function_arguments(), ProcedureCreate(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForRenameAttribute(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackForTruncate(), RangeVarCallbackOwnsRelation(), recomputeNamespacePath(), recordExtObjInitPriv(), refresh_by_match_merge(), regclassout(), regcollationout(), regconfigout(), regdictionaryout(), regoperout(), regprocout(), regtypeout(), relation_mark_replica_identity(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationCacheInitializePhase3(), RelationClearMissing(), relationHasPrimaryKey(), RelationInitIndexAccessInfo(), RelationInitTableAccessMethod(), RelationIsVisible(), RelationReloadIndexInfo(), RemoveConstraintById(), removeExtObjInitPriv(), RemoveFunctionById(), RemoveOperatorById(), RemovePartitionKeyByRelId(), RemovePublicationRelById(), RemoveStatisticsById(), RemoveTSConfigurationById(), RemoveTypeById(), rename_constraint_internal(), RenameConstraint(), RenameRole(), replorigin_by_name(), replorigin_by_oid(), replorigin_drop(), ResetSequence(), ResolveOpClass(), ri_GenerateQualCollation(), ri_LoadConstraintInfo(), SearchSysCacheAttName(), SearchSysCacheAttNum(), SearchSysCacheCopy(), SearchSysCacheCopyAttName(), SearchSysCacheCopyAttNum(), SearchSysCacheExists(), SearchSysCacheExistsAttName(), sepgsql_proc_setattr(), sepgsql_relation_setattr(), sequence_options(), SetAttrMissing(), SetDefaultACL(), simplify_function(), spgvalidate(), SPI_gettype(), statext_dependencies_load(), statext_mcv_load(), statext_ndistinct_load(), statext_store(), StatisticsObjIsVisible(), superuser_arg(), transformColumnDefinition(), transformColumnNameList(), transformColumnType(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), transformOfType(), triggered_change_notification(), tryAttachPartitionForeignKey(), TryReuseForeignKey(), TSConfigIsVisible(), TSDictionaryIsVisible(), TSParserIsVisible(), TSTemplateIsVisible(), TupleDescInitEntry(), typeidTypeRelid(), typeIsOfTypedTable(), TypeIsVisible(), typenameTypeId(), typenameTypeIdAndMod(), typeOrDomainTypeRelid(), update_attstats(), UpdateStatisticsForTypeChange(), validatePartitionedIndex(), and verify_dictoptions().

1176 {
1177  ReleaseCatCache(tuple);
1178 }
void ReleaseCatCache(HeapTuple tuple)
Definition: catcache.c:1440

◆ SearchSysCache()

HeapTuple SearchSysCache ( int  cacheId,
Datum  key1,
Datum  key2,
Datum  key3,
Datum  key4 
)

Definition at line 1114 of file syscache.c.

References Assert, PointerIsValid, SearchCatCache(), and SysCacheSize.

Referenced by GetSysCacheOid(), plsample_func_handler(), SearchSysCacheCopy(), and SearchSysCacheExists().

1119 {
1120  Assert(cacheId >= 0 && cacheId < SysCacheSize &&
1121  PointerIsValid(SysCache[cacheId]));
1122 
1123  return SearchCatCache(SysCache[cacheId], key1, key2, key3, key4);
1124 }
#define SysCacheSize
Definition: syscache.h:114
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
HeapTuple SearchCatCache(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4)
Definition: catcache.c:1147
#define PointerIsValid(pointer)
Definition: c.h:686

◆ SearchSysCache1()

HeapTuple SearchSysCache1 ( int  cacheId,
Datum  key1 
)

Definition at line 1127 of file syscache.c.

References Assert, PointerIsValid, SearchCatCache1(), and SysCacheSize.

Referenced by aclitemout(), add_cast_to(), add_function_cost(), AggregateCreate(), AlterDomainValidateConstraint(), AlterEnum(), AlterObjectRename_internal(), AlterOpFamily(), AlterSchemaOwner(), AlterSchemaOwner_oid(), AlterStatistics(), AlterTSDictionary(), AlterTypeOwner_oid(), AlterTypeRecurse(), amvalidate(), appendAggOrderBy(), appendFunctionName(), assignOperTypes(), assignProcTypes(), ATAddForeignKeyConstraint(), ATDetachCheckNoForeignKeyRefs(), ATExecAlterColumnGenericOptions(), ATExecChangeOwner(), ATExecDetachPartition(), ATExecDropNotNull(), ATExecSetRelOptions(), ATPostAlterTypeCleanup(), blvalidate(), brinvalidate(), btvalidate(), build_coercion_expression(), CacheInvalidateRelcacheByRelid(), call_pltcl_start_proc(), CallStmtResultDesc(), check_amop_signature(), check_amproc_signature(), check_enable_rls(), check_hash_func_signature(), check_object_ownership(), check_role(), check_session_authorization(), check_sql_fn_statements(), check_TSCurrentConfig(), CheckFunctionValidatorAccess(), CheckIndexCompatible(), CheckMyDatabase(), CloneFkReferenced(), CloneFkReferencing(), CollationIsVisible(), compile_plperl_function(), compile_pltcl_function(), ComputeIndexAttrs(), ConstraintSetParentConstraint(), ConstructTupleDescriptor(), ConversionIsVisible(), CreateCast(), CreateEventTrigger(), CreateFunction(), CreateProceduralLanguage(), CreateSchemaCommand(), CreateTransform(), DefineCollation(), DefineIndex(), DefineOpClass(), DefineTSConfiguration(), DeleteRelationTuple(), DeleteSequenceTuple(), deparseOpExpr(), deparseScalarArrayOpExpr(), do_autovacuum(), do_compile(), do_setval(), dropdb(), DropObjectById(), DropRole(), enum_cmp_internal(), enum_out(), enum_send(), errdatatype(), eval_const_expressions_mutator(), exec_stmt_call(), ExecGrant_Database(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecGrant_Tablespace(), ExecGrant_Type(), ExecInitAgg(), ExecuteCallStmt(), ExecuteDoStmt(), expand_vacuum_rel(), fetch_agg_sort_op(), fetch_fp_info(), fixup_whole_row_references(), flatten_reloptions(), fmgr_c_validator(), fmgr_info_cxt_security(), fmgr_info_other_lang(), fmgr_internal_validator(), fmgr_security_definer(), fmgr_sql_validator(), fmgr_symbol(), format_operator_extended(), format_operator_parts(), format_procedure_extended(), format_procedure_parts(), format_type_extended(), func_get_detail(), func_parallel(), func_strict(), func_volatile(), FunctionIsVisible(), generate_collation_name(), generate_function_name(), generate_operator_clause(), generate_operator_name(), generate_partition_qual(), generate_qualified_relation_name(), generate_qualified_type_name(), generate_relation_name(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_am_name(), get_am_type_oid(), get_array_type(), get_attstatsslot(), get_base_element_type(), get_collation(), get_collation_isdeterministic(), get_collation_name(), get_collation_version_for_oid(), get_commutator(), get_constraint_index(), get_constraint_name(), get_database_name(), get_db_info(), get_default_partition_oid(), get_element_type(), get_func_leakproof(), get_func_name(), get_func_namespace(), get_func_nargs(), get_func_prokind(), get_func_result_name(), get_func_retset(), get_func_rettype(), get_func_signature(), get_func_support(), get_func_variadictype(), get_function_rows(), get_index_column_opclass(), get_index_isclustered(), get_index_isreplident(), get_index_isvalid(), get_language_name(), get_multirange_range(), get_namespace_name(), get_negator(), get_object_address_defacl(), get_object_address_usermapping(), get_object_namespace(), get_op_rettype(), get_opclass(), get_opclass_family(), get_opclass_input_type(), get_opclass_name(), get_opclass_opfamily_and_input_type(), get_opcode(), get_opname(), get_oprjoin(), get_oprrest(), get_publication_name(), get_qual_for_range(), get_range_collation(), get_range_multirange(), get_range_subtype(), get_rel_name(), get_rel_namespace(), get_rel_persistence(), get_rel_relispartition(), get_rel_relkind(), get_rel_tablespace(), get_rel_type_id(), get_relation_statistics(), get_relname_relid(), get_role_password(), get_rolespec_tuple(), get_subscription_name(), get_tablespace(), get_typ_typrelid(), get_typbyval(), get_typcollation(), get_typdefault(), get_type_category_preferred(), get_type_io_data(), get_typisdefined(), get_typlen(), get_typlenbyval(), get_typlenbyvalalign(), get_typmodin(), get_typstorage(), get_typsubscript(), get_typtype(), getBaseTypeAndTypmod(), GetFdwRoutineByServerId(), GetForeignDataWrapperExtended(), GetForeignServerExtended(), GetForeignServerIdByRelId(), GetForeignTable(), GetIndexAmRoutineByAmId(), getObjectDescription(), getObjectIdentityParts(), getOpFamilyDescription(), getOpFamilyIdentity(), getProcedureTypeDescription(), GetPublication(), getRelationDescription(), getRelationIdentity(), GetRelationPublicationActions(), getRelationTypeDescription(), GetSubscription(), GetTSConfigTuple(), getTypeBinaryInputInfo(), getTypeBinaryOutputInfo(), GetTypeCollations(), getTypeInputInfo(), getTypeOutputInfo(), GetUserNameFromId(), ginvalidate(), gistvalidate(), has_bypassrls_privilege(), has_createrole_privilege(), has_rolinherit(), has_rolreplication(), has_subclass(), hash_ok_operator(), hashvalidate(), have_createdb_privilege(), heap_drop_with_catalog(), index_concurrently_create_copy(), index_create(), index_drop(), index_get_partition(), indexam_property(), IndexGetRelation(), IndexSupportsBackwardScan(), init_sql_fcache(), initialize_peragg(), InitializeSessionUserId(), inline_set_returning_function(), internal_get_result_type(), left_oper(), load_domaintype_info(), load_rangetype_info(), logicalrep_write_tuple(), logicalrep_write_typ(), lookup_collation_cache(), lookup_ts_config_cache(), lookup_ts_dictionary_cache(), lookup_ts_parser_cache(), lookup_type_cache(), LookupTypeNameExtended(), make_new_heap(), map_sql_table_to_xmlschema(), map_sql_type_to_xml_name(), nextval_internal(), op_hashjoinable(), op_input_types(), op_mergejoinable(), OpClassCacheLookup(), OpclassIsVisible(), oper(), OperatorIsVisible(), OpFamilyCacheLookup(), OpfamilyIsVisible(), ParseFuncOrColumn(), pg_attribute_aclcheck_all(), pg_attribute_aclmask(), pg_class_aclmask(), pg_class_ownercheck(), pg_collation_ownercheck(), pg_conversion_ownercheck(), pg_database_aclmask(), pg_database_ownercheck(), pg_event_trigger_ownercheck(), pg_foreign_data_wrapper_aclmask(), pg_foreign_data_wrapper_ownercheck(), pg_foreign_server_aclmask(), pg_foreign_server_ownercheck(), pg_get_constraintdef_worker(), pg_get_function_arg_default(), pg_get_function_arguments(), pg_get_function_identity_arguments(), pg_get_function_result(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_get_userbyid(), pg_language_aclmask(), pg_language_ownercheck(), pg_namespace_aclmask(), pg_namespace_ownercheck(), pg_newlocale_from_collation(), pg_opclass_ownercheck(), pg_oper_ownercheck(), pg_opfamily_ownercheck(), pg_proc_aclmask(), pg_proc_ownercheck(), pg_publication_ownercheck(), pg_relation_filenode(), pg_relation_filepath(), pg_relation_is_publishable(), pg_sequence_parameters(), pg_statistics_object_ownercheck(), pg_subscription_ownercheck(), pg_tablespace_aclmask(), pg_tablespace_ownercheck(), pg_ts_config_ownercheck(), pg_ts_dict_ownercheck(), pg_type_aclmask(), pg_type_ownercheck(), plperl_validator(), plpgsql_build_datatype(), plpgsql_compile(), plpgsql_parse_cwordtype(), plpgsql_validator(), plpython_validator(), plsample_func_handler(), PLy_procedure_create(), PLy_procedure_get(), prepare_column_cache(), preprocess_aggref(), print_function_arguments(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForAttachIndex(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForRenameAttribute(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackForTruncate(), RangeVarCallbackOwnsRelation(), recomputeNamespacePath(), recordExtObjInitPriv(), refresh_by_match_merge(), regclassout(), regcollationout(), regconfigout(), regdictionaryout(), regoperout(), regprocout(), regtypeout(), relation_mark_replica_identity(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), RelationCacheInitializePhase3(), relationHasPrimaryKey(), RelationInitIndexAccessInfo(), RelationInitTableAccessMethod(), RelationIsVisible(), RelationReloadIndexInfo(), RemoveConstraintById(), removeExtObjInitPriv(), RemoveFunctionById(), RemoveOperatorById(), RemovePartitionKeyByRelId(), RemovePublicationRelById(), RemoveStatisticsById(), RemoveTSConfigurationById(), RemoveTypeById(), rename_constraint_internal(), RenameConstraint(), RenameRole(), replorigin_by_name(), replorigin_by_oid(), replorigin_drop(), ResetSequence(), ResolveOpClass(), ri_GenerateQualCollation(), ri_LoadConstraintInfo(), sepgsql_proc_setattr(), sepgsql_relation_setattr(), sequence_options(), simplify_function(), spgvalidate(), SPI_gettype(), statext_dependencies_load(), statext_mcv_load(), statext_ndistinct_load(), statext_store(), StatisticsObjIsVisible(), superuser_arg(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), triggered_change_notification(), tryAttachPartitionForeignKey(), TryReuseForeignKey(), TSConfigIsVisible(), TSDictionaryIsVisible(), TSParserIsVisible(), TSTemplateIsVisible(), TupleDescInitEntry(), typeidType(), typeidTypeRelid(), typeIsOfTypedTable(), TypeIsVisible(), typeOrDomainTypeRelid(), UpdateStatisticsForTypeChange(), validatePartitionedIndex(), and verify_dictoptions().

1129 {
1130  Assert(cacheId >= 0 && cacheId < SysCacheSize &&
1131  PointerIsValid(SysCache[cacheId]));
1132  Assert(SysCache[cacheId]->cc_nkeys == 1);
1133 
1134  return SearchCatCache1(SysCache[cacheId], key1);
1135 }
#define SysCacheSize
Definition: syscache.h:114
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
#define PointerIsValid(pointer)
Definition: c.h:686
HeapTuple SearchCatCache1(CatCache *cache, Datum v1)
Definition: catcache.c:1164

◆ SearchSysCache2()

HeapTuple SearchSysCache2 ( int  cacheId,
Datum  key1,
Datum  key2 
)

Definition at line 1138 of file syscache.c.

References Assert, PointerIsValid, SearchCatCache2(), and SysCacheSize.

Referenced by AddEnumLabel(), AddRoleMems(), CastCreate(), check_for_column_name_collision(), column_privilege_check(), convert_column_name(), CreateTransform(), DelRoleMems(), DropSubscription(), enum_in(), enum_recv(), ExecGrant_Attribute(), expand_all_col_privileges(), find_coercion_pathway(), find_typmod_coercion_function(), fixup_whole_row_references(), get_attgenerated(), get_attname(), get_attoptions(), get_attribute_options(), get_atttype(), get_atttypetypmodcoll(), get_object_address_usermapping(), get_rewrite_oid(), get_rte_attribute_is_dropped(), get_transform_fromsql(), get_transform_tosql(), GetForeignColumnOptions(), GetSubscriptionRelState(), GetUserMapping(), index_check_primary_key(), InsertRule(), IsBinaryCoercible(), pg_attribute_aclcheck_all(), pg_attribute_aclmask(), recordExtObjInitPriv(), RelationClearMissing(), removeExtObjInitPriv(), SearchSysCacheAttName(), and SearchSysCacheAttNum().

1140 {
1141  Assert(cacheId >= 0 && cacheId < SysCacheSize &&
1142  PointerIsValid(SysCache[cacheId]));
1143  Assert(SysCache[cacheId]->cc_nkeys == 2);
1144 
1145  return SearchCatCache2(SysCache[cacheId], key1, key2);
1146 }
#define SysCacheSize
Definition: syscache.h:114
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
#define PointerIsValid(pointer)
Definition: c.h:686
HeapTuple SearchCatCache2(CatCache *cache, Datum v1, Datum v2)
Definition: catcache.c:1172

◆ SearchSysCache3()

HeapTuple SearchSysCache3 ( int  cacheId,
Datum  key1,
Datum  key2,
Datum  key3 
)

Definition at line 1149 of file syscache.c.

References Assert, PointerIsValid, SearchCatCache3(), and SysCacheSize.

Referenced by brincostestimate(), btcostestimate(), DefineOpClass(), examine_simple_variable(), examine_variable(), ExecHashBuildSkewHash(), get_attavgwidth(), get_default_acl_internal(), get_object_address_defacl(), get_op_opfamily_properties(), get_op_opfamily_sortfamily(), get_op_opfamily_strategy(), lookup_collation(), OpClassCacheLookup(), OpFamilyCacheLookup(), ProcedureCreate(), ResolveOpClass(), SetDefaultACL(), and update_attstats().

1151 {
1152  Assert(cacheId >= 0 && cacheId < SysCacheSize &&
1153  PointerIsValid(SysCache[cacheId]));
1154  Assert(SysCache[cacheId]->cc_nkeys == 3);
1155 
1156  return SearchCatCache3(SysCache[cacheId], key1, key2, key3);
1157 }
#define SysCacheSize
Definition: syscache.h:114
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
HeapTuple SearchCatCache3(CatCache *cache, Datum v1, Datum v2, Datum v3)
Definition: catcache.c:1180
#define PointerIsValid(pointer)
Definition: c.h:686

◆ SearchSysCache4()

HeapTuple SearchSysCache4 ( int  cacheId,
Datum  key1,
Datum  key2,
Datum  key3,
Datum  key4 
)

Definition at line 1160 of file syscache.c.

References Assert, PointerIsValid, SearchCatCache4(), and SysCacheSize.

Referenced by get_object_address_opf_member(), get_opfamily_member(), get_opfamily_proc(), inclusion_get_strategy_procinfo(), minmax_get_strategy_procinfo(), OperatorGet(), and OpernameGetOprid().

1162 {
1163  Assert(cacheId >= 0 && cacheId < SysCacheSize &&
1164  PointerIsValid(SysCache[cacheId]));
1165  Assert(SysCache[cacheId]->cc_nkeys == 4);
1166 
1167  return SearchCatCache4(SysCache[cacheId], key1, key2, key3, key4);
1168 }
#define SysCacheSize
Definition: syscache.h:114
HeapTuple SearchCatCache4(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4)
Definition: catcache.c:1188
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
#define PointerIsValid(pointer)
Definition: c.h:686

◆ SearchSysCacheAttName()

HeapTuple SearchSysCacheAttName ( Oid  relid,
const char *  attname 
)

Definition at line 1268 of file syscache.c.

References ATTNAME, CStringGetDatum, GETSTRUCT, HeapTupleIsValid, ObjectIdGetDatum, ReleaseSysCache(), and SearchSysCache2().

Referenced by ATExecAlterColumnGenericOptions(), ATExecCheckNotNull(), ATExecDropColumn(), ATExecSetOptions(), ATPrepAlterColumnType(), ATPrepSetNotNull(), ComputeIndexAttrs(), ComputePartitionAttrs(), CreateStatistics(), get_attnum(), make_inh_translation_list(), pg_nextoid(), plpgsql_parse_cwordtype(), SearchSysCacheCopyAttName(), SearchSysCacheExistsAttName(), SetAttrMissing(), and transformColumnNameList().

1269 {
1270  HeapTuple tuple;
1271 
1272  tuple = SearchSysCache2(ATTNAME,
1273  ObjectIdGetDatum(relid),
1275  if (!HeapTupleIsValid(tuple))
1276  return NULL;
1277  if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
1278  {
1279  ReleaseSysCache(tuple);
1280  return NULL;
1281  }
1282  return tuple;
1283 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
NameData attname
Definition: pg_attribute.h:40
#define CStringGetDatum(X)
Definition: postgres.h:578
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138

◆ SearchSysCacheAttNum()

HeapTuple SearchSysCacheAttNum ( Oid  relid,
int16  attnum 
)

Definition at line 1331 of file syscache.c.

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

Referenced by SearchSysCacheCopyAttNum().

1332 {
1333  HeapTuple tuple;
1334 
1335  tuple = SearchSysCache2(ATTNUM,
1336  ObjectIdGetDatum(relid),
1338  if (!HeapTupleIsValid(tuple))
1339  return NULL;
1340  if (((Form_pg_attribute) GETSTRUCT(tuple))->attisdropped)
1341  {
1342  ReleaseSysCache(tuple);
1343  return NULL;
1344  }
1345  return tuple;
1346 }
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
#define Int16GetDatum(X)
Definition: postgres.h:451
#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:1175
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:1138

◆ SearchSysCacheCopy()

HeapTuple SearchSysCacheCopy ( int  cacheId,
Datum  key1,
Datum  key2,
Datum  key3,
Datum  key4 
)

Definition at line 1189 of file syscache.c.

References heap_copytuple(), HeapTupleIsValid, ReleaseSysCache(), and SearchSysCache().

1194 {
1195  HeapTuple tuple,
1196  newtuple;
1197 
1198  tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
1199  if (!HeapTupleIsValid(tuple))
1200  return tuple;
1201  newtuple = heap_copytuple(tuple);
1202  ReleaseSysCache(tuple);
1203  return newtuple;
1204 }
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1114
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ SearchSysCacheCopyAttName()

HeapTuple SearchSysCacheCopyAttName ( Oid  relid,
const char *  attname 
)

Definition at line 1291 of file syscache.c.

References heap_copytuple(), HeapTupleIsValid, ReleaseSysCache(), and SearchSysCacheAttName().

Referenced by ATExecAddColumn(), ATExecAddIdentity(), ATExecAlterColumnType(), ATExecDropColumn(), ATExecDropExpression(), ATExecDropIdentity(), ATExecDropNotNull(), ATExecSetIdentity(), ATExecSetNotNull(), ATExecSetStatistics(), ATExecSetStorage(), ATPrepDropExpression(), MergeAttributesIntoExisting(), and renameatt_internal().

1292 {
1293  HeapTuple tuple,
1294  newtuple;
1295 
1296  tuple = SearchSysCacheAttName(relid, attname);
1297  if (!HeapTupleIsValid(tuple))
1298  return tuple;
1299  newtuple = heap_copytuple(tuple);
1300  ReleaseSysCache(tuple);
1301  return newtuple;
1302 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
NameData attname
Definition: pg_attribute.h:40
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1268

◆ SearchSysCacheCopyAttNum()

HeapTuple SearchSysCacheCopyAttNum ( Oid  relid,
int16  attnum 
)

Definition at line 1354 of file syscache.c.

References heap_copytuple(), HeapTupleIsValid, ReleaseSysCache(), and SearchSysCacheAttNum().

Referenced by ATExecSetStatistics(), and ATExecSetStorage().

1355 {
1356  HeapTuple tuple,
1357  newtuple;
1358 
1359  tuple = SearchSysCacheAttNum(relid, attnum);
1360  if (!HeapTupleIsValid(tuple))
1361  return NULL;
1362  newtuple = heap_copytuple(tuple);
1363  ReleaseSysCache(tuple);
1364  return newtuple;
1365 }
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1331
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int16 attnum
Definition: pg_attribute.h:79
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ SearchSysCacheExists()

bool SearchSysCacheExists ( int  cacheId,
Datum  key1,
Datum  key2,
Datum  key3,
Datum  key4 
)

Definition at line 1213 of file syscache.c.

References HeapTupleIsValid, ReleaseSysCache(), and SearchSysCache().

1218 {
1219  HeapTuple tuple;
1220 
1221  tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
1222  if (!HeapTupleIsValid(tuple))
1223  return false;
1224  ReleaseSysCache(tuple);
1225  return true;
1226 }
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1114
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78

◆ SearchSysCacheExistsAttName()

bool SearchSysCacheExistsAttName ( Oid  relid,
const char *  attname 
)

Definition at line 1310 of file syscache.c.

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

Referenced by RemoveInheritance().

1311 {
1312  HeapTuple tuple;
1313 
1314  tuple = SearchSysCacheAttName(relid, attname);
1315  if (!HeapTupleIsValid(tuple))
1316  return false;
1317  ReleaseSysCache(tuple);
1318  return true;
1319 }
NameData attname
Definition: pg_attribute.h:40
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1268

◆ SearchSysCacheList()

struct catclist* SearchSysCacheList ( int  cacheId,
int  nkeys,
Datum  key1,
Datum  key2,
Datum  key3 
)

Definition at line 1440 of file syscache.c.

References elog, ERROR, PointerIsValid, SearchCatCacheList(), and SysCacheSize.

1442 {
1443  if (cacheId < 0 || cacheId >= SysCacheSize ||
1444  !PointerIsValid(SysCache[cacheId]))
1445  elog(ERROR, "invalid cache ID: %d", cacheId);
1446 
1447  return SearchCatCacheList(SysCache[cacheId], nkeys,
1448  key1, key2, key3);
1449 }
#define SysCacheSize
Definition: syscache.h:114
#define ERROR
Definition: elog.h:45
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
CatCList * SearchCatCacheList(CatCache *cache, int nkeys, Datum v1, Datum v2, Datum v3)
Definition: catcache.c:1506
#define elog(elevel,...)
Definition: elog.h:228
#define PointerIsValid(pointer)
Definition: c.h:686

◆ SysCacheGetAttr()

Datum SysCacheGetAttr ( int  cacheId,
HeapTuple  tup,
AttrNumber  attributeNumber,
bool isNull 
)

Definition at line 1388 of file syscache.c.

References Assert, elog, ERROR, heap_getattr, InitCatCachePhase2(), PointerIsValid, and SysCacheSize.

Referenced by AlterDomainValidateConstraint(), AlterForeignDataWrapper(), AlterForeignServer(), AlterFunction(), AlterRole(), AlterSchemaOwner_internal(), AlterTSDictionary(), AlterUserMapping(), ATExecAlterColumnGenericOptions(), ATExecChangeOwner(), ATExecGenericOptions(), ATExecSetOptions(), ATExecSetRelOptions(), ATExecValidateConstraint(), build_function_result_tupdesc_t(), build_replindex_scan_key(), CheckIndexCompatible(), compile_plperl_function(), compile_pltcl_function(), DeconstructFkConstraintRow(), DefineDomain(), do_compile(), DropSubscription(), ExecGrant_Attribute(), ExecGrant_Fdw(), ExecGrant_ForeignServer(), ExecGrant_Function(), ExecGrant_Language(), ExecGrant_Namespace(), ExecGrant_Relation(), ExecInitAgg(), fetch_function_defaults(), fetch_statentries_for_relation(), flatten_reloptions(), fmgr_c_validator(), fmgr_info_C_lang(), fmgr_info_cxt_security(), fmgr_internal_validator(), fmgr_security_definer(), fmgr_sql_validator(), fmgr_symbol(), func_get_detail(), generate_partition_qual(), generateClonedExtStatsStmt(), generateClonedIndexStmt(), get_attoptions(), get_attribute_options(), get_attstatsslot(), get_default_acl_internal(), get_func_arg_info(), get_func_result_name(), get_func_trftypes(), get_index_column_opclass(), get_object_namespace(), get_qual_for_range(), get_role_password(), get_tablespace(), get_typdefault(), GetForeignColumnOptions(), GetForeignDataWrapperExtended(), GetForeignServerExtended(), GetForeignTable(), GetSubscription(), GetSubscriptionNotReadyRelations(), GetSubscriptionRelations(), GetSubscriptionRelState(), GetUserMapping(), inclusion_get_strategy_procinfo(), index_concurrently_create_copy(), index_opclass_options(), init_sql_fcache(), initialize_peragg(), inline_function(), inline_set_returning_function(), lookup_ts_dictionary_cache(), make_new_heap(), MatchNamedCall(), minmax_get_strategy_procinfo(), pg_attribute_aclmask(), pg_class_aclmask(), pg_database_aclmask(), pg_foreign_data_wrapper_aclmask(), pg_foreign_server_aclmask(), pg_get_constraintdef_worker(), pg_get_function_arg_default(), pg_get_functiondef(), pg_get_indexdef_worker(), pg_get_partkeydef_worker(), pg_get_statisticsobj_worker(), pg_language_aclmask(), pg_namespace_aclmask(), pg_proc_aclmask(), pg_tablespace_aclmask(), pg_type_aclmask(), plsample_func_handler(), PLy_procedure_create(), prepare_sql_fn_parse_info(), preprocess_aggref(), print_function_arguments(), ProcedureCreate(), recordExtObjInitPriv(), refresh_by_match_merge(), RelationBuildPartitionDesc(), RelationBuildPartitionKey(), SetDefaultACL(), statext_dependencies_load(), statext_mcv_load(), statext_ndistinct_load(), StorePartitionBound(), test_indoption(), transformFkeyCheckAttrs(), transformFkeyGetPrimaryKey(), transformIndexConstraint(), and TryReuseForeignKey().

1391 {
1392  /*
1393  * We just need to get the TupleDesc out of the cache entry, and then we
1394  * can apply heap_getattr(). Normally the cache control data is already
1395  * valid (because the caller recently fetched the tuple via this same
1396  * cache), but there are cases where we have to initialize the cache here.
1397  */
1398  if (cacheId < 0 || cacheId >= SysCacheSize ||
1399  !PointerIsValid(SysCache[cacheId]))
1400  elog(ERROR, "invalid cache ID: %d", cacheId);
1401  if (!PointerIsValid(SysCache[cacheId]->cc_tupdesc))
1402  {
1403  InitCatCachePhase2(SysCache[cacheId], false);
1404  Assert(PointerIsValid(SysCache[cacheId]->cc_tupdesc));
1405  }
1406 
1407  return heap_getattr(tup, attributeNumber,
1408  SysCache[cacheId]->cc_tupdesc,
1409  isNull);
1410 }
#define SysCacheSize
Definition: syscache.h:114
#define ERROR
Definition: elog.h:45
#define heap_getattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:762
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define Assert(condition)
Definition: c.h:792
#define elog(elevel,...)
Definition: elog.h:228
void InitCatCachePhase2(CatCache *cache, bool touch_index)
Definition: catcache.c:1032
#define PointerIsValid(pointer)
Definition: c.h:686

◆ SysCacheInvalidate()

void SysCacheInvalidate ( int  cacheId,
uint32  hashValue 
)

Definition at line 1460 of file syscache.c.

References CatCacheInvalidate(), elog, ERROR, PointerIsValid, and SysCacheSize.

Referenced by LocalExecuteInvalidationMessage().

1461 {
1462  if (cacheId < 0 || cacheId >= SysCacheSize)
1463  elog(ERROR, "invalid cache ID: %d", cacheId);
1464 
1465  /* if this cache isn't initialized yet, no need to do anything */
1466  if (!PointerIsValid(SysCache[cacheId]))
1467  return;
1468 
1469  CatCacheInvalidate(SysCache[cacheId], hashValue);
1470 }
void CatCacheInvalidate(CatCache *cache, uint32 hashValue)
Definition: catcache.c:552
#define SysCacheSize
Definition: syscache.h:114
#define ERROR
Definition: elog.h:45
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define elog(elevel,...)
Definition: elog.h:228
#define PointerIsValid(pointer)
Definition: c.h:686

Variable Documentation

◆ cacheinfo

const struct cachedesc cacheinfo[]
static

Definition at line 123 of file syscache.c.

◆ CacheInitialized

bool CacheInitialized = false
static

Definition at line 999 of file syscache.c.

Referenced by InitCatalogCache(), and InitCatalogCachePhase2().

◆ SysCache

CatCache* SysCache[SysCacheSize]
static

Definition at line 997 of file syscache.c.

◆ SysCacheRelationOid

Oid SysCacheRelationOid[SysCacheSize]
static

Definition at line 1002 of file syscache.c.

Referenced by InitCatalogCache(), and RelationHasSysCache().

◆ SysCacheRelationOidSize

int SysCacheRelationOidSize
static

Definition at line 1003 of file syscache.c.

Referenced by InitCatalogCache(), and RelationHasSysCache().

◆ SysCacheSupportingRelOid

Oid SysCacheSupportingRelOid[SysCacheSize *2]
static

Definition at line 1006 of file syscache.c.

Referenced by InitCatalogCache(), and RelationSupportsSysCache().

◆ SysCacheSupportingRelOidSize

int SysCacheSupportingRelOidSize
static

Definition at line 1007 of file syscache.c.

Referenced by InitCatalogCache(), and RelationSupportsSysCache().