44#include "utils/fmgroids.h"
45#include "utils/fmgrprotos.h"
54#define GETNEWOID_LOG_THRESHOLD 1000000
55#define GETNEWOID_LOG_MAX_INTERVAL 128000000
164 return (relid == RelationRelationId ||
165 relid == DatabaseRelationId);
197 Oid relnamespace = reltuple->relnamespace;
214 return namespaceId == PG_CATALOG_NAMESPACE;
232 return (namespaceId == PG_TOAST_NAMESPACE) ||
250 return (
name[0] ==
'p' &&
276 if (relationId == AuthIdRelationId ||
277 relationId == AuthMemRelationId ||
278 relationId == DatabaseRelationId ||
279 relationId == DbRoleSettingRelationId ||
280 relationId == ParameterAclRelationId ||
281 relationId == ReplicationOriginRelationId ||
282 relationId == SharedDependRelationId ||
283 relationId == SharedDescriptionRelationId ||
284 relationId == SharedSecLabelRelationId ||
285 relationId == SubscriptionRelationId ||
286 relationId == TableSpaceRelationId)
289 if (relationId == AuthIdOidIndexId ||
290 relationId == AuthIdRolnameIndexId ||
291 relationId == AuthMemMemRoleIndexId ||
292 relationId == AuthMemRoleMemIndexId ||
293 relationId == AuthMemOidIndexId ||
294 relationId == AuthMemGrantorIndexId ||
295 relationId == DatabaseNameIndexId ||
296 relationId == DatabaseOidIndexId ||
297 relationId == DbRoleSettingDatidRolidIndexId ||
298 relationId == ParameterAclOidIndexId ||
299 relationId == ParameterAclParnameIndexId ||
300 relationId == ReplicationOriginIdentIndex ||
301 relationId == ReplicationOriginNameIndex ||
302 relationId == SharedDependDependerIndexId ||
303 relationId == SharedDependReferenceIndexId ||
304 relationId == SharedDescriptionObjIndexId ||
305 relationId == SharedSecLabelObjectIndexId ||
306 relationId == SubscriptionNameIndexId ||
307 relationId == SubscriptionObjectIndexId ||
308 relationId == TablespaceNameIndexId ||
309 relationId == TablespaceOidIndexId)
312 if (relationId == PgDatabaseToastTable ||
313 relationId == PgDatabaseToastIndex ||
314 relationId == PgDbRoleSettingToastTable ||
315 relationId == PgDbRoleSettingToastIndex ||
316 relationId == PgParameterAclToastTable ||
317 relationId == PgParameterAclToastIndex ||
318 relationId == PgReplicationOriginToastTable ||
319 relationId == PgReplicationOriginToastIndex ||
320 relationId == PgShdescriptionToastTable ||
321 relationId == PgShdescriptionToastIndex ||
322 relationId == PgShseclabelToastTable ||
323 relationId == PgShseclabelToastIndex ||
324 relationId == PgSubscriptionToastTable ||
325 relationId == PgSubscriptionToastIndex ||
326 relationId == PgTablespaceToastTable ||
327 relationId == PgTablespaceToastIndex)
355 if (classId == LargeObjectRelationId)
371 if (classId == NamespaceRelationId &&
372 objectId == PG_PUBLIC_NAMESPACE)
381 if (classId == DatabaseRelationId)
472 if (retries >= retries_before_log)
475 (
errmsg(
"still searching for an unused OID in relation \"%s\"",
477 errdetail_plural(
"OID candidates have been checked %llu time, but no unused OID has been found yet.",
478 "OID candidates have been checked %llu times, but no unused OID has been found yet.",
480 (
unsigned long long) retries)));
487 retries_before_log *= 2;
502 (
errmsg_plural(
"new OID has been assigned in relation \"%s\" after %llu retry",
503 "new OID has been assigned in relation \"%s\" after %llu retries",
542 switch (relpersistence)
544 case RELPERSISTENCE_TEMP:
547 case RELPERSISTENCE_UNLOGGED:
548 case RELPERSISTENCE_PERMANENT:
552 elog(
ERROR,
"invalid relpersistence: %c", relpersistence);
583 if (
access(rpath, F_OK) == 0)
634 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
635 errmsg(
"must be superuser to call %s()",
643 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
644 errmsg(
"pg_nextoid() can only be used on system catalogs")));
648 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
649 errmsg(
"index \"%s\" does not belong to table \"%s\"",
656 (
errcode(ERRCODE_UNDEFINED_COLUMN),
657 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
661 attno = attform->attnum;
663 if (attform->atttypid != OIDOID)
665 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
666 errmsg(
"column \"%s\" is not of type oid",
670 idx->rd_index->indkey.values[0] != attno)
672 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
673 errmsg(
"index \"%s\" is not the index for column \"%s\"",
701 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
702 errmsg(
"must be superuser to call %s()",
703 "pg_stop_making_pinned_objects")));
Datum idx(PG_FUNCTION_ARGS)
#define Assert(condition)
bool IsToastRelation(Relation relation)
#define GETNEWOID_LOG_THRESHOLD
bool IsToastNamespace(Oid namespaceId)
bool IsSystemRelation(Relation relation)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
RelFileNumber GetNewRelFileNumber(Oid reltablespace, Relation pg_class, char relpersistence)
bool IsCatalogNamespace(Oid namespaceId)
bool IsToastClass(Form_pg_class reltuple)
bool IsCatalogRelation(Relation relation)
bool IsPinnedObject(Oid classId, Oid objectId)
bool IsSharedRelation(Oid relationId)
bool IsCatalogRelationOid(Oid relid)
bool IsInplaceUpdateRelation(Relation relation)
bool IsReservedName(const char *name)
#define GETNEWOID_LOG_MAX_INTERVAL
Datum pg_nextoid(PG_FUNCTION_ARGS)
bool IsInplaceUpdateOid(Oid relid)
bool IsSystemClass(Oid relid, Form_pg_class reltuple)
Datum pg_stop_making_pinned_objects(PG_FUNCTION_ARGS)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errdetail_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_GETARG_NAME(n)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
#define HeapTupleIsValid(tuple)
void index_close(Relation relation, LOCKMODE lockmode)
Relation index_open(Oid relationId, LOCKMODE lockmode)
void pfree(void *pointer)
#define IsBootstrapProcessingMode()
#define CHECK_FOR_INTERRUPTS()
bool isTempToastNamespace(Oid namespaceId)
FormData_pg_attribute * Form_pg_attribute
FormData_pg_class * Form_pg_class
static Datum ObjectIdGetDatum(Oid X)
#define ProcNumberForTempRelations()
#define INVALID_PROC_NUMBER
#define RelationGetRelid(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
#define IndexRelationGetNumberOfKeyAttributes(relation)
#define relpath(rlocator, forknum)
#define InvalidRelFileNumber
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
#define BTEqualStrategyNumber
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
#define FirstUnpinnedObjectId
void StopGeneratingPinnedObjectIds(void)