PostgreSQL Source Code git master
pg_subscription_rel.h File Reference
#include "access/xlogdefs.h"
#include "catalog/genbki.h"
#include "catalog/pg_subscription_rel_d.h"
#include "nodes/pg_list.h"
Include dependency graph for pg_subscription_rel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SubscriptionRelState
 
struct  LogicalRepSequenceInfo
 

Typedefs

typedef FormData_pg_subscription_relForm_pg_subscription_rel
 
typedef struct SubscriptionRelState SubscriptionRelState
 
typedef struct LogicalRepSequenceInfo LogicalRepSequenceInfo
 

Functions

 CATALOG (pg_subscription_rel, 6102, SubscriptionRelRelationId)
 
 DECLARE_UNIQUE_INDEX_PKEY (pg_subscription_rel_srrelid_srsubid_index, 6117, SubscriptionRelSrrelidSrsubidIndexId, pg_subscription_rel, btree(srrelid oid_ops, srsubid oid_ops))
 
 MAKE_SYSCACHE (SUBSCRIPTIONRELMAP, pg_subscription_rel_srrelid_srsubid_index, 64)
 
void AddSubscriptionRelState (Oid subid, Oid relid, char state, XLogRecPtr sublsn, bool retain_lock)
 
void UpdateSubscriptionRelState (Oid subid, Oid relid, char state, XLogRecPtr sublsn, bool already_locked)
 
char GetSubscriptionRelState (Oid subid, Oid relid, XLogRecPtr *sublsn)
 
void RemoveSubscriptionRel (Oid subid, Oid relid)
 
bool HasSubscriptionTables (Oid subid)
 
ListGetSubscriptionRelations (Oid subid, bool tables, bool sequences, bool not_ready)
 
void UpdateDeadTupleRetentionStatus (Oid subid, bool active)
 

Variables

 FormData_pg_subscription_rel
 

Typedef Documentation

◆ Form_pg_subscription_rel

◆ LogicalRepSequenceInfo

◆ SubscriptionRelState

Function Documentation

◆ AddSubscriptionRelState()

void AddSubscriptionRelState ( Oid  subid,
Oid  relid,
char  state,
XLogRecPtr  sublsn,
bool  retain_lock 
)

Definition at line 270 of file pg_subscription.c.

272{
273 Relation rel;
274 HeapTuple tup;
275 bool nulls[Natts_pg_subscription_rel];
276 Datum values[Natts_pg_subscription_rel];
277
278 LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
279
280 rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
281
282 /* Try finding existing mapping. */
283 tup = SearchSysCacheCopy2(SUBSCRIPTIONRELMAP,
284 ObjectIdGetDatum(relid),
285 ObjectIdGetDatum(subid));
286 if (HeapTupleIsValid(tup))
287 elog(ERROR, "subscription relation %u in subscription %u already exists",
288 relid, subid);
289
290 /* Form the tuple. */
291 memset(values, 0, sizeof(values));
292 memset(nulls, false, sizeof(nulls));
293 values[Anum_pg_subscription_rel_srsubid - 1] = ObjectIdGetDatum(subid);
294 values[Anum_pg_subscription_rel_srrelid - 1] = ObjectIdGetDatum(relid);
295 values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
296 if (XLogRecPtrIsValid(sublsn))
297 values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
298 else
299 nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
300
301 tup = heap_form_tuple(RelationGetDescr(rel), values, nulls);
302
303 /* Insert tuple into catalog. */
304 CatalogTupleInsert(rel, tup);
305
306 heap_freetuple(tup);
307
308 /* Cleanup. */
309 if (retain_lock)
310 {
311 table_close(rel, NoLock);
312 }
313 else
314 {
316 UnlockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
317 }
318}
static Datum values[MAXATTR]
Definition: bootstrap.c:153
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
Definition: heaptuple.c:1117
void heap_freetuple(HeapTuple htup)
Definition: heaptuple.c:1435
#define HeapTupleIsValid(tuple)
Definition: htup.h:78
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
Definition: indexing.c:233
void LockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition: lmgr.c:1088
void UnlockSharedObject(Oid classid, Oid objid, uint16 objsubid, LOCKMODE lockmode)
Definition: lmgr.c:1148
#define NoLock
Definition: lockdefs.h:34
#define AccessShareLock
Definition: lockdefs.h:36
#define RowExclusiveLock
Definition: lockdefs.h:38
static Datum LSNGetDatum(XLogRecPtr X)
Definition: pg_lsn.h:31
static Datum ObjectIdGetDatum(Oid X)
Definition: postgres.h:262
uint64_t Datum
Definition: postgres.h:70
static Datum CharGetDatum(char X)
Definition: postgres.h:132
#define RelationGetDescr(relation)
Definition: rel.h:541
Definition: regguts.h:323
#define SearchSysCacheCopy2(cacheId, key1, key2)
Definition: syscache.h:93
void table_close(Relation relation, LOCKMODE lockmode)
Definition: table.c:126
Relation table_open(Oid relationId, LOCKMODE lockmode)
Definition: table.c:40
#define XLogRecPtrIsValid(r)
Definition: xlogdefs.h:29

References AccessShareLock, CatalogTupleInsert(), CharGetDatum(), elog, ERROR, heap_form_tuple(), heap_freetuple(), HeapTupleIsValid, LockSharedObject(), LSNGetDatum(), NoLock, ObjectIdGetDatum(), RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy2, table_close(), table_open(), UnlockSharedObject(), values, and XLogRecPtrIsValid.

Referenced by AlterSubscription_refresh(), binary_upgrade_add_sub_rel_state(), and CreateSubscription().

◆ CATALOG()

CATALOG ( pg_subscription_rel  ,
6102  ,
SubscriptionRelRelationId   
)

Definition at line 31 of file pg_subscription_rel.h.

32{
33 Oid srsubid BKI_LOOKUP(pg_subscription); /* Oid of subscription */
34 Oid srrelid BKI_LOOKUP(pg_class); /* Oid of relation */
35 char srsubstate; /* state of the relation in subscription */
36
37 /*
38 * Although srsublsn is a fixed-width type, it is allowed to be NULL, so
39 * we prevent direct C code access to it just as for a varlena field.
40 */
41#ifdef CATALOG_VARLEN /* variable-length fields start here */
42
43 XLogRecPtr srsublsn BKI_FORCE_NULL; /* remote LSN of the state change
44 * used for synchronization
45 * coordination, or NULL if not
46 * valid */
47#endif
#define BKI_LOOKUP(catalog)
Definition: genbki.h:46
#define BKI_FORCE_NULL
Definition: genbki.h:32
FormData_pg_subscription_rel
unsigned int Oid
Definition: postgres_ext.h:32
uint64 XLogRecPtr
Definition: xlogdefs.h:21

References BKI_FORCE_NULL, and BKI_LOOKUP.

◆ DECLARE_UNIQUE_INDEX_PKEY()

DECLARE_UNIQUE_INDEX_PKEY ( pg_subscription_rel_srrelid_srsubid_index  ,
6117  ,
SubscriptionRelSrrelidSrsubidIndexId  ,
pg_subscription_rel  ,
btree(srrelid oid_ops, srsubid oid_ops)   
)

◆ GetSubscriptionRelations()

List * GetSubscriptionRelations ( Oid  subid,
bool  tables,
bool  sequences,
bool  not_ready 
)

Definition at line 568 of file pg_subscription.c.

570{
571 List *res = NIL;
572 Relation rel;
573 HeapTuple tup;
574 int nkeys = 0;
575 ScanKeyData skey[2];
576 SysScanDesc scan;
577
578 /* One or both of 'tables' and 'sequences' must be true. */
579 Assert(tables || sequences);
580
581 rel = table_open(SubscriptionRelRelationId, AccessShareLock);
582
583 ScanKeyInit(&skey[nkeys++],
584 Anum_pg_subscription_rel_srsubid,
585 BTEqualStrategyNumber, F_OIDEQ,
586 ObjectIdGetDatum(subid));
587
588 if (not_ready)
589 ScanKeyInit(&skey[nkeys++],
590 Anum_pg_subscription_rel_srsubstate,
591 BTEqualStrategyNumber, F_CHARNE,
592 CharGetDatum(SUBREL_STATE_READY));
593
594 scan = systable_beginscan(rel, InvalidOid, false,
595 NULL, nkeys, skey);
596
597 while (HeapTupleIsValid(tup = systable_getnext(scan)))
598 {
600 SubscriptionRelState *relstate;
601 Datum d;
602 bool isnull;
603 char relkind;
604
605 subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
606
607 /* Relation is either a sequence or a table */
608 relkind = get_rel_relkind(subrel->srrelid);
609 Assert(relkind == RELKIND_SEQUENCE || relkind == RELKIND_RELATION ||
610 relkind == RELKIND_PARTITIONED_TABLE);
611
612 /* Skip sequences if they were not requested */
613 if ((relkind == RELKIND_SEQUENCE) && !sequences)
614 continue;
615
616 /* Skip tables if they were not requested */
617 if ((relkind == RELKIND_RELATION ||
618 relkind == RELKIND_PARTITIONED_TABLE) && !tables)
619 continue;
620
621 relstate = (SubscriptionRelState *) palloc(sizeof(SubscriptionRelState));
622 relstate->relid = subrel->srrelid;
623 relstate->state = subrel->srsubstate;
624 d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
625 Anum_pg_subscription_rel_srsublsn, &isnull);
626 if (isnull)
627 relstate->lsn = InvalidXLogRecPtr;
628 else
629 relstate->lsn = DatumGetLSN(d);
630
631 res = lappend(res, relstate);
632 }
633
634 /* Cleanup */
635 systable_endscan(scan);
637
638 return res;
639}
void systable_endscan(SysScanDesc sysscan)
Definition: genam.c:603
HeapTuple systable_getnext(SysScanDesc sysscan)
Definition: genam.c:514
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
Definition: genam.c:388
Assert(PointerIsAligned(start, uint64))
static void * GETSTRUCT(const HeapTupleData *tuple)
Definition: htup_details.h:728
List * lappend(List *list, void *datum)
Definition: list.c:339
char get_rel_relkind(Oid relid)
Definition: lsyscache.c:2170
void * palloc(Size size)
Definition: mcxt.c:1365
static SequenceItem * sequences
Definition: pg_dump.c:212
#define NIL
Definition: pg_list.h:68
static XLogRecPtr DatumGetLSN(Datum X)
Definition: pg_lsn.h:25
FormData_pg_subscription_rel * Form_pg_subscription_rel
#define InvalidOid
Definition: postgres_ext.h:37
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Definition: scankey.c:76
#define BTEqualStrategyNumber
Definition: stratnum.h:31
Definition: pg_list.h:54
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Definition: syscache.c:595
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28

References AccessShareLock, Assert(), BTEqualStrategyNumber, CharGetDatum(), DatumGetLSN(), get_rel_relkind(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, InvalidXLogRecPtr, lappend(), SubscriptionRelState::lsn, NIL, ObjectIdGetDatum(), palloc(), SubscriptionRelState::relid, ScanKeyInit(), sequences, SubscriptionRelState::state, SysCacheGetAttr(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().

Referenced by AlterSubscription_refresh(), AlterSubscription_refresh_seq(), DropSubscription(), and FetchRelationStates().

◆ GetSubscriptionRelState()

char GetSubscriptionRelState ( Oid  subid,
Oid  relid,
XLogRecPtr sublsn 
)

Definition at line 390 of file pg_subscription.c.

391{
392 HeapTuple tup;
393 char substate;
394 bool isnull;
395 Datum d;
396 Relation rel;
397
398 /*
399 * This is to avoid the race condition with AlterSubscription which tries
400 * to remove this relstate.
401 */
402 rel = table_open(SubscriptionRelRelationId, AccessShareLock);
403
404 /* Try finding the mapping. */
405 tup = SearchSysCache2(SUBSCRIPTIONRELMAP,
406 ObjectIdGetDatum(relid),
407 ObjectIdGetDatum(subid));
408
409 if (!HeapTupleIsValid(tup))
410 {
412 *sublsn = InvalidXLogRecPtr;
413 return SUBREL_STATE_UNKNOWN;
414 }
415
416 /* Get the state. */
417 substate = ((Form_pg_subscription_rel) GETSTRUCT(tup))->srsubstate;
418
419 /* Get the LSN */
420 d = SysCacheGetAttr(SUBSCRIPTIONRELMAP, tup,
421 Anum_pg_subscription_rel_srsublsn, &isnull);
422 if (isnull)
423 *sublsn = InvalidXLogRecPtr;
424 else
425 *sublsn = DatumGetLSN(d);
426
427 /* Cleanup */
428 ReleaseSysCache(tup);
429
431
432 return substate;
433}
void ReleaseSysCache(HeapTuple tuple)
Definition: syscache.c:264
HeapTuple SearchSysCache2(int cacheId, Datum key1, Datum key2)
Definition: syscache.c:230

References AccessShareLock, DatumGetLSN(), GETSTRUCT(), HeapTupleIsValid, InvalidXLogRecPtr, ObjectIdGetDatum(), ReleaseSysCache(), SearchSysCache2(), SysCacheGetAttr(), table_close(), and table_open().

Referenced by AlterSubscription_refresh(), logicalrep_rel_open(), LogicalRepSyncTableStart(), and wait_for_table_state_change().

◆ HasSubscriptionTables()

bool HasSubscriptionTables ( Oid  subid)

Definition at line 519 of file pg_subscription.c.

520{
521 Relation rel;
522 ScanKeyData skey[1];
523 SysScanDesc scan;
524 HeapTuple tup;
525 bool has_subtables = false;
526
527 rel = table_open(SubscriptionRelRelationId, AccessShareLock);
528
529 ScanKeyInit(&skey[0],
530 Anum_pg_subscription_rel_srsubid,
531 BTEqualStrategyNumber, F_OIDEQ,
532 ObjectIdGetDatum(subid));
533
534 scan = systable_beginscan(rel, InvalidOid, false,
535 NULL, 1, skey);
536
537 while (HeapTupleIsValid(tup = systable_getnext(scan)))
538 {
540 char relkind;
541
542 subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
543 relkind = get_rel_relkind(subrel->srrelid);
544
545 if (relkind == RELKIND_RELATION ||
546 relkind == RELKIND_PARTITIONED_TABLE)
547 {
548 has_subtables = true;
549 break;
550 }
551 }
552
553 /* Cleanup */
554 systable_endscan(scan);
556
557 return has_subtables;
558}

References AccessShareLock, BTEqualStrategyNumber, get_rel_relkind(), GETSTRUCT(), HeapTupleIsValid, InvalidOid, ObjectIdGetDatum(), ScanKeyInit(), systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), and table_open().

Referenced by FetchRelationStates().

◆ MAKE_SYSCACHE()

MAKE_SYSCACHE ( SUBSCRIPTIONRELMAP  ,
pg_subscription_rel_srrelid_srsubid_index  ,
64   
)

◆ RemoveSubscriptionRel()

void RemoveSubscriptionRel ( Oid  subid,
Oid  relid 
)

Definition at line 440 of file pg_subscription.c.

441{
442 Relation rel;
443 TableScanDesc scan;
444 ScanKeyData skey[2];
445 HeapTuple tup;
446 int nkeys = 0;
447
448 rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
449
450 if (OidIsValid(subid))
451 {
452 ScanKeyInit(&skey[nkeys++],
453 Anum_pg_subscription_rel_srsubid,
455 F_OIDEQ,
456 ObjectIdGetDatum(subid));
457 }
458
459 if (OidIsValid(relid))
460 {
461 ScanKeyInit(&skey[nkeys++],
462 Anum_pg_subscription_rel_srrelid,
464 F_OIDEQ,
465 ObjectIdGetDatum(relid));
466 }
467
468 /* Do the search and delete what we found. */
469 scan = table_beginscan_catalog(rel, nkeys, skey);
471 {
473
474 subrel = (Form_pg_subscription_rel) GETSTRUCT(tup);
475
476 /*
477 * We don't allow to drop the relation mapping when the table
478 * synchronization is in progress unless the caller updates the
479 * corresponding subscription as well. This is to ensure that we don't
480 * leave tablesync slots or origins in the system when the
481 * corresponding table is dropped. For sequences, however, it's ok to
482 * drop them since no separate slots or origins are created during
483 * synchronization.
484 */
485 if (!OidIsValid(subid) &&
486 subrel->srsubstate != SUBREL_STATE_READY &&
487 get_rel_relkind(subrel->srrelid) != RELKIND_SEQUENCE)
488 {
490 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
491 errmsg("could not drop relation mapping for subscription \"%s\"",
492 get_subscription_name(subrel->srsubid, false)),
493 errdetail("Table synchronization for relation \"%s\" is in progress and is in state \"%c\".",
494 get_rel_name(relid), subrel->srsubstate),
495
496 /*
497 * translator: first %s is a SQL ALTER command and second %s is a
498 * SQL DROP command
499 */
500 errhint("Use %s to enable subscription if not already enabled or use %s to drop the subscription.",
501 "ALTER SUBSCRIPTION ... ENABLE",
502 "DROP SUBSCRIPTION ...")));
503 }
504
505 CatalogTupleDelete(rel, &tup->t_self);
506 }
507 table_endscan(scan);
508
510}
#define OidIsValid(objectId)
Definition: c.h:777
int errdetail(const char *fmt,...)
Definition: elog.c:1216
int errhint(const char *fmt,...)
Definition: elog.c:1330
int errcode(int sqlerrcode)
Definition: elog.c:863
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define ereport(elevel,...)
Definition: elog.h:150
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
Definition: heapam.c:1361
void CatalogTupleDelete(Relation heapRel, const ItemPointerData *tid)
Definition: indexing.c:365
char * get_rel_name(Oid relid)
Definition: lsyscache.c:2095
char * get_subscription_name(Oid subid, bool missing_ok)
Definition: lsyscache.c:3862
@ ForwardScanDirection
Definition: sdir.h:28
ItemPointerData t_self
Definition: htup.h:65
TableScanDesc table_beginscan_catalog(Relation relation, int nkeys, ScanKeyData *key)
Definition: tableam.c:113
static void table_endscan(TableScanDesc scan)
Definition: tableam.h:985

References BTEqualStrategyNumber, CatalogTupleDelete(), ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, ForwardScanDirection, get_rel_name(), get_rel_relkind(), get_subscription_name(), GETSTRUCT(), heap_getnext(), HeapTupleIsValid, ObjectIdGetDatum(), OidIsValid, RowExclusiveLock, ScanKeyInit(), HeapTupleData::t_self, table_beginscan_catalog(), table_close(), table_endscan(), and table_open().

Referenced by AlterSubscription_refresh(), DropSubscription(), and heap_drop_with_catalog().

◆ UpdateDeadTupleRetentionStatus()

void UpdateDeadTupleRetentionStatus ( Oid  subid,
bool  active 
)

Definition at line 645 of file pg_subscription.c.

646{
647 Relation rel;
648 bool nulls[Natts_pg_subscription];
649 bool replaces[Natts_pg_subscription];
650 Datum values[Natts_pg_subscription];
651 HeapTuple tup;
652
653 /* Look up the subscription in the catalog */
654 rel = table_open(SubscriptionRelationId, RowExclusiveLock);
655 tup = SearchSysCacheCopy1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
656
657 if (!HeapTupleIsValid(tup))
658 elog(ERROR, "cache lookup failed for subscription %u", subid);
659
660 LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
661
662 /* Form a new tuple. */
663 memset(values, 0, sizeof(values));
664 memset(nulls, false, sizeof(nulls));
665 memset(replaces, false, sizeof(replaces));
666
667 /* Set the subscription to disabled. */
668 values[Anum_pg_subscription_subretentionactive - 1] = active;
669 replaces[Anum_pg_subscription_subretentionactive - 1] = true;
670
671 /* Update the catalog */
672 tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
673 replaces);
674 CatalogTupleUpdate(rel, &tup->t_self, tup);
675 heap_freetuple(tup);
676
677 table_close(rel, NoLock);
678}
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
Definition: heaptuple.c:1210
void CatalogTupleUpdate(Relation heapRel, const ItemPointerData *otid, HeapTuple tup)
Definition: indexing.c:313
#define SearchSysCacheCopy1(cacheId, key1)
Definition: syscache.h:91

References AccessShareLock, CatalogTupleUpdate(), elog, ERROR, heap_freetuple(), heap_modify_tuple(), HeapTupleIsValid, LockSharedObject(), NoLock, ObjectIdGetDatum(), RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), table_open(), and values.

Referenced by update_retention_status().

◆ UpdateSubscriptionRelState()

void UpdateSubscriptionRelState ( Oid  subid,
Oid  relid,
char  state,
XLogRecPtr  sublsn,
bool  already_locked 
)

Definition at line 324 of file pg_subscription.c.

326{
327 Relation rel;
328 HeapTuple tup;
329 bool nulls[Natts_pg_subscription_rel];
330 Datum values[Natts_pg_subscription_rel];
331 bool replaces[Natts_pg_subscription_rel];
332
333 if (already_locked)
334 {
335#ifdef USE_ASSERT_CHECKING
336 LOCKTAG tag;
337
338 Assert(CheckRelationOidLockedByMe(SubscriptionRelRelationId,
339 RowExclusiveLock, true));
340 SET_LOCKTAG_OBJECT(tag, InvalidOid, SubscriptionRelationId, subid, 0);
341 Assert(LockHeldByMe(&tag, AccessShareLock, true));
342#endif
343
344 rel = table_open(SubscriptionRelRelationId, NoLock);
345 }
346 else
347 {
348 LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
349 rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
350 }
351
352 /* Try finding existing mapping. */
353 tup = SearchSysCacheCopy2(SUBSCRIPTIONRELMAP,
354 ObjectIdGetDatum(relid),
355 ObjectIdGetDatum(subid));
356 if (!HeapTupleIsValid(tup))
357 elog(ERROR, "subscription relation %u in subscription %u does not exist",
358 relid, subid);
359
360 /* Update the tuple. */
361 memset(values, 0, sizeof(values));
362 memset(nulls, false, sizeof(nulls));
363 memset(replaces, false, sizeof(replaces));
364
365 replaces[Anum_pg_subscription_rel_srsubstate - 1] = true;
366 values[Anum_pg_subscription_rel_srsubstate - 1] = CharGetDatum(state);
367
368 replaces[Anum_pg_subscription_rel_srsublsn - 1] = true;
369 if (XLogRecPtrIsValid(sublsn))
370 values[Anum_pg_subscription_rel_srsublsn - 1] = LSNGetDatum(sublsn);
371 else
372 nulls[Anum_pg_subscription_rel_srsublsn - 1] = true;
373
374 tup = heap_modify_tuple(tup, RelationGetDescr(rel), values, nulls,
375 replaces);
376
377 /* Update the catalog. */
378 CatalogTupleUpdate(rel, &tup->t_self, tup);
379
380 /* Cleanup. */
381 table_close(rel, NoLock);
382}
bool CheckRelationOidLockedByMe(Oid relid, LOCKMODE lockmode, bool orstronger)
Definition: lmgr.c:351
bool LockHeldByMe(const LOCKTAG *locktag, LOCKMODE lockmode, bool orstronger)
Definition: lock.c:643
#define SET_LOCKTAG_OBJECT(locktag, dboid, classoid, objoid, objsubid)
Definition: lock.h:264
Definition: lock.h:167

References AccessShareLock, Assert(), CatalogTupleUpdate(), CharGetDatum(), CheckRelationOidLockedByMe(), elog, ERROR, heap_modify_tuple(), HeapTupleIsValid, InvalidOid, LockHeldByMe(), LockSharedObject(), LSNGetDatum(), NoLock, ObjectIdGetDatum(), RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy2, SET_LOCKTAG_OBJECT, HeapTupleData::t_self, table_close(), table_open(), values, and XLogRecPtrIsValid.

Referenced by AlterSubscription_refresh_seq(), copy_sequence(), LogicalRepSyncTableStart(), ProcessSyncingTablesForApply(), and ProcessSyncingTablesForSync().

Variable Documentation

◆ FormData_pg_subscription_rel

FormData_pg_subscription_rel

Definition at line 48 of file pg_subscription_rel.h.