PostgreSQL 13 New Features
PostgreSQL 13 New Features
WITH EXAMPLES · ENGLISH SOURCE EDITION
Explore the features, SQL examples, and compatibility changes documented by Noriyoshi Shinoda.
Contents
Reference indexes
The opening chapter includes the first numbered table, Table 1. The indexes below collect the book’s other native numbered components.
Tables
- Table 1 — Version
- Table 2 — Examples notation
- Table 3 — Syntax rules
- Table 4 — Changing default settings
- Table 5 — Added system catalogs
- Table 6 — Dropped catalog
- Table 7 — Dropped views in information_schema schema
- Table 8 — System catalogs with columns added
- Table 9 — System catalogs with columns dropped
- Table 10 — System catalog with changed output tuples
- Table 11 — pg_shmem_allocations catalog
- Table 12 — pg_stat_progress_analyze catalog
- Table 13 — pg_stat_progress_basebackup catalog
- Table 14 — pg_stat_slru catalog
- Table 15 — Functions that use 64-bit transaction IDs
- Table 16 — Added abstract data types
- Table 17 — Added wait events
- Table 18 — Wait event that has been renamed
- Table 19 — channel_binding parameter values
- Table 20 — Attributes that can be changed
- Table 21 — Added format pattern
- Table 22 — null_value_treatment parameter value
- Table 23 — Added parameters
- Table 24 — Changed parameters
- Table 25 — Parameters that default value has been changed
- Table 26 — pg_verifybackup command option
- Table 27 — Added command
- Table 28 — Added columns
- Table 29 — Added columns
- Table 30 — Modified columns
Examples
- Example 1 — CSV log (part)
- Example 2 — Default prompt
- Example 3 — Execute the to_date function
- Example 4 — Partition key with pseudo-types
- Example 5 — PostgreSQL 12 behavior
- Example 6 — PostgreSQL 13 behavior
- Example 7 — Refer pg_shmem_allocations catalog
- Example 8 — Refer pg_stat_progress_analyze catalog
- Example 9 — Refer pg_stat_progress_basebackup catalog
- Example 10 — Refer pg_stat_slru catalog
- Example 11 — Execute to_regcollation function
- Example 12 — Disk-based hash aggregation
- Example 13 — Incremental sort
- Example 14 — backup_manifest file
- Example 15 — Manifest file for backup in tar file format
- Example 16 — pg_verifybackup command
- Example 17 — Add partitioned table to PUBLICATION
- Example 18 — Non-partitioned table on SUBSCRIPTION side
- Example 19 — CREATE TRIGGER statement for a partitioned table
- Example 20 — Partitiond column expression
- Example 21 — Log output for Autovacuum
- Example 22 — Shared memory key-value
- Example 23 — plpgsql.control file contents
- Example 24 — CREATE EXTENSION statement executed by a general user
- Example 25 — Information on automatically created replication slots
- Example 26 — Text search languages
- Example 27 — ALTER NO DEPENDS ON statement
- Example 28 — ALTER STATISTICS SET STATISTICS statement
- Example 29 — ALTER TABLE DROP EXPRESSION statement
- Example 30 — ALTER TABLE SET STORAGE statement
- Example 31 — ALTER TYPE SET statement
- Example 32 — Rename view column name
- Example 33 — Specify LOCALE clause
- Example 34 — B-Tree index deduplication
- Example 35 — Effect of index deduplication
- Example 36 — Specifying additional attributes for tables
- Example 37 — Specify maintenance_io_concurrency attribute
- Example 38 — DROP DATABASE statement
- Example 39 — EXPLAIN (ANALYZE, BUFFERS) statement
- Example 40 — EXPLAIN (BUFFERS) statement
- Example 41 — Output of the EXPLAIN ANALYZE statement (JIT)
- Example 42 — Output of the EXPLAIN ANALYZE statement (Sort)
- Example 43 — EXPLAIN (ANALYZE, WAL) statement
- Example 44 — INSERT OVERRIDING USER VALUE statement
- Example 45 — datetime method
- Example 46 — MAX(pg_lsn) function
- Example 47 — Extracting values from ROW expressions
- Example 48 — SELECT FETCH FIRST WITH TIES statement
- Example 49 — PARALLEL specification of VACUUM statement
- Example 50 — Operator <->
- Example 51 — gen_random_uuid function
- Example 52 — Date format
- Example 53 — min_scale, trim_scale function
- Example 54 — jsonb_set_lax function
- Example 55 — gcd, lcm function
- Example 56 — is normalized syntax
- Example 57 — is normalized syntax
- Example 58 — backtrace_functions parameter
- Example 59 — dropdb --force option
- Example 60 — pg_basebackup ---no-estimate-size option
- Example 61 — pg_dump --include-foreign-data option
- Example 62 — ALTER DEPENDS ON EXTENSION statement
- Example 63 — pg_rewind command
- Example 64 — pg_verifybackup command
- Example 65 — pg_verifybackup command with error
- Example 66 — pg_verifybackup command with error
- Example 67 — \dAc command
- Example 68 — \g command
- Example 69 — \warn command
- Example 70 — \e command
- Example 71 — \d command
- Example 72 — PROMPT2 variable value
- Example 73 — reindexdb --jobs option
- Example 74 — vacuumdb --parallel option
- Example 75 — --help option
- Example 76 — pg_file_sync function
- Example 77 — log_wal parameter
- Example 78 — ABSVAL attribute
- Example 79 — information on the ltree data type
- Example 80 — heap_tuple_infomask_flags function
- Example 81 — Output of bt_metap function
- Example 82 — Output of bt_page_items function
- Example 83 — Refer the pg_stat_statements view
- Example 84 — Create USER MAPPING object without a password
- Example 85 — Creation of external table by general user and error
- Example 86 — Setting to allow password omission
- Example 87 — bool_plperl extension
Figures
Source edition
The source chapter order, wording, examples, and publication credits are retained. PDF page markers link the reading edition to the original document. Source identity and coverage · About the collection
1 About This Document
PDF page 5
1.1 Purpose
The purpose of this document is to provide information about the major new features of PostgreSQL 13 (13.0).
1.2 Audience
This document is written for engineers who already know PostgreSQL, such as installation, basic management, etc.
1.3 Scope
This document describes the major difference between PostgreSQL 12 (12.4) and PostgreSQL 13 Beta 1 (13.0). As a general rule, this document examines the features of behavior change. This document does not describe and verify all new features. In particular, the following new features are not included.
Bugfix
Performance improvement by changing internal behavior
Improvement of regression test
Operability improvement by psql command tab input
Improvement of pgbench command
Improvement of documentation, modify typo in the source code
Refactoring without a change in behavior
1.4 Software Version
The contents of this document have been verified for the following versions and platforms.
| Software | Version |
|---|---|
| PostgreSQL | PostgreSQL 12.4 (for comparison) PostgreSQL 13 (13.0) GA (Sep 21, 2020 20:51:14) |
| Operating System | Red Hat Enterprise Linux 7 Update 5 (x86-64) |
| Configure option | –with-llvm –with-openssl –with-perl –with-python |
PDF page 6
1.5 The Question, comment, and Responsibility
The contents of this document are not an official opinion of Hewlett Packard Enterprise Japan Co, Ltd. The author and affiliation company do not take any responsibility for the problem caused by the mistake of contents. If you have any comments for this document, please contact Noriyoshi Shinoda (noriyoshi.shinoda@hpe.com) Hewlett Packard Enterprise Japan Co, Ltd.
1.6 Notation
This document contains examples of the execution of the command or SQL statement. Execution examples are described according to the following rules:
| Notation | Description |
|---|---|
| # | Shell prompt for Linux root user. |
| $ | Shell prompt for Linux general user. |
| Bold | The user input string. |
| postgres=# | psql command prompt for PostgreSQL administrator. |
| postgres=> | psql command prompt for PostgreSQL general user. |
| Underline | Important output items. |
| Underline «PASSWORD» | Important output items. Replaced by password string. |
The syntax is described in the following rules:
| Notation | Description |
|---|---|
| Italic | Replaced by the name of the object which users use, or the other syntax. |
| [ ] | Indicate that it can be omitted. |
| { A | B } | Indicate that it is possible to select A or B. |
| … | General syntax. It is the same as the previous version. |
2 New Features Summary
PDF page 7
More than 200 new features have been added to PostgreSQL 13. Here are some major new features and benefits.
2.1 Improve analytic query performance
Enhancement of Parallel operations
If more than one of the indexes has been created in the table, now VACUUM processing is performed in parallel.
Deduplication of B-Tree index
Deduplication is now executed by default for B-Tree indexes. Storage capacity and I/O can be reduced.
Reduce WAL output
The statement that suppresses WAL output when the wal_level parameter is set to ‘minimal’ has been increased.
2.2 Improve reliability
PostgreSQL 13 implements the following enhancements to improve reliability.
Improve backup reliability
Backup consistency can now be checked. Base backups, such as the pg_basebackup command, take the size and checksum of each file and save it to the backup destination. The consistency of the obtained backup can be checked with the pg_verifybackup command.
Dynamic configuration changes for streaming replication
Various parameters used on the standby instance of streaming replication can now be changed dynamically. This new feature eliminates the need to restart the standby instance if the primary instance fails.
PDF page 8
2.3 Improved maintainability
The following features that can improve operability have been added.
Disk-based Hash Aggregation
Operations that manipulate hash tables now are performed on storage when the memory usage limit is exceeded. Previously, there was no upper limit on memory usage, which sometimes led to OOM Killer.
Logical replication of partitioned tables
Partitioned tables can now be used in logical replication environments.
Enhanced monitoring features
Catalogs that can check the execution status of the ANALYZE statement or pg_basebackup command in real-time have been added. Also, the cache hit ratio and I/O status can be checked.
Execution plan creation and WAL output tracking
The amount of WAL output can now be tracked when creating an execution plan or executing an SQL statement. It can be checked by the pg_stat_statements module and EXPLAIN statement.
More wait events
Several wait events have been added that can be monitored. Wait events can be checked in the pg_stat_activity catalog.
2.4 Preparing for future new features
PostgreSQL 13 is now ready for features that will be provided in future versions.
Supports 64-bit transaction ID
The xid8 data type that indicates a 64-bit transaction ID and various functions that handle this data type has been added.
Lock contention
Page locks and extended locks can now conflict between parallel worker processes. With this implementation, it is now possible to implement parallelization such as COPY, INSERT, VACUUM, etc.
PDF page 9
Enhancement of PUBLICATION
It is now ready to add non-table objects to PUBLICATION.
PDF page 10
2.5 Incompatibility
In PostgreSQL 13, the following specifications have been changed from PostgreSQL 12.
2.5.1 configure
The –disable-float4-byval option has been removed from the ‘configure’ command. Also, the pkgconfig command is now used to search for the libxml2 library.
2.5.2 createuser
The –adduser and –no-adduser options have been removed from the createuser command.
2.5.3 CSV log format
Backend type is added at the end of CSV format log (log_destination = ‘csvlog’).
2.5.4 Extension
Remove support for upgrading “unpackaged” extensions.
PDF page 11
2.5.5 opaque
The opaque pseudo-data type has been removed. This data type was used for compatibility from PostgreSQL 7.3 and earlier.
2.5.6 Require version of OpenSSL
OpenSSL 1.0.0 and below are no longer supported. OpenSSL 1.0.1 or higher is required. With this fix, the minimum value of the parameter ssl_min_protocol_version has been changed from TLSv1 to TLSv1.2.
2.5.7 pg_regress
The –load-language option has been removed from the pg_regress command.
2.5.8 psql default prompt
The default prompt settings PROMPT1 and PROMPT2 of the psql command now include %x to indicate the status of the transaction.
| Variable name | PostgreSQL 12 | PostgreSQL 13 | Note |
|---|---|---|---|
| PROMPT1 | “%/%R%# " | “%/%R%x%# " | |
| PROMPT2 | “%/%R%# " | “%/%R%x%# " | |
| PROMPT3 | “» " | “» " | no change |
PDF page 12
2.5.9 to_date/to_timestamp
The output contents of the format string TM change according to the locale. Previously, it was ignored.
2.5.10 Promotion during recovery
Previously, if a promotion was made while the recovery was paused, the paused state would continue. In PostgreSQL 13, if a promotion is performed while recovery is paused, the promotion takes precedence.
2.5.11 Partition key
Disallow partition key expressions that return pseudo-types. This specification has been backported to PostgreSQL 12.2 and later.
2.5.12 Wait Event
Many wait events have been renamed. The event_name column in the pg_stat_activity catalog and the output string in the locktype column in the pg_locks catalog has been changed1.
1 See 3.1.8 Wait events
PDF page 13
2.5.13 SIMILAR TO ESCAPE
SIMILAR TO… ESCAPE NULL clause returns NULL. In previous versions, the ESCAPE NULL clause was ignored.
PDF page 14
3 Architecture
PDF page 14
3.1.1 Modified catalogs
The following catalogs have been changed.
| Catalog name | Description |
|---|---|
| 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. |
| Catalog name | Description |
|---|---|
| pg_pltemplate | Procedural language templates. |
| Catalog name | Description |
|---|---|
| sql_languages | SQL statement standards compliance levels, options, and dialects. |
| sql_packages | List of standard packages. |
| sql_sizing_profiles | List of defined size information. |
PDF page 15
| Catalog name | Added column | Data type | Description |
|---|---|---|---|
| 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. |
| Catalog name | Dropped column | Description |
|---|---|---|
| pg_stat_wal_receiver | received_lsn | Split into written_lsn and flushed_lsn. |
| Catalogname | Description |
|---|---|
| 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. |
Catalog name Description
Among the modified system catalogs, the details of the major catalogs are described below.
PDF page 16
Pg_shmem_allocations catalog
The pg_shmem_allocations catalog allows you to see the breakdown in shared memory. However, it does not include the area of dynamic shared memory. Only users with the SUPERUSER attribute can see this catalog.
| Column name | Data type | Description |
|---|---|---|
| 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. |
Pg_stat_progress_analyze catalog
The pg_stat_progress_analyze catalog allows you to check the execution status of the ANALYZE statement. This catalog can be viewed by ordinary users, but ordinary users cannot see the status of other users’ command execution.
PDF page 17
| Column name | Data type | Description |
|---|---|---|
| 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. |
Pg_stat_progress_basebackup catalog
The pg_stat_progress_basebackup catalog allows you to check the status of the backups performed by tools such as the pg_basebackup command. This catalog can be viewed by non-superuser users, but only the ‘pid’ column can be viewed by non-connected users.
PDF page 18
| Column name | Data type | Description |
|---|---|---|
| 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. |
Pg_stat_slru catalog
Pg_stat_slru catalog can check the usage status of the SLRU cache. Displays statistics on accesses to cached pages for each SLRU cache area.
| Column name | Data type | Description |
|---|---|---|
| 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. |
PDF page 19
The counter values in this view will persist across instance reboots. Execute pg_stat_reset_slru function2 to reset the counter value.
3.1.2 Data types
The following data types have been added:
Regcollation
The regcollation type that indicates the Collation name has been added. A to_regcollation function has been added to convert from text type to regcollation type.
PDF page 20
Xid8
The xid8 type that indicates a 64-bit transaction ID has been added. Functions that use the xid8 type have been added. The functions that return the conventional 32-bit transaction ID are kept for compatibility. However, they may be removed in the future.
| function name | function name |
|---|---|
| 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
The pg_snapshot type stores information about the transaction ID visibility (xmin, xmax, xip_list) at a specific point in time.
Other abstract data types
In addition, the following abstract data types have been added.
| Data type name | Description |
|---|---|
| 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.1.3 Disk-based hash aggregation
A hash table may be created in memory when executing a GROUP BY or DISTINCT clause. PostgreSQL 13 performs storage-based hash aggregation if the hash table cannot be stored in work memory. In previous versions, work memory was created on the assumption that it could be stored in
PDF page 21
memory, which could lead to unexpected increases in memory usage.
3.1.4 Incremental sort
Incremental sorting is a way to reduce the resources used for multi-column sorting. It is used when another column needs to be sorted in addition to the already sorted column. This feature can be controlled by the enable_incremental_sort parameter. The default value is ‘on’.
PDF page 22
3.1.5 Backup manifests
Consistency checks can now be executed on base backups created with the pg_basebackup command, etc. The size and checksum are calculated for each file in the database cluster.
Checksum
The checksum calculation method can be selected from SHA224, SHA256, SHA384, SHA512, and CRC32C. CRC32C is the default value.
Manifest file
The backup manifest is stored as backup_manifest in the backup directory. It is a file in JSON format.
PDF page 23
Check consistency
The pg_verifybackup command is provided to recheck the integrity of the obtained backup. Specify the backup destination directory name to the pg_verifybackup command3.
3 See 3.4.6 pg_verifybackup
PDF page 24
3.1.6 Partitioned table
The following features have been added to the partitioned table.
Logical replication support
The partitioned tables can now be added to PUBLICATION in a logical replication environment. In the previous version, the CREATE PUBLICATION statement in the example below failed. In order for replication to succeed, a table with the same structure is required on the SUBSCRIPTION side.
PDF page 25
By default, PUBLICATION sends updates to the partition to SUBSCRIPTION without converting them to updates to the partition table. When replicating to a non-partitioned table on the SUBSCRIPTION side, set the PUBLICATION attribute publish_via_partition_root to ‘off’.
BEFORE INSERT trigger
ROW level BEFORE INSERT triggers can now be set. However, a tuple is not possible to change the partition to be stored.
PDF page 26
Allow partition wise join in more case
Partition-wise join can now be performed even if the partition structures are not the same. This feature does not work with hash partitioned tables.
Partitioned column using the entire table
It is now possible to specify an entire column to the definition of the partitioning columns.
PDF page 27
3.1.7 Log output for Autovacuum
WAL statistics are now output to the automatic VACUUM log.
3.1.8 Wait events
Wait events that are output to the wait_event column of the pg_stat_activity catalog had the following changes.
PDF page 28
| Wait event name | Description |
|---|---|
| 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. |
| Wait event name (PostgreSQL 12) | Wait event name (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 |
PDF page 29
There are many event name changes other than the above table, such as deleting ‘Lock’ from the end of the event name.
3.1.9 libpq connection string
The following libpq connection strings have been added/changed.
Channel_binding parameter
The channel_binding parameter has been added to the client connection string to control channel binding. The values that can be specified are as follows.
| Value | Description |
|---|---|
| require | Required. |
| prefer | Client selection. |
| disable | Disable. |
‘Prefer’ is the default value when SSL is enabled. ‘Disable’ is the default value if SSL is disabled. The environment variable PGCHANNELBINDING can specify the same value as this parameter.
Sslkey parameter
ASN.1 DER format files can now be specified for the sslkey parameter.
Ssl_min_protocol_version, ssl_max_protocol_version parameter
Specify the minimum version (ssl_min_protocol_version) and maximum version (ssl_max_protocol_version) of the SSL / TLS protocol. Possible values are TLSv1, TLSv1.1, TLSv1.2, and TLSv1.3. The default value of ssl_min_protocol_version is TLSv1.2. if the value of ssl_max_protocol_version is not specified, the backend value is used. It is also possible to use the environment variables PGSSLMINPROTOCOLVERSION and PGSSLMAXPROTOCOLVERSION
PDF page 30
instead of using parameters.
Sslpassword parameter
Specify the password of the private key specified by the sslkey parameter.
3.1.10 libpq functions
BufferUsageAccumDiff
TupleHashTableHash
LookupTupleHashEntryHash
PQsetSSLKeyPassHook_OpenSSL
LogicalTapeSetExtend
3.1.11 Hook
The following hook functions have been provided.
TLS initialization hook
The TLS initialization hook was provided. Specify the callback function in openssl_tls_init_hook.
TRUNCATE hook
The hook is executed to allow mandatory access control (MAC) for the TRUNCATE statement. Contrib module sepgsql can control access to the TRUNCATE statement.
3.1.12 Column trigger
In a logical replication environment, column triggers are now executed on the subscription side.
3.1.13 Local connection key
Conventionally, the key information of the shared memory used by the instance was determined based on the connection waiting port number (parameter ‘port’). PostgreSQL 13 now uses the i-node number of the database cluster.
PDF page 31
3.1.14 Trusted Extension
The ’trusted’ attribute described in the extension control file ({extension}.control) file has been added. The default value for this attribute is ‘off’. Extensions with this attribute value set to ‘on’ can execute the CREATE EXTENSION statement even if the user does not have the SUPERUSER attribute. Users must have CREATE privilege on the database.
PDF page 32
PDF page 33
3.1.15 Replication slot
If the parameter primary_slot_name is not specified on the standby instance in a streaming replication environment, a temporary replication slot can be created on the primary instance. The standby instance parameter wal_receiver_create_temp_slot must be ‘on’ (default ‘off’).
3.1.16 Text search
Languages for text search have been increased. In PostgreSQL 12, there were 22 languages, but in PostgreSQL 13, Greek has been added.
PDF page 34
4 SQL Statements
PDF page 35
This section explains new features related to SQL statements.
3.2.1 ALTER NO DEPENDS ON
ALTER statements for functions, indexes, materialized views, and triggers can now remove dependency settings for extensions. Syntax
3.2.2 ALTER STATISTICS SET STATISTICS
Specify the statistics collection target when executing ANALYZE. The value that can be set is from 0 to 10,000. If you specify 10,000 or more, it is assumed to be 10,000. Specify -1 to reset to the default value. Syntax
The specified value can be checked in the stxstattarget column of the pg_statistic_ext catalog or with the command “\d” in the psql utility.
PDF page 36
3.2.3 ALTER TABLE
The following enhancements have been added to the ALTER TABLE statement.
ALTER TABLE ALTER COLUMN DROP EXPRESSION
By executing the ALTER TABLE ALTER COLUMN DROP EXPRESSION statement, it is now possible to drop an auto-created definition from a column specified with the GENERATED ALWAYS clause. Simply drop the calculation information and the column values will remain. IF EXISTS clause can be specified.
PDF page 37
Syntax
PDF page 38
ALTER TABLE ALTER COLUMN SET STORAGE
Alters to a column’s STORAGE attribute are now propagated to the index. This feature has been backported to the latest versions of PostgreSQL 12 and PostgreSQL 11.
3.2.4 ALTER TYPE
In the ALTER TYPE statement, attributes can be changed using the SET clause. Syntax
The attributes that can be changed are as follows. Part of the attributes that can be specified in the CREATE TYPE statement.
PDF page 39
| Attribute name | Description |
|---|---|
| RECEIVE | The function that converts external representation into an internal representation. |
| SEND | The function to convert from the internal representation to binary. |
| TYPMOD_IN | Modifier support function. |
| TYPMOD_OUT | Modifier support function. |
| ANALYZE | Statistics collection function. |
| STORAGE | The function that determines how to store variable-length data. |
3.2.5 ALTER VIEW
Column names in views can now be changed. Execute an ALTER VIEW RENAME COLUMN statement. Syntax
PDF page 40
3.2.6 CREATE DATABASE
The LOCALE clause can now be specified as an option in the CREATE DATABASE statement. It cannot be specified at the same time as LC_CTYPE clause or LC_COLLATE clause. Syntax
PDF page 41
3.2.7 CREATE INDEX
In-page deduplication has been added to the B-Tree index. This feature is enabled by default. To disable this feature, set the deduplicate_items attribute to ‘off’.
PDF page 42
3.2.8 CREATE TABLE
Some attributes4 can be specified in the CREATE TABLE/ALTER TABLE statement.
3.2.9 CREATE TABLESPACE
Maintenance_io_concurrency5 can now be specified for tablespace attributes.
4 See 3.3.1 Added parameters 5 See 3.3.1 Added parameters
PDF page 43
3.2.10 DROP DATABASE FORCE
The database can now be forcibly dropped even if there are connected session exists. The connected session is forcibly closed. The database to which the session issuing the DROP DATABASE statement is connected cannot be dropped. Syntax
3.2.11 EXPLAIN ANALYZE
The following extensions have been implemented in the EXPLAIN ANALYZE statement.
PDF page 44
The output of cache information
By specifying BUFFERS, the status of the shared buffer when creating an execution plan is now output.
Output sort information
The output of the EXPLAIN ANALYZE statement when executing a parallel query has changed. JIT function information is now output for each worker. Also, the output of sort information has changed.
PDF page 45
PDF page 46
The output of WAL information
If the WAL option is specified in the EXPLAIN ANALYZE statement, the generated WAL information will be output.
PDF page 47
3.2.12 INSERT
Specifying a value using the INSERT OVERRIDING USER VALUE statement for an IDENTITY column with the GENERATED ALWAYS clause specified is now allowed. However, the value specified for the IDENTITY column is ignored.
PDF page 48
3.2.13 JSON
The following JSON related features have been added.
Allow Unicode escape
Unicode escapes are now allowed for character literals and identifiers, even if the server’s character encoding is not UTF-8.
Datetime method of jsonpath
The datetime method that converts a character string to a date/time type has been added.
3.2.14 MAX/MIN pg_lsn
MAX / MIN function can be used for pg_lsn data type.
3.2.15 ROW
ROW can now be directly extracted fields in some data types from the expressions.
PDF page 49
3.2.16 SELECT FETCH FIRST WITH TIES
The WITH TIES clause can be specified in the SELECT FETCH FIRST statement. It outputs the same number of tuples as the number of tuples specified in the ROWS clause.
3.2.17 VACUUM PARALLEL
VACUUM statements for indexes can now be parallelized. Parallelism works by default, and the degree of parallelism is determined by the number of indexes created on the table. To specify the degree of parallelism, specify a value between 0 and 1024 in the PARALLEL clause. This feature does not work with automatic VACUUM.
PDF page 50
3.2.18 Operator <->
Distance operators (<->) can now be used between several data types. GiST index and SP-GiST index can be used in box_ops operator class.
3.2.19 Functions
The following functions have been added/enhanced.
PDF page 51
Gen_random_uuid
The gen_random_uuid function has been provided to generate a random UUID.
Date format
FF1 to FF6 format patterns defined in SQL Standard 2016 have been added to the date format.
| Pattern | Output value | Note |
|---|---|---|
| FF1 | 1/10th of a second. | |
| FF2 | 1/100 second. | |
| FF3 | Millisecond . | |
| FF4 | 1/10 ms. | |
| FF5 | 1/100 ms. | |
| FF6 | Microsecond . |
The pattern SSSSS is now an alias for SSSS.
Min_scale, trim_scale
The min_scale function obtains the minimum number of digits from the NUMERIC type, excluding trailing zeros after the decimal point. The trim_scale function gets the value of the NUMERIC type excluding trailing zeros after the decimal point.
PDF page 52
Jsonb_set_lax
The jsonb_set_lax function is the same as the jsonb_set function except that a null_value_treatment parameter (text type) has been added. The following values can be specified for this parameter.
| Value | Description | Note |
|---|---|---|
| use_json_nullraise_exceptiondelete_keyreturn_target | Return NULL. Raise exception. Delete key. Return target. | default value |
Gcd, lcm
The lcm function, which returns the least common multiple, and the gcd function, which returns the greatest common divisor, have been added. Specify two numbers of the same type in the parameter. If both parameters are 0, these functions return 0.
PDF page 53
Get_bit / set_bit
The offset parameter of the get_bit / set_bit function that specifies the bytea type has been changed from integer type to bigint type.
Unicode normalization
The normalize function that performs UNICODE normalization and the ‘is_normalized’ function that checks whether it is normalized has been implemented. You can also use the ‘is normalized’ syntax to check the specified text. Syntax
In the [form] part, NFC (default), NFD, NFKC, or NFKD can be specified.
PDF page 54
Pg_stat_reset_slru
This function resets the counter value in the pg_stat_slru catalog. If NULL is specified for the parameter of this function, all counters will be reset. By specifying the counter name (’name’ column of pg_stat_slru catalog) to this function, the specified counter is reset.
5 Configuration Parameters
PDF page 55
In PostgreSQL 13 the following parameters have been changed.
3.3.1 Added parameters
The following parameters have been added.
| Parameter name | Description (context) | Default Val |
|---|---|---|
| autovacuum_vacuum_ | Percentage of INSERT records for which automatic | 0.2 |
| insert_scale_factor | VACUUM is executed (sighup). | |
| autovacuum_vacuum_insert_threshold | Number of INSERT records for which automatic VACUUM is executed (sighup). | 1000 |
| backtrace_functions | List of function names that output backtrace when an error occurs (superuser). | '' |
| enable_incremental_sort | Enable incremental sorting (user). | on |
| hash_mem_multiplier | Used to compute the maximum amount of memory that hash-based operations can use (user). | 1 |
| ignore_invalid_pages | Ignore invalid page references during recovery (postmaster) . | off |
| log_min_duration_sample | Time to output SQL statement log by sampling (superuser) . | -1 |
| log_parameter_max_length | Bind parameter value in the non-error statement logging messages are trimmed to setting value (superuser). | -1 |
| log_parameter_max_length_on_error | Bind parameter value in the error statement logging messages are trimmed to setting value (user). | 0 |
| log_statement_sample_rate | SQL statement log output rate by sampling (superuser) | 1.0 |
| logical_decoding_work_mem | Work memory for decoding for the logical replication environment (user). | 64MB |
| maintenance_io_concurrency | Number of I/O concurrent executions used for maintenance (user). | 10 |
| max_slot_wal_keep_size | The maximum MB size of WAL is held by the replication slot (sighup). | -1 |
| wal_receiver_create_temp_slot | Whether the wal receiver process creates a temporary replication slot (sighup). | off |
| wal_skip_threshold | Write the interval at which fsync is executed when wal_level is ‘minimal’ (user). | 2MB |
PDF page 56
Output backtrace
In the parameter backtrace_functions, specify the name of the function that performs trace output when an error occurs. The specified function is not the SQL function, but the function name in the source code.
PDF page 57
PDF page 58
3.3.2 Changed parameters
The setting range and options were changed for the following configuration parameters.
| Parameter name | Changes |
|---|---|
| allow_system_table_mods | The context changed from postmaster to superuser. |
| effective_io_concurrency | Changed to use directly specified value instead of using calculated value by the internal logic. |
| log_line_prefix | Backend type (%b) has been added. |
| log_min_duration_statement | The short_desc column value in the pg_settings view has changed. |
| max_files_per_process | The minimum value has been changed from 25 to 64. |
| primary_conninfo | Context changed from postmaster to sighup. |
| primary_slot_name | Context changed from postmaster to sighup. |
| ssl_passphrase_command | Only SUPERUSER can be referenced. |
| track_activity_query_size | The maximum value has been changed from 102,400 to 1,048,576. |
| wal_keep_size | Changed name from wal_keep_segments. Units have been changed from number of the files to size. |
3.3.3 Parameters with default values changed
The following parameters have changed default values.
| Parametername | PostgreSQL12 | PostgreSQL13 | Note |
|---|---|---|---|
| server_version | 12.4 | 13.0 | |
| server_version_num | 120004 | 130000 | |
| ssl_min_protocol_version | TLSv1 | TLSv1.2 |
6 Utilities
PDF page 59
Describes the major enhancements of utility commands.
3.4.1 dropdb
The –force option (or -f option) has been added. Forces database deletion even if a connection session exists. The connected session will be closed.
3.4.2 pg_basebackup
The following enhancements have been implemented in the pg_basebackup command.
–manifest-checksums option
Specify the algorithm for creating the checksum. The options that can be specified are CRC32C, SHA224, SHA256, SHA384, SHA512, or NONE. The default value is CRC32C. If NONE is specified, the manifest will not include the checksum.
–manifest-force-encode option
Outputs the file name to be written to the manifest in hexadecimal. By default, only non-UTF-8 file names are represented in hexadecimal.
–no-estimate-size option
The pg_basebackup command has been changed to estimate the data size without specifying the -progress option. Specify the option –no-estimate-size when not calculating the data amount estimate. This option cannot be used with –progress.
PDF page 60
–no-manifest option
Disables generation of a backup manifest.
–no-verify-checksums option
Do not verify checksums.
3.4.3 pg_dump
The following enhancements have been implemented in the pg_dump command.
–include-foreign-data option
Added –include-foreign-data option to dump FOREIGN SERVER data. This option specifies the FOREIGN SERVER name pattern. This option can be specified more than once.
PDF page 61
Output ALTER DEPEND ON EXTENSION statement
ALTER object DEPENDS ON EXTENSION statement is now output.
PDF page 62
3.4.4 pg_rewind
The following three options have been added to the pg_rewind command.
–no-ensure-shutdown option
The pg_rewind will start in single-user mode if it detects a database cluster that has not shut down properly. Specify the –no-ensure-shutdown command and do not perform startup processing.
–write-recovery-conf option
The –write-recovery-conf option (or -R option) configures replication-related settings. This option must be specified with the –source-server option.
–restore-target-wal option
The –restore-target-wal option (or -c option) gets the restore_command parameter value from the target cluster and restores the required WAL segments from the archive.
PDF page 63
3.4.5 pg_verifybackup
The pg_verifybackup command checks consistency by comparing the contents of the backup and the manifest. This command performs the following checks:
Manifest file version
The checksum of the manifest file itself
File size
PDF page 64
File checksum
WAL file integrity Syntax
| Long Option | Short Option | Description |
|---|---|---|
| –exit-on-error | -e | Exit immediately on error. |
| –ignore=PATH | -i | Ignore the indicated path. |
| –manifest-path=PATH | -m | Use a specified path for the manifest. |
| –no-parse-wal | -n | Do not try to parse WAL files. |
| –quiet | -q | Do not print any output, except for errors. |
| –skip-checksums | -s | Skip checksum verification. |
| –wal-directory=PATH | -w | Use the specified path for WAL files. |
| –version | -V | Output version information. |
| –help | -? | Output usage information. |
Validation error
The pg_verifybackup command outputs an error message if the size or content of the file has changed.
PDF page 65
Execution error
An error occurs when executing a backup for which a manifest has not been created or a backup created in tar format.
PDF page 66
3.4.6 pg_waldump
The –quiet option (or -q option) has been added to the pg_waldump command. This option suppresses non-error screen output.
3.4.7 psql
The following features have been added to the psql command.
\dAc, \dAf, \dAo, \dAp commands
Commands for outputting operator information have been added.
| Command | Output contents | Note |
|---|---|---|
| \dAc | AM, Input type, Storage type, Operator class, Default?. | |
| \aAf | AM, Operator family, Applicable types | |
| \dAo | AM, Operator family, Operator, Strategy, Purpose | |
| \dAp | AM, Operator family, Registered left type, Registered right type, Number, Function |
PDF page 67
\g, \gx commands
The feature has been added to the \g and \gx commands to temporarily change variables specified by the \pset command.
\warn command
The \warn command that outputs a message to standard error has been added.
\e command
After closing the editor, the edited SQL statement is now displayed.
PDF page 68
\d+ command
The table type is now output as a ‘Persistence’ column.
PROMPT2 value
Variable PROMPT2 now a %w can be specified. If this value is specified, it will be converted to a space of the same length as PROMPT1.
I/O error detection
Errors when outputting files can now be detected.
The default value of PROMPT1/PROMPT2
3.4.8 reindexdb
The –jobs option to execute parallel processing has been added to the reindexdb command. The default value is 1 and no parallel processing is performed.
6 Refer 2.5.7 Psql default prompt psql
PDF page 69
3.4.9 vacuumdb
The –parallel option (or -P option) has been added. Specify the degree of parallelism (0 to 1024) in the option. This option cannot be specified together with the –full or –analyze-only option.
3.4.10 Other
The URL to www.postgresql.org has been added to the output of the –help option for many commands.
7 Contrib Modules
PDF page 70
Describe new features related to the Contrib modules.
3.5.1 adminpack
The pg_file_sync function has been added to the extension adminpack. This function guarantees a reliable write to the specified file or directory.
3.5.2 auto_explain
The log_wal parameter to output WAL information has been added to the extension auto_explain. The default value is ‘off’, and WAL information is not output. If this parameter is set to ‘on’, auto_explain.log_analyze must also be set to ‘on’.
PDF page 71
3.5.3 dict_int
The dict_int extension now has an ABSVAL attribute. If this attribute is specified, the sign specified for the integer value will be ignored.
PDF page 72
3.5.4 ltree
The ltree, lquery, and ltxtquery types now support binary I/O.
3.5.5 pageinspect
The following enhancements have been implemented in pageinspect extension.
Heap_tuple_infomask_flags function
This function converts the values of t_infomask, t_infomask2 into a human-readable form.
PDF page 73
Bt_metap function
An allequalimage column has been added to the output of the bt_metap function to indicate the status of duplicate data in the index.
Bt_page_items function
The dead, htid, and tids columns have been added to the output of the bt_page_items function.
PDF page 74
| Column name | Description |
|---|---|
| dead | A boolean value indicating the value of the LP_DEAD bit. |
| htid | Indicates a single heap TID value for each tuple. |
| tids | An array of TID. |
3.5.6 pg_stat_statements
The features to output execution plan and WAL information have been added to the pg_stat_statements extension.
Track_planning parameter
This parameter specifies whether to track the execution plan. The default value is ‘off’. If this parameter is specified, information about the execution plan will be added to the pg_stat_statements view.
Pg_stat_statements view
The following columns have been added to the pg_stat_statements view:
PDF page 75
| Column name | Data type | Description |
|---|---|---|
| plans | bigint | Number of times the statement was planned. |
| total_plan_time | double precision | Total time spent planning the statement. |
| min_plan_time | double precision | Minimum time spent planning the statement, in milliseconds. |
| max_plan_time | double precision | Maximum time spent planning the statement, in milliseconds. |
| mean_plan_time | double precision | Meantime spent planning the statement, in milliseconds. |
| stddev_plan_time | double precision | Population standard deviation of time spent planning the statement, in milliseconds. |
| wal_records | bigint | Total count of WAL records. |
| wal_fpi | bigint | Total number of WAL full-page writes. |
| wal_bytes | numeric | Total amount of WAL bytes. |
The column names in the pg_stat_statements view have been changed as follows.
| PostgreSQL 12 | PostgreSQL 13 | Description |
|---|---|---|
| total_time | total_exec_time | Total time spent executing the statement. |
| min_time | min_exec_time | Minimum time spent executing the statement. |
| max_time | max_exec_time | Maximum time spent executing the statement. |
| mean_time | mean_exec_time | Mean time spent executing the statement. |
| stddev_time | stddev_exec_time | Population standard deviation of time spent executing the statement. |
PDF page 76
SQL statement normalization
The SELECT statement with the FOR UPDATE clause specified and the SELECT statement without it are now separated. Previously, the presence or absence of the FOR UPDATE clause was ignored.
3.5.7 postgres_fdw
The following options have been added to the postgres_fdw extension:
Password_required option
By default, general users are refused connections without a password. This behavior can now be changed by specifying the password_required attribute when creating/changing a user mapping. Only superusers can change this option.
PDF page 77
Additional authentication options
The sslkey and sslcert options can be specified as options when creating a user mapping. These options can only be specified if the superuser is creating/modifying USER MAPPING.
3.5.8 bool_plperl
The extension bool_plperl was added. Use this extension with PL/Perl extension. Used to correctly transfer the value of a bool value to a Perl program.
PDF page 78
8 URL List
The links in this chapter are preserved from the source PDF’s URL list.
PDF page 79
9 Change History
This chapter preserves the source document’s revision history and publication credits.
PDF page 80
Change history
| Version | Date | Author | Description |
|---|---|---|---|
| 0.1 | Apr 09, 2020 | Noriyoshi Shinoda | Create an internal review version. Reviewers: Tomoo Takahashi Akiko Takeshima (Hewlett Packard Enterprise Japan) |
| 1.0 | May 27, 2020 | Noriyoshi Shinoda | Modification completed according to PostgreSQL 13 Beta 1 Reviewer: Satoshi Nagayasu (Uptime Technologies, LCC.) |
| 1.1 | Sep 27, 2020 | Noriyoshi Shinoda | Modified for PostgreSQL 13 GA - Modify ANALYZE (BUFFERS) statement - Modify column pg_stat_replication view - Drop columns pg_stat_replication view - Drop GUC enable_hashagg_disk - Rename GUC enable_incrementalsort - Add GUC hash_mem_multiplier - Add GUC max_slot_wal_keep_size - Modify GUC server_version value - Rename GUC wal_keep_segments - Modify the setting of earthdistance module - Modify default value of pg_stat_statements.track_planning - Modify default minimum SSL version to TLSv1.2 - Fix typo |