From c412669dd1ac5f2bf93264a3793193ef3371ea2c Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Wed, 29 Jan 2014 22:25:42 -0500 Subject: [PATCH] Rename data_xmin->xmin. --- doc/src/sgml/catalogs.sgml | 9 ++++----- doc/src/sgml/high-availability.sgml | 6 +++--- src/backend/catalog/system_views.sql | 2 +- src/backend/replication/slot.c | 22 +++++++++++----------- src/backend/replication/slotfuncs.c | 8 ++++---- src/backend/replication/walsender.c | 15 +++++++-------- src/include/catalog/pg_proc.h | 2 +- src/include/replication/slot.h | 10 +++++----- src/test/regress/expected/rules.out | 4 ++-- 9 files changed, 38 insertions(+), 40 deletions(-) diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index f9e62ccfae..19fe69ef12 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -5233,13 +5233,12 @@ - data_xmin + xmin xid - The xmin, or oldest transaction ID, of - user data that this slot forces to be retained in the database. - VACUUM cannot remove tuples whose - xmax is greater than this. + The oldest transaction that this slot needs the database to + retain. VACUUM cannot remove tuples deleted + by any later transaction. diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index 18f8fb6fe7..e3ab7f85c8 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -932,9 +932,9 @@ postgres=# SELECT * FROM create_physical_replication_slot('node_a_slot'); node_a_slot | postgres=# SELECT * FROM pg_replication_slots; - slot_name | slot_type | datoid | database | active | data_xmin | restart_lsn --------------+-----------+--------+----------+--------+-----------+------------- - node_a_slot | physical | 0 | | f | 0 | 0/0 + slot_name | slot_type | datoid | database | active | xmin | restart_lsn +-------------+-----------+--------+----------+--------+------+------------- + node_a_slot | physical | 0 | | f | 0 | 0/0 (1 row) To configure the standby to use this slot, primary_slotname diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 85717f5b52..f02efeca97 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -620,7 +620,7 @@ CREATE VIEW pg_replication_slots AS L.datoid, D.datname AS database, L.active, - L.data_xmin, + L.xmin, L.restart_lsn FROM pg_get_replication_slots() AS L LEFT JOIN pg_database D ON (L.datoid = D.oid); diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index 89c77e1714..17d026711c 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -246,8 +246,8 @@ ReplicationSlotCreate(const char *name, bool db_specific) */ Assert(!slot->in_use); Assert(!slot->active); - slot->data.data_xmin = InvalidTransactionId; - slot->effective_data_xmin = InvalidTransactionId; + slot->data.xmin = InvalidTransactionId; + slot->effective_xmin = InvalidTransactionId; strncpy(NameStr(slot->data.name), name, NAMEDATALEN); NameStr(slot->data.name)[NAMEDATALEN - 1] = '\0'; slot->data.database = db_specific ? MyDatabaseId : InvalidOid; @@ -525,7 +525,7 @@ void ReplicationSlotsComputeRequiredXmin(void) { int i; - TransactionId agg_data_xmin = InvalidTransactionId; + TransactionId agg_xmin = InvalidTransactionId; Assert(ReplicationSlotCtl != NULL); @@ -533,7 +533,7 @@ ReplicationSlotsComputeRequiredXmin(void) for (i = 0; i < max_replication_slots; i++) { ReplicationSlot *s = &ReplicationSlotCtl->replication_slots[i]; - TransactionId effective_data_xmin; + TransactionId effective_xmin; if (!s->in_use) continue; @@ -542,19 +542,19 @@ ReplicationSlotsComputeRequiredXmin(void) volatile ReplicationSlot *vslot = s; SpinLockAcquire(&s->mutex); - effective_data_xmin = vslot->effective_data_xmin; + effective_xmin = vslot->effective_xmin; SpinLockRelease(&s->mutex); } /* check the data xmin */ - if (TransactionIdIsValid(effective_data_xmin) && - (!TransactionIdIsValid(agg_data_xmin) || - TransactionIdPrecedes(effective_data_xmin, agg_data_xmin))) - agg_data_xmin = effective_data_xmin; + if (TransactionIdIsValid(effective_xmin) && + (!TransactionIdIsValid(agg_xmin) || + TransactionIdPrecedes(effective_xmin, agg_xmin))) + agg_xmin = effective_xmin; } LWLockRelease(ReplicationSlotControlLock); - ProcArraySetReplicationSlotXmin(agg_data_xmin); + ProcArraySetReplicationSlotXmin(agg_xmin); } /* @@ -1038,7 +1038,7 @@ RestoreSlotFromDisk(const char *name) sizeof(ReplicationSlotPersistentData)); /* initialize in memory state */ - slot->effective_data_xmin = cp.slotdata.data_xmin; + slot->effective_xmin = cp.slotdata.xmin; slot->in_use = true; slot->active = false; diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index aa44826d09..3009cfc614 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -136,7 +136,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) Datum values[PG_STAT_GET_REPLICATION_SLOTS_COLS]; bool nulls[PG_STAT_GET_REPLICATION_SLOTS_COLS]; - TransactionId data_xmin; + TransactionId xmin; XLogRecPtr restart_lsn; bool active; Oid database; @@ -153,7 +153,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) } else { - data_xmin = slot->data.data_xmin; + xmin = slot->data.xmin; database = slot->data.database; restart_lsn = slot->data.restart_lsn; slot_name = pstrdup(NameStr(slot->data.name)); @@ -175,8 +175,8 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) values[i++] = CStringGetTextDatum("logical"); values[i++] = database; values[i++] = BoolGetDatum(active); - if (data_xmin != InvalidTransactionId) - values[i++] = TransactionIdGetDatum(data_xmin); + if (xmin != InvalidTransactionId) + values[i++] = TransactionIdGetDatum(xmin); else nulls[i++] = true; if (restart_lsn != InvalidTransactionId) diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index d1edf7ed30..119a920af2 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -1028,22 +1028,21 @@ PhysicalReplicationSlotNewXmin(TransactionId feedbackXmin) { bool changed = false; volatile ReplicationSlot *slot = MyReplicationSlot; - SpinLockAcquire(&slot->mutex); + SpinLockAcquire(&slot->mutex); MyPgXact->xmin = InvalidTransactionId; - /* * For physical replication we don't need the the interlock provided - * by data_xmin and effective_data_xmin since the consequences of a - * missed increase aren't bad, so set both at once. + * by xmin and effective_xmin since the consequences of a missed increase + * are limited to query cancellations, so set both at once. */ - if (!TransactionIdIsNormal(slot->data.data_xmin) || + if (!TransactionIdIsNormal(slot->data.xmin) || !TransactionIdIsNormal(feedbackXmin) || - TransactionIdPrecedes(slot->data.data_xmin, feedbackXmin)) + TransactionIdPrecedes(slot->data.xmin, feedbackXmin)) { changed = true; - slot->data.data_xmin = feedbackXmin; - slot->effective_data_xmin = feedbackXmin; + slot->data.xmin = feedbackXmin; + slot->effective_xmin = feedbackXmin; } SpinLockRelease(&slot->mutex); diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 3aa174dcac..0dc5ebde31 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -4783,7 +4783,7 @@ DATA(insert OID = 3780 ( create_physical_replication_slot PGNSP PGUID 12 1 0 0 DESCR("create a physical replication slot"); DATA(insert OID = 3781 ( drop_replication_slot PGNSP PGUID 12 1 0 0 0 f f f f f f v 1 0 23 "19" _null_ _null_ _null_ _null_ drop_replication_slot _null_ _null_ _null_ )); DESCR("drop a replication slot"); -DATA(insert OID = 3475 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{25,25,26,16,28,25}" "{o,o,o,o,o,o}" "{slot_name,slot_type,datoid,active,data_xmin,restart_lsn}" _null_ pg_get_replication_slots _null_ _null_ _null_ )); +DATA(insert OID = 3475 ( pg_get_replication_slots PGNSP PGUID 12 1 10 0 0 f f f f f t s 0 0 2249 "" "{25,25,26,16,28,25}" "{o,o,o,o,o,o}" "{slot_name,slot_type,datoid,active,xmin,restart_lsn}" _null_ pg_get_replication_slots _null_ _null_ _null_ )); DESCR("information about replication slots currently in use"); /* event triggers */ diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h index a0cc56b9c5..089b0f4b70 100644 --- a/src/include/replication/slot.h +++ b/src/include/replication/slot.h @@ -28,9 +28,9 @@ typedef struct ReplicationSlotPersistentData * xmin horizon for data * * NB: This may represent a value that hasn't been written to disk yet; - * see notes for effective_data_xmin, below. + * see notes for effective_xmin, below. */ - TransactionId data_xmin; + TransactionId xmin; /* oldest LSN that might be required by this replication slot */ XLogRecPtr restart_lsn; @@ -62,11 +62,11 @@ typedef struct ReplicationSlot * replication also needs to prevent old row versions from being removed * too soon, but the worst consequence we might encounter there is unwanted * query cancellations on the standby. Thus, for logical decoding, - * this value represents the latest data_xmin that has actually been + * this value represents the latest xmin that has actually been * written to disk, whereas for streaming replication, it's just the - * same as the persistent value (data.data_xmin). + * same as the persistent value (data.xmin). */ - TransactionId effective_data_xmin; + TransactionId effective_xmin; /* data surviving shutdowns and crashes */ ReplicationSlotPersistentData data; diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index f391f06b82..220e18b0bb 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -1372,9 +1372,9 @@ pg_replication_slots| SELECT l.slot_name, l.datoid, d.datname AS database, l.active, - l.data_xmin, + l.xmin, l.restart_lsn - FROM (pg_get_replication_slots() l(slot_name, slot_type, datoid, active, data_xmin, restart_lsn) + FROM (pg_get_replication_slots() l(slot_name, slot_type, datoid, active, xmin, restart_lsn) LEFT JOIN pg_database d ON ((l.datoid = d.oid))); pg_roles| SELECT pg_authid.rolname, pg_authid.rolsuper, -- 2.39.5