PostgreSQL Source Code  git master
catalog.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * catalog.c
4  * routines concerned with catalog naming conventions and other
5  * bits of hard-wired knowledge
6  *
7  *
8  * Portions Copyright (c) 1996-2021, PostgreSQL Global Development Group
9  * Portions Copyright (c) 1994, Regents of the University of California
10  *
11  *
12  * IDENTIFICATION
13  * src/backend/catalog/catalog.c
14  *
15  *-------------------------------------------------------------------------
16  */
17 
18 #include "postgres.h"
19 
20 #include <fcntl.h>
21 #include <unistd.h>
22 
23 #include "access/genam.h"
24 #include "access/htup_details.h"
25 #include "access/sysattr.h"
26 #include "access/table.h"
27 #include "access/transam.h"
28 #include "catalog/catalog.h"
29 #include "catalog/namespace.h"
31 #include "catalog/pg_authid.h"
32 #include "catalog/pg_database.h"
34 #include "catalog/pg_largeobject.h"
35 #include "catalog/pg_namespace.h"
37 #include "catalog/pg_shdepend.h"
39 #include "catalog/pg_shseclabel.h"
41 #include "catalog/pg_tablespace.h"
42 #include "catalog/pg_type.h"
43 #include "miscadmin.h"
44 #include "storage/fd.h"
45 #include "utils/fmgroids.h"
46 #include "utils/fmgrprotos.h"
47 #include "utils/rel.h"
48 #include "utils/snapmgr.h"
49 #include "utils/syscache.h"
50 
51 /*
52  * Parameters to determine when to emit a log message in
53  * GetNewOidWithIndex()
54  */
55 #define GETNEWOID_LOG_THRESHOLD 1000000
56 #define GETNEWOID_LOG_MAX_INTERVAL 128000000
57 
58 /*
59  * IsSystemRelation
60  * True iff the relation is either a system catalog or a toast table.
61  * See IsCatalogRelation for the exact definition of a system catalog.
62  *
63  * We treat toast tables of user relations as "system relations" for
64  * protection purposes, e.g. you can't change their schemas without
65  * special permissions. Therefore, most uses of this function are
66  * checking whether allow_system_table_mods restrictions apply.
67  * For other purposes, consider whether you shouldn't be using
68  * IsCatalogRelation instead.
69  *
70  * This function does not perform any catalog accesses.
71  * Some callers rely on that!
72  */
73 bool
75 {
76  return IsSystemClass(RelationGetRelid(relation), relation->rd_rel);
77 }
78 
79 /*
80  * IsSystemClass
81  * Like the above, but takes a Form_pg_class as argument.
82  * Used when we do not want to open the relation and have to
83  * search pg_class directly.
84  */
85 bool
87 {
88  /* IsCatalogRelationOid is a bit faster, so test that first */
89  return (IsCatalogRelationOid(relid) || IsToastClass(reltuple));
90 }
91 
92 /*
93  * IsCatalogRelation
94  * True iff the relation is a system catalog.
95  *
96  * By a system catalog, we mean one that is created during the bootstrap
97  * phase of initdb. That includes not just the catalogs per se, but
98  * also their indexes, and TOAST tables and indexes if any.
99  *
100  * This function does not perform any catalog accesses.
101  * Some callers rely on that!
102  */
103 bool
105 {
106  return IsCatalogRelationOid(RelationGetRelid(relation));
107 }
108 
109 /*
110  * IsCatalogRelationOid
111  * True iff the relation identified by this OID is a system catalog.
112  *
113  * By a system catalog, we mean one that is created during the bootstrap
114  * phase of initdb. That includes not just the catalogs per se, but
115  * also their indexes, and TOAST tables and indexes if any.
116  *
117  * This function does not perform any catalog accesses.
118  * Some callers rely on that!
119  */
120 bool
122 {
123  /*
124  * We consider a relation to be a system catalog if it has a pinned OID.
125  * This includes all the defined catalogs, their indexes, and their TOAST
126  * tables and indexes.
127  *
128  * This rule excludes the relations in information_schema, which are not
129  * integral to the system and can be treated the same as user relations.
130  * (Since it's valid to drop and recreate information_schema, any rule
131  * that did not act this way would be wrong.)
132  *
133  * This test is reliable since an OID wraparound will skip this range of
134  * OIDs; see GetNewObjectId().
135  */
136  return (relid < (Oid) FirstUnpinnedObjectId);
137 }
138 
139 /*
140  * IsToastRelation
141  * True iff relation is a TOAST support relation (or index).
142  *
143  * Does not perform any catalog accesses.
144  */
145 bool
147 {
148  /*
149  * What we actually check is whether the relation belongs to a pg_toast
150  * namespace. This should be equivalent because of restrictions that are
151  * enforced elsewhere against creating user relations in, or moving
152  * relations into/out of, a pg_toast namespace. Notice also that this
153  * will not say "true" for toast tables belonging to other sessions' temp
154  * tables; we expect that other mechanisms will prevent access to those.
155  */
156  return IsToastNamespace(RelationGetNamespace(relation));
157 }
158 
159 /*
160  * IsToastClass
161  * Like the above, but takes a Form_pg_class as argument.
162  * Used when we do not want to open the relation and have to
163  * search pg_class directly.
164  */
165 bool
167 {
168  Oid relnamespace = reltuple->relnamespace;
169 
170  return IsToastNamespace(relnamespace);
171 }
172 
173 /*
174  * IsCatalogNamespace
175  * True iff namespace is pg_catalog.
176  *
177  * Does not perform any catalog accesses.
178  *
179  * NOTE: the reason this isn't a macro is to avoid having to include
180  * catalog/pg_namespace.h in a lot of places.
181  */
182 bool
184 {
185  return namespaceId == PG_CATALOG_NAMESPACE;
186 }
187 
188 /*
189  * IsToastNamespace
190  * True iff namespace is pg_toast or my temporary-toast-table namespace.
191  *
192  * Does not perform any catalog accesses.
193  *
194  * Note: this will return false for temporary-toast-table namespaces belonging
195  * to other backends. Those are treated the same as other backends' regular
196  * temp table namespaces, and access is prevented where appropriate.
197  * If you need to check for those, you may be able to use isAnyTempNamespace,
198  * but beware that that does involve a catalog access.
199  */
200 bool
201 IsToastNamespace(Oid namespaceId)
202 {
203  return (namespaceId == PG_TOAST_NAMESPACE) ||
204  isTempToastNamespace(namespaceId);
205 }
206 
207 
208 /*
209  * IsReservedName
210  * True iff name starts with the pg_ prefix.
211  *
212  * For some classes of objects, the prefix pg_ is reserved for
213  * system objects only. As of 8.0, this was only true for
214  * schema and tablespace names. With 9.6, this is also true
215  * for roles.
216  */
217 bool
218 IsReservedName(const char *name)
219 {
220  /* ugly coding for speed */
221  return (name[0] == 'p' &&
222  name[1] == 'g' &&
223  name[2] == '_');
224 }
225 
226 
227 /*
228  * IsSharedRelation
229  * Given the OID of a relation, determine whether it's supposed to be
230  * shared across an entire database cluster.
231  *
232  * In older releases, this had to be hard-wired so that we could compute the
233  * locktag for a relation and lock it before examining its catalog entry.
234  * Since we now have MVCC catalog access, the race conditions that made that
235  * a hard requirement are gone, so we could look at relaxing this restriction.
236  * However, if we scanned the pg_class entry to find relisshared, and only
237  * then locked the relation, pg_class could get updated in the meantime,
238  * forcing us to scan the relation again, which would definitely be complex
239  * and might have undesirable performance consequences. Fortunately, the set
240  * of shared relations is fairly static, so a hand-maintained list of their
241  * OIDs isn't completely impractical.
242  */
243 bool
245 {
246  /* These are the shared catalogs (look for BKI_SHARED_RELATION) */
247  if (relationId == AuthIdRelationId ||
248  relationId == AuthMemRelationId ||
249  relationId == DatabaseRelationId ||
250  relationId == SharedDescriptionRelationId ||
251  relationId == SharedDependRelationId ||
252  relationId == SharedSecLabelRelationId ||
253  relationId == TableSpaceRelationId ||
254  relationId == DbRoleSettingRelationId ||
255  relationId == ReplicationOriginRelationId ||
256  relationId == SubscriptionRelationId)
257  return true;
258  /* These are their indexes */
259  if (relationId == AuthIdRolnameIndexId ||
260  relationId == AuthIdOidIndexId ||
261  relationId == AuthMemRoleMemIndexId ||
262  relationId == AuthMemMemRoleIndexId ||
263  relationId == DatabaseNameIndexId ||
264  relationId == DatabaseOidIndexId ||
265  relationId == SharedDescriptionObjIndexId ||
266  relationId == SharedDependDependerIndexId ||
267  relationId == SharedDependReferenceIndexId ||
268  relationId == SharedSecLabelObjectIndexId ||
269  relationId == TablespaceOidIndexId ||
270  relationId == TablespaceNameIndexId ||
271  relationId == DbRoleSettingDatidRolidIndexId ||
272  relationId == ReplicationOriginIdentIndex ||
273  relationId == ReplicationOriginNameIndex ||
274  relationId == SubscriptionObjectIndexId ||
275  relationId == SubscriptionNameIndexId)
276  return true;
277  /* These are their toast tables and toast indexes */
278  if (relationId == PgAuthidToastTable ||
279  relationId == PgAuthidToastIndex ||
280  relationId == PgDatabaseToastTable ||
281  relationId == PgDatabaseToastIndex ||
282  relationId == PgDbRoleSettingToastTable ||
283  relationId == PgDbRoleSettingToastIndex ||
284  relationId == PgReplicationOriginToastTable ||
285  relationId == PgReplicationOriginToastIndex ||
286  relationId == PgShdescriptionToastTable ||
287  relationId == PgShdescriptionToastIndex ||
288  relationId == PgShseclabelToastTable ||
289  relationId == PgShseclabelToastIndex ||
290  relationId == PgSubscriptionToastTable ||
291  relationId == PgSubscriptionToastIndex ||
292  relationId == PgTablespaceToastTable ||
293  relationId == PgTablespaceToastIndex)
294  return true;
295  return false;
296 }
297 
298 /*
299  * IsPinnedObject
300  * Given the class + OID identity of a database object, report whether
301  * it is "pinned", that is not droppable because the system requires it.
302  *
303  * We used to represent this explicitly in pg_depend, but that proved to be
304  * an undesirable amount of overhead, so now we rely on an OID range test.
305  */
306 bool
307 IsPinnedObject(Oid classId, Oid objectId)
308 {
309  /*
310  * Objects with OIDs above FirstUnpinnedObjectId are never pinned. Since
311  * the OID generator skips this range when wrapping around, this check
312  * guarantees that user-defined objects are never considered pinned.
313  */
314  if (objectId >= FirstUnpinnedObjectId)
315  return false;
316 
317  /*
318  * Large objects are never pinned. We need this special case because
319  * their OIDs can be user-assigned.
320  */
321  if (classId == LargeObjectRelationId)
322  return false;
323 
324  /*
325  * There are a few objects defined in the catalog .dat files that, as a
326  * matter of policy, we prefer not to treat as pinned. We used to handle
327  * that by excluding them from pg_depend, but it's just as easy to
328  * hard-wire their OIDs here. (If the user does indeed drop and recreate
329  * them, they'll have new but certainly-unpinned OIDs, so no problem.)
330  *
331  * Checking both classId and objectId is overkill, since OIDs below
332  * FirstGenbkiObjectId should be globally unique, but do it anyway for
333  * robustness.
334  */
335 
336  /* template1 is not pinned */
337  if (classId == DatabaseRelationId &&
338  objectId == TemplateDbOid)
339  return false;
340 
341  /* the public namespace is not pinned */
342  if (classId == NamespaceRelationId &&
343  objectId == PG_PUBLIC_NAMESPACE)
344  return false;
345 
346  /*
347  * All other initdb-created objects are pinned. This is overkill (the
348  * system doesn't really depend on having every last weird datatype, for
349  * instance) but generating only the minimum required set of dependencies
350  * seems hard, and enforcing an accurate list would be much more expensive
351  * than the simple range test used here.
352  */
353  return true;
354 }
355 
356 
357 /*
358  * GetNewOidWithIndex
359  * Generate a new OID that is unique within the system relation.
360  *
361  * Since the OID is not immediately inserted into the table, there is a
362  * race condition here; but a problem could occur only if someone else
363  * managed to cycle through 2^32 OIDs and generate the same OID before we
364  * finish inserting our row. This seems unlikely to be a problem. Note
365  * that if we had to *commit* the row to end the race condition, the risk
366  * would be rather higher; therefore we use SnapshotAny in the test, so that
367  * we will see uncommitted rows. (We used to use SnapshotDirty, but that has
368  * the disadvantage that it ignores recently-deleted rows, creating a risk
369  * of transient conflicts for as long as our own MVCC snapshots think a
370  * recently-deleted row is live. The risk is far higher when selecting TOAST
371  * OIDs, because SnapshotToast considers dead rows as active indefinitely.)
372  *
373  * Note that we are effectively assuming that the table has a relatively small
374  * number of entries (much less than 2^32) and there aren't very long runs of
375  * consecutive existing OIDs. This is a mostly reasonable assumption for
376  * system catalogs.
377  *
378  * Caller must have a suitable lock on the relation.
379  */
380 Oid
381 GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
382 {
383  Oid newOid;
384  SysScanDesc scan;
386  bool collides;
387  uint64 retries = 0;
388  uint64 retries_before_log = GETNEWOID_LOG_THRESHOLD;
389 
390  /* Only system relations are supported */
391  Assert(IsSystemRelation(relation));
392 
393  /* In bootstrap mode, we don't have any indexes to use */
395  return GetNewObjectId();
396 
397  /*
398  * We should never be asked to generate a new pg_type OID during
399  * pg_upgrade; doing so would risk collisions with the OIDs it wants to
400  * assign. Hitting this assert means there's some path where we failed to
401  * ensure that a type OID is determined by commands in the dump script.
402  */
403  Assert(!IsBinaryUpgrade || RelationGetRelid(relation) != TypeRelationId);
404 
405  /* Generate new OIDs until we find one not in the table */
406  do
407  {
409 
410  newOid = GetNewObjectId();
411 
412  ScanKeyInit(&key,
413  oidcolumn,
414  BTEqualStrategyNumber, F_OIDEQ,
415  ObjectIdGetDatum(newOid));
416 
417  /* see notes above about using SnapshotAny */
418  scan = systable_beginscan(relation, indexId, true,
419  SnapshotAny, 1, &key);
420 
421  collides = HeapTupleIsValid(systable_getnext(scan));
422 
423  systable_endscan(scan);
424 
425  /*
426  * Log that we iterate more than GETNEWOID_LOG_THRESHOLD but have not
427  * yet found OID unused in the relation. Then repeat logging with
428  * exponentially increasing intervals until we iterate more than
429  * GETNEWOID_LOG_MAX_INTERVAL. Finally repeat logging every
430  * GETNEWOID_LOG_MAX_INTERVAL unless an unused OID is found. This
431  * logic is necessary not to fill up the server log with the similar
432  * messages.
433  */
434  if (retries >= retries_before_log)
435  {
436  ereport(LOG,
437  (errmsg("still searching for an unused OID in relation \"%s\"",
438  RelationGetRelationName(relation)),
439  errdetail_plural("OID candidates have been checked %llu time, but no unused OID has been found yet.",
440  "OID candidates have been checked %llu times, but no unused OID has been found yet.",
441  retries,
442  (unsigned long long) retries)));
443 
444  /*
445  * Double the number of retries to do before logging next until it
446  * reaches GETNEWOID_LOG_MAX_INTERVAL.
447  */
448  if (retries_before_log * 2 <= GETNEWOID_LOG_MAX_INTERVAL)
449  retries_before_log *= 2;
450  else
451  retries_before_log += GETNEWOID_LOG_MAX_INTERVAL;
452  }
453 
454  retries++;
455  } while (collides);
456 
457  /*
458  * If at least one log message is emitted, also log the completion of OID
459  * assignment.
460  */
461  if (retries > GETNEWOID_LOG_THRESHOLD)
462  {
463  ereport(LOG,
464  (errmsg_plural("new OID has been assigned in relation \"%s\" after %llu retry",
465  "new OID has been assigned in relation \"%s\" after %llu retries",
466  retries,
467  RelationGetRelationName(relation), (unsigned long long) retries)));
468  }
469 
470  return newOid;
471 }
472 
473 /*
474  * GetNewRelFileNode
475  * Generate a new relfilenode number that is unique within the
476  * database of the given tablespace.
477  *
478  * If the relfilenode will also be used as the relation's OID, pass the
479  * opened pg_class catalog, and this routine will guarantee that the result
480  * is also an unused OID within pg_class. If the result is to be used only
481  * as a relfilenode for an existing relation, pass NULL for pg_class.
482  *
483  * As with GetNewOidWithIndex(), there is some theoretical risk of a race
484  * condition, but it doesn't seem worth worrying about.
485  *
486  * Note: we don't support using this in bootstrap mode. All relations
487  * created by bootstrap have preassigned OIDs, so there's no need.
488  */
489 Oid
490 GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
491 {
492  RelFileNodeBackend rnode;
493  char *rpath;
494  bool collides;
495  BackendId backend;
496 
497  /*
498  * If we ever get here during pg_upgrade, there's something wrong; all
499  * relfilenode assignments during a binary-upgrade run should be
500  * determined by commands in the dump script.
501  */
503 
504  switch (relpersistence)
505  {
506  case RELPERSISTENCE_TEMP:
507  backend = BackendIdForTempRelations();
508  break;
509  case RELPERSISTENCE_UNLOGGED:
510  case RELPERSISTENCE_PERMANENT:
511  backend = InvalidBackendId;
512  break;
513  default:
514  elog(ERROR, "invalid relpersistence: %c", relpersistence);
515  return InvalidOid; /* placate compiler */
516  }
517 
518  /* This logic should match RelationInitPhysicalAddr */
519  rnode.node.spcNode = reltablespace ? reltablespace : MyDatabaseTableSpace;
520  rnode.node.dbNode = (rnode.node.spcNode == GLOBALTABLESPACE_OID) ? InvalidOid : MyDatabaseId;
521 
522  /*
523  * The relpath will vary based on the backend ID, so we must initialize
524  * that properly here to make sure that any collisions based on filename
525  * are properly detected.
526  */
527  rnode.backend = backend;
528 
529  do
530  {
532 
533  /* Generate the OID */
534  if (pg_class)
535  rnode.node.relNode = GetNewOidWithIndex(pg_class, ClassOidIndexId,
536  Anum_pg_class_oid);
537  else
538  rnode.node.relNode = GetNewObjectId();
539 
540  /* Check for existing file of same name */
541  rpath = relpath(rnode, MAIN_FORKNUM);
542 
543  if (access(rpath, F_OK) == 0)
544  {
545  /* definite collision */
546  collides = true;
547  }
548  else
549  {
550  /*
551  * Here we have a little bit of a dilemma: if errno is something
552  * other than ENOENT, should we declare a collision and loop? In
553  * practice it seems best to go ahead regardless of the errno. If
554  * there is a colliding file we will get an smgr failure when we
555  * attempt to create the new relation file.
556  */
557  collides = false;
558  }
559 
560  pfree(rpath);
561  } while (collides);
562 
563  return rnode.node.relNode;
564 }
565 
566 /*
567  * SQL callable interface for GetNewOidWithIndex(). Outside of initdb's
568  * direct insertions into catalog tables, and recovering from corruption, this
569  * should rarely be needed.
570  *
571  * Function is intentionally not documented in the user facing docs.
572  */
573 Datum
575 {
576  Oid reloid = PG_GETARG_OID(0);
578  Oid idxoid = PG_GETARG_OID(2);
579  Relation rel;
580  Relation idx;
581  HeapTuple atttuple;
582  Form_pg_attribute attform;
583  AttrNumber attno;
584  Oid newoid;
585 
586  /*
587  * As this function is not intended to be used during normal running, and
588  * only supports system catalogs (which require superuser permissions to
589  * modify), just checking for superuser ought to not obstruct valid
590  * usecases.
591  */
592  if (!superuser())
593  ereport(ERROR,
594  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
595  errmsg("must be superuser to call %s()",
596  "pg_nextoid")));
597 
598  rel = table_open(reloid, RowExclusiveLock);
599  idx = index_open(idxoid, RowExclusiveLock);
600 
601  if (!IsSystemRelation(rel))
602  ereport(ERROR,
603  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
604  errmsg("pg_nextoid() can only be used on system catalogs")));
605 
606  if (idx->rd_index->indrelid != RelationGetRelid(rel))
607  ereport(ERROR,
608  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
609  errmsg("index \"%s\" does not belong to table \"%s\"",
611  RelationGetRelationName(rel))));
612 
613  atttuple = SearchSysCacheAttName(reloid, NameStr(*attname));
614  if (!HeapTupleIsValid(atttuple))
615  ereport(ERROR,
616  (errcode(ERRCODE_UNDEFINED_COLUMN),
617  errmsg("column \"%s\" of relation \"%s\" does not exist",
618  NameStr(*attname), RelationGetRelationName(rel))));
619 
620  attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
621  attno = attform->attnum;
622 
623  if (attform->atttypid != OIDOID)
624  ereport(ERROR,
625  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
626  errmsg("column \"%s\" is not of type oid",
627  NameStr(*attname))));
628 
630  idx->rd_index->indkey.values[0] != attno)
631  ereport(ERROR,
632  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
633  errmsg("index \"%s\" is not the index for column \"%s\"",
635  NameStr(*attname))));
636 
637  newoid = GetNewOidWithIndex(rel, idxoid, attno);
638 
639  ReleaseSysCache(atttuple);
642 
643  PG_RETURN_OID(newoid);
644 }
645 
646 /*
647  * SQL callable interface for StopGeneratingPinnedObjectIds().
648  *
649  * This is only to be used by initdb, so it's intentionally not documented in
650  * the user facing docs.
651  */
652 Datum
654 {
655  /*
656  * Belt-and-suspenders check, since StopGeneratingPinnedObjectIds will
657  * fail anyway in non-single-user mode.
658  */
659  if (!superuser())
660  ereport(ERROR,
661  (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
662  errmsg("must be superuser to call %s()",
663  "pg_stop_making_pinned_objects")));
664 
666 
667  PG_RETURN_VOID();
668 }
#define PgDatabaseToastTable
Definition: pg_database.h:84
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:381
bool IsToastRelation(Relation relation)
Definition: catalog.c:146
bool IsCatalogRelation(Relation relation)
Definition: catalog.c:104
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:595
#define GETSTRUCT(TUP)
Definition: htup_details.h:654
bool IsSystemRelation(Relation relation)
Definition: catalog.c:74
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition: elog.c:1019
#define PgSubscriptionToastIndex
int errcode(int sqlerrcode)
Definition: elog.c:698
bool superuser(void)
Definition: superuser.c:46
Datum idx(PG_FUNCTION_ARGS)
Definition: _int_op.c:259
#define PgShseclabelToastTable
Definition: pg_shseclabel.h:43
#define LOG
Definition: elog.h:26
bool IsToastNamespace(Oid namespaceId)
Definition: catalog.c:201
Form_pg_class rd_rel
Definition: rel.h:109
unsigned int Oid
Definition: postgres_ext.h:31
bool IsReservedName(const char *name)
Definition: catalog.c:218
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:383
bool IsBinaryUpgrade
Definition: globals.c:113
Oid MyDatabaseTableSpace
Definition: globals.c:90
#define PgAuthidToastIndex
Definition: pg_authid.h:60
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
Definition: catalog.c:86
#define PgShseclabelToastIndex
Definition: pg_shseclabel.h:44
bool IsCatalogRelationOid(Oid relid)
Definition: catalog.c:121
Oid GetNewObjectId(void)
Definition: varsup.c:528
Form_pg_index rd_index
Definition: rel.h:187
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:502
void pfree(void *pointer)
Definition: mcxt.c:1169
bool IsPinnedObject(Oid classId, Oid objectId)
Definition: catalog.c:307
bool IsToastClass(Form_pg_class reltuple)
Definition: catalog.c:166
#define PgDatabaseToastIndex
Definition: pg_database.h:85
#define ObjectIdGetDatum(X)
Definition: postgres.h:551
#define ERROR
Definition: elog.h:46
NameData attname
Definition: pg_attribute.h:41
#define FirstUnpinnedObjectId
Definition: transam.h:196
#define PgReplicationOriginToastIndex
void StopGeneratingPinnedObjectIds(void)
Definition: varsup.c:625
Definition: c.h:675
#define BackendIdForTempRelations()
Definition: backendid.h:34
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define PgShdescriptionToastTable
#define RowExclusiveLock
Definition: lockdefs.h:38
#define PgAuthidToastTable
Definition: pg_authid.h:59
#define RelationGetRelationName(relation)
Definition: rel.h:511
Datum pg_stop_making_pinned_objects(PG_FUNCTION_ARGS)
Definition: catalog.c:653
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:207
#define IndexRelationGetNumberOfKeyAttributes(relation)
Definition: rel.h:496
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3214
#define PgDbRoleSettingToastTable
#define PgSubscriptionToastTable
#define InvalidBackendId
Definition: backendid.h:23
uintptr_t Datum
Definition: postgres.h:411
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1175
int BackendId
Definition: backendid.h:21
Oid MyDatabaseId
Definition: globals.c:88
bool IsSharedRelation(Oid relationId)
Definition: catalog.c:244
#define PgReplicationOriginToastTable
#define InvalidOid
Definition: postgres_ext.h:36
#define ereport(elevel,...)
Definition: elog.h:157
RelFileNode node
Definition: relfilenode.h:74
#define PG_RETURN_VOID()
Definition: fmgr.h:349
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:804
BackendId backend
Definition: relfilenode.h:75
int errdetail_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition: elog.c:1134
Oid GetNewRelFileNode(Oid reltablespace, Relation pg_class, char relpersistence)
Definition: catalog.c:490
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1268
#define PgTablespaceToastTable
Definition: pg_tablespace.h:51
const char * name
Definition: encode.c:515
#define SnapshotAny
Definition: snapmgr.h:67
#define PgTablespaceToastIndex
Definition: pg_tablespace.h:52
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:158
bool IsCatalogNamespace(Oid namespaceId)
Definition: catalog.c:183
#define GETNEWOID_LOG_THRESHOLD
Definition: catalog.c:55
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:406
FormData_pg_class * Form_pg_class
Definition: pg_class.h:153
int errmsg(const char *fmt,...)
Definition: elog.c:909
#define elog(elevel,...)
Definition: elog.h:232
#define relpath(rnode, forknum)
Definition: relpath.h:87
#define NameStr(name)
Definition: c.h:681
#define PgShdescriptionToastIndex
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
#define PG_FUNCTION_ARGS
Definition: fmgr.h:193
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:120
#define PgDbRoleSettingToastIndex
Datum pg_nextoid(PG_FUNCTION_ARGS)
Definition: catalog.c:574
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
#define PG_RETURN_OID(x)
Definition: fmgr.h:360
int16 AttrNumber
Definition: attnum.h:21
#define RelationGetRelid(relation)
Definition: rel.h:477
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:132
#define BTEqualStrategyNumber
Definition: stratnum.h:31
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278
#define GETNEWOID_LOG_MAX_INTERVAL
Definition: catalog.c:56
#define RelationGetNamespace(relation)
Definition: rel.h:518