

# pgactive 函数参考
<a name="pgactive-functions-reference"></a>

在下文中，您可以找到 pgactive 函数及其参数、返回值和实际使用说明，以助您高效使用它们：

## get\_last\_applied\_xact\_info
<a name="get-last-applied-xact-info"></a>

检索指定节点的上次应用的事务信息。

**Arguments (参数)**  
+ sysid (text) - timeline OID
+ dboid (OID)

**返回类型**  
它将记录以下内容：  
+ last\_applied\_xact\_id（OID）
+ last\_applied\_xact\_committs（带时区的时间戳）
+ last\_applied\_xact\_at（带时区的时间戳）

**使用说明**  
使用此函数可检索指定节点的上次应用的事务信息。

## pgactive\_apply\_pause
<a name="pgactive-apply-pause"></a>

暂停复制应用进程。

**Arguments (参数)**  
无

**返回类型**  
布尔值

**使用说明**  
调用此函数可暂停复制应用进程。

## pgactive\_apply\_resume
<a name="pgactive-apply-resume"></a>

恢复复制应用进程。

**Arguments (参数)**  
无

**返回类型**  
void

**使用说明**  
调用此函数可恢复复制应用进程。

## pgactive\_is\_apply\_paused
<a name="pgactive-is-apply-paused"></a>

检查复制应用当前是否已暂停。

**Arguments (参数)**  
无

**返回类型**  
布尔值

**使用说明**  
使用此函数可检查复制应用当前是否已暂停。

## pgactive\_create\_group
<a name="pgactive-create-group"></a>

通过将独立数据库转换为初始节点来创建 pgactive 组。



**Arguments (参数)**  
+ node\_name (text)
+ node\_dsn (text)
+ apply\_delay integer DEFAULT NULL::integer - replication\_sets text[] DEFAULT ARRAY[‘default’::text]

**返回类型**  
void

**使用说明**  
通过将独立数据库转换为初始节点来创建 pgactive 组。此函数在将节点转换为 pgactive 节点之前执行完整性检查。在使用此函数之前，请确保您的 PostgreSQL 集群有足够的可用 `max_worker_processes` 来支持 pgactive 后台工作线程。

## pgactive\_detach\_nodes
<a name="pgactive-detach-nodes"></a>

从 pgactive 组中移除指定节点。

**Arguments (参数)**  
+ p\_nodes (text[])

**返回类型**  
void

**使用说明**  
使用此函数可从 pgactive 组中移除指定节点。

## pgactive\_exclude\_table\_replication\_set
<a name="pgactive-exclude-table-replication-set"></a>

将特定表排除在复制之外。

**Arguments (参数)**  
+ p\_relation（regclass）

**返回类型**  
void

**使用说明**  
使用此函数可将特定表排除在复制之外。

## pgactive\_get\_replication\_lag\_info
<a name="pgactive-get-replication-lag-info"></a>

检索详细的复制滞后信息，包括节点详细信息、WAL 状态和 LSN 值。

**Arguments (参数)**  
无

**返回类型**  
SETOF 记录 - node\_name text - node\_sysid text - application\_name text - slot\_name text - active boolean - active\_pid integer - pending\_wal\_decoding bigint - 发送者节点上待解码的 WAL 的近似大小（以字节为单位）- pending\_wal\_to\_apply bigint - 要在接收节点上应用的 WAL 的近似大小（以字节为单位）- restart\_lsn pg\_lsn - confirmed\_flush\_lsn pg\_lsn - sent\_lsn pg\_lsn - write\_lsn pg\_lsn - flush\_lsn pg\_lsn - replay\_lsn pg\_lsn

**使用说明**  
调用此函数可检索复制滞后信息，包括节点详细信息、WAL 状态和 LSN 值。

## pgactive\_get\_stats
<a name="pgactive-get-stats"></a>

检索 pgactive 复制统计信息。

**Arguments (参数)**  
无

**返回类型**  
SETOF 记录 - rep\_node\_id oid - rilocalid oid - riremoteid text - nr\_commit bigint - nr\_rollback bigint - nr\_insert bigint - nr\_insert\_conflict bigint - nr\_update bigint - nr\_update\_conflict bigint - nr\_delete bigint - nr\_delete\_conflict bigint - nr\_disconnect bigint

**使用说明**  
使用此函数可检索 pgactive 复制统计信息。

## pgactive\_get\_table\_replication\_sets
<a name="pgactive-get-table-replication-sets"></a>

获取特定关系的复制集配置。

**Arguments (参数)**  
+ relation (regclass)

**返回类型**  
SETOF 记录

**使用说明**  
调用此函数可获取特定关系的复制集配置。

## pgactive\_include\_table\_replication\_set
<a name="pgactive-include-table-replication-set"></a>

将特定表包含在复制中。

**Arguments (参数)**  
+ p\_relation（regclass）

**返回类型**  
void

**使用说明**  
使用此函数可将特定表包含在复制中。

## pgactive\_join\_group
<a name="pgactive-join-group"></a>

向现有 pgactive 组添加节点。

**Arguments (参数)**  
+ node\_name (text)
+ node\_dsn (text)
+ join\_using\_dsn (text)
+ apply\_delay (integer，可选)
+ replication\_sets (text[]，默认值：['default'])
+ bypass\_collation\_check (boolean，默认值：false)
+ bypass\_node\_identifier\_creation (boolean，默认值：false)
+ bypass\_user\_tables\_check (boolean，默认值：false)

**返回类型**  
void

**使用说明**  
调用此函数可将节点添加到现有 pgactive 组中。确保您的 PostgreSQL 集群有足够的 max\_worker\_processes 以供 pgactive 后台工作线程使用。

## pgactive\_remove
<a name="pgactive-remove"></a>

从本地节点中移除所有 pgactive 组件。

**Arguments (参数)**  
+ force (boolean，默认值：false)

**返回类型**  
void

**使用说明**  
调用此函数可从本地节点中移除所有 pgactive 组件。

## pgactive\_snowflake\_id\_nextval
<a name="pgactive-snowflake-id-nextval"></a>

生成特定于节点的唯一序列值。

**Arguments (参数)**  
+ regclass

**返回类型**  
bigint

**使用说明**  
使用此函数可生成特定于节点的唯一序列值。

## pgactive\_update\_node\_conninfo
<a name="pgactive-update-node-conninfo"></a>

更新 pgactive 节点的连接信息。

**Arguments (参数)**  
+ node\_name\_to\_update (text)
+ node\_dsn\_to\_update (text)

**返回类型**  
void

**使用说明**  
使用此函数可更新 pgactive 节点的连接信息。

## pgactive\_wait\_for\_node\_ready
<a name="pgactive-wait-for-node-ready"></a>

监控组创建或加入操作的进度。

**Arguments (参数)**  
+ timeout (integer，默认值：0)
+ progress\_interval (integer，默认值：60)

**返回类型**  
void

**使用说明**  
调用此函数可监控组创建或加入操作的进度。