mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +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:
@ -45,6 +45,7 @@
|
||||
#include "miscadmin.h"
|
||||
#include "pgstat.h"
|
||||
#include "postmaster/bgwriter.h"
|
||||
#include "replication/slot.h"
|
||||
#include "storage/copydir.h"
|
||||
#include "storage/fd.h"
|
||||
#include "storage/lmgr.h"
|
||||
@ -750,6 +751,7 @@ dropdb(const char *dbname, bool missing_ok)
|
||||
HeapTuple tup;
|
||||
int notherbackends;
|
||||
int npreparedxacts;
|
||||
int nslots, nslots_active;
|
||||
|
||||
/*
|
||||
* Look up the target database's OID, and get exclusive lock on it. We
|
||||
@ -806,6 +808,19 @@ dropdb(const char *dbname, bool missing_ok)
|
||||
(errcode(ERRCODE_OBJECT_IN_USE),
|
||||
errmsg("cannot drop the currently open database")));
|
||||
|
||||
/*
|
||||
* Check whether there are, possibly unconnected, logical slots that refer
|
||||
* to the to-be-dropped database. The database lock we are holding
|
||||
* prevents the creation of new slots using the database.
|
||||
*/
|
||||
if (ReplicationSlotsCountDBSlots(db_id, &nslots, &nslots_active))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OBJECT_IN_USE),
|
||||
errmsg("database \"%s\" is used by a logical decoding slot",
|
||||
dbname),
|
||||
errdetail("There are %d slot(s), %d of them active",
|
||||
nslots, nslots_active)));
|
||||
|
||||
/*
|
||||
* Check for other backends in the target database. (Because we hold the
|
||||
* database lock, no new ones can start after this.)
|
||||
|
Reference in New Issue
Block a user