mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Introduce logical decoding.
This feature, building on previous commits, allows the write-ahead log stream to be decoded into a series of logical changes; that is, inserts, updates, and deletes and the transactions which contain them. It is capable of handling decoding even across changes to the schema of the effected tables. The output format is controlled by a so-called "output plugin"; an example is included. To make use of this in a real replication system, the output plugin will need to be modified to produce output in the format appropriate to that system, and to perform filtering. Currently, information can be extracted from the logical decoding system only via SQL; future commits will add the ability to stream changes via walsender. Andres Freund, with review and other contributions from many other people, including Álvaro Herrera, Abhijit Menon-Sen, Peter Gheogegan, Kevin Grittner, Robert Haas, Heikki Linnakangas, Fujii Masao, Abhijit Menon-Sen, Michael Paquier, Simon Riggs, Craig Ringer, and Steve Singer.
This commit is contained in:
@ -18,13 +18,14 @@
|
||||
#include "access/heapam_xlog.h"
|
||||
#include "access/transam.h"
|
||||
#include "access/htup_details.h"
|
||||
#include "catalog/catalog.h"
|
||||
#include "miscadmin.h"
|
||||
#include "pgstat.h"
|
||||
#include "storage/bufmgr.h"
|
||||
#include "utils/snapmgr.h"
|
||||
#include "utils/rel.h"
|
||||
#include "utils/tqual.h"
|
||||
|
||||
|
||||
/* Working data for heap_page_prune and subroutines */
|
||||
typedef struct
|
||||
{
|
||||
@ -70,10 +71,34 @@ static void heap_prune_record_unused(PruneState *prstate, OffsetNumber offnum);
|
||||
* or RECENTLY_DEAD (see HeapTupleSatisfiesVacuum).
|
||||
*/
|
||||
void
|
||||
heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin)
|
||||
heap_page_prune_opt(Relation relation, Buffer buffer)
|
||||
{
|
||||
Page page = BufferGetPage(buffer);
|
||||
Size minfree;
|
||||
TransactionId OldestXmin;
|
||||
|
||||
/*
|
||||
* We can't write WAL in recovery mode, so there's no point trying to
|
||||
* clean the page. The master will likely issue a cleaning WAL record soon
|
||||
* anyway, so this is no particular loss.
|
||||
*/
|
||||
if (RecoveryInProgress())
|
||||
return;
|
||||
|
||||
/*
|
||||
* Use the appropriate xmin horizon for this relation. If it's a proper
|
||||
* catalog relation or a user defined, additional, catalog relation, we
|
||||
* need to use the horizon that includes slots, otherwise the data-only
|
||||
* horizon can be used. Note that the toast relation of user defined
|
||||
* relations are *not* considered catalog relations.
|
||||
*/
|
||||
if (IsCatalogRelation(relation) ||
|
||||
RelationIsAccessibleInLogicalDecoding(relation))
|
||||
OldestXmin = RecentGlobalXmin;
|
||||
else
|
||||
OldestXmin = RecentGlobalDataXmin;
|
||||
|
||||
Assert(TransactionIdIsValid(OldestXmin));
|
||||
|
||||
/*
|
||||
* Let's see if we really need pruning.
|
||||
@ -84,14 +109,6 @@ heap_page_prune_opt(Relation relation, Buffer buffer, TransactionId OldestXmin)
|
||||
if (!PageIsPrunable(page, OldestXmin))
|
||||
return;
|
||||
|
||||
/*
|
||||
* We can't write WAL in recovery mode, so there's no point trying to
|
||||
* clean the page. The master will likely issue a cleaning WAL record soon
|
||||
* anyway, so this is no particular loss.
|
||||
*/
|
||||
if (RecoveryInProgress())
|
||||
return;
|
||||
|
||||
/*
|
||||
* We prune when a previous UPDATE failed to find enough space on the page
|
||||
* for a new tuple version, or when free space falls below the relation's
|
||||
|
Reference in New Issue
Block a user