44 #include "utils/fmgroids.h"
45 #include "utils/fmgrprotos.h"
54 #define GETNEWOID_LOG_THRESHOLD 1000000
55 #define GETNEWOID_LOG_MAX_INTERVAL 128000000
167 Oid relnamespace = reltuple->relnamespace;
184 return namespaceId == PG_CATALOG_NAMESPACE;
202 return (namespaceId == PG_TOAST_NAMESPACE) ||
220 return (
name[0] ==
'p' &&
246 if (relationId == AuthIdRelationId ||
247 relationId == AuthMemRelationId ||
248 relationId == DatabaseRelationId ||
249 relationId == DbRoleSettingRelationId ||
250 relationId == ParameterAclRelationId ||
251 relationId == ReplicationOriginRelationId ||
252 relationId == SharedDependRelationId ||
253 relationId == SharedDescriptionRelationId ||
254 relationId == SharedSecLabelRelationId ||
255 relationId == SubscriptionRelationId ||
256 relationId == TableSpaceRelationId)
259 if (relationId == AuthIdOidIndexId ||
260 relationId == AuthIdRolnameIndexId ||
261 relationId == AuthMemMemRoleIndexId ||
262 relationId == AuthMemRoleMemIndexId ||
263 relationId == AuthMemOidIndexId ||
264 relationId == AuthMemGrantorIndexId ||
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)
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)
327 if (classId == LargeObjectRelationId)
343 if (classId == NamespaceRelationId &&
344 objectId == PG_PUBLIC_NAMESPACE)
353 if (classId == DatabaseRelationId)
444 if (retries >= retries_before_log)
447 (
errmsg(
"still searching for an unused OID in relation \"%s\"",
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.",
452 (
unsigned long long) retries)));
459 retries_before_log *= 2;
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",
514 switch (relpersistence)
516 case RELPERSISTENCE_TEMP:
519 case RELPERSISTENCE_UNLOGGED:
520 case RELPERSISTENCE_PERMANENT:
524 elog(
ERROR,
"invalid relpersistence: %c", relpersistence);
555 if (
access(rpath, F_OK) == 0)
606 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
607 errmsg(
"must be superuser to call %s()",
615 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
616 errmsg(
"pg_nextoid() can only be used on system catalogs")));
620 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
621 errmsg(
"index \"%s\" does not belong to table \"%s\"",
628 (
errcode(ERRCODE_UNDEFINED_COLUMN),
629 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
633 attno = attform->attnum;
635 if (attform->atttypid != OIDOID)
637 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
638 errmsg(
"column \"%s\" is not of type oid",
642 idx->rd_index->indkey.values[0] != attno)
644 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
645 errmsg(
"index \"%s\" is not the index for column \"%s\"",
673 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
674 errmsg(
"must be superuser to call %s()",
675 "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 IsReservedName(const char *name)
#define GETNEWOID_LOG_MAX_INTERVAL
Datum pg_nextoid(PG_FUNCTION_ARGS)
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)