diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/access/heapam.h | 21 | ||||
-rw-r--r-- | src/include/access/htup.h | 128 | ||||
-rw-r--r-- | src/include/access/relscan.h | 5 | ||||
-rw-r--r-- | src/include/catalog/catversion.h | 4 | ||||
-rw-r--r-- | src/include/catalog/pg_attribute.h | 14 | ||||
-rw-r--r-- | src/include/catalog/pg_index.h | 18 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.h | 4 | ||||
-rw-r--r-- | src/include/nodes/execnodes.h | 9 | ||||
-rw-r--r-- | src/include/nodes/plannodes.h | 4 | ||||
-rw-r--r-- | src/include/nodes/relation.h | 4 | ||||
-rw-r--r-- | src/include/optimizer/var.h | 3 | ||||
-rw-r--r-- | src/include/pgstat.h | 13 | ||||
-rw-r--r-- | src/include/storage/bufmgr.h | 3 | ||||
-rw-r--r-- | src/include/storage/bufpage.h | 34 | ||||
-rw-r--r-- | src/include/utils/plancache.h | 4 | ||||
-rw-r--r-- | src/include/utils/rel.h | 4 | ||||
-rw-r--r-- | src/include/utils/relcache.h | 3 |
17 files changed, 217 insertions, 58 deletions
diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index cade6a26aa9..fbe24c8e45f 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.126 2007/06/09 18:49:55 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/heapam.h,v 1.127 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -153,6 +153,10 @@ extern bool heap_fetch(Relation relation, Snapshot snapshot, extern bool heap_release_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf, bool keep_buf, Relation stats_relation); +extern bool heap_hot_search_buffer(ItemPointer tid, Buffer buffer, + Snapshot snapshot, bool *all_dead); +extern bool heap_hot_search(ItemPointer tid, Relation relation, + Snapshot snapshot, bool *all_dead); extern void heap_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid); @@ -183,6 +187,8 @@ extern void simple_heap_update(Relation relation, ItemPointer otid, extern void heap_markpos(HeapScanDesc scan); extern void heap_restrpos(HeapScanDesc scan); +extern void heap_sync(Relation relation); + extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr); extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec); extern void heap2_redo(XLogRecPtr lsn, XLogRecord *rptr); @@ -192,7 +198,10 @@ extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from, Buffer newbuf, HeapTuple newtup); extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer, - OffsetNumber *unused, int uncnt); + OffsetNumber *redirected, int nredirected, + OffsetNumber *nowdead, int ndead, + OffsetNumber *nowunused, int nunused, + bool redirect_move); extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer, TransactionId cutoff_xid, OffsetNumber *offsets, int offcnt); @@ -240,7 +249,13 @@ extern MinimalTuple minimal_tuple_from_heap_tuple(HeapTuple htup); extern HeapTuple heap_addheader(int natts, bool withoid, Size structlen, void *structure); -extern void heap_sync(Relation relation); +/* in heap/pruneheap.c */ +extern void heap_page_prune_opt(Relation relation, Buffer buffer, + TransactionId OldestXmin); +extern int heap_page_prune(Relation relation, Buffer buffer, + TransactionId OldestXmin, + bool redirect_move, bool report_stats); +extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets); /* in heap/syncscan.c */ extern void ss_report_location(Relation rel, BlockNumber location); diff --git a/src/include/access/htup.h b/src/include/access/htup.h index ee816c568a8..32a27c972cb 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.93 2007/04/06 04:21:43 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/htup.h,v 1.94 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -184,8 +184,12 @@ typedef HeapTupleHeaderData *HeapTupleHeader; /* * information stored in t_infomask2: */ -#define HEAP_NATTS_MASK 0x7FF /* 11 bits for number of attributes */ -/* bits 0xF800 are currently unused */ +#define HEAP_NATTS_MASK 0x07FF /* 11 bits for number of attributes */ +/* bits 0x3800 are available */ +#define HEAP_HOT_UPDATED 0x4000 /* tuple was HOT-updated */ +#define HEAP_ONLY_TUPLE 0x8000 /* this is heap-only tuple */ + +#define HEAP2_XACT_MASK 0xC000 /* visibility-related bits */ /* * HeapTupleHeader accessor macros @@ -201,7 +205,7 @@ typedef HeapTupleHeaderData *HeapTupleHeader; #define HeapTupleHeaderSetXmin(tup, xid) \ ( \ - TransactionIdStore((xid), &(tup)->t_choice.t_heap.t_xmin) \ + (tup)->t_choice.t_heap.t_xmin = (xid) \ ) #define HeapTupleHeaderGetXmax(tup) \ @@ -211,7 +215,7 @@ typedef HeapTupleHeaderData *HeapTupleHeader; #define HeapTupleHeaderSetXmax(tup, xid) \ ( \ - TransactionIdStore((xid), &(tup)->t_choice.t_heap.t_xmax) \ + (tup)->t_choice.t_heap.t_xmax = (xid) \ ) /* @@ -255,7 +259,7 @@ do { \ #define HeapTupleHeaderSetXvac(tup, xid) \ do { \ Assert((tup)->t_infomask & HEAP_MOVED); \ - TransactionIdStore((xid), &(tup)->t_choice.t_heap.t_field3.t_xvac); \ + (tup)->t_choice.t_heap.t_field3.t_xvac = (xid); \ } while (0) #define HeapTupleHeaderGetDatumLength(tup) \ @@ -298,6 +302,43 @@ do { \ *((Oid *) ((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) = (oid); \ } while (0) +/* + * Note that we stop considering a tuple HOT-updated as soon as it is known + * aborted or the would-be updating transaction is known aborted. For best + * efficiency, check tuple visibility before using this macro, so that the + * INVALID bits will be as up to date as possible. + */ +#define HeapTupleHeaderIsHotUpdated(tup) \ +( \ + ((tup)->t_infomask2 & HEAP_HOT_UPDATED) != 0 && \ + ((tup)->t_infomask & (HEAP_XMIN_INVALID | HEAP_XMAX_INVALID)) == 0 \ +) + +#define HeapTupleHeaderSetHotUpdated(tup) \ +( \ + (tup)->t_infomask2 |= HEAP_HOT_UPDATED \ +) + +#define HeapTupleHeaderClearHotUpdated(tup) \ +( \ + (tup)->t_infomask2 &= ~HEAP_HOT_UPDATED \ +) + +#define HeapTupleHeaderIsHeapOnly(tup) \ +( \ + (tup)->t_infomask2 & HEAP_ONLY_TUPLE \ +) + +#define HeapTupleHeaderSetHeapOnly(tup) \ +( \ + (tup)->t_infomask2 |= HEAP_ONLY_TUPLE \ +) + +#define HeapTupleHeaderClearHeapOnly(tup) \ +( \ + (tup)->t_infomask2 &= ~HEAP_ONLY_TUPLE \ +) + #define HeapTupleHeaderGetNatts(tup) \ ((tup)->t_infomask2 & HEAP_NATTS_MASK) @@ -331,6 +372,11 @@ do { \ * fit on one heap page. (Note that indexes could have more, because they * use a smaller tuple header.) We arrive at the divisor because each tuple * must be maxaligned, and it must have an associated item pointer. + * + * Note: with HOT, there could theoretically be more line pointers (not actual + * tuples) than this on a heap page. However we constrain the number of line + * pointers to this anyway, to avoid excessive line-pointer bloat and not + * require increases in the size of work arrays. */ #define MaxHeapTuplesPerPage \ ((int) ((BLCKSZ - offsetof(PageHeaderData, pd_linp)) / \ @@ -484,6 +530,24 @@ typedef HeapTupleData *HeapTuple; #define HeapTupleHasExternal(tuple) \ (((tuple)->t_data->t_infomask & HEAP_HASEXTERNAL) != 0) +#define HeapTupleIsHotUpdated(tuple) \ + HeapTupleHeaderIsHotUpdated((tuple)->t_data) + +#define HeapTupleSetHotUpdated(tuple) \ + HeapTupleHeaderSetHotUpdated((tuple)->t_data) + +#define HeapTupleClearHotUpdated(tuple) \ + HeapTupleHeaderClearHotUpdated((tuple)->t_data) + +#define HeapTupleIsHeapOnly(tuple) \ + HeapTupleHeaderIsHeapOnly((tuple)->t_data) + +#define HeapTupleSetHeapOnly(tuple) \ + HeapTupleHeaderSetHeapOnly((tuple)->t_data) + +#define HeapTupleClearHeapOnly(tuple) \ + HeapTupleHeaderClearHeapOnly((tuple)->t_data) + #define HeapTupleGetOid(tuple) \ HeapTupleHeaderGetOid((tuple)->t_data) @@ -497,27 +561,30 @@ typedef HeapTupleData *HeapTuple; * XLOG allows to store some information in high 4 bits of log * record xl_info field. We use 3 for opcode and one for init bit. */ -#define XLOG_HEAP_INSERT 0x00 -#define XLOG_HEAP_DELETE 0x10 -#define XLOG_HEAP_UPDATE 0x20 -#define XLOG_HEAP_MOVE 0x30 -#define XLOG_HEAP_CLEAN 0x40 -#define XLOG_HEAP_NEWPAGE 0x50 -#define XLOG_HEAP_LOCK 0x60 -#define XLOG_HEAP_INPLACE 0x70 -#define XLOG_HEAP_OPMASK 0x70 +#define XLOG_HEAP_INSERT 0x00 +#define XLOG_HEAP_DELETE 0x10 +#define XLOG_HEAP_UPDATE 0x20 +#define XLOG_HEAP_MOVE 0x30 +#define XLOG_HEAP_HOT_UPDATE 0x40 +#define XLOG_HEAP_NEWPAGE 0x50 +#define XLOG_HEAP_LOCK 0x60 +#define XLOG_HEAP_INPLACE 0x70 + +#define XLOG_HEAP_OPMASK 0x70 /* * When we insert 1st item on new page in INSERT/UPDATE * we can (and we do) restore entire page in redo */ -#define XLOG_HEAP_INIT_PAGE 0x80 +#define XLOG_HEAP_INIT_PAGE 0x80 /* * We ran out of opcodes, so heapam.c now has a second RmgrId. These opcodes * are associated with RM_HEAP2_ID, but are not logically different from * the ones above associated with RM_HEAP_ID. We apply XLOG_HEAP_OPMASK, * although currently XLOG_HEAP_INIT_PAGE is not used for any of these. */ -#define XLOG_HEAP2_FREEZE 0x00 +#define XLOG_HEAP2_FREEZE 0x00 +#define XLOG_HEAP2_CLEAN 0x10 +#define XLOG_HEAP2_CLEAN_MOVE 0x20 /* * All what we need to find changed tuple @@ -569,7 +636,7 @@ typedef struct xl_heap_insert #define SizeOfHeapInsert (offsetof(xl_heap_insert, target) + SizeOfHeapTid) -/* This is what we need to know about update|move */ +/* This is what we need to know about update|move|hot_update */ typedef struct xl_heap_update { xl_heaptid target; /* deleted tuple id */ @@ -580,15 +647,34 @@ typedef struct xl_heap_update #define SizeOfHeapUpdate (offsetof(xl_heap_update, newtid) + SizeOfIptrData) -/* This is what we need to know about vacuum page cleanup */ +/* + * This is what we need to know about vacuum page cleanup/redirect + * + * The array of OffsetNumbers following the fixed part of the record contains: + * * for each redirected item: the item offset, then the offset redirected to + * * for each now-dead item: the item offset + * * for each now-unused item: the item offset + * The total number of OffsetNumbers is therefore 2*nredirected+ndead+nunused. + * Note that nunused is not explicitly stored, but may be found by reference + * to the total record length. + * + * If the opcode is CLEAN_MOVE instead of CLEAN, then each redirection pair + * should be interpreted as physically moving the "to" item pointer to the + * "from" slot, rather than placing a redirection item in the "from" slot. + * The moved pointers should be replaced by LP_UNUSED items (there will not + * be explicit entries in the "now-unused" list for this). Also, the + * HEAP_ONLY bit in the moved tuples must be turned off. + */ typedef struct xl_heap_clean { RelFileNode node; BlockNumber block; - /* UNUSED OFFSET NUMBERS FOLLOW AT THE END */ + uint16 nredirected; + uint16 ndead; + /* OFFSET NUMBERS FOLLOW */ } xl_heap_clean; -#define SizeOfHeapClean (offsetof(xl_heap_clean, block) + sizeof(BlockNumber)) +#define SizeOfHeapClean (offsetof(xl_heap_clean, ndead) + sizeof(uint16)) /* This is for replacing a page's contents in toto */ /* NB: this is used for indexes as well as heaps */ diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 15b9b8a3374..b145e09e36a 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.56 2007/06/09 18:49:55 tgl Exp $ + * $PostgreSQL: pgsql/src/include/access/relscan.h,v 1.57 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -82,6 +82,9 @@ typedef struct IndexScanDescData HeapTupleData xs_ctup; /* current heap tuple, if any */ Buffer xs_cbuf; /* current heap buffer in scan, if any */ /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */ + TransactionId xs_prev_xmax; /* previous HOT chain member's XMAX, if any */ + OffsetNumber xs_next_hot; /* next member of HOT chain, if any */ + bool xs_hot_dead; /* T if all members of HOT chain are dead */ } IndexScanDescData; typedef IndexScanDescData *IndexScanDesc; diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index e21606a1259..c295aab857c 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -37,7 +37,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.425 2007/09/18 17:41:17 adunstan Exp $ + * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.426 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 200709181 +#define CATALOG_VERSION_NO 200709201 #endif diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 7970cac3c48..006a8e4392d 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.132 2007/09/03 00:39:21 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_attribute.h,v 1.133 2007/09/20 17:56:32 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -471,10 +471,12 @@ DATA(insert ( 1259 tableoid 26 0 4 -7 0 -1 -1 t p i t f f t 0)); { 0, {"indisprimary"}, 16, -1, 1, 5, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ { 0, {"indisclustered"}, 16, -1, 1, 6, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ { 0, {"indisvalid"}, 16, -1, 1, 7, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ -{ 0, {"indkey"}, 22, -1, -1, 8, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ -{ 0, {"indclass"}, 30, -1, -1, 9, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ -{ 0, {"indoption"}, 22, -1, -1, 10, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ -{ 0, {"indexprs"}, 25, -1, -1, 11, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ -{ 0, {"indpred"}, 25, -1, -1, 12, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 } +{ 0, {"indcheckxmin"}, 16, -1, 1, 8, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 0, {"indisready"}, 16, -1, 1, 9, 0, -1, -1, true, 'p', 'c', true, false, false, true, 0 }, \ +{ 0, {"indkey"}, 22, -1, -1, 10, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ +{ 0, {"indclass"}, 30, -1, -1, 11, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ +{ 0, {"indoption"}, 22, -1, -1, 12, 1, -1, -1, false, 'p', 'i', true, false, false, true, 0 }, \ +{ 0, {"indexprs"}, 25, -1, -1, 13, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 }, \ +{ 0, {"indpred"}, 25, -1, -1, 14, 0, -1, -1, false, 'x', 'i', false, false, false, true, 0 } #endif /* PG_ATTRIBUTE_H */ diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 31c6e25fb0d..f74ff4af0b9 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.43 2007/01/09 02:14:15 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_index.h,v 1.44 2007/09/20 17:56:32 tgl Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -42,6 +42,8 @@ CATALOG(pg_index,2610) BKI_WITHOUT_OIDS bool indisprimary; /* is this index for primary key? */ bool indisclustered; /* is this the index last clustered by? */ bool indisvalid; /* is this index valid for use by queries? */ + bool indcheckxmin; /* must we wait for xmin to be old? */ + bool indisready; /* is this index ready for inserts? */ /* VARIABLE LENGTH FIELDS: */ int2vector indkey; /* column numbers of indexed cols, or 0 */ @@ -65,7 +67,7 @@ typedef FormData_pg_index *Form_pg_index; * compiler constants for pg_index * ---------------- */ -#define Natts_pg_index 12 +#define Natts_pg_index 14 #define Anum_pg_index_indexrelid 1 #define Anum_pg_index_indrelid 2 #define Anum_pg_index_indnatts 3 @@ -73,11 +75,13 @@ typedef FormData_pg_index *Form_pg_index; #define Anum_pg_index_indisprimary 5 #define Anum_pg_index_indisclustered 6 #define Anum_pg_index_indisvalid 7 -#define Anum_pg_index_indkey 8 -#define Anum_pg_index_indclass 9 -#define Anum_pg_index_indoption 10 -#define Anum_pg_index_indexprs 11 -#define Anum_pg_index_indpred 12 +#define Anum_pg_index_indcheckxmin 8 +#define Anum_pg_index_indisready 9 +#define Anum_pg_index_indkey 10 +#define Anum_pg_index_indclass 11 +#define Anum_pg_index_indoption 12 +#define Anum_pg_index_indexprs 13 +#define Anum_pg_index_indpred 14 /* * Index AMs that support ordered scans must support these two indoption diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 5f534839b23..3eaead16bda 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.470 2007/09/18 17:41:17 adunstan Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.471 2007/09/20 17:56:32 tgl Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -2873,6 +2873,8 @@ DATA(insert OID = 1932 ( pg_stat_get_tuples_updated PGNSP PGUID 12 1 0 f f t f DESCR("statistics: number of tuples updated"); DATA(insert OID = 1933 ( pg_stat_get_tuples_deleted PGNSP PGUID 12 1 0 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_deleted - _null_ _null_ )); DESCR("statistics: number of tuples deleted"); +DATA(insert OID = 1972 ( pg_stat_get_tuples_hot_updated PGNSP PGUID 12 1 0 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_tuples_hot_updated - _null_ _null_ )); +DESCR("statistics: number of tuples hot updated"); DATA(insert OID = 2878 ( pg_stat_get_live_tuples PGNSP PGUID 12 1 0 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_live_tuples - _null_ _null_ )); DESCR("statistics: number of live tuples"); DATA(insert OID = 2879 ( pg_stat_get_dead_tuples PGNSP PGUID 12 1 0 f f t f s 1 20 "26" _null_ _null_ _null_ pg_stat_get_dead_tuples - _null_ _null_ )); diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index d886c0149fc..82f851eeacc 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.177 2007/08/15 21:39:50 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/execnodes.h,v 1.178 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,12 @@ * Predicate partial-index predicate, or NIL if none * PredicateState exec state for predicate, or NIL if none * Unique is it a unique index? + * ReadyForInserts is it valid for inserts? * Concurrent are we doing a concurrent index build? + * BrokenHotChain did we detect any broken HOT chains? + * + * ii_Concurrent and ii_BrokenHotChain are used only during index build; + * they're conventionally set to false otherwise. * ---------------- */ typedef struct IndexInfo @@ -50,7 +55,9 @@ typedef struct IndexInfo List *ii_Predicate; /* list of Expr */ List *ii_PredicateState; /* list of ExprState */ bool ii_Unique; + bool ii_ReadyForInserts; bool ii_Concurrent; + bool ii_BrokenHotChain; } IndexInfo; /* ---------------- diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 9d336e4b889..992b47f58d8 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.94 2007/04/27 22:05:49 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/plannodes.h,v 1.95 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,8 @@ typedef struct PlannedStmt bool canSetTag; /* do I set the command result tag? */ + bool transientPlan; /* redo plan when TransactionXmin changes? */ + struct Plan *planTree; /* tree of Plan nodes */ List *rtable; /* list of RangeTblEntry nodes */ diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index ab26491a629..32c699b6de6 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.145 2007/08/31 01:44:06 tgl Exp $ + * $PostgreSQL: pgsql/src/include/nodes/relation.h,v 1.146 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -71,6 +71,8 @@ typedef struct PlannerGlobal Bitmapset *rewindPlanIDs; /* indices of subplans that require REWIND */ List *finalrtable; /* "flat" rangetable for executor */ + + bool transientPlan; /* redo plan when TransactionXmin changes? */ } PlannerGlobal; /* macro for fetching the Plan associated with a SubPlan node */ diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 34f8c73f3f6..824ba5a1a4b 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/optimizer/var.h,v 1.35 2007/01/05 22:19:56 momjian Exp $ + * $PostgreSQL: pgsql/src/include/optimizer/var.h,v 1.36 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -18,6 +18,7 @@ extern Relids pull_varnos(Node *node); +extern void pull_varattnos(Node *node, Bitmapset **varattnos); extern bool contain_var_reference(Node *node, int varno, int varattno, int levelsup); extern bool contain_var_clause(Node *node); diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 93f08cd2fbf..9cdeb2ee909 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -5,7 +5,7 @@ * * Copyright (c) 2001-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.65 2007/09/11 03:28:05 tgl Exp $ + * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.66 2007/09/20 17:56:32 tgl Exp $ * ---------- */ #ifndef PGSTAT_H @@ -55,10 +55,10 @@ typedef int64 PgStat_Counter; * the index AM, while tuples_fetched is the number of tuples successfully * fetched by heap_fetch under the control of simple indexscans for this index. * - * tuples_inserted/tuples_updated/tuples_deleted count attempted actions, + * tuples_inserted/updated/deleted/hot_updated count attempted actions, * regardless of whether the transaction committed. new_live_tuples and * new_dead_tuples are properly adjusted depending on commit or abort. - * Note that new_live_tuples can be negative! + * Note that new_live_tuples and new_dead_tuples can be negative! * ---------- */ typedef struct PgStat_TableCounts @@ -71,6 +71,7 @@ typedef struct PgStat_TableCounts PgStat_Counter t_tuples_inserted; PgStat_Counter t_tuples_updated; PgStat_Counter t_tuples_deleted; + PgStat_Counter t_tuples_hot_updated; PgStat_Counter t_new_live_tuples; PgStat_Counter t_new_dead_tuples; @@ -323,7 +324,7 @@ typedef union PgStat_Msg * ------------------------------------------------------------ */ -#define PGSTAT_FILE_FORMAT_ID 0x01A5BC96 +#define PGSTAT_FILE_FORMAT_ID 0x01A5BC97 /* ---------- * PgStat_StatDBEntry The collector's data per database @@ -367,6 +368,7 @@ typedef struct PgStat_StatTabEntry PgStat_Counter tuples_inserted; PgStat_Counter tuples_updated; PgStat_Counter tuples_deleted; + PgStat_Counter tuples_hot_updated; PgStat_Counter n_live_tuples; PgStat_Counter n_dead_tuples; @@ -545,8 +547,9 @@ extern void pgstat_initstats(Relation rel); } while (0) extern void pgstat_count_heap_insert(Relation rel); -extern void pgstat_count_heap_update(Relation rel); +extern void pgstat_count_heap_update(Relation rel, bool hot); extern void pgstat_count_heap_delete(Relation rel); +extern void pgstat_update_heap_dead_tuples(Relation rel, int delta); extern void AtEOXact_PgStat(bool isCommit); extern void AtEOSubXact_PgStat(bool isCommit, int nestDepth); diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 7a4190d044b..1324befa1e2 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.106 2007/07/25 12:22:53 mha Exp $ + * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.107 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -156,6 +156,7 @@ extern void UnlockBuffers(void); extern void LockBuffer(Buffer buffer, int mode); extern bool ConditionalLockBuffer(Buffer buffer); extern void LockBufferForCleanup(Buffer buffer); +extern bool ConditionalLockBufferForCleanup(Buffer buffer); extern void AbortBufferIO(void); diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index 7e6e429108d..8ca2dd8e38f 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.73 2007/09/12 22:10:26 tgl Exp $ + * $PostgreSQL: pgsql/src/include/storage/bufpage.h,v 1.74 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -140,10 +140,21 @@ typedef PageHeaderData *PageHeader; * PD_HAS_FREE_LINES is set if there are any LP_UNUSED line pointers before * pd_lower. This should be considered a hint rather than the truth, since * changes to it are not WAL-logged. + * + * PD_PRUNABLE is set if there are any prunable tuples in the page. + * This should be considered a hint rather than the truth, since + * the transaction which generates a prunable tuple may or may not commit. + * Also there is a lag before a tuple is declared dead. + * + * PD_PAGE_FULL is set if an UPDATE doesn't find enough free space in the + * page for its new tuple version; this suggests that a prune is needed. + * Again, this is just a hint. */ #define PD_HAS_FREE_LINES 0x0001 /* are there any unused line pointers? */ +#define PD_PRUNABLE 0x0002 /* are there any prunable tuples? */ +#define PD_PAGE_FULL 0x0004 /* not enough free space for new tuple? */ -#define PD_VALID_FLAG_BITS 0x0001 /* OR of all valid pd_flags bits */ +#define PD_VALID_FLAG_BITS 0x0007 /* OR of all valid pd_flags bits */ /* * Page layout version number 0 is for pre-7.3 Postgres releases. @@ -337,6 +348,20 @@ typedef PageHeaderData *PageHeader; #define PageClearHasFreeLinePointers(page) \ (((PageHeader) (page))->pd_flags &= ~PD_HAS_FREE_LINES) +#define PageIsPrunable(page) \ + (((PageHeader) (page))->pd_flags & PD_PRUNABLE) +#define PageSetPrunable(page) \ + (((PageHeader) (page))->pd_flags |= PD_PRUNABLE) +#define PageClearPrunable(page) \ + (((PageHeader) (page))->pd_flags &= ~PD_PRUNABLE) + +#define PageIsFull(page) \ + (((PageHeader) (page))->pd_flags & PD_PAGE_FULL) +#define PageSetFull(page) \ + (((PageHeader) (page))->pd_flags |= PD_PAGE_FULL) +#define PageClearFull(page) \ + (((PageHeader) (page))->pd_flags &= ~PD_PAGE_FULL) + /* ---------------------------------------------------------------- * extern declarations @@ -346,12 +371,13 @@ typedef PageHeaderData *PageHeader; extern void PageInit(Page page, Size pageSize, Size specialSize); extern bool PageHeaderIsValid(PageHeader page); extern OffsetNumber PageAddItem(Page page, Item item, Size size, - OffsetNumber offsetNumber, bool overwrite); + OffsetNumber offsetNumber, bool overwrite, bool is_heap); extern Page PageGetTempPage(Page page, Size specialSize); extern void PageRestoreTempPage(Page tempPage, Page oldPage); -extern int PageRepairFragmentation(Page page, OffsetNumber *unused); +extern void PageRepairFragmentation(Page page); extern Size PageGetFreeSpace(Page page); extern Size PageGetExactFreeSpace(Page page); +extern Size PageGetHeapFreeSpace(Page page); extern void PageIndexTupleDelete(Page page, OffsetNumber offset); extern void PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems); diff --git a/src/include/utils/plancache.h b/src/include/utils/plancache.h index d8152142aac..0a91e886e29 100644 --- a/src/include/utils/plancache.h +++ b/src/include/utils/plancache.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.7 2007/06/05 20:00:41 wieck Exp $ + * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.8 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -75,6 +75,8 @@ typedef struct CachedPlan List *stmt_list; /* list of statement or Query nodes */ bool fully_planned; /* do we cache planner or rewriter output? */ bool dead; /* if true, do not use */ + TransactionId saved_xmin; /* if valid, replan when TransactionXmin + * changes from this value */ int refcount; /* count of live references to this struct */ int generation; /* counter, starting at 1, for replans */ MemoryContext context; /* context containing this CachedPlan */ diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index bc6bf190b86..48569c583b2 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.101 2007/05/27 03:50:39 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/rel.h,v 1.102 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -19,6 +19,7 @@ #include "catalog/pg_class.h" #include "catalog/pg_index.h" #include "fmgr.h" +#include "nodes/bitmapset.h" #include "rewrite/prs2lock.h" #include "storage/block.h" #include "storage/relfilenode.h" @@ -145,6 +146,7 @@ typedef struct RelationData TupleDesc rd_att; /* tuple descriptor */ Oid rd_id; /* relation's object id */ List *rd_indexlist; /* list of OIDs of indexes on relation */ + Bitmapset *rd_indexattr; /* identifies columns used in indexes */ Oid rd_oidindex; /* OID of unique index on OID, if any */ LockInfoData rd_lockInfo; /* lock mgr's info for locking relation */ RuleLock *rd_rules; /* rewrite rules */ diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 25b60082a09..a2b6f21248f 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.59 2007/03/29 00:15:39 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/relcache.h,v 1.60 2007/09/20 17:56:32 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -29,6 +29,7 @@ extern List *RelationGetIndexList(Relation relation); extern Oid RelationGetOidIndex(Relation relation); extern List *RelationGetIndexExpressions(Relation relation); extern List *RelationGetIndexPredicate(Relation relation); +extern Bitmapset *RelationGetIndexAttrBitmap(Relation relation); extern void RelationSetIndexList(Relation relation, List *indexIds, Oid oidIndex); |