1998-01-25 06:04:21 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* heapam.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* POSTGRES heap access method definitions.
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*
|
2008-01-01 20:46:01 +01:00
|
|
|
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
2008-10-08 03:14:44 +02:00
|
|
|
* $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.139 2008/10/08 01:14:44 tgl Exp $
|
1996-08-27 23:50:29 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1997-09-07 07:04:48 +02:00
|
|
|
#ifndef HEAPAM_H
|
1996-08-27 23:50:29 +02:00
|
|
|
#define HEAPAM_H
|
|
|
|
|
1999-07-11 00:06:26 +02:00
|
|
|
#include "access/htup.h"
|
2002-05-21 01:51:44 +02:00
|
|
|
#include "access/sdir.h"
|
2008-06-19 02:46:06 +02:00
|
|
|
#include "access/skey.h"
|
2008-06-07 00:35:22 +02:00
|
|
|
#include "access/xlog.h"
|
2002-03-26 20:17:02 +01:00
|
|
|
#include "nodes/primnodes.h"
|
2008-06-19 02:46:06 +02:00
|
|
|
#include "storage/bufpage.h"
|
2008-05-12 02:00:54 +02:00
|
|
|
#include "storage/lock.h"
|
2008-06-19 02:46:06 +02:00
|
|
|
#include "utils/relcache.h"
|
2008-03-26 22:10:39 +01:00
|
|
|
#include "utils/snapshot.h"
|
1996-08-27 23:50:29 +02:00
|
|
|
|
|
|
|
|
2007-06-08 20:23:53 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
LockTupleShared,
|
|
|
|
LockTupleExclusive
|
|
|
|
} LockTupleMode;
|
|
|
|
|
|
|
|
|
1996-08-27 23:50:29 +02:00
|
|
|
/* ----------------
|
1997-09-07 07:04:48 +02:00
|
|
|
* function prototypes for heap access method
|
2000-06-19 00:44:35 +02:00
|
|
|
*
|
|
|
|
* heap_create, heap_create_with_catalog, and heap_drop_with_catalog
|
|
|
|
* are declared in catalog/heap.h
|
1996-08-27 23:50:29 +02:00
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
2007-06-08 20:23:53 +02:00
|
|
|
/* in heap/heapam.c */
|
2001-11-02 17:30:29 +01:00
|
|
|
extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
|
2006-08-18 18:09:13 +02:00
|
|
|
extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
|
|
|
|
extern Relation relation_open_nowait(Oid relationId, LOCKMODE lockmode);
|
2002-03-26 20:17:02 +01:00
|
|
|
extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
2008-10-08 03:14:44 +02:00
|
|
|
extern Relation try_relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
2001-11-02 17:30:29 +01:00
|
|
|
extern void relation_close(Relation relation, LOCKMODE lockmode);
|
|
|
|
|
1999-09-18 21:08:25 +02:00
|
|
|
extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
|
2002-03-26 20:17:02 +01:00
|
|
|
extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
2008-10-08 03:14:44 +02:00
|
|
|
extern Relation try_heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
|
2001-11-05 18:46:40 +01:00
|
|
|
|
2001-11-02 17:30:29 +01:00
|
|
|
#define heap_close(r,l) relation_close(r,l)
|
|
|
|
|
2008-06-19 02:46:06 +02:00
|
|
|
/* struct definition appears in relscan.h */
|
|
|
|
typedef struct HeapScanDescData *HeapScanDesc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HeapScanIsValid
|
|
|
|
* True iff the heap scan is valid.
|
|
|
|
*/
|
|
|
|
#define HeapScanIsValid(scan) PointerIsValid(scan)
|
|
|
|
|
2002-05-21 01:51:44 +02:00
|
|
|
extern HeapScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
|
2002-09-04 22:31:48 +02:00
|
|
|
int nkeys, ScanKey key);
|
2008-01-14 02:39:09 +01:00
|
|
|
extern HeapScanDesc heap_beginscan_strat(Relation relation, Snapshot snapshot,
|
|
|
|
int nkeys, ScanKey key,
|
|
|
|
bool allow_strat, bool allow_sync);
|
2007-06-09 20:49:55 +02:00
|
|
|
extern HeapScanDesc heap_beginscan_bm(Relation relation, Snapshot snapshot,
|
2007-11-15 22:14:46 +01:00
|
|
|
int nkeys, ScanKey key);
|
2002-05-21 01:51:44 +02:00
|
|
|
extern void heap_rescan(HeapScanDesc scan, ScanKey key);
|
1998-08-19 04:04:17 +02:00
|
|
|
extern void heap_endscan(HeapScanDesc scan);
|
2002-05-21 01:51:44 +02:00
|
|
|
extern HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction);
|
|
|
|
|
2002-05-24 20:57:57 +02:00
|
|
|
extern bool heap_fetch(Relation relation, Snapshot snapshot,
|
2002-09-04 22:31:48 +02:00
|
|
|
HeapTuple tuple, Buffer *userbuf, bool keep_buf,
|
2007-05-27 05:50:39 +02:00
|
|
|
Relation stats_relation);
|
2007-09-20 19:56:33 +02:00
|
|
|
extern bool heap_hot_search_buffer(ItemPointer tid, Buffer buffer,
|
2007-11-15 22:14:46 +01:00
|
|
|
Snapshot snapshot, bool *all_dead);
|
2007-09-20 19:56:33 +02:00
|
|
|
extern bool heap_hot_search(ItemPointer tid, Relation relation,
|
2007-11-15 22:14:46 +01:00
|
|
|
Snapshot snapshot, bool *all_dead);
|
2002-05-21 01:51:44 +02:00
|
|
|
|
2005-08-20 02:40:32 +02:00
|
|
|
extern void heap_get_latest_tid(Relation relation, Snapshot snapshot,
|
2002-09-04 22:31:48 +02:00
|
|
|
ItemPointer tid);
|
2001-09-17 02:29:10 +02:00
|
|
|
extern void setLastTid(const ItemPointer tid);
|
2002-05-22 00:05:55 +02:00
|
|
|
|
2005-10-15 04:49:52 +02:00
|
|
|
extern Oid heap_insert(Relation relation, HeapTuple tup, CommandId cid,
|
|
|
|
bool use_wal, bool use_fsm);
|
2005-08-20 02:40:32 +02:00
|
|
|
extern HTSU_Result heap_delete(Relation relation, ItemPointer tid,
|
2005-10-15 04:49:52 +02:00
|
|
|
ItemPointer ctid, TransactionId *update_xmax,
|
|
|
|
CommandId cid, Snapshot crosscheck, bool wait);
|
2005-08-20 02:40:32 +02:00
|
|
|
extern HTSU_Result heap_update(Relation relation, ItemPointer otid,
|
2005-10-15 04:49:52 +02:00
|
|
|
HeapTuple newtup,
|
|
|
|
ItemPointer ctid, TransactionId *update_xmax,
|
|
|
|
CommandId cid, Snapshot crosscheck, bool wait);
|
2005-08-20 02:40:32 +02:00
|
|
|
extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
|
2005-10-15 04:49:52 +02:00
|
|
|
Buffer *buffer, ItemPointer ctid,
|
|
|
|
TransactionId *update_xmax, CommandId cid,
|
|
|
|
LockTupleMode mode, bool nowait);
|
2006-05-11 01:18:39 +02:00
|
|
|
extern void heap_inplace_update(Relation relation, HeapTuple tuple);
|
Fix recently-understood problems with handling of XID freezing, particularly
in PITR scenarios. We now WAL-log the replacement of old XIDs with
FrozenTransactionId, so that such replacement is guaranteed to propagate to
PITR slave databases. Also, rather than relying on hint-bit updates to be
preserved, pg_clog is not truncated until all instances of an XID are known to
have been replaced by FrozenTransactionId. Add new GUC variables and
pg_autovacuum columns to allow management of the freezing policy, so that
users can trade off the size of pg_clog against the amount of freezing work
done. Revise the already-existing code that forces autovacuum of tables
approaching the wraparound point to make it more bulletproof; also, revise the
autovacuum logic so that anti-wraparound vacuuming is done per-table rather
than per-database. initdb forced because of changes in pg_class, pg_database,
and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-11-05 23:42:10 +01:00
|
|
|
extern bool heap_freeze_tuple(HeapTupleHeader tuple, TransactionId cutoff_xid,
|
2007-11-15 22:14:46 +01:00
|
|
|
Buffer buf);
|
2002-05-22 00:05:55 +02:00
|
|
|
|
|
|
|
extern Oid simple_heap_insert(Relation relation, HeapTuple tup);
|
2001-01-23 05:32:23 +01:00
|
|
|
extern void simple_heap_delete(Relation relation, ItemPointer tid);
|
|
|
|
extern void simple_heap_update(Relation relation, ItemPointer otid,
|
2001-03-22 05:01:46 +01:00
|
|
|
HeapTuple tup);
|
2002-05-22 00:05:55 +02:00
|
|
|
|
1998-08-19 04:04:17 +02:00
|
|
|
extern void heap_markpos(HeapScanDesc scan);
|
|
|
|
extern void heap_restrpos(HeapScanDesc scan);
|
1996-08-27 23:50:29 +02:00
|
|
|
|
2007-09-20 19:56:33 +02:00
|
|
|
extern void heap_sync(Relation relation);
|
|
|
|
|
2000-11-21 22:16:06 +01:00
|
|
|
extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr);
|
2006-03-24 05:32:13 +01:00
|
|
|
extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec);
|
Fix recently-understood problems with handling of XID freezing, particularly
in PITR scenarios. We now WAL-log the replacement of old XIDs with
FrozenTransactionId, so that such replacement is guaranteed to propagate to
PITR slave databases. Also, rather than relying on hint-bit updates to be
preserved, pg_clog is not truncated until all instances of an XID are known to
have been replaced by FrozenTransactionId. Add new GUC variables and
pg_autovacuum columns to allow management of the freezing policy, so that
users can trade off the size of pg_clog against the amount of freezing work
done. Revise the already-existing code that forces autovacuum of tables
approaching the wraparound point to make it more bulletproof; also, revise the
autovacuum logic so that anti-wraparound vacuuming is done per-table rather
than per-database. initdb forced because of changes in pg_class, pg_database,
and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-11-05 23:42:10 +01:00
|
|
|
extern void heap2_redo(XLogRecPtr lsn, XLogRecord *rptr);
|
|
|
|
extern void heap2_desc(StringInfo buf, uint8 xl_info, char *rec);
|
|
|
|
|
2001-07-12 06:11:13 +02:00
|
|
|
extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf,
|
2001-10-25 07:50:21 +02:00
|
|
|
ItemPointerData from,
|
|
|
|
Buffer newbuf, HeapTuple newtup);
|
Fix recently-understood problems with handling of XID freezing, particularly
in PITR scenarios. We now WAL-log the replacement of old XIDs with
FrozenTransactionId, so that such replacement is guaranteed to propagate to
PITR slave databases. Also, rather than relying on hint-bit updates to be
preserved, pg_clog is not truncated until all instances of an XID are known to
have been replaced by FrozenTransactionId. Add new GUC variables and
pg_autovacuum columns to allow management of the freezing policy, so that
users can trade off the size of pg_clog against the amount of freezing work
done. Revise the already-existing code that forces autovacuum of tables
approaching the wraparound point to make it more bulletproof; also, revise the
autovacuum logic so that anti-wraparound vacuuming is done per-table rather
than per-database. initdb forced because of changes in pg_class, pg_database,
and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-11-05 23:42:10 +01:00
|
|
|
extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
|
2007-09-20 19:56:33 +02:00
|
|
|
OffsetNumber *redirected, int nredirected,
|
|
|
|
OffsetNumber *nowdead, int ndead,
|
|
|
|
OffsetNumber *nowunused, int nunused,
|
|
|
|
bool redirect_move);
|
Fix recently-understood problems with handling of XID freezing, particularly
in PITR scenarios. We now WAL-log the replacement of old XIDs with
FrozenTransactionId, so that such replacement is guaranteed to propagate to
PITR slave databases. Also, rather than relying on hint-bit updates to be
preserved, pg_clog is not truncated until all instances of an XID are known to
have been replaced by FrozenTransactionId. Add new GUC variables and
pg_autovacuum columns to allow management of the freezing policy, so that
users can trade off the size of pg_clog against the amount of freezing work
done. Revise the already-existing code that forces autovacuum of tables
approaching the wraparound point to make it more bulletproof; also, revise the
autovacuum logic so that anti-wraparound vacuuming is done per-table rather
than per-database. initdb forced because of changes in pg_class, pg_database,
and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane.
2006-11-05 23:42:10 +01:00
|
|
|
extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer,
|
2007-11-15 22:14:46 +01:00
|
|
|
TransactionId cutoff_xid,
|
|
|
|
OffsetNumber *offsets, int offcnt);
|
2008-08-11 13:05:11 +02:00
|
|
|
extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum,
|
|
|
|
BlockNumber blk, Page page);
|
2000-11-21 22:16:06 +01:00
|
|
|
|
2007-09-20 19:56:33 +02:00
|
|
|
/* in heap/pruneheap.c */
|
|
|
|
extern void heap_page_prune_opt(Relation relation, Buffer buffer,
|
2007-11-15 22:14:46 +01:00
|
|
|
TransactionId OldestXmin);
|
|
|
|
extern int heap_page_prune(Relation relation, Buffer buffer,
|
|
|
|
TransactionId OldestXmin,
|
|
|
|
bool redirect_move, bool report_stats);
|
2008-06-12 11:12:31 +02:00
|
|
|
extern void heap_page_prune_execute(Buffer buffer,
|
2008-03-08 22:57:59 +01:00
|
|
|
OffsetNumber *redirected, int nredirected,
|
|
|
|
OffsetNumber *nowdead, int ndead,
|
|
|
|
OffsetNumber *nowunused, int nunused,
|
|
|
|
bool redirect_move);
|
2007-09-20 19:56:33 +02:00
|
|
|
extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets);
|
2007-01-25 03:17:26 +01:00
|
|
|
|
2007-06-08 20:23:53 +02:00
|
|
|
/* in heap/syncscan.c */
|
|
|
|
extern void ss_report_location(Relation rel, BlockNumber location);
|
|
|
|
extern BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks);
|
|
|
|
extern void SyncScanShmemInit(void);
|
|
|
|
extern Size SyncScanShmemSize(void);
|
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* HEAPAM_H */
|