暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

PostgreSQL 13 新特性学习-架构调整

原创 柚子身上依 2025-04-24
193

1.字典表修改

  • 新增字典
字典名称 描述
pg_shmem_allocations View the breakdown of shared memory.
pg_stat_progress_analyze Tracking the progress of the ANALYZE statement.
pg_stat_progress_basebackup Tracking the progress of the base backup.
pg_stat_slru Tracking SLRU cache statistics.
  • 删除字典
字典名称 描述
pg_pltemplate Procedural language templates.
  • information_schema删除字典
字典名称 描述
sql_languages SQL statement standards compliance levels, options, and dialects.
sql_packages List of standard packages.
sql_sizing_profiles List of defined size information.
  • 字典增加列
字典名称 新增列 类型 描述
pg_available_extension_versions trusted boolean The extension can be installed by-nonsuperusers.
pg_publication pubviaroot boolean Convert partition updates to route tables.
pg_replication_slots wal_status text WAL file status.
safe_wal_size bigint A number of bytes that can be written to WAL for the state “lost”.
pg_stat_activity leader_pid integer Leader PID for the parallel query.
pg_stat_{all|sys|user}_tables n_ins_since_vacuum bigint The Number of tuples inserted since the last VACUUM.
pg_stat_wal_receiver written_lsn pg_lsn The last WAL location for already received and written to disk, but not flushed.
flushed_lsn pg_lsn The last WAL location already received and flushed to disk.
pg_statistic_ext stxstattarget integer SET STATISTIC value.
pg_trigger tgparentid oid OID of parent trigger.
  • 字典删除列
字典名称 删除列 描述
pg_stat_wal_receiver received_lsn Split into written_lsn and flushed_lsn.
  • 字典列输出调整
字典名称 修改列 描述
pg_locks The value ‘speculative token’ output in the locktype column has changed to
‘spectoken’.
pg_stat_ssl Process information other than client connection has been removed.
pg_stat_gssapi Process information other than client connection has been removed.

在修改后的系统目录中,主要目录的详细信息如下所述。

  • pg_shmem_allocations

pg_shmem_allocations 字典允许您查看共享内存中的细分。它不包括动态共享内存的区域。只有具有 SUPERUSER 属性的用户才能查看此字典表。

列名称 列类型 描述
name text The name of the memory area, ‘null’ is an unused area.
off bigint Offset from the start position.
size bigint Reserved bytes.
allocated_size bigint Reserved bytes including padding.
postgres=# SELECT * FROM pg_shmem_allocations limit 10; 
               name               |    off    |  size   | allocated_size 
----------------------------------+-----------+---------+----------------
 Buffer IO Locks                  | 140660480 |  524288 |         524288
 Buffer Descriptors               |   5394176 | 1048576 |        1048576
 Backend SSL Status Buffer        | 146585472 |   42312 |          42368
 Async Queue Control              | 147128320 |    2492 |           2560
 Wal Sender Ctl                   | 147121920 |    1040 |           1152
 AutoVacuum Data                  | 147113344 |    5368 |           5376
 PROCLOCK hash                    | 143136384 |    2904 |           2944
 FinishedSerializableTransactions | 146098048 |      16 |            128
 XLOG Ctl                         |     53888 | 4208272 |        4208384
 Shared MultiXact State           |   5393024 |    1028 |           1152
(10 rows)
  • pg_stat_progress_analyze

pg_stat_progress_analyze 字典允许您检查 ANALYZE 语句的执行状态。普通用户可以查看该字典,但普通用户无法看到其他用户的命令执行状态。

列名称 列类型 描述
pid integer Backend process ID.
datid oid OID of the connection database.
datname name Connection database name.
relid oid Table OID executing ANALYZE statement.
phase text Execution phase.
sample_blks_total bigint Total number of blocks sampled.
sample_blks_scanned bigint Number of sampled blocks.
ext_stats_total bigint Extended statistics.
ext_stats_computed bigint Number of extended statistics computed.
child_tables_total bigint Number of child tables.
child_tables_done bigint Number of child tables for ANALYZE are done.
current_child_table_relid oid ANALYZE executing child table OID.
ostgres=# SELECT * FROM pg_stat_progress_analyze ; 
-[ RECORD 1 ]-------------+--------------------- 
pid                       | 30932 
datid                     | 13578 
datname                   | postgres 
relid                     | 16388 
phase                     | computing statistics 
sample_blks_total         | 54055 
sample_blks_scanned       | 54055 
ext_stats_total           | 0 
ext_stats_computed        | 0 
child_tables_total        | 0 
child_tables_done         | 0 
current_child_table_relid | 0 
  • pg_stat_progress_basebackup

pg_stat_progress_basebackup 视图允许您检查由 pg_basebackup 命令等工具执行的备份的状态。非超级用户用户可以查看此目录,但非连接用户只能查看 ‘pid’ 列。

列名称 列类型 描述
pid integer WAL sender process ID.
phase text The string indicating the execution phase.
backup_total bigint Total backup size.
backup_streamed bigint Streaming data volume.
tablespaces_total bigint Number of total tablespaces.
tablespaces_streamed bigint Number of streaming tablespaces.
postgres=# SELECT * FROM pg_stat_progress_basebackup ; 
-[ RECORD 1 ]--------+------------------------- 
pid                  | 31080 
phase                | streaming database files 
backup_total         | 467913216 
backup_streamed      | 302026752 
tablespaces_total    | 1 
tablespaces_streamed | 0
  • pg_stat_slru

pg_stat_slru目录可以检查 SLRU 缓存的使用状态。显示每个 SLRU 缓存区域对缓存页的访问统计信息。

列名称 列类型 描述
name text SLRU name.
blks_zeroed bigint Number of blocks initialized to zero.
blks_hit bigint Number of blocks that hit the cache.
blks_read bigint Number of blocks read.
blks_written bigint Number of blocks written.
blks_exists bigint Number of blocks checked for existence in the cache.
flushes bigint Number of dirty blocks flushed.
truncates bigint Number of blocks truncated.
stats_reset timestamp with time zone Date and time when statistics were reset.

此视图中的计数器值将在实例重启后保留。执行 pg_stat_reset_slru function 以重置计数器值。

postgres=#  SELECT name, blks_hit, blks_read, blks_written  FROM pg_stat_slru ;
      name       | blks_hit | blks_read | blks_written 
-----------------+----------+-----------+--------------
 CommitTs        |        0 |         0 |            0
 MultiXactMember |        0 |         0 |            0
 MultiXactOffset |        0 |         0 |            0
 Notify          |        0 |         0 |            0
 Serial          |        0 |         0 |            0
 Subtrans        |        0 |         0 |            0
 Xact            |     1484 |         0 |            0
 other           |        0 |         0 |            0
(8 rows)

2.数据类型

添加了以下数据类型:

  • regcollation

指示已添加 Collation 名称的 regcollation 类型。添加了 to_regcollation 函数,用于将文本类型转换为 regcollation 类型。

postgres=#  SELECT to_regcollation('"POSIX"') ;
 to_regcollation 
-----------------
 "POSIX"
(1 row)
  • xid8

添加了 xid8 类型,表示已添加 64 位事务 ID。添加了使用 xid8 类型的函数。保留返回常规 32 位事务 ID 的函数是为了兼容性。但是它们将来可能会被删除。

旧函数名称 新函数名称
txid_current pg_current_xact_id
txid_current_if_assigned pg_current_xact_id_if_assigned
txid_current_snapshot pg_current_snapshot
txid_snapshot_xip pg_snapshot_xip
txid_snapshot_xmax pg_snapshot_xmax
txid_snapshot_xmin pg_snapshot_xmin
txid_visible_in_snapshot pg_visible_in_snapshot
txid_status pg_xact_status
  • pg_snapshot

pg_snapshot 类型存储有关特定时间点的交易 ID 可见性(xmin、xmax xip_list)的信息。

  • 其他抽象数据类型

还添加了以下抽象数据类型。

数据类型名称 描述
anycompatible The function accepts any data type and is automatically promoted.
anycompatiblearray The function accepts any array type and is automatically promoted.
anycompatiblenonarray The function accepts an non-array type and is automatically promoted.
anycompatiblerange The function accepts any range type and is automatically promoted.
table_am_handler Table access method handler.

3.基于磁盘的哈希聚合

执行 GROUP BY 或 DISTINCT 子句时,可以在内存中创建哈希表。如果哈希表无法存储在工作内存中,PostgreSQL 13 将执行基于存储的哈希聚合。在以前的版本中,创建工作内存时,假设它可以存储在内存中,这可能会导致内存使用量意外增加。

postgres=> EXPLAIN ANALYZE SELECT COUNT(*) FROM data1 GROUP BY c1 ; 
QUERY PLAN 
----------------------------------------------------------------- 
HashAggregate  
(cost=4304055.00..5029055.00 
rows=10000000 
width=14) (actual time=2703.993..16089.774 rows=10000000 loops=1) 
Group Key: c1 
Planned Partitions: 4  Batches: 87381  Memory Usage: 109kB  Disk 
Usage: 268256kB ->  
Seq Scan on data1  (cost=0.00..154055.00 rows=10000000 
width=6) (actual time=0.025..606.455 rows=10000000 loops=1) 
Planning Time: 0.039 ms 
Execution Time: 16407.060 ms 
(6 rows) 

4.增量排序

增量排序是一种减少用于多列排序的资源的方法。当除了已排序的列之外还需要对另一列进行排序时,会使用它。此功能可通过 enable_incremental_sort 参数进行控制。默认值为 ‘on’。

postgres=> EXPLAIN ANALYZE SELECT * FROM (SELECT * FROM data1 ORDER 
BY c1) t ORDER BY c1, c2; 
                                   QUERY PLAN ----------------------------------------------------------------- 
Incremental Sort  (cost=0.49..853808.44 rows=10000000 width=12) 
(actual time=0.063..2253.672 rows=10000000 loops=1) 
   Sort Key: data1.c1, data1.c2 
   Presorted Key: data1.c1 
   Full-sort Groups: 312500  Sort Method: quicksort  Average 
Memory: 26kB  Peak Memory: 26kB 
   ->  Index Only Scan using idx1_data1 on data1  
(cost=0.43..303808.43 rows=10000000 width=12) (actual 
time=0.045..891.341 rows=10000000 loo 
ps=1) 
         Heap Fetches: 0 
 Planning Time: 0.258 ms 
 Execution Time: 2495.751 ms 
(8 rows) 

5.备份清单

现在可以对使用 pg_basebackup 命令等创建的基本备份执行一致性检查。大小和校验和是针对数据库集群中的每个文件计算的。

  • checksum

校验和的计算方法可以从 SHA224、SHA256、SHA384、SHA512 和 CRC32C 中选择。CRC32C 是默认值。

  • Manifest文件

备份清单以 backup_manifest 的形式存储在备份目录中。它是一个 JSON 格式的文件。

$ head back/backup_manifest 
{ "PostgreSQL-Backup-Manifest-Version": 1,
"Files": [
{ "Path": "backup_label", "Size": 224, "Last-Modified": "2025-03-06 07:51:27 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "999de53f" },
{ "Path": "base/13468/2605_vm", "Size": 8192, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "2e5feb7a" },
{ "Path": "base/13468/2683", "Size": 8192, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "28359312" },
{ "Path": "base/13468/2605", "Size": 16384, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "20e9ee4d" },
{ "Path": "base/13468/2754", "Size": 16384, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "5830131e" },
{ "Path": "base/13468/4154", "Size": 8192, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "7dff9b26" },
{ "Path": "base/13468/5002", "Size": 8192, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "e8119cf2" },
{ "Path": "base/13468/2619_fsm", "Size": 24576, "Last-Modified": "2025-03-06 03:05:40 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "d5548f35" },

$ tail back/backup_manifest 
{ "Path": "postgresql.conf", "Size": 28148, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "cf08553a" },
{ "Path": "pg_multixact/offsets/0000", "Size": 8192, "Last-Modified": "2025-02-28 01:39:26 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "23464490" },
{ "Path": "pg_multixact/members/0000", "Size": 8192, "Last-Modified": "2025-02-28 01:34:25 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "23464490" },
{ "Path": "pg_hba.conf", "Size": 4782, "Last-Modified": "2025-02-28 01:34:26 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "8784e335" },
{ "Path": "global/pg_control", "Size": 8192, "Last-Modified": "2025-03-06 07:51:27 GMT", "Checksum-Algorithm": "CRC32C", "Checksum": "43872087" }
],
"WAL-Ranges": [
{ "Timeline": 1, "Start-LSN": "0/C000028", "End-LSN": "0/C000100" }
],
"Manifest-Checksum": "391dd56b705b684a8592e6ee92af5bf5ac7e5000e523f4b309ad02510908400e"}

如果以 tar 格式执行备份,则 manifest 文件不包含在 tar 文件中。

$ pg_basebackup --format=tar -D back 
$ 
$ ls back/
backup_manifest  base.tar  pg_wal.tar
  • 检查一致性

提供 pg_verifybackup 命令以重新检查获取的备份的完整性。将备份目标目录名称指定给 pg_verifybackup 命令。

$ pg_verifybackup back 
backup successfully verified

6.分区表

分区表中新增了以下功能。

  • 逻辑复制支持

现在可以将分区表添加到逻辑复制环境中的 PUBLICATION 中。在以前的版本中 CREATE PUBLICATION 语句失败。为了使复制成功,SUBSCRIPTION 端需要具有相同结构的表。

postgres=# CREATE TABLE part1(c1 NUMERIC PRIMARY KEY, c2 VARCHAR(10)) PARTITION BY RANGE(c1) ;
CREATE TABLE
postgres=# CREATE TABLE part1v1 PARTITION OF part1 FOR VALUES FROM (0) TO (100000) ;
CREATE TABLE
postgres=# CREATE TABLE part1v2 PARTITION OF part1 FOR VALUES FROM (100000) TO (200000) ;
CREATE TABLE
postgres=#  CREATE PUBLICATION pub1 FOR TABLE part1 ;
WARNING:  wal_level is insufficient to publish logical changes
HINT:  Set wal_level to logical before creating subscriptions.
CREATE PUBLICATION
postgres=# 
postgres=# show wal_level;
 wal_level 
-----------
 replica
(1 row)

postgres=#  \dRp+ pub1
                              Publication pub1
  Owner   | All tables | Inserts | Updates | Deletes | Truncates | Via root 
----------+------------+---------+---------+---------+-----------+----------
 postgres | f          | t       | t       | t       | t         | f
Tables:
    "public.part1"

postgres=# select * from pg_publication_tables ;
 pubname | schemaname | tablename 
---------+------------+-----------
 pub1    | public     | part1v1
 pub1    | public     | part1v2
(2 rows)

默认情况下,PUBLICATION 将分区的更新发送到 SUBSCRIPTION,而不将其转换为分区表的更新。在 SUBSCRIPTION 端复制到非分区表时,将 PUBLICATION 属性publish_via_partition_root设置为 ‘on’。

postgres=#  ALTER PUBLICATION pub1 SET (publish_via_partition_root = on) ;
ALTER PUBLICATION
postgres=# \dRp+ pub1
                              Publication pub1
  Owner   | All tables | Inserts | Updates | Deletes | Truncates | Via root 
----------+------------+---------+---------+---------+-----------+----------
 postgres | f          | t       | t       | t       | t         | t
Tables:
    "public.part1"

postgres=# select * from pg_publication_tables ;
 pubname | schemaname | tablename 
---------+------------+-----------
 pub1    | public     | part1
(1 row)


-- SUBSCRIPTION 侧
postgres=> CREATE TABLE part1(c1 NUMERIC PRIMARY KEY, c2 VARCHAR(10)) ; 
CREATE TABLE 
postgres=# CREATE SUBSCRIPTION sub1 CONNECTION 'host=remhost1 dbname=postgres 
user=postgres password=<<PASSWORD>>' PUBLICATION pub1 ; 
NOTICE:  created replication slot "sub1" on publisher 
CREATE SUBSCRIPTION 
postgres=# 
  • BEFORE INSERT 触发器

现在可以设置 ROW 级别 BEFORE INSERT 触发器。但是元组无法更改要存储的分区。

postgres=# CREATE TABLE part2 (c1 INT, c2 INT, c3 VARCHAR(10)) PARTITION BY LIST(c1) ;
CREATE TABLE
postgres=# CREATE TABLE part2v1 PARTITION OF part2 FOR VALUES IN (10) ;
CREATE TABLE
postgres=#  CREATE OR REPLACE FUNCTION fnc1_part2() RETURNS TRIGGER  
postgres-# LANGUAGE plpgsql AS $$ 
postgres$#    BEGIN 
postgres$#      NEW.c3 = 'TRIGGER'; 
postgres$#      RETURN NEW; 
postgres$#  END; $$ ;
CREATE FUNCTION
postgres=# CREATE TRIGGER trg1_part2 BEFORE INSERT ON part2 FOR EACH ROW EXECUTE FUNCTION fnc1_part2() ;
CREATE TRIGGER

postgres=# INSERT INTO part2(c1, c2) VALUES (10, 20) ;
INSERT 0 1
postgres=# SELECT * FROM part2;
 c1 | c2 |   c3    
----+----+---------
 10 | 20 | TRIGGER
(1 row)
  • 在更多情况下允许分区连接

即使分区结构不同,现在也可以执行分区连接。此功能不适用于哈希分区表。

  • 使用整个表的分区列

现在可以为分区列的定义指定整个列。

postgres=#  CREATE TABLE part3(c1 INT, c2 INT) PARTITION  BY LIST((part3)) ;
CREATE TABLE
postgres=# \d part3;
         Partitioned table "public.part3"
 Column |  Type   | Collation | Nullable | Default 
--------+---------+-----------+----------+---------
 c1     | integer |           |          | 
 c2     | integer |           |          | 
Partition key: LIST ((part3.*))
Number of partitions: 0

postgres=#  CREATE TABLE part3v1 PARTITION OF part3 FOR VALUES  IN ('(1, 2)') ;
CREATE TABLE
postgres=# CREATE TABLE part3v2 PARTITION OF part3 FOR VALUES  IN ('(2, 4)') ;
CREATE TABLE

7.Autovacuum 的日志输出

WAL 统计信息现在输出到自动 VACUUM 日志中。

2025-03-07 12:54:28.329 CST [64] LOG:  automatic vacuum of table "postgres.public.test": index scans: 1
        pages: 0 removed, 11336 remain, 0 skipped due to pins, 0 skipped frozen
        tuples: 262144 removed, 1572864 remain, 0 are dead but not yet removable, oldest xmin: 881
        buffer usage: 36711 hits, 1781 misses, 2908 dirtied
        avg read rate: 5.405 MB/s, avg write rate: 8.826 MB/s
        system usage: CPU: user: 0.31 s, system: 0.22 s, elapsed: 2.57 s
        WAL usage: 35338 records, 11784 full page images, 77952836 bytes

8.等待事件

输出到 pg_stat_activity 目录的 wait_event 列的 Wait 事件进行了以下更改。

增加的等待事件

等待事件名称 描述
BackupWaitWalArchive Waiting for archive creation.
RecoveryConflictSnapshot Waiting for recovery conflict resolution during VACUUM cleanup.
RecoveryConflictTablespace Waiting for resolution of recovery conflict when deleting table space.
RecoveryPause Waiting for the promotion of standby instance.
VacuumDelay Cost-based VACUUM delay.
ProcSignalBarrier Waiting for a barrier event to be processed by all backends.

重命名等待事件

等待事件名称(PostgreSQL 12) 等待事件名称(PostgreSQL 13)
AsyncCtlLock NotifySLRU
AsyncQueueLock NotifyQueue
CLogControlLock XactSLRU
ClogGroupUpdate XactGroupUpdate
CommitTsControlLock CommitTsSLRU
Hash/Batch/Allocating HashBatchAllocate
Hash/Batch/Electing HashBatchElect
Hash/Batch/Loading HashBatchLoad
Hash/Build/Allocating HashBuildAllocate
Hash/Build/Electing HashBuildElect
Hash/Build/HashingInner HashBuildHashInner
Hash/Build/HashingOuter HashBuildHashOuter
Hash/GrowBatches/Allocating HashGrowBatchesAllocate
Hash/GrowBatches/Deciding HashGrowBatchesDecide
Hash/GrowBatches/Electing HashGrowBatchesElect
Hash/GrowBatches/Finishing HashGrowBatchesFinish
Hash/GrowBatches/Repartitioning HashGrowBatchesRepartition
Hash/GrowBuckets/Allocating HashGrowBucketsAllocate
Hash/GrowBuckets/Electing HashGrowBucketsElect
Hash/GrowBuckets/Reinserting HashGrowBucketsReinsert
MultiXactOffsetControlLock MultiXactOffsetSLRU
MultiXactMemberControlLock MultiXactMemberSLRU
OldSerXidLock SerialSLRU
RecoveryWalAll RecoveryWalStream
RecoveryWalStream RecoveryRetrieveRetryInterval
SerializablePredicateLockListLock SerializablePredicateList
SubtransControlLock SubtransSLRU
speculative token spectoken

除了上表之外,还有许多事件名称更改,例如删除事件名称末尾的 ‘Lock’。

9.libpq 连接字符串

已添加/更改以下 libpq 连接字符串。

  • channel_binding 参数

channel_binding 参数已添加到客户端连接字符串中,以控制通道绑定。可指定的值如下。

描述
require Required.
prefer Client selection.
disable Disable.

‘Prefer’ 是启用 SSL 时的默认值。如果禁用 SSL,则“禁用”是默认值。环境变量 PGCHANNELBINDING 可以指定与此参数相同的值。

  • Sslkey 参数

现在可以为 sslkey 参数指定 ASN.1 DER 格式文件。

  • ssl_min_protocol_version, ssl_max_protocol_version 参数

指定 SSL/TLS 协议的最低版本 (ssl_min_protocol_version) 和最高版本 (ssl_max_protocol_version)。可能的值为 TLSv1、TLSv1.1、TLSv1.2 和 TLSv1.3。ssl_min_protocol_version 的默认值为 TLSv1.2。如果未指定 ssl_max_protocol_version 的值,则使用 backend 值。也可以使用环境变量 PGSSLMINPROTOCOLVERSION 和 PGSSLMAXPROTOCOLVERSION 而不是使用参数。

  • sslpassword 参数

指定 sslkey 参数指定的私钥的密码。

10.libpq 函数

添加了以下 libpq 函数。
• BufferUsageAccumDiff
• TupleHashTableHash
• LookupTupleHashEntryHash
• PQsetSSLKeyPassHook_OpenSSL
• LogicalTapeSetExtend

11.Hook

提供了以下钩子函数。

  • TLS 初始化钩子
    提供了 TLS 初始化钩子。在 openssl_tls_init_hook 中指定回调函数。

  • TRUNCATE 钩子

执行该钩子以允许对 TRUNCATE 语句进行强制访问控制 (MAC)。Contrib 模块 sepgsql 可以控制对 TRUNCATE 语句的访问。

  • 列触发器

在逻辑复制环境中,列触发器现在在订阅端执行。

  • 本地连接密钥

传统上,实例使用的共享内存的关键信息是根据连接等待端口号(参数 ‘port’)来确定的。PostgreSQL 13 现在使用数据库集群的 i-node 编号。

$ ls -lid data
2228445 drwx------ 20 postgres root 4096 Mar  7 04:49 data
$ 
$ ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status      
0x002200dd 0          postgres   600        56         7                       

在上面的示例中,i-node 编号为 2228445 ,转换为十六进制时为 0x002200dd 。

14.受信任的扩展

添加了扩展控制文件 ({extension}.control) 文件中描述的 ‘trusted’ 属性。此属性的默认值为 ‘off’。此属性值设置为 ‘on’ 的扩展可以执行 CREATE EXTENSION 语句,即使用户没有 SUPERUSER 属性也是如此。用户必须对数据库具有 CREATE 权限。

postgres=# CREATE USER demo PASSWORD '<<PASSWORD>>' ; 
CREATE ROLE 
postgres=# GRANT CREATE ON DATABASE postgres TO demo ; 
GRANT 
postgres=# \connect postgres demo 
You are now connected to database "postgres" as user "demo". 
postgres=> CREATE EXTENSION hstore ; 
CREATE EXTENSION 

$ cat hstore.control 
# hstore extension
comment = 'data type for storing sets of (key, value) pairs'
default_version = '1.7'
module_pathname = '$libdir/hstore'
relocatable = true
trusted = true

以下扩展的 trusted 设置设置为 ‘on’。
• bool_plperl
• btree_gin
• btree_gist
• citext
• cube
• dict_int
• fuzzystrmatch
• hstore
• intarray.
• isn
• jsonb_plperl
• lo
• ltree
• pgcrypto
• pg_trgm
• plperl
• plpgsql
• seg
• tablefunc
• tcn
• tsm_system_rows
• tsm_system_time
• unaccent

15.复制槽

在流式复制环境中,如果备实例上未指定参数 primary_slot_name,则可以在主实例上创建临时复制槽。备用实例参数 wal_receiver_create_temp_slot 必须为 ‘on’ (默认为 ‘off’)。

postgres=# SELECT * FROM pg_replication_slots ; 
-[ RECORD 1 ]-------+-------------------- 
slot_name           | pg_walreceiver_4273 
plugin        |       
slot_type    | physical        
datoid         |      
database       |      
temporary      | t      
active         | t      
active_pid     | 4273      
xmin           |      
catalog_xmin   |      
restart_lsn    | 0/390005A0      
confirmed_flush_lsn | 
wal_status          | reserved 
safe_wal_size       

16.文本搜索

增加了文本搜索的语言。在 PostgreSQL 12 中,有 22 种语言,但在 PostgreSQL 13 中添加了希腊语。

postgres=# \dF 
               List of text search configurations
   Schema   |    Name    |              Description              
------------+------------+---------------------------------------
 pg_catalog | arabic     | configuration for arabic language
 pg_catalog | danish     | configuration for danish language
 pg_catalog | dutch      | configuration for dutch language
 pg_catalog | english    | configuration for english language
 pg_catalog | finnish    | configuration for finnish language
 pg_catalog | french     | configuration for french language
 pg_catalog | german     | configuration for german language
 pg_catalog | greek      | configuration for greek language
 pg_catalog | hungarian  | configuration for hungarian language
 pg_catalog | indonesian | configuration for indonesian language
 pg_catalog | irish      | configuration for irish language
 pg_catalog | italian    | configuration for italian language
 pg_catalog | lithuanian | configuration for lithuanian language
 pg_catalog | nepali     | configuration for nepali language
 pg_catalog | norwegian  | configuration for norwegian language
 pg_catalog | portuguese | configuration for portuguese language
 pg_catalog | romanian   | configuration for romanian language
 pg_catalog | russian    | configuration for russian language
 pg_catalog | simple     | simple configuration
 pg_catalog | spanish    | configuration for spanish language
 pg_catalog | swedish    | configuration for swedish language
 pg_catalog | tamil      | configuration for tamil language
 pg_catalog | turkish    | configuration for turkish language
(23 rows)

参考

《PostgreSQL_13_GA_New_Features_en_20200927-1.pdf》

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论