7 Architecture
PDF page 44
3.5.1 Added Catalogs
With the additional features, the following system catalogs have been added.
| Catalog name | Description |
|---|---|
| pg_hba_file_rules | Referencing pg_hba.conf file |
| pg_partitioned_table | Partitioning table information |
| pg_publication | PUBLICATION object for Logical Replication |
| pg_publication_rel | Target table list for Logical Replication |
| pg_publication_tables | Target table list for Logical Replication |
| pg_sequence | SEQUENCE object list |
| pg_sequences | SEQUENCE object list |
| pg_stat_subscription | Status for Logical Replication |
| pg_statistic_ext | Extended statistics view |
| pg_subscription | SUBSCRIPTION object for Logical Replication |
| pg_subscription_rel | Target table list for Logical Replication |
pg_hba_file_rules catalog
The pg_hba_file_rules catalog can refer to the contents of the pg_hba.conf file. When changing the file, the contents of the view are reflected immediately. Comment only lines are not included.
PDF page 45
| Column name | Data type | Description |
|---|---|---|
| line_number | integer | Line number in the file |
| type | text | Connection type of local, host, etc |
| database | text[] | Target database or all, replication |
| user_name | text[] | Username or all |
| address | text | TCP/IP address |
| netmask | text | Net mask |
| auth_method | text | Authentication method |
| options | text[] | Options |
| error | text | Error messages |
pg_partitioned_table catalog
The pg_partitioned_table catalog stores information on the parent table on partitioning table.
| Column name | Data type | Description |
|---|---|---|
| partrelid | oid | OID for the table |
| partstrat | char | Partitioning method (list = ’l’, range = ‘r’) |
| partnatts | smallint | Number of attached partitions |
| partattrs | int2vector | Array of partition column values |
| partclass | oidvector | The data type of the partition key. |
| partcollation | oidvector | Collation information of partition-key columns |
| partexprs | pg_node_tree | Information on partitioning columns |
pg_publication catalog
The pg_publication catalog stores information on PUBLICATION objects used in Logical Replication.
PDF page 46
| Column name | Data type | Description |
|---|---|---|
| pubname | name | Name of the PUBLICATION |
| pubowner | oid | Owner of the PUBLICATION object |
| puballtables | boolean | If true, this publication automatically includes all tables in the database |
| pubinsert | boolean | If true, INSERT operations are replicated for tables |
| pubupdate | boolean | If true, UPDATE operations are replicated for tables |
| pubdelete | boolean | If true, UPDATE operations are replicated for tables |
pg_publication_rel catalog
The pg_publication_rel catalog stores the information of the replication target table contained in the PUBLICATION object.
| Column name | Data type | Description |
|---|---|---|
| prpubidprrelid | oid | OID of the PUBLICATION object OID of the target table |
pg_publication_tables catalog
The pg_publication_tables catalog stores the information of the replication target table contained in the PUBLICATION object.
| Column name | Data type | Description |
|---|---|---|
| pubname | name | Name of the PUBLICATION object |
| schemaname | name | Name of the schema |
| tablename | name | Name of the target table |
pg_sequence catalog
The pg_sequence catalog that provides a list of SEQUENCE objects has been added. This catalog can be searched by general users.
PDF page 47
| Column name | Data type | Description |
|---|---|---|
| seqrelid | oid | OID of the object |
| seqtypid | oid | Data type of the SEQUENCE |
| seqstart | bigint | Start value |
| seqincrement | bigint | Incremental value |
| seqmax | bigint | Maximum sequence value |
| seqmin | bigint | Minimum sequence value |
| seqcache | bigint | Number of caches |
| seqcycle | boolean | Indicate whether to cyclic |
pg_sequences catalog
The pg_sequences catalog that provides a list of SEQUENCE object has been added. Although this catalog can be searched by general users, the last_value column is NULL if the nextval function has not been executed yet or if the search user does not have USAGE or SELECT privilege on that SEQUENCE.
| Column name | Data type | Description |
|---|---|---|
| schemaname | name | Name of the schema |
| sequencename | name | Name of the SEQUENCE object |
| sequenceowner | name | Name of the owner |
| data_type | regtype | Data type of the SEQUENCE |
| start_value | bigint | Start value |
| min_value | bigint | Minimum value |
| max_value | bigint | Maximum value |
| increment_by | bigint | Incremental value |
| cycle | boolean | Indicate whether to cyclic |
| cache_size | bigint | Number of caches |
| last_value | bigint | Last sequence value or NULL |
PDF page 48
PDF page 49
pg_stat_subscription catalog
The pg_stat_subscription catalog stores WAL information received by the SUBSCRIPTION object. This catalog can refer to data only while the replication process is running.
| Column name | Data type | Description |
|---|---|---|
| subid | oid | OID of the SUBSCRIPTION |
| subname | name | Name of the SUBSCRIPTION |
| pid | integer | Process id of the logical replication worker |
| relid | oid | OID of the table |
| received_lsn | pg_lsn | Received LSN |
| last_msg_send_time | timestamp with time zone | Message send time |
| last_msg_receipt_time | timestamp with time zone | Message receive time |
| latest_end_lsn | pg_lsn | Latest end LSN |
| latest_end_time | timestamp with time zone | Latest end timestamp |
pg_statistic_ext catalog
The pg_statistic_ext catalog stores information on extended statistics created with the CREATE STATISTICS statement.
PDF page 50
| Column name | Data type | Description |
|---|---|---|
| stxrelid | oid | OID of the statistics acquisition table |
| stxname | name | Name of the extended statistics |
| stxnamespace | oid | OID of the namespace |
| stxowner | oid | Owner of extended statistics |
| stxkeys | int2vector | Array of column numbers from which extended statistics were obtained |
| stxkind | “char”[] | Types of the statistics activated |
| stxndistinct | pg_ndistinct | Serialized N-distinct value |
| stxdependencies | pg_dependencies | Column dependencies |
pg_subscription catalog
The pg_subscription catalog stores information on the SUBSCRIPTION object used by Logical Replication. This catalog can only be viewed by users with SUPERUSER privilege.
| Column name | Data type | Description |
|---|---|---|
| subdbid | oid | OID of database constituting SUBSCRIPTION |
| subname | name | Name of the SUBSCRIPTION object |
| subowner | oid | Owner’s OID |
| subenabled | boolean | Is the object valid? |
| subconninfo | text | Connection information to PUBLICATION instance |
| subslotname | name | Name of the replication slot |
| subsynccommit | text | Synchronous COMMIT setting value |
| subpublications | text[] | Array of PUBLICATION names |
pg_subscription_rel catalog
The pg_subscription_rel catalog stores the information on table targeted by the SUBSCRIPTION object used in Logical Replication.
PDF page 51
| Column name | Data type | Description |
|---|---|---|
| srsubid | oid | OID of SUBSCRIPTION object |
| srrelid | oid | OID of target table |
| srsubstate | “char” | Status i = initializing, d = data transferring, s = synchronizing, r = normal |
| srsublsn | pg_lsn | The last LSN of the s or r state of srsubstate column |
3.5.2 Modified catalogs
The following catalogs have been changed.
| Catalog name | Added column | Data Type | Description |
|---|---|---|---|
| pg_class | relispartition | boolean | Partition parent table |
| relpartbound | pg_node_tree | Partitioning information | |
| pg_replication_slots | temporary | boolean | Indicate a temporary slot |
| pg_policy | polpermissive | boolean | PERMISSIVE mode |
| pg_policies | permissive | text | PERMISSIVE mode |
| pg_stat_replication | write_lag | interval | Write lag |
| flush_lag | interval | Flush lag | |
| replay_lag | interval | Replay lag | |
| pg_collation | collprovider | char | Provider information |
| collversion | text | Version information | |
| pg_stat_activity | backend_type | text | Type of process |
| pg_attribute | attidentity | char | GENERATED column |
pg_stat_activity catalog
The statuses of all backend processes except the postmaster process are now displayed in the pg_stat_activity catalog. The type of backend process can be confirmed by backend_type column.
PDF page 52
3.5.3 Enhancement of libpq library
The following enhancements have been added to the PostgreSQL Client library libpq.
Multi-instance specification
Settings for connecting to multiple instances which are already supported in the JDBC Driver are also implemented in the libpq library. As described below, multiple host names and port numbers can be described in comma-separated form.
Syntax 7 - Multi-instance specification
Multiple values can be specified with the comma (,) separator in the environment variables PGHOST and PGPORT. Along with this, it is now possible to specify multiple values for the –host and –port parameters of the psql and pg_basebackup commands
Added target_session_attrs attribute
Target_session_attrs has been added as a new connection attribute. This parameter can be specified as “any” if the instance to be connected can be hot standby, or “read-write” if the instance is writable. A similar specification can be specified for the environment variable PGTARGETSESSIONATTRS. Internally, it seems to be use the SHOW transaction_read_only statement to determine the connection
PDF page 53
destination.
Added passfile attribute
“passfile” has been added as a new connection attribute. In the past, it was specified with the environment variable PGPASSFILE etc.
3.5.4 Change from XLOG to WAL
The name of XLOG used in the function, directory name, and utility was unified in WAL. Also, the pg_clog directory has been changed to the pg_xact directory. The default output directory name of the log file has been changed due to the effect of changing the default value of the parameter log_directory. The name “location” indicating the location of WAL has been changed to “lsn”.
| Category | change | After changing |
|---|---|---|
| Directories | pg_xlog | pg_wal |
| pg_clog | pg_xact | |
| pg_log | log | |
| Utilities | pg_receivexlog | pg_receivewal |
| pg_resetxlog | pg_resetwal | |
| pg_xlogdump | pg_waldump | |
| pg_basebackup –xlog-method | pg_basebackup –wal-method | |
| pg_basebackup –xlogdir | pg_basebackup –waldir | |
| initdb –xlogdir | initdb –waldir | |
| Functions | pg xlog location diff___ | pg_wal_location_diff |
| pg_switch_xlog | pg_switch_wal | |
| pg_current_xlog_* | pg_current_wal_* | |
| pg xlogfile*_ | pg_walfile* | |
| pg_is_xlog_replay_replay_paused | pg_is_wal_replay_replay_paused | |
| pg_last_xlog_* | pg_last_wal_* | |
| pg location_ | pg_lsn | |
| Catalog | pg_stat_replication Catalog | pg_stat_replication Catalog |
| - sent location_ | sent_lsn | |
| - write location_ | write_lsn | |
| - flush location_ | flush_lsn | |
| - replay location_ | replay_lsn |
PDF page 54
At the same time, the string XLOG included in the error message has also been changed to WAL. It has been changed to the following message.
Failed while allocating a WAL reading processor.
could not read two-phase state from WAL at …
expected two-phase state data is not present in WAL at …
Failed while allocating a WAL reading processor.
WAL redo at %X/%X for %s
Forces a switch to the next WAL file if a new file has not been started within N seconds. The description of the parameter archive_timeout has been changed as follows.
Forces a switch to the next WAL file if a new file has not been started within N seconds.
3.5.5 Temporary replication slot
Replication slots can be used for building a streaming replication environment or for the pg_basebackup command. In PostgreSQL 10, temporary replication slots can now be created. A temporary replication slot is the same as a normal replication slot except that it is automatically deleted by session termination. To create a temporary replication slot, specify true for the third parameter of the pg_create_physical_replication_slot function or pg_create_logical_replication_slot function. Along with this, “temporary” column has been added to the pg_replication_slots catalog.
3.5.6 Change instance startup log
The listen address and port number are now output to the instance startup log.
PDF page 55
3.5.7 WAL of hash index
Hash index of previous versions did not generate WAL on update. In PostgreSQL 10, it now generate WAL, so it can now be used in streaming replication environments. The warnings outputted in the CREATE INDEX USING HASH statement are no longer output.
3.5.8 Added roles
The following roles have been added. All roles do not have “login” privilege.
| Role | Description |
|---|---|
| pg_read_all_settings | All configuration parameters can be referred. |
| pg_read_all_stats | All pg_stat_ * views can be referred. |
| pg_stat_scan_tables | Execute the monitoring function to take AccessShareLock lock |
| pg_monitor | All of the above 3 roles have authority |
PDF page 56
Registering the following Contrib modules, execute permissions for function are automatically granted to the roles above.
pg_buffercache
pg_freespacemap
pg_stat_statements
pg_visibility
pgstattuple
3.5.9 Custom Scan Callback
A new callback called at the end of the parallel query has been added. It is explained in the manual “58.3. Executing Custom Scans” as follows.
3.5.10 Size of WAL file
The choice of WAL file size determined by the –with-wal-segsize option of the “configure” command has increased. 128, 256, 512, 1024 can be used in addition to the conventional 1 to 64.
3.5.11 ICU
ICU can be used for locale function. Specify –with-icu when executing “configure” command. When building in Linux environment, installation of libicu package and libicu-devel package is necessary.
3.5.12 EUI-64 data type
The data type macaddr8 indicating the EUI-64 address is now available.
3.5.13 Unique Join
PDF page 57
In the execution plan displayed by EXPLAIN VERBOSE statement, it will appear as “Inner Unique: true”.
3.5.14 Shared Memory Address
When the EXEC_BACKEND macro is defined and installed, the environment variable PG_SHMEM_ADDR can be used. Specify the start address of System V shared memory used as part of the cache. Internally it is digitized with the strtoul function and used as the second parameter of the shmat system call.