

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

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

## get\$1last\$1applied\$1xact\$1info
<a name="get-last-applied-xact-info"></a>

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

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

**返回类型**  
它将记录以下内容：  
+ last\$1applied\$1xact\$1id（OID）
+ last\$1applied\$1xact\$1committs（带时区的时间戳）
+ last\$1applied\$1xact\$1at（带时区的时间戳）

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

## pgactive\$1apply\$1pause
<a name="pgactive-apply-pause"></a>

暂停复制应用进程。

**Arguments (参数)**  
无

**返回类型**  
布尔值

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

## pgactive\$1apply\$1resume
<a name="pgactive-apply-resume"></a>

恢复复制应用进程。

**Arguments (参数)**  
无

**返回类型**  
void

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

## pgactive\$1is\$1apply\$1paused
<a name="pgactive-is-apply-paused"></a>

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

**Arguments (参数)**  
无

**返回类型**  
布尔值

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

## pgactive\$1create\$1group
<a name="pgactive-create-group"></a>

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



**Arguments (参数)**  
+ node\$1name (text)
+ node\$1dsn (text)
+ apply\$1delay integer DEFAULT NULL::integer - replication\$1sets text[] DEFAULT ARRAY[‘default’::text]

**返回类型**  
void

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

## pgactive\$1detach\$1nodes
<a name="pgactive-detach-nodes"></a>

从 pgactive 组中移除指定节点。

**Arguments (参数)**  
+ p\$1nodes (text[])

**返回类型**  
void

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

## pgactive\$1exclude\$1table\$1replication\$1set
<a name="pgactive-exclude-table-replication-set"></a>

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

**Arguments (参数)**  
+ p\$1relation（regclass）

**返回类型**  
void

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

## pgactive\$1get\$1replication\$1lag\$1info
<a name="pgactive-get-replication-lag-info"></a>

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

**Arguments (参数)**  
无

**返回类型**  
SETOF 记录 - node\$1name text - node\$1sysid text - application\$1name text - slot\$1name text - active boolean - active\$1pid integer - pending\$1wal\$1decoding bigint - 发送者节点上待解码的 WAL 的近似大小（以字节为单位）- pending\$1wal\$1to\$1apply bigint - 要在接收节点上应用的 WAL 的近似大小（以字节为单位）- restart\$1lsn pg\$1lsn - confirmed\$1flush\$1lsn pg\$1lsn - sent\$1lsn pg\$1lsn - write\$1lsn pg\$1lsn - flush\$1lsn pg\$1lsn - replay\$1lsn pg\$1lsn

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

## pgactive\$1get\$1stats
<a name="pgactive-get-stats"></a>

检索 pgactive 复制统计信息。

**Arguments (参数)**  
无

**返回类型**  
SETOF 记录 - rep\$1node\$1id oid - rilocalid oid - riremoteid text - nr\$1commit bigint - nr\$1rollback bigint - nr\$1insert bigint - nr\$1insert\$1conflict bigint - nr\$1update bigint - nr\$1update\$1conflict bigint - nr\$1delete bigint - nr\$1delete\$1conflict bigint - nr\$1disconnect bigint

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

## pgactive\$1get\$1table\$1replication\$1sets
<a name="pgactive-get-table-replication-sets"></a>

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

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

**返回类型**  
SETOF 记录

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

## pgactive\$1include\$1table\$1replication\$1set
<a name="pgactive-include-table-replication-set"></a>

将特定表包含在复制中。

**Arguments (参数)**  
+ p\$1relation（regclass）

**返回类型**  
void

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

## pgactive\$1join\$1group
<a name="pgactive-join-group"></a>

向现有 pgactive 组添加节点。

**Arguments (参数)**  
+ node\$1name (text)
+ node\$1dsn (text)
+ join\$1using\$1dsn (text)
+ apply\$1delay (integer，可选)
+ replication\$1sets (text[]，默认值：['default'])
+ bypass\$1collation\$1check (boolean，默认值：false)
+ bypass\$1node\$1identifier\$1creation (boolean，默认值：false)
+ bypass\$1user\$1tables\$1check (boolean，默认值：false)

**返回类型**  
void

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

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

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

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

**返回类型**  
void

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

## pgactive\$1snowflake\$1id\$1nextval
<a name="pgactive-snowflake-id-nextval"></a>

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

**Arguments (参数)**  
+ regclass

**返回类型**  
bigint

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

## pgactive\$1update\$1node\$1conninfo
<a name="pgactive-update-node-conninfo"></a>

更新 pgactive 节点的连接信息。

**Arguments (参数)**  
+ node\$1name\$1to\$1update (text)
+ node\$1dsn\$1to\$1update (text)

**返回类型**  
void

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

## pgactive\$1wait\$1for\$1node\$1ready
<a name="pgactive-wait-for-node-ready"></a>

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

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

**返回类型**  
void

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