mirror of
https://github.com/postgres/postgres.git
synced 2026-02-15 16:48:17 -05:00
A few places that access this catalog don't set up an active snapshot before potentially accessing its TOAST table. However, roname (the replication origin name) is the only varlena column, so this is only a problem if the name requires out-of-line storage. This commit removes its TOAST table to avoid needing to set up a snapshot. It also places a limit on replication origin names so that attempts to set long names will fail with a more user-friendly error. Those chosen limit of 512 bytes should be sufficient to avoid "row is too big" errors independent of BLCKSZ, but it should also be lenient enough for all reasonable use-cases. Bumps catversion. Reviewed-by: Michael Paquier <michael@paquier.xyz> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Reviewed-by: Euler Taveira <euler@eulerto.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/ZvMSUPOqUU-VNADN%40nathan
83 lines
2.7 KiB
C
83 lines
2.7 KiB
C
/*-------------------------------------------------------------------------
|
|
* origin.h
|
|
* Exports from replication/logical/origin.c
|
|
*
|
|
* Copyright (c) 2013-2025, PostgreSQL Global Development Group
|
|
*
|
|
* src/include/replication/origin.h
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PG_ORIGIN_H
|
|
#define PG_ORIGIN_H
|
|
|
|
#include "access/xlog.h"
|
|
#include "access/xlogdefs.h"
|
|
#include "access/xlogreader.h"
|
|
#include "catalog/pg_replication_origin.h"
|
|
|
|
typedef struct xl_replorigin_set
|
|
{
|
|
XLogRecPtr remote_lsn;
|
|
RepOriginId node_id;
|
|
bool force;
|
|
} xl_replorigin_set;
|
|
|
|
typedef struct xl_replorigin_drop
|
|
{
|
|
RepOriginId node_id;
|
|
} xl_replorigin_drop;
|
|
|
|
#define XLOG_REPLORIGIN_SET 0x00
|
|
#define XLOG_REPLORIGIN_DROP 0x10
|
|
|
|
#define InvalidRepOriginId 0
|
|
#define DoNotReplicateId PG_UINT16_MAX
|
|
|
|
/*
|
|
* To avoid needing a TOAST table for pg_replication_origin, we limit
|
|
* replication origin names to 512 bytes. This should be more than enough for
|
|
* all practical use.
|
|
*/
|
|
#define MAX_RONAME_LEN 512
|
|
|
|
extern PGDLLIMPORT RepOriginId replorigin_session_origin;
|
|
extern PGDLLIMPORT XLogRecPtr replorigin_session_origin_lsn;
|
|
extern PGDLLIMPORT TimestampTz replorigin_session_origin_timestamp;
|
|
|
|
/* GUCs */
|
|
extern PGDLLIMPORT int max_active_replication_origins;
|
|
|
|
/* API for querying & manipulating replication origins */
|
|
extern RepOriginId replorigin_by_name(const char *roname, bool missing_ok);
|
|
extern RepOriginId replorigin_create(const char *roname);
|
|
extern void replorigin_drop_by_name(const char *name, bool missing_ok, bool nowait);
|
|
extern bool replorigin_by_oid(RepOriginId roident, bool missing_ok,
|
|
char **roname);
|
|
|
|
/* API for querying & manipulating replication progress tracking */
|
|
extern void replorigin_advance(RepOriginId node,
|
|
XLogRecPtr remote_commit,
|
|
XLogRecPtr local_commit,
|
|
bool go_backward, bool wal_log);
|
|
extern XLogRecPtr replorigin_get_progress(RepOriginId node, bool flush);
|
|
|
|
extern void replorigin_session_advance(XLogRecPtr remote_commit,
|
|
XLogRecPtr local_commit);
|
|
extern void replorigin_session_setup(RepOriginId node, int acquired_by);
|
|
extern void replorigin_session_reset(void);
|
|
extern XLogRecPtr replorigin_session_get_progress(bool flush);
|
|
|
|
/* Checkpoint/Startup integration */
|
|
extern void CheckPointReplicationOrigin(void);
|
|
extern void StartupReplicationOrigin(void);
|
|
|
|
/* WAL logging */
|
|
extern void replorigin_redo(XLogReaderState *record);
|
|
extern void replorigin_desc(StringInfo buf, XLogReaderState *record);
|
|
extern const char *replorigin_identify(uint8 info);
|
|
|
|
/* shared memory allocation */
|
|
extern Size ReplicationOriginShmemSize(void);
|
|
extern void ReplicationOriginShmemInit(void);
|
|
|
|
#endif /* PG_ORIGIN_H */
|