系统管理函数。
包括配置设置函数,服务信号函数,备份控制函数,恢复控制函数,快照同步函数,流复制函数,数据库对象管理函数,索引维护函数,通用文件访问函数,advisory锁定。
Name |
Return Type |
Description |
current_setting(setting_name [, missing_ok ]) |
text |
查看当前设置 |
set_config(setting_name, new_value, is_local) |
text |
设置参数 |
Name |
Return Type |
Description |
pg_cancel_backend(pidint) |
boolean |
Cancel后端查询 |
pg_reload_conf() |
boolean |
重新加载配置文件。生效不用重启就可以生效的参数 |
pg_rotate_logfile() |
boolean |
转换log文件 |
pg_terminate_backend(pidint) |
boolean |
终止后端连接。 |
Name |
Return Type |
Description |
pg_create_restore_point(name text) |
pg_lsn |
创建恢复 |
pg_current_wal_flush_lsn() |
pg_lsn |
获取当前write-ahead log flush 位置 |
pg_current_wal_insert_lsn() |
pg_lsn |
获取当前 write-ahead log insert 位置 |
pg_current_wal_lsn() |
pg_lsn |
获取当前 write-ahead log write 位置 |
pg_start_backup(label text [, fastboolean [, exclusive boolean ]]) |
pg_lsn |
准备开始在线备份。 |
pg_stop_backup() |
pg_lsn |
停止在线备份 |
pg_stop_backup(exclusive boolean [,wait_for_archive boolean ]) |
setof record |
完成独占或非排他性在线备份 |
pg_is_in_backup() |
bool |
是否为备份状态 |
pg_backup_start_time() |
timestamp with time zone |
获取备份开始时间 |
pg_switch_wal() |
pg_lsn |
强制切换到新的write-ahead log file |
pg_walfile_name(lsn pg_lsn) |
text |
转换 write-ahead log 文件名 |
pg_walfile_name_offset(lsn pg_lsn) |
text, integer |
将写入前日志位置转换为文件内的文件名和十进制字节偏移量 |
pg_wal_lsn_diff(lsn pg_lsn, lsn pg_lsn) |
numeric |
计算两个lsn位置的差距 |
Name |
Return Type |
Description |
pg_is_in_recovery() |
bool |
数据库是否在恢复(备库) |
pg_last_wal_receive_lsn() |
pg_lsn |
获取最后一个写入前日志位置,并通过流复制同步到磁盘。当流复制正在进行时,这将单调增加。如果恢复完成,这将保持在接收到的最后一个WAL记录的值,并在恢复期间同步到磁盘。如果禁用流复制,或者如果尚未启动,则函数返回NULL。 |
pg_last_wal_replay_lsn() |
pg_lsn |
在恢复过程中重写上次写入的日志位置。如果恢复仍在进行中,这将单调增加。如果恢复完成,则该值在恢复期间应用的最后一个WAL记录的值将保持静态。当服务器正常启动而不恢复时,函数返回NULL。 |
pg_last_xact_replay_timestamp() |
timestamp with time zone |
获取恢复过程中重放的最后一次事务的时间戳。这是在主事务上生成该事务的提交或中止WAL记录的时间。如果在恢复过程中没有重放事务,则此函数返回null。否则,如果恢复仍在进行中,这将单调增加。如果恢复完成,则该值将在该恢复期间应用的最后一个事务的值保持静态。当服务器正常启动而不恢复时,函数返回NULL。 |
Name |
Return Type |
Description |
pg_is_wal_replay_paused() |
bool |
如果恢复暂停,则为真。 |
pg_wal_replay_pause() |
void |
暂停恢复 |
pg_wal_replay_resume() |
void |
如果暂停,则恢复启动 |
Name |
Return Type |
Description |
pg_export_snapshot() |
text |
保存当前快照并返回标识 |
Function |
Return Type |
Description |
pg_create_physical_replication_slot(slot_namename [, immediately_reserve boolean,temporary boolean]) |
(slot_namename, lsnpg_lsn) |
创建一个新的物理复制槽命名slot_name。可选的第二个参数,当TRUE时,指定该复制时隙的LSN立即被保留,否则LSN在流连接复制客户端的第一个连接上被保留。从物理slot进行流式传输只能用流式复制协议来实现。可选的第三参数临时设置为true时,指定槽不应永久存储到磁盘,而仅用于当前会话。临时槽也被释放在任何错误。 |
pg_drop_replication_slot(slot_name name) |
void |
Drop的物理或逻辑复制槽命名slot_name。同drop_replication_slot复制协议的命令。对于逻辑槽,当连接到同一个数据库时必须调用这个槽。 |
pg_create_logical_replication_slot(slot_namename, plugin name [, temporary boolean]) |
(slot_namename, lsnpg_lsn) |
创建一个新的逻辑(解码)复制槽命名slot_name使用输出插件插件。可选的第三参数临时设置为true时,指定时隙不应永久存储到磁盘,而仅用于当前会话。临时槽也被释放在任何错误。对该函数的调用具有与复制协议命令CREATE_REPLICATION_SLOT ... LOGICAL. |
pg_logical_slot_get_changes(slot_name name,upto_lsn pg_lsn, upto_nchanges int, VARIADICoptions text[]) |
(lsnpg_lsn, xid xid, data text) |
返回slot_name名称的更改,从上次更改后的点开始。如果upto_lsn和upto_nchanges是空,则逻辑解码将持续到WAL结束。如果upto_lsn是非空的,逻辑解码将只包括在指定LSN之前提交的那些事务。如果upto_nchanges不为空,则当解码产生的行数超过指定值时,解码将停止。但是请注意,返回的实际行数可能更大,因为只有在添加解码新的事务提交时生成的行时才检查该限制。 |
pg_logical_slot_peek_changes(slot_name name,upto_lsn pg_lsn, upto_nchanges int, VARIADICoptions text[]) |
(lsnpg_lsn, xid xid, data text) |
类似于pg_logical_slot_get_changes() 函数, 只是没有更改,也就是说,它们将在将来的调用中再次返回。 |
pg_logical_slot_get_binary_changes(slot_namename, upto_lsn pg_lsn, upto_nchanges int, VARIADIC options text[]) |
(lsnpg_lsn, xid xid, databytea) |
类似于pg_logical_slot_get_changes() 函数, 只是将更改作为bytea返回. |
pg_logical_slot_peek_binary_changes(slot_namename, upto_lsn pg_lsn, upto_nchanges int, VARIADIC options text[]) |
(lsnpg_lsn, xid xid, databytea) |
类似于pg_logical_slot_get_changes() 函数, 只是将更改作为bytea返回,并且不使用更改;也就是说,它们将在将来的调用中再次返回。 |
pg_replication_origin_create(node_name text) |
oid |
用给定的外部名称创建复制原点,并返回分配给它的内部ID。 |
pg_replication_origin_drop(node_name text) |
void |
删除先前创建的复制原点,包括任何相关的回放进度。 |
pg_replication_origin_oid(node_name text) |
oid |
通过名称查找复制原点并返回内部ID。如果没有找到相应的复制原点,则会引发错误。 |
pg_replication_origin_session_setup(node_nametext) |
void |
从给定的起点标记当前会话作为重做,允许重做进程被跟踪。使用pg_replication_origin_session_reset命令复位,只能在没有以前的原点配置的情况下使用。 |
pg_replication_origin_session_reset() |
void |
取消pg_replication_origin_session_setup(). |
pg_replication_origin_session_is_setup() |
bool |
在当前会话中是否已配置复制原点? |
pg_replication_origin_session_progress(flushbool) |
pg_lsn |
返回在当前会话中配置的复制原点的重放位置。参数确定是否将确保相应的本地事务已被刷新到磁盘。 |
pg_replication_origin_xact_setup(origin_lsnpg_lsn, origin_timestamp timestamptz) |
void |
标记当前事务是重放在给定的LSN和时间戳下提交的事务。只能在复制原点之前使用pg_replication_origin_session_setup 配置时调用。 |
pg_replication_origin_xact_reset() |
void |
取消 pg_replication_origin_xact_setup(). |
pg_replication_origin_advance(node_name text,lsn pg_lsn) |
void |
将给定节点的复制进度设置为给定位置。这主要用于在配置更改和类似之后设置初始位置或新位置。请注意,不小心使用此函数会导致不一致的复制数据。 |
pg_replication_origin_progress(node_nametext, flush bool) |
pg_lsn |
返回给定复制原点的重放位置。参数确定是否将确保相应的本地事务已被刷新到磁盘。 |
pg_logical_emit_message(transactional bool,prefix text, content text) |
pg_lsn |
发出文本逻辑解码消息。这可以用来通过WAL将通用消息传递给逻辑解码插件。参数事务事务指定消息是否应该是当前事务的一部分,或者是否应该在逻辑解码读取记录时立即写入并解码。“前缀”是逻辑解码插件使用的文本前缀,以方便识别它们的有趣消息。“内容”是消息的文本。 |
pg_logical_emit_message(transactional bool,prefix text, content bytea) |
pg_lsn |
发送二进制逻辑解码消息。这可以用来通过WAL将通用消息传递给逻辑解码插件。参数事务事务指定消息是否应该是当前事务的一部分,或者是否应该在逻辑解码读取记录时立即写入并解码。“前缀”是逻辑解码插件使用的文本前缀,以方便识别它们的有趣消息。第二内容是消息的二进制内容。 |
Name |
Return Type |
Description |
pg_column_size(any) |
int |
用于存储特定值(可能被压缩)的字节数 |
pg_database_size(oid) |
bigint |
具有指定OID的数据库使用的磁盘空间 |
pg_database_size(name) |
bigint |
具有指定名称的数据库所使用的磁盘空间 |
pg_indexes_size(regclass) |
bigint |
连接到指定表的索引使用的总磁盘空间 |
pg_relation_size(relation regclass,fork text) |
bigint |
指定的表或索引(“main”、‘fsm’、‘vm’或‘init’)所用的磁盘空间 |
pg_relation_size(relation regclass) |
bigint |
速记 for pg_relation_size(..., 'main') |
pg_size_bytes(text) |
bigint |
将具有大小单位的人类可读格式转换为字节 |
pg_size_pretty(bigint) |
text |
将以64位整数表示的字节大小转换为具有大小单位的可读格式 |
pg_size_pretty(numeric) |
text |
将以字节表示的字节大小转换为具有大小单位的可读格式 |
pg_table_size(regclass) |
bigint |
指定表使用的磁盘空间,不包括索引(但包括TOAST、自由空间映射和可视图) |
pg_tablespace_size(oid) |
bigint |
表空间使用指定空间的磁盘空间 |
pg_tablespace_size(name) |
bigint |
具有指定名称的表空间使用的磁盘空间 |
pg_total_relation_size(regclass) |
bigint |
指定表所使用的总磁盘空间,包括所有索引和TOAST数据 |
Name |
Return Type |
Description |
pg_relation_filenode(relation regclass) |
oid |
指定表的文件号 |
pg_relation_filepath(relation regclass) |
text |
指定表的文件路径名 |
pg_filenode_relation(tablespace oid, filenode oid) |
regclass |
查找与给定表空间和文件名关联的关系 |
Name |
Return Type |
Description |
pg_collation_actual_version(oid) |
text |
从操作系统返回校对的实际版本 |
pg_import_system_collations(schema regnamespace) |
integer |
导入操作系统排序规则 |
Name |
Return Type |
Description |
brin_summarize_new_values(index regclass) |
integer |
查看brin索引中未被索引汇总的基表中的页范围。 |
brin_summarize_range(index regclass, blockNumber bigint) |
integer |
summarize the page range covering the given block, if not already summarized |
brin_desummarize_range(index regclass, blockNumberbigint) |
integer |
de-summarize the page range covering the given block, if summarized |
gin_clean_pending_list(index regclass) |
bigint |
move GIN pending list entries into main index structure |
Name |
Return Type |
Description |
pg_ls_dir(dirname text [, missing_ok boolean,include_dot_dirs boolean]) |
setof text |
列出data目录中的文件夹中的内容 |
pg_ls_logdir() |
setof record |
列出log文件时间,大小,最后修改时间 |
pg_ls_waldir() |
setof record |
列出所有WAL文件,大小,时间 |
pg_read_file(filename text [, offset bigint,length bigint [, missing_ok boolean] ]) |
text |
查询文件内容(text) |
pg_read_binary_file(filename text [, offsetbigint, length bigint [, missing_ok boolean] ]) |
bytea |
查询文件内容(二进制) |
pg_stat_file(filename text[, missing_okboolean]) |
record |
查询文件信息 |
Name |
Return Type |
Description |
pg_advisory_lock(key bigint) |
void |
获得排他会话级咨询锁 |
pg_advisory_lock(key1 int, key2 int) |
void |
获得排他会话级咨询锁 |
pg_advisory_lock_shared(key bigint) |
void |
获得共享会话级咨询锁 |
pg_advisory_lock_shared(key1 int, key2 int) |
void |
获得共享会话级咨询锁 |
pg_advisory_unlock(key bigint) |
boolean |
释放排他会话级咨询锁 |
pg_advisory_unlock(key1 int, key2 int) |
boolean |
释放排他会话级咨询锁 |
pg_advisory_unlock_all() |
void |
释放当前会话所持有的所有会话级咨询锁 |
pg_advisory_unlock_shared(key bigint) |
boolean |
释放共享会话级咨询锁 |
pg_advisory_unlock_shared(key1 int, key2 int) |
boolean |
释放共享会话级咨询锁 |
pg_advisory_xact_lock(key bigint) |
void |
获得排他事务级别咨询锁 |
pg_advisory_xact_lock(key1 int, key2 int) |
void |
获得排他事务级别咨询锁 |
pg_advisory_xact_lock_shared(key bigint) |
void |
获得共享事务级别咨询锁 |
pg_advisory_xact_lock_shared(key1 int, key2 int) |
void |
获得共享事务级别咨询锁 |
pg_try_advisory_lock(key bigint) |
boolean |
获得排他会话级别的咨询锁 |
pg_try_advisory_lock(key1 int, key2 int) |
boolean |
获得排他会话级别的咨询锁 |
pg_try_advisory_lock_shared(key bigint) |
boolean |
获得共享会话级别的咨询锁 |
pg_try_advisory_lock_shared(key1 int, key2 int) |
boolean |
获得共享会话级别的咨询锁 |
pg_try_advisory_xact_lock(key bigint) |
boolean |
获得排他事务级别咨询锁(如果可用) |
pg_try_advisory_xact_lock(key1 int, key2 int) |
boolean |
获得排他事务级别咨询锁(如果可用) |
pg_try_advisory_xact_lock_shared(key bigint) |
boolean |
获得可用的共享事务级别咨询锁 |
pg_try_advisory_xact_lock_shared(key1 int, key2 int) |
boolean |
获得可用的共享事务级别咨询锁 |