PostgreSQL Source Code  git master
catalog.c File Reference
#include "postgres.h"
#include <fcntl.h>
#include <unistd.h>
#include "access/genam.h"
#include "access/htup_details.h"
#include "access/sysattr.h"
#include "access/table.h"
#include "access/transam.h"
#include "catalog/catalog.h"
#include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_auth_members.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_db_role_setting.h"
#include "catalog/pg_namespace.h"
#include "catalog/pg_replication_origin.h"
#include "catalog/pg_shdepend.h"
#include "catalog/pg_shdescription.h"
#include "catalog/pg_shseclabel.h"
#include "catalog/pg_subscription.h"
#include "catalog/pg_tablespace.h"
#include "catalog/pg_type.h"
#include "catalog/toasting.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/fmgroids.h"
#include "utils/fmgrprotos.h"
#include "utils/rel.h"
#include "utils/snapmgr.h"
#include "utils/syscache.h"
Include dependency graph for catalog.c:

Go to the source code of this file.

Functions

bool IsSystemRelation (Relation relation)
 
bool IsSystemClass (Oid relid, Form_pg_class reltuple)
 
bool IsCatalogRelation (Relation relation)
 
bool IsCatalogRelationOid (Oid relid)
 
bool IsToastRelation (Relation relation)
 
bool IsToastClass (Form_pg_class reltuple)
 
bool IsCatalogNamespace (Oid namespaceId)
 
bool IsToastNamespace (Oid namespaceId)
 
bool IsReservedName (const char *name)
 
bool IsSharedRelation (Oid relationId)
 
Oid GetNewOidWithIndex (Relation relation, Oid indexId, AttrNumber oidcolumn)
 
Oid GetNewRelFileNode (Oid reltablespace, Relation pg_class, char relpersistence)
 
Datum pg_nextoid (PG_FUNCTION_ARGS)
 

Function Documentation

◆ GetNewOidWithIndex()

Oid GetNewOidWithIndex ( Relation  relation,
Oid  indexId,
AttrNumber  oidcolumn 
)

Definition at line 317 of file catalog.c.

References Assert, BTEqualStrategyNumber, CHECK_FOR_INTERRUPTS, GetNewObjectId(), HeapTupleIsValid, IsBinaryUpgrade, IsBootstrapProcessingMode, IsSystemRelation(), sort-test::key, ObjectIdGetDatum, RelationGetRelid, ScanKeyInit(), SnapshotAny, systable_beginscan(), systable_endscan(), and systable_getnext().

Referenced by AddEnumLabel(), AssignTypeArrayOid(), CastCreate(), CollationCreate(), ConversionCreate(), CreateAccessMethod(), CreateConstraintEntry(), createdb(), CreateForeignDataWrapper(), CreateForeignServer(), CreateOpFamily(), CreatePolicy(), CreateProceduralLanguage(), CreatePublication(), CreateRole(), CreateStatistics(), CreateSubscription(), CreateTableSpace(), CreateTransform(), CreateTrigger(), CreateUserMapping(), DefineOpClass(), DefineTSConfiguration(), DefineTSDictionary(), DefineTSParser(), DefineTSTemplate(), EnumValuesCreate(), GetNewRelFileNode(), insert_event_trigger_tuple(), InsertExtensionTuple(), InsertRule(), LargeObjectCreate(), NamespaceCreate(), OperatorCreate(), OperatorShellMake(), pg_nextoid(), ProcedureCreate(), publication_add_relation(), SetDefaultACL(), StoreAttrDefault(), storeOperators(), storeProcedures(), toast_save_datum(), TypeCreate(), and TypeShellMake().

318 {
319  Oid newOid;
320  SysScanDesc scan;
322  bool collides;
323 
324  /* Only system relations are supported */
325  Assert(IsSystemRelation(relation));
326 
327  /* In bootstrap mode, we don't have any indexes to use */
329  return GetNewObjectId();
330 
331  /*
332  * We should never be asked to generate a new pg_type OID during
333  * pg_upgrade; doing so would risk collisions with the OIDs it wants to
334  * assign. Hitting this assert means there's some path where we failed to
335  * ensure that a type OID is determined by commands in the dump script.
336  */
337  Assert(!IsBinaryUpgrade || RelationGetRelid(relation) != TypeRelationId);
338 
339  /* Generate new OIDs until we find one not in the table */
340  do
341  {
343 
344  newOid = GetNewObjectId();
345 
346  ScanKeyInit(&key,
347  oidcolumn,
348  BTEqualStrategyNumber, F_OIDEQ,
349  ObjectIdGetDatum(newOid));
350 
351  /* see notes above about using SnapshotAny */
352  scan = systable_beginscan(relation, indexId, true,
353  SnapshotAny, 1, &key);
354 
355  collides = HeapTupleIsValid(systable_getnext(scan));
356 
357  systable_endscan(scan);
358  } while (collides);
359 
360  return newOid;
361 }
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:569
bool IsSystemRelation(Relation relation)
Definition: catalog.c:68
unsigned int Oid
Definition: postgres_ext.h:31
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:357
bool IsBinaryUpgrade
Definition: globals.c:110
Oid GetNewObjectId(void)
Definition: varsup.c:528
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:476
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
#define Assert(condition)
Definition: c.h:746
#define SnapshotAny
Definition: snapmgr.h:68
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:393
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:99
#define RelationGetRelid(relation)
Definition: rel.h:456
#define BTEqualStrategyNumber
Definition: stratnum.h:31

◆ GetNewRelFileNode()

Oid GetNewRelFileNode ( Oid  reltablespace,
Relation  pg_class,
char  relpersistence 
)

Definition at line 380 of file catalog.c.

References Assert, RelFileNodeBackend::backend, BackendIdForTempRelations, CHECK_FOR_INTERRUPTS, ClassOidIndexId, RelFileNode::dbNode, elog, ERROR, GetNewObjectId(), GetNewOidWithIndex(), InvalidBackendId, InvalidOid, IsBinaryUpgrade, MAIN_FORKNUM, MyDatabaseId, MyDatabaseTableSpace, RelFileNodeBackend::node, pfree(), RelFileNode::relNode, relpath, and RelFileNode::spcNode.

Referenced by ATExecSetTableSpace(), heap_create_with_catalog(), index_create(), and RelationSetNewRelfilenode().

381 {
382  RelFileNodeBackend rnode;
383  char *rpath;
384  bool collides;
385  BackendId backend;
386 
387  /*
388  * If we ever get here during pg_upgrade, there's something wrong; all
389  * relfilenode assignments during a binary-upgrade run should be
390  * determined by commands in the dump script.
391  */
393 
394  switch (relpersistence)
395  {
396  case RELPERSISTENCE_TEMP:
397  backend = BackendIdForTempRelations();
398  break;
399  case RELPERSISTENCE_UNLOGGED:
400  case RELPERSISTENCE_PERMANENT:
401  backend = InvalidBackendId;
402  break;
403  default:
404  elog(ERROR, "invalid relpersistence: %c", relpersistence);
405  return InvalidOid; /* placate compiler */
406  }
407 
408  /* This logic should match RelationInitPhysicalAddr */
409  rnode.node.spcNode = reltablespace ? reltablespace : MyDatabaseTableSpace;
410  rnode.node.dbNode = (rnode.node.spcNode == GLOBALTABLESPACE_OID) ? InvalidOid : MyDatabaseId;
411 
412  /*
413  * The relpath will vary based on the backend ID, so we must initialize
414  * that properly here to make sure that any collisions based on filename
415  * are properly detected.
416  */
417  rnode.backend = backend;
418 
419  do
420  {
422 
423  /* Generate the OID */
424  if (pg_class)
426  Anum_pg_class_oid);
427  else
428  rnode.node.relNode = GetNewObjectId();
429 
430  /* Check for existing file of same name */
431  rpath = relpath(rnode, MAIN_FORKNUM);
432 
433  if (access(rpath, F_OK) == 0)
434  {
435  /* definite collision */
436  collides = true;
437  }
438  else
439  {
440  /*
441  * Here we have a little bit of a dilemma: if errno is something
442  * other than ENOENT, should we declare a collision and loop? In
443  * practice it seems best to go ahead regardless of the errno. If
444  * there is a colliding file we will get an smgr failure when we
445  * attempt to create the new relation file.
446  */
447  collides = false;
448  }
449 
450  pfree(rpath);
451  } while (collides);
452 
453  return rnode.node.relNode;
454 }
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:317
bool IsBinaryUpgrade
Definition: globals.c:110
Oid MyDatabaseTableSpace
Definition: globals.c:87
Oid GetNewObjectId(void)
Definition: varsup.c:528
void pfree(void *pointer)
Definition: mcxt.c:1057
#define ERROR
Definition: elog.h:43
#define BackendIdForTempRelations()
Definition: backendid.h:34
#define ClassOidIndexId
Definition: indexing.h:125
#define InvalidBackendId
Definition: backendid.h:23
int BackendId
Definition: backendid.h:21
Oid MyDatabaseId
Definition: globals.c:85
#define InvalidOid
Definition: postgres_ext.h:36
RelFileNode node
Definition: relfilenode.h:74
#define Assert(condition)
Definition: c.h:746
BackendId backend
Definition: relfilenode.h:75
#define elog(elevel,...)
Definition: elog.h:214
#define relpath(rnode, forknum)
Definition: relpath.h:87
#define CHECK_FOR_INTERRUPTS()
Definition: miscadmin.h:99

◆ IsCatalogNamespace()

bool IsCatalogNamespace ( Oid  namespaceId)

Definition at line 177 of file catalog.c.

Referenced by AlterTableMoveAll(), heap_create(), and RelationBuildLocalRelation().

178 {
179  return namespaceId == PG_CATALOG_NAMESPACE;
180 }

◆ IsCatalogRelation()

bool IsCatalogRelation ( Relation  relation)

◆ IsCatalogRelationOid()

bool IsCatalogRelationOid ( Oid  relid)

Definition at line 115 of file catalog.c.

References FirstBootstrapObjectId.

Referenced by check_relation_privileges(), is_publishable_class(), IsCatalogRelation(), IsSystemClass(), ReindexMultipleTables(), and ReindexRelationConcurrently().

116 {
117  /*
118  * We consider a relation to be a system catalog if it has an OID that was
119  * manually assigned or assigned by genbki.pl. This includes all the
120  * defined catalogs, their indexes, and their TOAST tables and indexes.
121  *
122  * This rule excludes the relations in information_schema, which are not
123  * integral to the system and can be treated the same as user relations.
124  * (Since it's valid to drop and recreate information_schema, any rule
125  * that did not act this way would be wrong.)
126  *
127  * This test is reliable since an OID wraparound will skip this range of
128  * OIDs; see GetNewObjectId().
129  */
130  return (relid < (Oid) FirstBootstrapObjectId);
131 }
unsigned int Oid
Definition: postgres_ext.h:31
#define FirstBootstrapObjectId
Definition: transam.h:189

◆ IsReservedName()

bool IsReservedName ( const char *  name)

Definition at line 212 of file catalog.c.

Referenced by check_rolespec_name(), CreateRole(), CreateSchemaCommand(), CreateTableSpace(), pg_replication_origin_create(), RenameRole(), RenameSchema(), and RenameTableSpace().

213 {
214  /* ugly coding for speed */
215  return (name[0] == 'p' &&
216  name[1] == 'g' &&
217  name[2] == '_');
218 }
const char * name
Definition: encode.c:561

◆ IsSharedRelation()

bool IsSharedRelation ( Oid  relationId)

Definition at line 238 of file catalog.c.

References AuthIdOidIndexId, AuthIdRolnameIndexId, AuthMemMemRoleIndexId, AuthMemRoleMemIndexId, DatabaseNameIndexId, DatabaseOidIndexId, DbRoleSettingDatidRolidIndexId, PgAuthidToastIndex, PgAuthidToastTable, PgDatabaseToastIndex, PgDatabaseToastTable, PgDbRoleSettingToastIndex, PgDbRoleSettingToastTable, PgReplicationOriginToastIndex, PgReplicationOriginToastTable, PgShdescriptionToastIndex, PgShdescriptionToastTable, PgShseclabelToastIndex, PgShseclabelToastTable, PgSubscriptionToastIndex, PgSubscriptionToastTable, PgTablespaceToastIndex, PgTablespaceToastTable, ReplicationOriginIdentIndex, ReplicationOriginNameIndex, SharedDependDependerIndexId, SharedDependReferenceIndexId, SharedDescriptionObjIndexId, SharedSecLabelObjectIndexId, SubscriptionNameIndexId, SubscriptionObjectIndexId, TablespaceNameIndexId, and TablespaceOidIndexId.

Referenced by CacheInvalidateCatalog(), CacheInvalidateHeapTuple(), classIdGetDbId(), DeleteSecurityLabel(), get_object_address(), GetSecurityLabel(), RelationBuildLocalRelation(), SetLocktagRelationOid(), SetSecurityLabel(), and UpdateLogicalMappings().

239 {
240  /* These are the shared catalogs (look for BKI_SHARED_RELATION) */
241  if (relationId == AuthIdRelationId ||
242  relationId == AuthMemRelationId ||
243  relationId == DatabaseRelationId ||
244  relationId == SharedDescriptionRelationId ||
245  relationId == SharedDependRelationId ||
246  relationId == SharedSecLabelRelationId ||
247  relationId == TableSpaceRelationId ||
248  relationId == DbRoleSettingRelationId ||
249  relationId == ReplicationOriginRelationId ||
250  relationId == SubscriptionRelationId)
251  return true;
252  /* These are their indexes (see indexing.h) */
253  if (relationId == AuthIdRolnameIndexId ||
254  relationId == AuthIdOidIndexId ||
255  relationId == AuthMemRoleMemIndexId ||
256  relationId == AuthMemMemRoleIndexId ||
257  relationId == DatabaseNameIndexId ||
258  relationId == DatabaseOidIndexId ||
259  relationId == SharedDescriptionObjIndexId ||
260  relationId == SharedDependDependerIndexId ||
261  relationId == SharedDependReferenceIndexId ||
262  relationId == SharedSecLabelObjectIndexId ||
263  relationId == TablespaceOidIndexId ||
264  relationId == TablespaceNameIndexId ||
265  relationId == DbRoleSettingDatidRolidIndexId ||
266  relationId == ReplicationOriginIdentIndex ||
267  relationId == ReplicationOriginNameIndex ||
268  relationId == SubscriptionObjectIndexId ||
269  relationId == SubscriptionNameIndexId)
270  return true;
271  /* These are their toast tables and toast indexes (see toasting.h) */
272  if (relationId == PgAuthidToastTable ||
273  relationId == PgAuthidToastIndex ||
274  relationId == PgDatabaseToastTable ||
275  relationId == PgDatabaseToastIndex ||
276  relationId == PgDbRoleSettingToastTable ||
277  relationId == PgDbRoleSettingToastIndex ||
278  relationId == PgReplicationOriginToastTable ||
279  relationId == PgReplicationOriginToastIndex ||
280  relationId == PgShdescriptionToastTable ||
281  relationId == PgShdescriptionToastIndex ||
282  relationId == PgShseclabelToastTable ||
283  relationId == PgShseclabelToastIndex ||
284  relationId == PgSubscriptionToastTable ||
285  relationId == PgSubscriptionToastIndex ||
286  relationId == PgTablespaceToastTable ||
287  relationId == PgTablespaceToastIndex)
288  return true;
289  return false;
290 }
#define PgShseclabelToastIndex
Definition: toasting.h:97
#define SharedDependDependerIndexId
Definition: indexing.h:234
#define PgAuthidToastTable
Definition: toasting.h:81
#define PgTablespaceToastTable
Definition: toasting.h:102
#define DbRoleSettingDatidRolidIndexId
Definition: indexing.h:325
#define PgShseclabelToastTable
Definition: toasting.h:96
#define AuthIdOidIndexId
Definition: indexing.h:112
#define PgSubscriptionToastTable
Definition: toasting.h:99
#define PgDatabaseToastTable
Definition: toasting.h:84
#define PgTablespaceToastIndex
Definition: toasting.h:103
#define ReplicationOriginIdentIndex
Definition: indexing.h:348
#define TablespaceOidIndexId
Definition: indexing.h:252
#define PgShdescriptionToastTable
Definition: toasting.h:93
#define PgReplicationOriginToastTable
Definition: toasting.h:90
#define DatabaseOidIndexId
Definition: indexing.h:157
#define PgShdescriptionToastIndex
Definition: toasting.h:94
#define PgDbRoleSettingToastTable
Definition: toasting.h:87
#define AuthMemRoleMemIndexId
Definition: indexing.h:115
#define SharedDescriptionObjIndexId
Definition: indexing.h:167
#define PgDatabaseToastIndex
Definition: toasting.h:85
#define PgAuthidToastIndex
Definition: toasting.h:82
#define PgReplicationOriginToastIndex
Definition: toasting.h:91
#define AuthMemMemRoleIndexId
Definition: indexing.h:117
#define DatabaseNameIndexId
Definition: indexing.h:155
#define SharedSecLabelObjectIndexId
Definition: indexing.h:331
#define TablespaceNameIndexId
Definition: indexing.h:254
#define SubscriptionNameIndexId
Definition: indexing.h:372
#define PgSubscriptionToastIndex
Definition: toasting.h:100
#define ReplicationOriginNameIndex
Definition: indexing.h:351
#define SharedDependReferenceIndexId
Definition: indexing.h:236
#define PgDbRoleSettingToastIndex
Definition: toasting.h:88
#define AuthIdRolnameIndexId
Definition: indexing.h:110
#define SubscriptionObjectIndexId
Definition: indexing.h:369

◆ IsSystemClass()

bool IsSystemClass ( Oid  relid,
Form_pg_class  reltuple 
)

Definition at line 80 of file catalog.c.

References IsCatalogRelationOid(), and IsToastClass().

Referenced by IsSystemRelation(), pg_class_aclmask(), RangeVarCallbackForAlterRelation(), RangeVarCallbackForDropRelation(), RangeVarCallbackForPolicy(), RangeVarCallbackForRenameRule(), RangeVarCallbackForRenameTrigger(), RangeVarCallbackOwnsRelation(), ReindexMultipleTables(), renameatt_check(), swap_relation_files(), and truncate_check_rel().

81 {
82  /* IsCatalogRelationOid is a bit faster, so test that first */
83  return (IsCatalogRelationOid(relid) || IsToastClass(reltuple));
84 }
bool IsCatalogRelationOid(Oid relid)
Definition: catalog.c:115
bool IsToastClass(Form_pg_class reltuple)
Definition: catalog.c:160

◆ IsSystemRelation()

◆ IsToastClass()

bool IsToastClass ( Form_pg_class  reltuple)

Definition at line 160 of file catalog.c.

References IsToastNamespace().

Referenced by IsSystemClass().

161 {
162  Oid relnamespace = reltuple->relnamespace;
163 
164  return IsToastNamespace(relnamespace);
165 }
bool IsToastNamespace(Oid namespaceId)
Definition: catalog.c:195
unsigned int Oid
Definition: postgres_ext.h:31

◆ IsToastNamespace()

bool IsToastNamespace ( Oid  namespaceId)

Definition at line 195 of file catalog.c.

References isTempToastNamespace().

Referenced by AlterTableMoveAll(), heap_create(), IsToastClass(), IsToastRelation(), reindex_index(), reindex_relation(), and ReindexRelationConcurrently().

196 {
197  return (namespaceId == PG_TOAST_NAMESPACE) ||
198  isTempToastNamespace(namespaceId);
199 }
bool isTempToastNamespace(Oid namespaceId)
Definition: namespace.c:3168

◆ IsToastRelation()

bool IsToastRelation ( Relation  relation)

Definition at line 140 of file catalog.c.

References IsToastNamespace(), and RelationGetNamespace.

Referenced by CacheInvalidateHeapTuple(), heap_abort_speculative(), heap_insert(), ReorderBufferProcessTXN(), and ReorderBufferToastAppendChunk().

141 {
142  /*
143  * What we actually check is whether the relation belongs to a pg_toast
144  * namespace. This should be equivalent because of restrictions that are
145  * enforced elsewhere against creating user relations in, or moving
146  * relations into/out of, a pg_toast namespace. Notice also that this
147  * will not say "true" for toast tables belonging to other sessions' temp
148  * tables; we expect that other mechanisms will prevent access to those.
149  */
150  return IsToastNamespace(RelationGetNamespace(relation));
151 }
bool IsToastNamespace(Oid namespaceId)
Definition: catalog.c:195
#define RelationGetNamespace(relation)
Definition: rel.h:497

◆ pg_nextoid()

Datum pg_nextoid ( PG_FUNCTION_ARGS  )

Definition at line 464 of file catalog.c.

References attname, ereport, errcode(), ERRCODE_INSUFFICIENT_PRIVILEGE, errmsg(), ERROR, GetNewOidWithIndex(), GETSTRUCT, HeapTupleIsValid, idx(), index_close(), index_open(), IndexRelationGetNumberOfKeyAttributes, IsSystemRelation(), NameStr, PG_GETARG_NAME, PG_GETARG_OID, RelationData::rd_index, RelationGetRelationName, RelationGetRelid, ReleaseSysCache(), RowExclusiveLock, SearchSysCacheAttName(), superuser(), table_close(), and table_open().

465 {
466  Oid reloid = PG_GETARG_OID(0);
468  Oid idxoid = PG_GETARG_OID(2);
469  Relation rel;
470  Relation idx;
471  HeapTuple atttuple;
472  Form_pg_attribute attform;
473  AttrNumber attno;
474  Oid newoid;
475 
476  /*
477  * As this function is not intended to be used during normal running, and
478  * only supports system catalogs (which require superuser permissions to
479  * modify), just checking for superuser ought to not obstruct valid
480  * usecases.
481  */
482  if (!superuser())
483  ereport(ERROR,
485  errmsg("must be superuser to call pg_nextoid()")));
486 
487  rel = table_open(reloid, RowExclusiveLock);
488  idx = index_open(idxoid, RowExclusiveLock);
489 
490  if (!IsSystemRelation(rel))
491  ereport(ERROR,
492  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
493  errmsg("pg_nextoid() can only be used on system catalogs")));
494 
495  if (idx->rd_index->indrelid != RelationGetRelid(rel))
496  ereport(ERROR,
497  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
498  errmsg("index \"%s\" does not belong to table \"%s\"",
500  RelationGetRelationName(rel))));
501 
502  atttuple = SearchSysCacheAttName(reloid, NameStr(*attname));
503  if (!HeapTupleIsValid(atttuple))
504  ereport(ERROR,
505  (errcode(ERRCODE_UNDEFINED_COLUMN),
506  errmsg("column \"%s\" of relation \"%s\" does not exist",
507  NameStr(*attname), RelationGetRelationName(rel))));
508 
509  attform = ((Form_pg_attribute) GETSTRUCT(atttuple));
510  attno = attform->attnum;
511 
512  if (attform->atttypid != OIDOID)
513  ereport(ERROR,
514  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
515  errmsg("column \"%s\" is not of type oid",
516  NameStr(*attname))));
517 
519  idx->rd_index->indkey.values[0] != attno)
520  ereport(ERROR,
521  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
522  errmsg("index \"%s\" is not the index for column \"%s\"",
524  NameStr(*attname))));
525 
526  newoid = GetNewOidWithIndex(rel, idxoid, attno);
527 
528  ReleaseSysCache(atttuple);
531 
532  return newoid;
533 }
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
Definition: catalog.c:317
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:167
#define GETSTRUCT(TUP)
Definition: htup_details.h:655
bool IsSystemRelation(Relation relation)
Definition: catalog.c:68
int errcode(int sqlerrcode)
Definition: elog.c:610
bool superuser(void)
Definition: superuser.c:46
Datum idx(PG_FUNCTION_ARGS)
Definition: _int_op.c:259
unsigned int Oid
Definition: postgres_ext.h:31
Form_pg_index rd_index
Definition: rel.h:174
#define ERRCODE_INSUFFICIENT_PRIVILEGE
#define ERROR
Definition: elog.h:43
NameData attname
Definition: pg_attribute.h:40
Definition: c.h:617
#define PG_GETARG_OID(n)
Definition: fmgr.h:275
#define RowExclusiveLock
Definition: lockdefs.h:38
#define RelationGetRelationName(relation)
Definition: rel.h:490
FormData_pg_attribute * Form_pg_attribute
Definition: pg_attribute.h:193
#define IndexRelationGetNumberOfKeyAttributes(relation)
Definition: rel.h:475
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:1164
#define ereport(elevel,...)
Definition: elog.h:144
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
HeapTuple SearchSysCacheAttName(Oid relid, const char *attname)
Definition: syscache.c:1257
void index_close(Relation relation, LOCKMODE lockmode)
Definition: indexam.c:158
int errmsg(const char *fmt,...)
Definition: elog.c:821
#define NameStr(name)
Definition: c.h:623
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:39
int16 AttrNumber
Definition: attnum.h:21
#define RelationGetRelid(relation)
Definition: rel.h:456
Relation index_open(Oid relationId, LOCKMODE lockmode)
Definition: indexam.c:132
#define PG_GETARG_NAME(n)
Definition: fmgr.h:278