PostgreSQL Source Code  git master
syscache.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * syscache.c
4  * System cache management routines
5  *
6  * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  *
10  * IDENTIFICATION
11  * src/backend/utils/cache/syscache.c
12  *
13  * NOTES
14  * These routines allow the parser/planner/executor to perform
15  * rapid lookups on the contents of the system catalogs.
16  *
17  * see utils/syscache.h for a list of the cache IDs
18  *
19  *-------------------------------------------------------------------------
20  */
21 #include "postgres.h"
22 
23 #include "access/htup_details.h"
24 #include "access/sysattr.h"
25 #include "catalog/pg_aggregate.h"
26 #include "catalog/pg_am.h"
27 #include "catalog/pg_amop.h"
28 #include "catalog/pg_amproc.h"
30 #include "catalog/pg_authid.h"
31 #include "catalog/pg_cast.h"
32 #include "catalog/pg_collation.h"
33 #include "catalog/pg_constraint.h"
34 #include "catalog/pg_conversion.h"
35 #include "catalog/pg_database.h"
37 #include "catalog/pg_default_acl.h"
38 #include "catalog/pg_depend.h"
39 #include "catalog/pg_description.h"
40 #include "catalog/pg_enum.h"
45 #include "catalog/pg_language.h"
46 #include "catalog/pg_namespace.h"
47 #include "catalog/pg_opclass.h"
48 #include "catalog/pg_operator.h"
49 #include "catalog/pg_opfamily.h"
51 #include "catalog/pg_proc.h"
52 #include "catalog/pg_publication.h"
54 #include "catalog/pg_range.h"
56 #include "catalog/pg_rewrite.h"
57 #include "catalog/pg_seclabel.h"
58 #include "catalog/pg_sequence.h"
59 #include "catalog/pg_shdepend.h"
61 #include "catalog/pg_shseclabel.h"
62 #include "catalog/pg_statistic.h"
67 #include "catalog/pg_tablespace.h"
68 #include "catalog/pg_transform.h"
69 #include "catalog/pg_ts_config.h"
71 #include "catalog/pg_ts_dict.h"
72 #include "catalog/pg_ts_parser.h"
73 #include "catalog/pg_ts_template.h"
74 #include "catalog/pg_type.h"
76 #include "lib/qunique.h"
77 #include "utils/catcache.h"
78 #include "utils/rel.h"
79 #include "utils/syscache.h"
80 
81 /*---------------------------------------------------------------------------
82 
83  Adding system caches:
84 
85  Add your new cache to the list in include/utils/syscache.h.
86  Keep the list sorted alphabetically.
87 
88  Add your entry to the cacheinfo[] array below. All cache lists are
89  alphabetical, so add it in the proper place. Specify the relation OID,
90  index OID, number of keys, key attribute numbers, and initial number of
91  hash buckets.
92 
93  The number of hash buckets must be a power of 2. It's reasonable to
94  set this to the number of entries that might be in the particular cache
95  in a medium-size database.
96 
97  There must be a unique index underlying each syscache (ie, an index
98  whose key is the same as that of the cache). If there is not one
99  already, add definitions for it to include/catalog/pg_*.h: you need
100  to add a DECLARE_UNIQUE_INDEX macro and a #define for the index OID.
101  (Adding an index requires a catversion.h update, while simply
102  adding/deleting caches only requires a recompile.)
103 
104  Finally, any place your relation gets heap_insert() or
105  heap_update() calls, use CatalogTupleInsert() or CatalogTupleUpdate()
106  instead, which also update indexes. The heap_* calls do not do that.
107 
108 *---------------------------------------------------------------------------
109 */
110 
111 /*
112  * struct cachedesc: information defining a single syscache
113  */
114 struct cachedesc
115 {
116  Oid reloid; /* OID of the relation being cached */
117  Oid indoid; /* OID of index relation for this cache */
118  int nkeys; /* # of keys needed for cache lookup */
119  int key[4]; /* attribute numbers of key attrs */
120  int nbuckets; /* number of hash buckets for this cache */
121 };
122 
123 static const struct cachedesc cacheinfo[] = {
124  {AggregateRelationId, /* AGGFNOID */
126  1,
127  {
128  Anum_pg_aggregate_aggfnoid,
129  0,
130  0,
131  0
132  },
133  16
134  },
135  {AccessMethodRelationId, /* AMNAME */
137  1,
138  {
139  Anum_pg_am_amname,
140  0,
141  0,
142  0
143  },
144  4
145  },
146  {AccessMethodRelationId, /* AMOID */
147  AmOidIndexId,
148  1,
149  {
150  Anum_pg_am_oid,
151  0,
152  0,
153  0
154  },
155  4
156  },
157  {AccessMethodOperatorRelationId, /* AMOPOPID */
159  3,
160  {
161  Anum_pg_amop_amopopr,
162  Anum_pg_amop_amoppurpose,
163  Anum_pg_amop_amopfamily,
164  0
165  },
166  64
167  },
168  {AccessMethodOperatorRelationId, /* AMOPSTRATEGY */
170  4,
171  {
172  Anum_pg_amop_amopfamily,
173  Anum_pg_amop_amoplefttype,
174  Anum_pg_amop_amoprighttype,
175  Anum_pg_amop_amopstrategy
176  },
177  64
178  },
179  {AccessMethodProcedureRelationId, /* AMPROCNUM */
181  4,
182  {
183  Anum_pg_amproc_amprocfamily,
184  Anum_pg_amproc_amproclefttype,
185  Anum_pg_amproc_amprocrighttype,
186  Anum_pg_amproc_amprocnum
187  },
188  16
189  },
190  {AttributeRelationId, /* ATTNAME */
192  2,
193  {
194  Anum_pg_attribute_attrelid,
195  Anum_pg_attribute_attname,
196  0,
197  0
198  },
199  32
200  },
201  {AttributeRelationId, /* ATTNUM */
203  2,
204  {
205  Anum_pg_attribute_attrelid,
206  Anum_pg_attribute_attnum,
207  0,
208  0
209  },
210  128
211  },
212  {AuthMemRelationId, /* AUTHMEMMEMROLE */
214  2,
215  {
216  Anum_pg_auth_members_member,
217  Anum_pg_auth_members_roleid,
218  0,
219  0
220  },
221  8
222  },
223  {AuthMemRelationId, /* AUTHMEMROLEMEM */
225  2,
226  {
227  Anum_pg_auth_members_roleid,
228  Anum_pg_auth_members_member,
229  0,
230  0
231  },
232  8
233  },
234  {AuthIdRelationId, /* AUTHNAME */
236  1,
237  {
238  Anum_pg_authid_rolname,
239  0,
240  0,
241  0
242  },
243  8
244  },
245  {AuthIdRelationId, /* AUTHOID */
247  1,
248  {
249  Anum_pg_authid_oid,
250  0,
251  0,
252  0
253  },
254  8
255  },
256  {
257  CastRelationId, /* CASTSOURCETARGET */
259  2,
260  {
261  Anum_pg_cast_castsource,
262  Anum_pg_cast_casttarget,
263  0,
264  0
265  },
266  256
267  },
268  {OperatorClassRelationId, /* CLAAMNAMENSP */
270  3,
271  {
272  Anum_pg_opclass_opcmethod,
273  Anum_pg_opclass_opcname,
274  Anum_pg_opclass_opcnamespace,
275  0
276  },
277  8
278  },
279  {OperatorClassRelationId, /* CLAOID */
281  1,
282  {
283  Anum_pg_opclass_oid,
284  0,
285  0,
286  0
287  },
288  8
289  },
290  {CollationRelationId, /* COLLNAMEENCNSP */
292  3,
293  {
294  Anum_pg_collation_collname,
295  Anum_pg_collation_collencoding,
296  Anum_pg_collation_collnamespace,
297  0
298  },
299  8
300  },
301  {CollationRelationId, /* COLLOID */
303  1,
304  {
305  Anum_pg_collation_oid,
306  0,
307  0,
308  0
309  },
310  8
311  },
312  {ConversionRelationId, /* CONDEFAULT */
314  4,
315  {
316  Anum_pg_conversion_connamespace,
317  Anum_pg_conversion_conforencoding,
318  Anum_pg_conversion_contoencoding,
319  Anum_pg_conversion_oid
320  },
321  8
322  },
323  {ConversionRelationId, /* CONNAMENSP */
325  2,
326  {
327  Anum_pg_conversion_conname,
328  Anum_pg_conversion_connamespace,
329  0,
330  0
331  },
332  8
333  },
334  {ConstraintRelationId, /* CONSTROID */
336  1,
337  {
338  Anum_pg_constraint_oid,
339  0,
340  0,
341  0
342  },
343  16
344  },
345  {ConversionRelationId, /* CONVOID */
347  1,
348  {
349  Anum_pg_conversion_oid,
350  0,
351  0,
352  0
353  },
354  8
355  },
356  {DatabaseRelationId, /* DATABASEOID */
358  1,
359  {
360  Anum_pg_database_oid,
361  0,
362  0,
363  0
364  },
365  4
366  },
367  {DefaultAclRelationId, /* DEFACLROLENSPOBJ */
369  3,
370  {
371  Anum_pg_default_acl_defaclrole,
372  Anum_pg_default_acl_defaclnamespace,
373  Anum_pg_default_acl_defaclobjtype,
374  0
375  },
376  8
377  },
378  {EnumRelationId, /* ENUMOID */
380  1,
381  {
382  Anum_pg_enum_oid,
383  0,
384  0,
385  0
386  },
387  8
388  },
389  {EnumRelationId, /* ENUMTYPOIDNAME */
391  2,
392  {
393  Anum_pg_enum_enumtypid,
394  Anum_pg_enum_enumlabel,
395  0,
396  0
397  },
398  8
399  },
400  {EventTriggerRelationId, /* EVENTTRIGGERNAME */
402  1,
403  {
404  Anum_pg_event_trigger_evtname,
405  0,
406  0,
407  0
408  },
409  8
410  },
411  {EventTriggerRelationId, /* EVENTTRIGGEROID */
413  1,
414  {
415  Anum_pg_event_trigger_oid,
416  0,
417  0,
418  0
419  },
420  8
421  },
422  {ForeignDataWrapperRelationId, /* FOREIGNDATAWRAPPERNAME */
424  1,
425  {
426  Anum_pg_foreign_data_wrapper_fdwname,
427  0,
428  0,
429  0
430  },
431  2
432  },
433  {ForeignDataWrapperRelationId, /* FOREIGNDATAWRAPPEROID */
435  1,
436  {
437  Anum_pg_foreign_data_wrapper_oid,
438  0,
439  0,
440  0
441  },
442  2
443  },
444  {ForeignServerRelationId, /* FOREIGNSERVERNAME */
446  1,
447  {
448  Anum_pg_foreign_server_srvname,
449  0,
450  0,
451  0
452  },
453  2
454  },
455  {ForeignServerRelationId, /* FOREIGNSERVEROID */
457  1,
458  {
459  Anum_pg_foreign_server_oid,
460  0,
461  0,
462  0
463  },
464  2
465  },
466  {ForeignTableRelationId, /* FOREIGNTABLEREL */
468  1,
469  {
470  Anum_pg_foreign_table_ftrelid,
471  0,
472  0,
473  0
474  },
475  4
476  },
477  {IndexRelationId, /* INDEXRELID */
479  1,
480  {
481  Anum_pg_index_indexrelid,
482  0,
483  0,
484  0
485  },
486  64
487  },
488  {LanguageRelationId, /* LANGNAME */
490  1,
491  {
492  Anum_pg_language_lanname,
493  0,
494  0,
495  0
496  },
497  4
498  },
499  {LanguageRelationId, /* LANGOID */
501  1,
502  {
503  Anum_pg_language_oid,
504  0,
505  0,
506  0
507  },
508  4
509  },
510  {NamespaceRelationId, /* NAMESPACENAME */
512  1,
513  {
514  Anum_pg_namespace_nspname,
515  0,
516  0,
517  0
518  },
519  4
520  },
521  {NamespaceRelationId, /* NAMESPACEOID */
523  1,
524  {
525  Anum_pg_namespace_oid,
526  0,
527  0,
528  0
529  },
530  16
531  },
532  {OperatorRelationId, /* OPERNAMENSP */
534  4,
535  {
536  Anum_pg_operator_oprname,
537  Anum_pg_operator_oprleft,
538  Anum_pg_operator_oprright,
539  Anum_pg_operator_oprnamespace
540  },
541  256
542  },
543  {OperatorRelationId, /* OPEROID */
545  1,
546  {
547  Anum_pg_operator_oid,
548  0,
549  0,
550  0
551  },
552  32
553  },
554  {OperatorFamilyRelationId, /* OPFAMILYAMNAMENSP */
556  3,
557  {
558  Anum_pg_opfamily_opfmethod,
559  Anum_pg_opfamily_opfname,
560  Anum_pg_opfamily_opfnamespace,
561  0
562  },
563  8
564  },
565  {OperatorFamilyRelationId, /* OPFAMILYOID */
567  1,
568  {
569  Anum_pg_opfamily_oid,
570  0,
571  0,
572  0
573  },
574  8
575  },
576  {PartitionedRelationId, /* PARTRELID */
578  1,
579  {
580  Anum_pg_partitioned_table_partrelid,
581  0,
582  0,
583  0
584  },
585  32
586  },
587  {ProcedureRelationId, /* PROCNAMEARGSNSP */
589  3,
590  {
591  Anum_pg_proc_proname,
592  Anum_pg_proc_proargtypes,
593  Anum_pg_proc_pronamespace,
594  0
595  },
596  128
597  },
598  {ProcedureRelationId, /* PROCOID */
600  1,
601  {
602  Anum_pg_proc_oid,
603  0,
604  0,
605  0
606  },
607  128
608  },
609  {PublicationRelationId, /* PUBLICATIONNAME */
611  1,
612  {
613  Anum_pg_publication_pubname,
614  0,
615  0,
616  0
617  },
618  8
619  },
620  {PublicationRelationId, /* PUBLICATIONOID */
622  1,
623  {
624  Anum_pg_publication_oid,
625  0,
626  0,
627  0
628  },
629  8
630  },
631  {PublicationRelRelationId, /* PUBLICATIONREL */
633  1,
634  {
635  Anum_pg_publication_rel_oid,
636  0,
637  0,
638  0
639  },
640  64
641  },
642  {PublicationRelRelationId, /* PUBLICATIONRELMAP */
644  2,
645  {
646  Anum_pg_publication_rel_prrelid,
647  Anum_pg_publication_rel_prpubid,
648  0,
649  0
650  },
651  64
652  },
653  {RangeRelationId, /* RANGEMULTIRANGE */
655  1,
656  {
657  Anum_pg_range_rngmultitypid,
658  0,
659  0,
660  0
661  },
662  4
663  },
664 
665  {RangeRelationId, /* RANGETYPE */
667  1,
668  {
669  Anum_pg_range_rngtypid,
670  0,
671  0,
672  0
673  },
674  4
675  },
676  {RelationRelationId, /* RELNAMENSP */
678  2,
679  {
680  Anum_pg_class_relname,
681  Anum_pg_class_relnamespace,
682  0,
683  0
684  },
685  128
686  },
687  {RelationRelationId, /* RELOID */
689  1,
690  {
691  Anum_pg_class_oid,
692  0,
693  0,
694  0
695  },
696  128
697  },
698  {ReplicationOriginRelationId, /* REPLORIGIDENT */
700  1,
701  {
702  Anum_pg_replication_origin_roident,
703  0,
704  0,
705  0
706  },
707  16
708  },
709  {ReplicationOriginRelationId, /* REPLORIGNAME */
711  1,
712  {
713  Anum_pg_replication_origin_roname,
714  0,
715  0,
716  0
717  },
718  16
719  },
720  {RewriteRelationId, /* RULERELNAME */
722  2,
723  {
724  Anum_pg_rewrite_ev_class,
725  Anum_pg_rewrite_rulename,
726  0,
727  0
728  },
729  8
730  },
731  {SequenceRelationId, /* SEQRELID */
733  1,
734  {
735  Anum_pg_sequence_seqrelid,
736  0,
737  0,
738  0
739  },
740  32
741  },
742  {StatisticExtDataRelationId, /* STATEXTDATASTXOID */
744  1,
745  {
746  Anum_pg_statistic_ext_data_stxoid,
747  0,
748  0,
749  0
750  },
751  4
752  },
753  {StatisticExtRelationId, /* STATEXTNAMENSP */
755  2,
756  {
757  Anum_pg_statistic_ext_stxname,
758  Anum_pg_statistic_ext_stxnamespace,
759  0,
760  0
761  },
762  4
763  },
764  {StatisticExtRelationId, /* STATEXTOID */
766  1,
767  {
768  Anum_pg_statistic_ext_oid,
769  0,
770  0,
771  0
772  },
773  4
774  },
775  {StatisticRelationId, /* STATRELATTINH */
777  3,
778  {
779  Anum_pg_statistic_starelid,
780  Anum_pg_statistic_staattnum,
781  Anum_pg_statistic_stainherit,
782  0
783  },
784  128
785  },
786  {SubscriptionRelationId, /* SUBSCRIPTIONNAME */
788  2,
789  {
790  Anum_pg_subscription_subdbid,
791  Anum_pg_subscription_subname,
792  0,
793  0
794  },
795  4
796  },
797  {SubscriptionRelationId, /* SUBSCRIPTIONOID */
799  1,
800  {
801  Anum_pg_subscription_oid,
802  0,
803  0,
804  0
805  },
806  4
807  },
808  {SubscriptionRelRelationId, /* SUBSCRIPTIONRELMAP */
810  2,
811  {
812  Anum_pg_subscription_rel_srrelid,
813  Anum_pg_subscription_rel_srsubid,
814  0,
815  0
816  },
817  64
818  },
819  {TableSpaceRelationId, /* TABLESPACEOID */
821  1,
822  {
823  Anum_pg_tablespace_oid,
824  0,
825  0,
826  0,
827  },
828  4
829  },
830  {TransformRelationId, /* TRFOID */
832  1,
833  {
834  Anum_pg_transform_oid,
835  0,
836  0,
837  0,
838  },
839  16
840  },
841  {TransformRelationId, /* TRFTYPELANG */
843  2,
844  {
845  Anum_pg_transform_trftype,
846  Anum_pg_transform_trflang,
847  0,
848  0,
849  },
850  16
851  },
852  {TSConfigMapRelationId, /* TSCONFIGMAP */
854  3,
855  {
856  Anum_pg_ts_config_map_mapcfg,
857  Anum_pg_ts_config_map_maptokentype,
858  Anum_pg_ts_config_map_mapseqno,
859  0
860  },
861  2
862  },
863  {TSConfigRelationId, /* TSCONFIGNAMENSP */
865  2,
866  {
867  Anum_pg_ts_config_cfgname,
868  Anum_pg_ts_config_cfgnamespace,
869  0,
870  0
871  },
872  2
873  },
874  {TSConfigRelationId, /* TSCONFIGOID */
876  1,
877  {
878  Anum_pg_ts_config_oid,
879  0,
880  0,
881  0
882  },
883  2
884  },
885  {TSDictionaryRelationId, /* TSDICTNAMENSP */
887  2,
888  {
889  Anum_pg_ts_dict_dictname,
890  Anum_pg_ts_dict_dictnamespace,
891  0,
892  0
893  },
894  2
895  },
896  {TSDictionaryRelationId, /* TSDICTOID */
898  1,
899  {
900  Anum_pg_ts_dict_oid,
901  0,
902  0,
903  0
904  },
905  2
906  },
907  {TSParserRelationId, /* TSPARSERNAMENSP */
909  2,
910  {
911  Anum_pg_ts_parser_prsname,
912  Anum_pg_ts_parser_prsnamespace,
913  0,
914  0
915  },
916  2
917  },
918  {TSParserRelationId, /* TSPARSEROID */
920  1,
921  {
922  Anum_pg_ts_parser_oid,
923  0,
924  0,
925  0
926  },
927  2
928  },
929  {TSTemplateRelationId, /* TSTEMPLATENAMENSP */
931  2,
932  {
933  Anum_pg_ts_template_tmplname,
934  Anum_pg_ts_template_tmplnamespace,
935  0,
936  0
937  },
938  2
939  },
940  {TSTemplateRelationId, /* TSTEMPLATEOID */
942  1,
943  {
944  Anum_pg_ts_template_oid,
945  0,
946  0,
947  0
948  },
949  2
950  },
951  {TypeRelationId, /* TYPENAMENSP */
953  2,
954  {
955  Anum_pg_type_typname,
956  Anum_pg_type_typnamespace,
957  0,
958  0
959  },
960  64
961  },
962  {TypeRelationId, /* TYPEOID */
964  1,
965  {
966  Anum_pg_type_oid,
967  0,
968  0,
969  0
970  },
971  64
972  },
973  {UserMappingRelationId, /* USERMAPPINGOID */
975  1,
976  {
977  Anum_pg_user_mapping_oid,
978  0,
979  0,
980  0
981  },
982  2
983  },
984  {UserMappingRelationId, /* USERMAPPINGUSERSERVER */
986  2,
987  {
988  Anum_pg_user_mapping_umuser,
989  Anum_pg_user_mapping_umserver,
990  0,
991  0
992  },
993  2
994  }
995 };
996 
998 
999 static bool CacheInitialized = false;
1000 
1001 /* Sorted array of OIDs of tables that have caches on them */
1004 
1005 /* Sorted array of OIDs of tables and indexes used by caches */
1008 
1009 static int oid_compare(const void *a, const void *b);
1010 
1011 
1012 /*
1013  * InitCatalogCache - initialize the caches
1014  *
1015  * Note that no database access is done here; we only allocate memory
1016  * and initialize the cache structure. Interrogation of the database
1017  * to complete initialization of a cache happens upon first use
1018  * of that cache.
1019  */
1020 void
1022 {
1023  int cacheId;
1024 
1025  StaticAssertStmt(SysCacheSize == (int) lengthof(cacheinfo),
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 */
1051  Assert(!RelationInvalidatesSnapshotsOnly(cacheinfo[cacheId].reloid));
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 }
1072 
1073 /*
1074  * InitCatalogCachePhase2 - finish initializing the caches
1075  *
1076  * Finish initializing all the caches, including necessary database
1077  * access.
1078  *
1079  * This is *not* essential; normally we allow syscaches to be initialized
1080  * on first use. However, it is useful as a mechanism to preload the
1081  * relcache with entries for the most-commonly-used system catalogs.
1082  * Therefore, we invoke this routine when we need to write a new relcache
1083  * init file.
1084  */
1085 void
1087 {
1088  int cacheId;
1089 
1091 
1092  for (cacheId = 0; cacheId < SysCacheSize; cacheId++)
1093  InitCatCachePhase2(SysCache[cacheId], true);
1094 }
1095 
1096 
1097 /*
1098  * SearchSysCache
1099  *
1100  * A layer on top of SearchCatCache that does the initialization and
1101  * key-setting for you.
1102  *
1103  * Returns the cache copy of the tuple if one is found, NULL if not.
1104  * The tuple is the 'cache' copy and must NOT be modified!
1105  *
1106  * When the caller is done using the tuple, call ReleaseSysCache()
1107  * to release the reference count grabbed by SearchSysCache(). If this
1108  * is not done, the tuple will remain locked in cache until end of
1109  * transaction, which is tolerable but not desirable.
1110  *
1111  * CAUTION: The tuple that is returned must NOT be freed by the caller!
1112  */
1113 HeapTuple
1114 SearchSysCache(int cacheId,
1115  Datum key1,
1116  Datum key2,
1117  Datum key3,
1118  Datum key4)
1119 {
1120  Assert(cacheId >= 0 && cacheId < SysCacheSize &&
1121  PointerIsValid(SysCache[cacheId]));
1122 
1123  return SearchCatCache(SysCache[cacheId], key1, key2, key3, key4);
1124 }
1125 
1126 HeapTuple
1127 SearchSysCache1(int cacheId,
1128  Datum key1)
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 }
1136 
1137 HeapTuple
1138 SearchSysCache2(int cacheId,
1139  Datum key1, Datum key2)
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 }
1147 
1148 HeapTuple
1149 SearchSysCache3(int cacheId,
1150  Datum key1, Datum key2, Datum key3)
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 }
1158 
1159 HeapTuple
1160 SearchSysCache4(int cacheId,
1161  Datum key1, Datum key2, Datum key3, Datum key4)
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 }
1169 
1170 /*
1171  * ReleaseSysCache
1172  * Release previously grabbed reference count on a tuple
1173  */
1174 void
1176 {
1177  ReleaseCatCache(tuple);
1178 }
1179 
1180 /*
1181  * SearchSysCacheCopy
1182  *
1183  * A convenience routine that does SearchSysCache and (if successful)
1184  * returns a modifiable copy of the syscache entry. The original
1185  * syscache entry is released before returning. The caller should
1186  * heap_freetuple() the result when done with it.
1187  */
1188 HeapTuple
1190  Datum key1,
1191  Datum key2,
1192  Datum key3,
1193  Datum key4)
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 }
1205 
1206 /*
1207  * SearchSysCacheExists
1208  *
1209  * A convenience routine that just probes to see if a tuple can be found.
1210  * No lock is retained on the syscache entry.
1211  */
1212 bool
1214  Datum key1,
1215  Datum key2,
1216  Datum key3,
1217  Datum key4)
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 }
1227 
1228 /*
1229  * GetSysCacheOid
1230  *
1231  * A convenience routine that does SearchSysCache and returns the OID in the
1232  * oidcol column of the found tuple, or InvalidOid if no tuple could be found.
1233  * No lock is retained on the syscache entry.
1234  */
1235 Oid
1236 GetSysCacheOid(int cacheId,
1237  AttrNumber oidcol,
1238  Datum key1,
1239  Datum key2,
1240  Datum key3,
1241  Datum key4)
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 }
1257 
1258 
1259 /*
1260  * SearchSysCacheAttName
1261  *
1262  * This routine is equivalent to SearchSysCache on the ATTNAME cache,
1263  * except that it will return NULL if the found attribute is marked
1264  * attisdropped. This is convenient for callers that want to act as
1265  * though dropped attributes don't exist.
1266  */
1267 HeapTuple
1268 SearchSysCacheAttName(Oid relid, const char *attname)
1269 {
1270  HeapTuple tuple;
1271 
1272  tuple = SearchSysCache2(ATTNAME,
1273  ObjectIdGetDatum(relid),
1274  CStringGetDatum(attname));
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 }
1284 
1285 /*
1286  * SearchSysCacheCopyAttName
1287  *
1288  * As above, an attisdropped-aware version of SearchSysCacheCopy.
1289  */
1290 HeapTuple
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 }
1303 
1304 /*
1305  * SearchSysCacheExistsAttName
1306  *
1307  * As above, an attisdropped-aware version of SearchSysCacheExists.
1308  */
1309 bool
1311 {
1312  HeapTuple tuple;
1313 
1314  tuple = SearchSysCacheAttName(relid, attname);
1315  if (!HeapTupleIsValid(tuple))
1316  return false;
1317  ReleaseSysCache(tuple);
1318  return true;
1319 }
1320 
1321 
1322 /*
1323  * SearchSysCacheAttNum
1324  *
1325  * This routine is equivalent to SearchSysCache on the ATTNUM cache,
1326  * except that it will return NULL if the found attribute is marked
1327  * attisdropped. This is convenient for callers that want to act as
1328  * though dropped attributes don't exist.
1329  */
1330 HeapTuple
1332 {
1333  HeapTuple tuple;
1334 
1335  tuple = SearchSysCache2(ATTNUM,
1336  ObjectIdGetDatum(relid),
1337  Int16GetDatum(attnum));
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 }
1347 
1348 /*
1349  * SearchSysCacheCopyAttNum
1350  *
1351  * As above, an attisdropped-aware version of SearchSysCacheCopy.
1352  */
1353 HeapTuple
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 }
1366 
1367 
1368 /*
1369  * SysCacheGetAttr
1370  *
1371  * Given a tuple previously fetched by SearchSysCache(),
1372  * extract a specific attribute.
1373  *
1374  * This is equivalent to using heap_getattr() on a tuple fetched
1375  * from a non-cached relation. Usually, this is only used for attributes
1376  * that could be NULL or variable length; the fixed-size attributes in
1377  * a system table are accessed just by mapping the tuple onto the C struct
1378  * declarations from include/catalog/.
1379  *
1380  * As with heap_getattr(), if the attribute is of a pass-by-reference type
1381  * then a pointer into the tuple data area is returned --- the caller must
1382  * not modify or pfree the datum!
1383  *
1384  * Note: it is legal to use SysCacheGetAttr() with a cacheId referencing
1385  * a different cache for the same catalog the tuple was fetched from.
1386  */
1387 Datum
1388 SysCacheGetAttr(int cacheId, HeapTuple tup,
1389  AttrNumber attributeNumber,
1390  bool *isNull)
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 }
1411 
1412 /*
1413  * GetSysCacheHashValue
1414  *
1415  * Get the hash value that would be used for a tuple in the specified cache
1416  * with the given search keys.
1417  *
1418  * The reason for exposing this as part of the API is that the hash value is
1419  * exposed in cache invalidation operations, so there are places outside the
1420  * catcache code that need to be able to compute the hash values.
1421  */
1422 uint32
1424  Datum key1,
1425  Datum key2,
1426  Datum key3,
1427  Datum key4)
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 }
1435 
1436 /*
1437  * List-search interface
1438  */
1439 struct catclist *
1440 SearchSysCacheList(int cacheId, int nkeys,
1441  Datum key1, Datum key2, Datum key3)
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 }
1450 
1451 /*
1452  * SysCacheInvalidate
1453  *
1454  * Invalidate entries in the specified cache, given a hash value.
1455  * See CatCacheInvalidate() for more info.
1456  *
1457  * This routine is only quasi-public: it should only be used by inval.c.
1458  */
1459 void
1460 SysCacheInvalidate(int cacheId, uint32 hashValue)
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 }
1471 
1472 /*
1473  * Certain relations that do not have system caches send snapshot invalidation
1474  * messages in lieu of catcache messages. This is for the benefit of
1475  * GetCatalogSnapshot(), which can then reuse its existing MVCC snapshot
1476  * for scanning one of those catalogs, rather than taking a new one, if no
1477  * invalidation has been received.
1478  *
1479  * Relations that have syscaches need not (and must not) be listed here. The
1480  * catcache invalidation messages will also flush the snapshot. If you add a
1481  * syscache for one of these relations, remove it from this list.
1482  */
1483 bool
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 }
1502 
1503 /*
1504  * Test whether a relation has a system cache.
1505  */
1506 bool
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 }
1526 
1527 /*
1528  * Test whether a relation supports a system cache, ie it is either a
1529  * cached table or the index used for a cache.
1530  */
1531 bool
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 }
1551 
1552 
1553 /*
1554  * OID comparator for pg_qsort
1555  */
1556 static int
1557 oid_compare(const void *a, const void *b)
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 }
HeapTuple SearchSysCache(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1114
#define EnumOidIndexId
Definition: pg_enum.h:47
signed short int16
Definition: c.h:428
HeapTuple heap_copytuple(HeapTuple tuple)
Definition: heaptuple.c:680
#define TransformOidIndexId
Definition: pg_transform.h:46
#define OpclassAmNameNspIndexId
Definition: pg_opclass.h:86
#define TSTemplateOidIndexId
static bool CacheInitialized
Definition: syscache.c:999
HeapTuple SearchSysCacheAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1331
bool RelationHasSysCache(Oid relid)
Definition: syscache.c:1507
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
#define ForeignServerNameIndexId
static int SysCacheSupportingRelOidSize
Definition: syscache.c:1007
void CatCacheInvalidate(CatCache *cache, uint32 hashValue)
Definition: catcache.c:552
static Oid SysCacheSupportingRelOid[SysCacheSize *2]
Definition: syscache.c:1006
#define StatisticExtOidIndexId
#define OpfamilyOidIndexId
Definition: pg_opfamily.h:56
#define IndexRelidIndexId
Definition: pg_index.h:74
#define NamespaceOidIndexId
Definition: pg_namespace.h:59
#define ClassNameNspIndexId
Definition: pg_class.h:158
#define ForeignDataWrapperOidIndexId
#define TypeOidIndexId
Definition: pg_type.h:266
#define Int16GetDatum(X)
Definition: postgres.h:495
#define ConversionNameNspIndexId
Definition: pg_conversion.h:66
#define AccessMethodOperatorIndexId
Definition: pg_amop.h:93
#define ForeignServerOidIndexId
static int SysCacheRelationOidSize
Definition: syscache.c:1003
#define RangeTypidIndexId
Definition: pg_range.h:61
#define lengthof(array)
Definition: c.h:734
#define ReplicationOriginIdentIndex
#define AttributeRelidNameIndexId
Definition: pg_attribute.h:206
unsigned int Oid
Definition: postgres_ext.h:31
#define ClassOidIndexId
Definition: pg_class.h:156
#define PublicationRelObjectIndexId
bool SearchSysCacheExistsAttName(Oid relid, const char *attname)
Definition: syscache.c:1310
#define AccessMethodStrategyIndexId
Definition: pg_amop.h:91
static const struct cachedesc cacheinfo[]
Definition: syscache.c:123
bool SearchSysCacheExists(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1213
#define AuthMemMemRoleIndexId
#define OperatorOidIndexId
Definition: pg_operator.h:86
#define EnumTypIdLabelIndexId
Definition: pg_enum.h:49
Oid reloid
Definition: syscache.c:116
#define StaticAssertStmt(condition, errmessage)
Definition: c.h:918
#define StatisticExtDataStxoidIndexId
#define LanguageOidIndexId
Definition: pg_language.h:72
#define TSDictionaryNameNspIndexId
Definition: pg_ts_dict.h:57
#define CollationOidIndexId
Definition: pg_collation.h:63
#define SysCacheSize
Definition: syscache.h:114
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
NameData attname
Definition: pg_attribute.h:41
#define TypeNameNspIndexId
Definition: pg_type.h:268
Oid GetSysCacheOid(int cacheId, AttrNumber oidcol, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1236
#define ReplicationOriginNameIndex
HeapTuple SearchSysCache3(int cacheId, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1149
HeapTuple SearchSysCacheCopyAttName(Oid relid, const char *attname)
Definition: syscache.c:1291
#define ConstraintOidIndexId
#define ConversionDefaultIndexId
Definition: pg_conversion.h:64
#define StatisticExtNameIndexId
HeapTuple SearchSysCacheCopyAttNum(Oid relid, int16 attnum)
Definition: syscache.c:1354
#define AttributeRelidNumIndexId
Definition: pg_attribute.h:208
#define SubscriptionObjectIndexId
#define LanguageNameIndexId
Definition: pg_language.h:70
int nbuckets
Definition: syscache.c:120
#define CStringGetDatum(X)
Definition: postgres.h:622
HeapTuple SearchCatCache4(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4)
Definition: catcache.c:1190
struct catclist * SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3)
Definition: syscache.c:1440
#define EventTriggerOidIndexId
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:203
unsigned int uint32
Definition: c.h:441
HeapTuple SearchSysCache4(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1160
#define OpclassOidIndexId
Definition: pg_opclass.h:88
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
#define ForeignTableRelidIndexId
#define ConversionOidIndexId
Definition: pg_conversion.h:68
#define TSConfigNameNspIndexId
Definition: pg_ts_config.h:51
#define DatabaseOidIndexId
Definition: pg_database.h:90
#define heap_getattr(tup, attnum, tupleDesc, isnull)
Definition: htup_details.h:761
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Definition: syscache.c:1127
#define PublicationNameIndexId
int nkeys
Definition: syscache.c:118
static CatCache * SysCache[SysCacheSize]
Definition: syscache.c:997
#define StatisticRelidAttnumInhIndexId
Definition: pg_statistic.h:140
#define SequenceRelidIndexId
Definition: pg_sequence.h:43
#define TSParserNameNspIndexId
Definition: pg_ts_parser.h:58
#define TablespaceOidIndexId
Definition: pg_tablespace.h:55
uintptr_t Datum
Definition: postgres.h:411
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
#define ForeignDataWrapperNameIndexId
#define TransformTypeLangIndexId
Definition: pg_transform.h:48
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:1388
static Oid SysCacheRelationOid[SysCacheSize]
Definition: syscache.c:1002
#define AccessMethodProcedureIndexId
Definition: pg_amproc.h:71
#define EventTriggerNameIndexId
#define CastSourceTargetIndexId
Definition: pg_cast.h:62
#define TSConfigOidIndexId
Definition: pg_ts_config.h:53
#define InvalidOid
Definition: postgres_ext.h:36
void ReleaseCatCache(HeapTuple tuple)
Definition: catcache.c:1442
int16 attnum
Definition: pg_attribute.h:83
#define TSConfigMapIndexId
uint32 GetSysCacheHashValue(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1423
#define TSTemplateNameNspIndexId
#define PartitionedRelidIndexId
#define CollationNameEncNspIndexId
Definition: pg_collation.h:61
#define OpfamilyAmNameNspIndexId
Definition: pg_opfamily.h:54
#define ProcedureNameArgsNspIndexId
Definition: pg_proc.h:143
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:804
bool RelationInvalidatesSnapshotsOnly(Oid relid)
Definition: syscache.c:1484
#define PublicationRelPrrelidPrpubidIndexId
#define UserMappingUserServerIndexId
#define OperatorNameNspIndexId
Definition: pg_operator.h:88
void SysCacheInvalidate(int cacheId, uint32 hashValue)
Definition: syscache.c:1460
#define RewriteRelRulenameIndexId
Definition: pg_rewrite.h:59
#define DefaultAclRoleNspObjIndexId
int key[4]
Definition: syscache.c:119
void pg_qsort(void *base, size_t nel, size_t elsize, int(*cmp)(const void *, const void *))
#define TSParserOidIndexId
Definition: pg_ts_parser.h:60
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:1138
static size_t qunique(void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
Definition: qunique.h:21
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1268
#define AmNameIndexId
Definition: pg_am.h:51
#define AuthIdOidIndexId
Definition: pg_authid.h:65
#define AmOidIndexId
Definition: pg_am.h:53
HeapTuple SearchSysCacheCopy(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4)
Definition: syscache.c:1189
CatCList * SearchCatCacheList(CatCache *cache, int nkeys, Datum v1, Datum v2, Datum v3)
Definition: catcache.c:1508
HeapTuple SearchCatCache3(CatCache *cache, Datum v1, Datum v2, Datum v3)
Definition: catcache.c:1182
void InitCatalogCache(void)
Definition: syscache.c:1021
HeapTuple SearchCatCache(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4)
Definition: catcache.c:1149
#define AggregateFnoidIndexId
Definition: pg_aggregate.h:114
static int oid_compare(const void *a, const void *b)
Definition: syscache.c:1557
#define SubscriptionRelSrrelidSrsubidIndexId
#define NamespaceNameIndexId
Definition: pg_namespace.h:57
#define ProcedureOidIndexId
Definition: pg_proc.h:141
#define elog(elevel,...)
Definition: elog.h:232
#define RangeMultirangeTypidIndexId
Definition: pg_range.h:64
void InitCatCachePhase2(CatCache *cache, bool touch_index)
Definition: catcache.c:1032
bool RelationSupportsSysCache(Oid relid)
Definition: syscache.c:1532
uint32 GetCatCacheHashValue(CatCache *cache, Datum v1, Datum v2, Datum v3, Datum v4)
Definition: catcache.c:1474
void InitCatalogCachePhase2(void)
Definition: syscache.c:1086
#define AuthIdRolnameIndexId
Definition: pg_authid.h:63
#define PointerIsValid(pointer)
Definition: c.h:698
#define UserMappingOidIndexId
HeapTuple SearchCatCache1(CatCache *cache, Datum v1)
Definition: catcache.c:1166
int16 AttrNumber
Definition: attnum.h:21
HeapTuple SearchCatCache2(CatCache *cache, Datum v1, Datum v2)
Definition: catcache.c:1174
#define AuthMemRoleMemIndexId
#define PublicationObjectIndexId
#define SubscriptionNameIndexId
#define TSDictionaryOidIndexId
Definition: pg_ts_dict.h:59