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.
2014-03-03 22:32:18 +01:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
* logical.h
|
|
|
|
* PostgreSQL logical decoding coordination
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012-2014, PostgreSQL Global Development Group
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef LOGICAL_H
|
|
|
|
#define LOGICAL_H
|
|
|
|
|
|
|
|
#include "replication/slot.h"
|
|
|
|
|
|
|
|
#include "access/xlog.h"
|
|
|
|
#include "access/xlogreader.h"
|
|
|
|
#include "replication/output_plugin.h"
|
|
|
|
|
|
|
|
struct LogicalDecodingContext;
|
|
|
|
|
|
|
|
typedef void (*LogicalOutputPluginWriterWrite) (
|
|
|
|
struct LogicalDecodingContext *lr,
|
|
|
|
XLogRecPtr Ptr,
|
|
|
|
TransactionId xid,
|
|
|
|
bool last_write
|
|
|
|
);
|
|
|
|
|
|
|
|
typedef LogicalOutputPluginWriterWrite LogicalOutputPluginWriterPrepareWrite;
|
|
|
|
|
|
|
|
typedef struct LogicalDecodingContext
|
|
|
|
{
|
|
|
|
/* memory context this is all allocated in */
|
|
|
|
MemoryContext context;
|
|
|
|
|
|
|
|
/* infrastructure pieces */
|
|
|
|
XLogReaderState *reader;
|
|
|
|
ReplicationSlot *slot;
|
|
|
|
struct ReorderBuffer *reorder;
|
|
|
|
struct SnapBuild *snapshot_builder;
|
|
|
|
|
|
|
|
OutputPluginCallbacks callbacks;
|
|
|
|
OutputPluginOptions options;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User specified options
|
|
|
|
*/
|
|
|
|
List *output_plugin_options;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* User-Provided callback for writing/streaming out data.
|
|
|
|
*/
|
|
|
|
LogicalOutputPluginWriterPrepareWrite prepare_write;
|
|
|
|
LogicalOutputPluginWriterWrite write;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Output buffer.
|
|
|
|
*/
|
|
|
|
StringInfo out;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private data pointer of the output plugin.
|
|
|
|
*/
|
|
|
|
void *output_plugin_private;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Private data pointer for the data writer.
|
|
|
|
*/
|
|
|
|
void *output_writer_private;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* State for writing output.
|
|
|
|
*/
|
2014-05-06 18:12:18 +02:00
|
|
|
bool accept_writes;
|
|
|
|
bool prepared_write;
|
|
|
|
XLogRecPtr write_location;
|
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.
2014-03-03 22:32:18 +01:00
|
|
|
TransactionId write_xid;
|
|
|
|
} LogicalDecodingContext;
|
|
|
|
|
|
|
|
extern void CheckLogicalDecodingRequirements(void);
|
|
|
|
|
|
|
|
extern LogicalDecodingContext *CreateInitDecodingContext(char *plugin,
|
2014-05-06 18:12:18 +02:00
|
|
|
List *output_plugin_options,
|
|
|
|
XLogPageReadCB read_page,
|
|
|
|
LogicalOutputPluginWriterPrepareWrite prepare_write,
|
|
|
|
LogicalOutputPluginWriterWrite do_write);
|
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.
2014-03-03 22:32:18 +01:00
|
|
|
extern LogicalDecodingContext *CreateDecodingContext(
|
2014-05-06 18:12:18 +02:00
|
|
|
XLogRecPtr start_lsn,
|
|
|
|
List *output_plugin_options,
|
|
|
|
XLogPageReadCB read_page,
|
|
|
|
LogicalOutputPluginWriterPrepareWrite prepare_write,
|
|
|
|
LogicalOutputPluginWriterWrite do_write);
|
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.
2014-03-03 22:32:18 +01:00
|
|
|
extern void DecodingContextFindStartpoint(LogicalDecodingContext *ctx);
|
|
|
|
extern bool DecodingContextReady(LogicalDecodingContext *ctx);
|
|
|
|
extern void FreeDecodingContext(LogicalDecodingContext *ctx);
|
|
|
|
|
|
|
|
extern void LogicalIncreaseXminForSlot(XLogRecPtr lsn, TransactionId xmin);
|
|
|
|
extern void LogicalIncreaseRestartDecodingForSlot(XLogRecPtr current_lsn,
|
2014-05-06 18:12:18 +02:00
|
|
|
XLogRecPtr restart_lsn);
|
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.
2014-03-03 22:32:18 +01:00
|
|
|
extern void LogicalConfirmReceivedLocation(XLogRecPtr lsn);
|
|
|
|
|
|
|
|
#endif
|