diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2012-12-01 12:54:20 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2012-12-01 12:54:20 +0000 |
commit | 8de72b66a2edcf12c812de0a73bd50b6b7d81d62 (patch) | |
tree | 3cb4fc55c3d70b7b972910cfeb22cbb7c704875a /src/backend/access/heap/heapam.c | |
parent | 44c03efee3d15a1db3d64bc5a2da91c145a91873 (diff) | |
download | postgresql-8de72b66a2edcf12c812de0a73bd50b6b7d81d62.tar.gz postgresql-8de72b66a2edcf12c812de0a73bd50b6b7d81d62.zip |
COPY FREEZE and mark committed on fresh tables.
When a relfilenode is created in this subtransaction or
a committed child transaction and it cannot otherwise
be seen by our own process, mark tuples committed ahead
of transaction commit for all COPY commands in same
transaction. If FREEZE specified on COPY
and pre-conditions met then rows will also be frozen.
Both options designed to avoid revisiting rows after commit,
increasing performance of subsequent commands after
data load and upgrade. pg_restore changes later.
Simon Riggs, review comments from Heikki Linnakangas, Noah Misch and design
input from Tom Lane, Robert Haas and Kevin Grittner
Diffstat (limited to 'src/backend/access/heap/heapam.c')
-rw-r--r-- | src/backend/access/heap/heapam.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 4abbdb68468..b66e26bebff 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -1875,6 +1875,14 @@ FreeBulkInsertState(BulkInsertState bistate) * The HEAP_INSERT_SKIP_FSM option is passed directly to * RelationGetBufferForTuple, which see for more info. * + * HEAP_INSERT_COMMITTED should only be specified for inserts into + * relfilenodes created during the current subtransaction and when + * there are no prior snapshots or pre-existing portals open. + * + * HEAP_INSERT_FROZEN only has meaning when HEAP_INSERT_COMMITTED is + * also set. This causes rows to be frozen, which is an MVCC violation + * and requires explicit options chosen by user. + * * Note that these options will be applied when inserting into the heap's * TOAST table, too, if the tuple requires any out-of-line data. * @@ -2078,7 +2086,14 @@ heap_prepare_insert(Relation relation, HeapTuple tup, TransactionId xid, tup->t_data->t_infomask &= ~(HEAP_XACT_MASK); tup->t_data->t_infomask2 &= ~(HEAP2_XACT_MASK); tup->t_data->t_infomask |= HEAP_XMAX_INVALID; - HeapTupleHeaderSetXmin(tup->t_data, xid); + if (options & HEAP_INSERT_COMMITTED) + { + tup->t_data->t_infomask |= HEAP_XMIN_COMMITTED; + if (options & HEAP_INSERT_FROZEN) + HeapTupleHeaderSetXmin(tup->t_data, FrozenTransactionId); + } + else + HeapTupleHeaderSetXmin(tup->t_data, xid); HeapTupleHeaderSetCmin(tup->t_data, cid); HeapTupleHeaderSetXmax(tup->t_data, 0); /* for cleanliness */ tup->t_tableOid = RelationGetRelid(relation); |