1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* rel.h
|
2000-01-31 05:35:57 +01:00
|
|
|
* POSTGRES relation descriptor (a/k/a relcache entry) definitions.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2010-01-02 17:58:17 +01:00
|
|
|
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-01-02 17:58:17 +01:00
|
|
|
* $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.118 2010/01/02 16:58:10 momjian Exp $
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef REL_H
|
1996-08-28 03:59:28 +02:00
|
|
|
#define REL_H
|
|
|
|
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "access/tupdesc.h"
|
1999-07-16 19:07:40 +02:00
|
|
|
#include "catalog/pg_am.h"
|
|
|
|
#include "catalog/pg_class.h"
|
2002-02-19 21:11:20 +01:00
|
|
|
#include "catalog/pg_index.h"
|
2005-05-28 01:31:21 +02:00
|
|
|
#include "fmgr.h"
|
2007-09-20 19:56:33 +02:00
|
|
|
#include "nodes/bitmapset.h"
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "rewrite/prs2lock.h"
|
2001-06-28 01:31:40 +02:00
|
|
|
#include "storage/block.h"
|
|
|
|
#include "storage/relfilenode.h"
|
2008-06-19 02:46:06 +02:00
|
|
|
#include "utils/relcache.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2000-01-31 05:35:57 +01:00
|
|
|
|
1999-09-18 21:08:25 +02:00
|
|
|
/*
|
|
|
|
* LockRelId and LockInfo really belong to lmgr.h, but it's more convenient
|
|
|
|
* to declare them here so we can have a LockInfoData field in a Relation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct LockRelId
|
|
|
|
{
|
|
|
|
Oid relId; /* a relation identifier */
|
|
|
|
Oid dbId; /* a database identifier */
|
|
|
|
} LockRelId;
|
|
|
|
|
|
|
|
typedef struct LockInfoData
|
|
|
|
{
|
|
|
|
LockRelId lockRelId;
|
|
|
|
} LockInfoData;
|
|
|
|
|
|
|
|
typedef LockInfoData *LockInfo;
|
|
|
|
|
2000-01-31 05:35:57 +01:00
|
|
|
/*
|
|
|
|
* Likewise, this struct really belongs to trigger.h, but for convenience
|
|
|
|
* we put it here.
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct Trigger
|
|
|
|
{
|
2002-04-02 00:36:13 +02:00
|
|
|
Oid tgoid; /* OID of trigger (pg_trigger row) */
|
|
|
|
/* Remaining fields are copied from pg_trigger, see pg_trigger.h */
|
1997-09-08 04:41:22 +02:00
|
|
|
char *tgname;
|
|
|
|
Oid tgfoid;
|
|
|
|
int16 tgtype;
|
2007-03-20 00:38:32 +01:00
|
|
|
char tgenabled;
|
1999-09-29 18:06:40 +02:00
|
|
|
bool tgisconstraint;
|
2002-04-02 00:36:13 +02:00
|
|
|
Oid tgconstrrelid;
|
2009-07-28 04:56:31 +02:00
|
|
|
Oid tgconstrindid;
|
2007-02-14 02:58:58 +01:00
|
|
|
Oid tgconstraint;
|
1999-09-29 18:06:40 +02:00
|
|
|
bool tgdeferrable;
|
|
|
|
bool tginitdeferred;
|
1997-09-08 04:41:22 +02:00
|
|
|
int16 tgnargs;
|
2005-03-29 02:17:27 +02:00
|
|
|
int16 tgnattr;
|
|
|
|
int16 *tgattr;
|
1997-09-08 04:41:22 +02:00
|
|
|
char **tgargs;
|
2009-11-20 21:38:12 +01:00
|
|
|
char *tgqual;
|
1997-09-08 23:56:23 +02:00
|
|
|
} Trigger;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
|
|
|
typedef struct TriggerDesc
|
|
|
|
{
|
2001-06-01 04:41:36 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* Index data to identify which triggers are which. Since each trigger
|
|
|
|
* can appear in more than one class, for each class we provide a list of
|
2008-03-28 01:21:56 +01:00
|
|
|
* integer indexes into the triggers array. The class codes are defined
|
|
|
|
* by TRIGGER_EVENT_xxx macros in commands/trigger.h.
|
2001-06-01 04:41:36 +02:00
|
|
|
*/
|
2008-03-28 01:21:56 +01:00
|
|
|
#define TRIGGER_NUM_EVENT_CLASSES 4
|
2001-06-01 04:41:36 +02:00
|
|
|
|
|
|
|
uint16 n_before_statement[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
uint16 n_before_row[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
uint16 n_after_row[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
uint16 n_after_statement[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
int *tg_before_statement[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
int *tg_before_row[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
int *tg_after_row[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
int *tg_after_statement[TRIGGER_NUM_EVENT_CLASSES];
|
|
|
|
|
|
|
|
/* The actual array of triggers is here */
|
1997-09-08 04:41:22 +02:00
|
|
|
Trigger *triggers;
|
2000-01-31 05:35:57 +01:00
|
|
|
int numtriggers;
|
1997-09-08 23:56:23 +02:00
|
|
|
} TriggerDesc;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2001-06-22 21:16:24 +02:00
|
|
|
|
2005-05-28 01:31:21 +02:00
|
|
|
/*
|
|
|
|
* Cached lookup information for the index access method functions defined
|
|
|
|
* by the pg_am row associated with an index relation.
|
|
|
|
*/
|
|
|
|
typedef struct RelationAmInfo
|
|
|
|
{
|
|
|
|
FmgrInfo aminsert;
|
|
|
|
FmgrInfo ambeginscan;
|
|
|
|
FmgrInfo amgettuple;
|
2008-04-11 00:25:26 +02:00
|
|
|
FmgrInfo amgetbitmap;
|
2005-05-28 01:31:21 +02:00
|
|
|
FmgrInfo amrescan;
|
|
|
|
FmgrInfo amendscan;
|
|
|
|
FmgrInfo ammarkpos;
|
|
|
|
FmgrInfo amrestrpos;
|
|
|
|
FmgrInfo ambuild;
|
|
|
|
FmgrInfo ambulkdelete;
|
|
|
|
FmgrInfo amvacuumcleanup;
|
|
|
|
FmgrInfo amcostestimate;
|
2006-07-04 00:45:41 +02:00
|
|
|
FmgrInfo amoptions;
|
2005-05-28 01:31:21 +02:00
|
|
|
} RelationAmInfo;
|
|
|
|
|
|
|
|
|
2000-01-31 05:35:57 +01:00
|
|
|
/*
|
|
|
|
* Here are the contents of a relation cache entry.
|
|
|
|
*/
|
1999-09-18 21:08:25 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
typedef struct RelationData
|
|
|
|
{
|
2004-02-10 02:55:27 +01:00
|
|
|
RelFileNode rd_node; /* relation physical identifier */
|
|
|
|
/* use "struct" here to avoid needing to include smgr.h: */
|
2004-08-29 07:07:03 +02:00
|
|
|
struct SMgrRelationData *rd_smgr; /* cached file handle, or NULL */
|
2001-10-25 07:50:21 +02:00
|
|
|
BlockNumber rd_targblock; /* current insertion target block, or
|
|
|
|
* InvalidBlockNumber */
|
2001-06-28 01:31:40 +02:00
|
|
|
int rd_refcnt; /* reference count */
|
2009-04-01 00:12:48 +02:00
|
|
|
bool rd_istemp; /* rel is a temporary relation */
|
2009-06-11 16:49:15 +02:00
|
|
|
bool rd_islocaltemp; /* rel is a temp rel of this session */
|
2004-08-28 22:31:44 +02:00
|
|
|
bool rd_isnailed; /* rel is nailed in cache */
|
|
|
|
bool rd_isvalid; /* relcache entry is valid */
|
2005-10-15 04:49:52 +02:00
|
|
|
char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 =
|
|
|
|
* valid, 2 = temporarily forced */
|
2004-09-16 18:58:44 +02:00
|
|
|
SubTransactionId rd_createSubid; /* rel was created in current xact */
|
2007-11-15 22:14:46 +01:00
|
|
|
SubTransactionId rd_newRelfilenodeSubid; /* new relfilenode assigned in
|
|
|
|
* current xact */
|
2004-08-29 07:07:03 +02:00
|
|
|
|
2004-08-28 22:31:44 +02:00
|
|
|
/*
|
2004-09-16 18:58:44 +02:00
|
|
|
* rd_createSubid is the ID of the highest subtransaction the rel has
|
2005-10-15 04:49:52 +02:00
|
|
|
* survived into; or zero if the rel was not created in the current top
|
|
|
|
* transaction. This should be relied on only for optimization purposes;
|
|
|
|
* it is possible for new-ness to be "forgotten" (eg, after CLUSTER).
|
2007-11-15 22:14:46 +01:00
|
|
|
* Likewise, rd_newRelfilenodeSubid is the ID of the highest
|
|
|
|
* subtransaction the relfilenode change has survived into, or zero if not
|
|
|
|
* changed in the current transaction (or we have forgotten changing it).
|
2004-08-28 22:31:44 +02:00
|
|
|
*/
|
1997-09-08 04:41:22 +02:00
|
|
|
Form_pg_class rd_rel; /* RELATION tuple */
|
2002-02-19 21:11:20 +01:00
|
|
|
TupleDesc rd_att; /* tuple descriptor */
|
1999-09-18 21:08:25 +02:00
|
|
|
Oid rd_id; /* relation's object id */
|
2000-06-17 23:49:04 +02:00
|
|
|
List *rd_indexlist; /* list of OIDs of indexes on relation */
|
2007-09-20 19:56:33 +02:00
|
|
|
Bitmapset *rd_indexattr; /* identifies columns used in indexes */
|
2005-08-12 03:36:05 +02:00
|
|
|
Oid rd_oidindex; /* OID of unique index on OID, if any */
|
2000-06-17 23:49:04 +02:00
|
|
|
LockInfoData rd_lockInfo; /* lock mgr's info for locking relation */
|
1997-09-08 04:41:22 +02:00
|
|
|
RuleLock *rd_rules; /* rewrite rules */
|
2000-06-30 09:04:23 +02:00
|
|
|
MemoryContext rd_rulescxt; /* private memory cxt for rd_rules, if any */
|
2000-01-31 05:35:57 +01:00
|
|
|
TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */
|
2001-06-22 21:16:24 +02:00
|
|
|
|
2006-07-04 00:45:41 +02:00
|
|
|
/*
|
|
|
|
* rd_options is set whenever rd_rel is loaded into the relcache entry.
|
2006-10-04 02:30:14 +02:00
|
|
|
* Note that you can NOT look into rd_rel for this data. NULL means "use
|
|
|
|
* defaults".
|
2006-07-04 00:45:41 +02:00
|
|
|
*/
|
|
|
|
bytea *rd_options; /* parsed pg_class.reloptions */
|
|
|
|
|
2002-02-19 21:11:20 +01:00
|
|
|
/* These are non-NULL only for an index relation: */
|
|
|
|
Form_pg_index rd_index; /* pg_index tuple describing this index */
|
2003-08-04 02:43:34 +02:00
|
|
|
struct HeapTupleData *rd_indextuple; /* all of pg_index tuple */
|
|
|
|
/* "struct HeapTupleData *" avoids need to include htup.h here */
|
2002-02-19 21:11:20 +01:00
|
|
|
Form_pg_am rd_am; /* pg_am tuple for index's AM */
|
|
|
|
|
2003-11-09 22:30:38 +01:00
|
|
|
/*
|
|
|
|
* index access support info (used only for an index relation)
|
|
|
|
*
|
2003-11-12 22:15:59 +01:00
|
|
|
* Note: only default operators and support procs for each opclass are
|
2006-12-23 01:43:13 +01:00
|
|
|
* cached, namely those with lefttype and righttype equal to the opclass's
|
2007-11-15 22:14:46 +01:00
|
|
|
* opcintype. The arrays are indexed by strategy or support number, which
|
|
|
|
* is a sufficient identifier given that restriction.
|
2006-04-26 00:46:05 +02:00
|
|
|
*
|
|
|
|
* Note: rd_amcache is available for index AMs to cache private data about
|
|
|
|
* an index. This must be just a cache since it may get reset at any time
|
|
|
|
* (in particular, it will get reset by a relcache inval message for the
|
2006-10-04 02:30:14 +02:00
|
|
|
* index). If used, it must point to a single memory chunk palloc'd in
|
2006-04-26 00:46:05 +02:00
|
|
|
* rd_indexcxt. A relcache reset will include freeing that chunk and
|
|
|
|
* setting rd_amcache = NULL.
|
2003-11-09 22:30:38 +01:00
|
|
|
*/
|
2001-10-07 01:21:45 +02:00
|
|
|
MemoryContext rd_indexcxt; /* private memory cxt for this stuff */
|
2005-05-28 01:31:21 +02:00
|
|
|
RelationAmInfo *rd_aminfo; /* lookup info for funcs found in pg_am */
|
2006-12-23 01:43:13 +01:00
|
|
|
Oid *rd_opfamily; /* OIDs of op families for each index col */
|
|
|
|
Oid *rd_opcintype; /* OIDs of opclass declared input data types */
|
2002-02-19 21:11:20 +01:00
|
|
|
Oid *rd_operator; /* OIDs of index operators */
|
2001-10-07 01:21:45 +02:00
|
|
|
RegProcedure *rd_support; /* OIDs of support procedures */
|
2005-10-15 04:49:52 +02:00
|
|
|
FmgrInfo *rd_supportinfo; /* lookup info for support procedures */
|
2007-01-09 03:14:16 +01:00
|
|
|
int16 *rd_indoption; /* per-column AM-specific flags */
|
2003-05-28 18:04:02 +02:00
|
|
|
List *rd_indexprs; /* index expression trees, if any */
|
|
|
|
List *rd_indpred; /* index predicate tree, if any */
|
2009-12-07 06:22:23 +01:00
|
|
|
Oid *rd_exclops; /* OIDs of exclusion operators, if any */
|
|
|
|
Oid *rd_exclprocs; /* OIDs of exclusion ops' procs, if any */
|
|
|
|
uint16 *rd_exclstrats; /* exclusion ops' strategy numbers, if any */
|
2006-04-26 00:46:05 +02:00
|
|
|
void *rd_amcache; /* available for use by index AM */
|
2001-10-07 01:21:45 +02:00
|
|
|
|
2008-12-03 14:05:22 +01:00
|
|
|
/*
|
|
|
|
* sizes of the free space and visibility map forks, or InvalidBlockNumber
|
|
|
|
* if not known yet
|
|
|
|
*/
|
2009-06-11 16:49:15 +02:00
|
|
|
BlockNumber rd_fsm_nblocks;
|
|
|
|
BlockNumber rd_vm_nblocks;
|
2008-09-30 12:52:14 +02:00
|
|
|
|
2007-05-27 05:50:39 +02:00
|
|
|
/* use "struct" here to avoid needing to include pgstat.h: */
|
2007-11-15 22:14:46 +01:00
|
|
|
struct PgStat_TableStatus *pgstat_info; /* statistics collection area */
|
1997-09-08 23:56:23 +02:00
|
|
|
} RelationData;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2006-07-04 00:45:41 +02:00
|
|
|
/*
|
|
|
|
* StdRdOptions
|
|
|
|
* Standard contents of rd_options for heaps and generic indexes.
|
|
|
|
*
|
|
|
|
* RelationGetFillFactor() and RelationGetTargetPageFreeSpace() can only
|
|
|
|
* be applied to relations that use this format or a superset for
|
|
|
|
* private options data.
|
|
|
|
*/
|
2009-02-09 21:57:59 +01:00
|
|
|
/* autovacuum-related reloptions. */
|
|
|
|
typedef struct AutoVacOpts
|
|
|
|
{
|
2009-06-11 16:49:15 +02:00
|
|
|
bool enabled;
|
|
|
|
int vacuum_threshold;
|
|
|
|
int analyze_threshold;
|
|
|
|
int vacuum_cost_delay;
|
|
|
|
int vacuum_cost_limit;
|
|
|
|
int freeze_min_age;
|
|
|
|
int freeze_max_age;
|
|
|
|
int freeze_table_age;
|
|
|
|
float8 vacuum_scale_factor;
|
|
|
|
float8 analyze_scale_factor;
|
2009-02-09 21:57:59 +01:00
|
|
|
} AutoVacOpts;
|
|
|
|
|
2006-07-04 00:45:41 +02:00
|
|
|
typedef struct StdRdOptions
|
|
|
|
{
|
2007-02-28 00:48:10 +01:00
|
|
|
int32 vl_len_; /* varlena header (do not touch directly!) */
|
2006-10-04 02:30:14 +02:00
|
|
|
int fillfactor; /* page fill factor in percent (0..100) */
|
2009-06-11 16:49:15 +02:00
|
|
|
AutoVacOpts autovacuum; /* autovacuum-related options */
|
2006-07-04 00:45:41 +02:00
|
|
|
} StdRdOptions;
|
|
|
|
|
|
|
|
#define HEAP_MIN_FILLFACTOR 10
|
|
|
|
#define HEAP_DEFAULT_FILLFACTOR 100
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RelationGetFillFactor
|
|
|
|
* Returns the relation's fillfactor. Note multiple eval of argument!
|
|
|
|
*/
|
|
|
|
#define RelationGetFillFactor(relation, defaultff) \
|
|
|
|
((relation)->rd_options ? \
|
|
|
|
((StdRdOptions *) (relation)->rd_options)->fillfactor : (defaultff))
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RelationGetTargetPageUsage
|
|
|
|
* Returns the relation's desired space usage per page in bytes.
|
|
|
|
*/
|
|
|
|
#define RelationGetTargetPageUsage(relation, defaultff) \
|
|
|
|
(BLCKSZ * RelationGetFillFactor(relation, defaultff) / 100)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RelationGetTargetPageFreeSpace
|
|
|
|
* Returns the relation's desired freespace per page in bytes.
|
|
|
|
*/
|
|
|
|
#define RelationGetTargetPageFreeSpace(relation, defaultff) \
|
|
|
|
(BLCKSZ * (100 - RelationGetFillFactor(relation, defaultff)) / 100)
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* RelationIsValid
|
1997-09-07 07:04:48 +02:00
|
|
|
* True iff relation descriptor is valid.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#define RelationIsValid(relation) PointerIsValid(relation)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1999-09-18 21:08:25 +02:00
|
|
|
#define InvalidRelation ((Relation) NULL)
|
|
|
|
|
1996-08-28 03:59:28 +02:00
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* RelationHasReferenceCountZero
|
1997-09-07 07:04:48 +02:00
|
|
|
* True iff relation reference count is zero.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
* Note:
|
1997-09-07 07:04:48 +02:00
|
|
|
* Assumes relation descriptor is valid.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
|
|
|
#define RelationHasReferenceCountZero(relation) \
|
1997-09-07 07:04:48 +02:00
|
|
|
((bool)((relation)->rd_refcnt == 0))
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* RelationGetForm
|
2000-01-31 05:35:57 +01:00
|
|
|
* Returns pg_class tuple for a relation.
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
* Note:
|
1997-09-07 07:04:48 +02:00
|
|
|
* Assumes relation descriptor is valid.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1998-09-01 05:29:17 +02:00
|
|
|
#define RelationGetForm(relation) ((relation)->rd_rel)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* RelationGetRelid
|
2004-01-06 19:07:32 +01:00
|
|
|
* Returns the OID of the relation
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1998-08-19 04:04:17 +02:00
|
|
|
#define RelationGetRelid(relation) ((relation)->rd_id)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
|
|
|
/*
|
1999-09-18 21:08:25 +02:00
|
|
|
* RelationGetNumberOfAttributes
|
2004-01-06 19:07:32 +01:00
|
|
|
* Returns the number of attributes in a relation.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
|
|
|
#define RelationGetNumberOfAttributes(relation) ((relation)->rd_rel->relnatts)
|
|
|
|
|
|
|
|
/*
|
1999-05-25 18:15:34 +02:00
|
|
|
* RelationGetDescr
|
1997-09-07 07:04:48 +02:00
|
|
|
* Returns tuple descriptor for a relation.
|
1996-08-28 03:59:28 +02:00
|
|
|
*/
|
1998-09-01 05:29:17 +02:00
|
|
|
#define RelationGetDescr(relation) ((relation)->rd_att)
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2001-06-19 14:03:41 +02:00
|
|
|
/*
|
|
|
|
* RelationGetRelationName
|
2004-01-06 19:07:32 +01:00
|
|
|
* Returns the rel's name.
|
2001-06-19 14:03:41 +02:00
|
|
|
*
|
2002-03-31 08:26:32 +02:00
|
|
|
* Note that the name is only unique within the containing namespace.
|
2001-06-19 14:03:41 +02:00
|
|
|
*/
|
|
|
|
#define RelationGetRelationName(relation) \
|
2002-03-31 08:26:32 +02:00
|
|
|
(NameStr((relation)->rd_rel->relname))
|
2001-06-19 14:03:41 +02:00
|
|
|
|
2002-03-26 20:17:02 +01:00
|
|
|
/*
|
|
|
|
* RelationGetNamespace
|
2004-01-06 19:07:32 +01:00
|
|
|
* Returns the rel's namespace OID.
|
2002-03-26 20:17:02 +01:00
|
|
|
*/
|
|
|
|
#define RelationGetNamespace(relation) \
|
|
|
|
((relation)->rd_rel->relnamespace)
|
|
|
|
|
2005-01-10 21:02:24 +01:00
|
|
|
/*
|
|
|
|
* RelationOpenSmgr
|
|
|
|
* Open the relation at the smgr level, if not already done.
|
|
|
|
*/
|
|
|
|
#define RelationOpenSmgr(relation) \
|
|
|
|
do { \
|
|
|
|
if ((relation)->rd_smgr == NULL) \
|
|
|
|
smgrsetowner(&((relation)->rd_smgr), smgropen((relation)->rd_node)); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RelationCloseSmgr
|
|
|
|
* Close the relation at the smgr level, if not already done.
|
|
|
|
*
|
|
|
|
* Note: smgrclose should unhook from owner pointer, hence the Assert.
|
|
|
|
*/
|
|
|
|
#define RelationCloseSmgr(relation) \
|
|
|
|
do { \
|
|
|
|
if ((relation)->rd_smgr != NULL) \
|
|
|
|
{ \
|
|
|
|
smgrclose((relation)->rd_smgr); \
|
|
|
|
Assert((relation)->rd_smgr == NULL); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2004-08-28 22:31:44 +02:00
|
|
|
/*
|
|
|
|
* RELATION_IS_LOCAL
|
|
|
|
* If a rel is either temp or newly created in the current transaction,
|
|
|
|
* it can be assumed to be visible only to the current backend.
|
|
|
|
*
|
|
|
|
* Beware of multiple eval of argument
|
|
|
|
*/
|
|
|
|
#define RELATION_IS_LOCAL(relation) \
|
2009-04-01 00:12:48 +02:00
|
|
|
((relation)->rd_islocaltemp || \
|
2004-09-16 18:58:44 +02:00
|
|
|
(relation)->rd_createSubid != InvalidSubTransactionId)
|
2004-08-28 22:31:44 +02:00
|
|
|
|
2009-04-01 00:12:48 +02:00
|
|
|
/*
|
|
|
|
* RELATION_IS_OTHER_TEMP
|
|
|
|
* Test for a temporary relation that belongs to some other session.
|
|
|
|
*
|
|
|
|
* Beware of multiple eval of argument
|
|
|
|
*/
|
|
|
|
#define RELATION_IS_OTHER_TEMP(relation) \
|
|
|
|
((relation)->rd_istemp && !(relation)->rd_islocaltemp)
|
|
|
|
|
2004-07-17 05:32:14 +02:00
|
|
|
/* routines in utils/cache/relcache.c */
|
|
|
|
extern void RelationIncrementReferenceCount(Relation rel);
|
|
|
|
extern void RelationDecrementReferenceCount(Relation rel);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* REL_H */
|