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