Other System Functions
The built-in functions and operators of openGauss are inherited from the open-source PG. For details about the following functions, see the official PG documents.
The following table lists the functions used by openGaussGaussDB Kernel to implement internal system functions. You are not advised to use these functions. If you need to use them, contact Huawei technical support.
pv_compute_pool_workload()
Description: Provides the current load information of the cloud acceleration database instance.
Return type: record
locktag_decode(locktag text)
Description: Parses lock details from locktag.
Return type: text
smgreq(a smgr, b smgr)
Description: Compares two smgrs to check whether they are the same.
Parameter: smgr, smgr
Return type: Boolean
smgrne(a smgr, b smgr)
Description: Checks whether the two smgrs are different.
Parameter: smgr, smgr
Return type: Boolean
xidin4
Description: Inputs a 4-byte xid.
Parameter: cstring
Return type: xid32
set_hashbucket_info
Description: Sets hash bucket information.
Parameter: text
Return type: Boolean
hs_concat
Description: Concatenates two pieces of hstore data.
Parameter: hstore, hstore
Return type: hstore
hs_contained
Description: Determines whether two hstore data records are included. The return value is of the Boolean type.
Parameter: hstore, hstore
Return type: Boolean
hs_contains
Description: Determines whether two hstore data records are included. The return value is of the Boolean type.
Parameter: hstore, hstore
Return type: Boolean
hstore
Description: Converts parameters to the hstore type.
Parameter: text, text
Return type: hstore
hstore_in
Description: Receives hstore data in string format.
Parameter: cstring
Return type: hstore
hstore_out
Description: Sends hstore data in string format.
Parameter: hstore
Return type: cstring
hstore_send
Description: Sends hstore data in bytea format.
Parameter: hstore
Return type: bytea
hstore_to_array
Description: Sends hstore data in text array format.
Parameter: hstore
Return type: text[]
hstore_to_matrix
Description: Sends hstore data in text array format.
Parameter: hstore
Return type: text[]
hstore_version_diag
Description: Sends hstore data in integer array format.
Parameter: hstore
Return type: integer
int1send
Description: Packs unsigned 1-byte integers into the internal data buffer stream.
Parameter: tinyint
Return type: bytea
isdefined
Description: Checks whether a specified key exists.
Parameter: hstore, text
Return type: Boolean
listagg
Description: Specifies aggregate functions of the list type.
Parameter: smallint, text
Return type: text
log_fdw_validator
Description: Specifies validation functions.
Parameter: text[], oid
Return type: void
nvarchar2typmodin
Description: Obtains the typmod information of the varchar type.
Parameter: cstring[]
Return type: integer
nvarchar2typmodout
Description: Obtains the typmod information of the varchar type, constructs a character string, and returns the character string.
Parameter: integer
Return type: cstring
read_disable_conn_file
Description: Reads forbidden connection files.
Parameter: nan
Return type: disconn_mode text, disconn_host text, disconn_port text, local_host text, local_port text, redo_finished text
regex_like_m
Description: Specifies the regular expression match, which is used to determine whether a character string complies with a specified regular expression.
Parameter: text, text
Return type: Boolean
update_pgjob
Description: Updates a job.
Parameter: bigint, “char”, bigint, timestamp without time zone, timestamp without time zone, timestamp without time zone, timestamp without time zone, timestamp without time zone, smallint, text
Return type: void
enum_cmp
Description: Specifies the enumeration comparison function, which is used to determine whether two enumeration classes are equal and determine their relative sizes.
Parameter: anyenum, anyenum
Return type: integer
enum_eq
Description: Specifies the enumeration comparison function, which is used to implement the equal sign (=).
Parameter: anyenum, anyenum
Return type: Boolean
enum_first
Description: Returns the first element in the enumeration class.
Parameter: anyenum
Return type: anyenum
enum_ge
Description: Specifies the enumeration comparison function, which is used to implement the greater-than sign (>) and equal sign (=).
Parameter: anyenum, anyenum
Return type: Boolean
enum_gt
Description: Specifies the enumeration comparison function, which is used to implement the greater-than sign (>).
Parameter: anyenum, anyenum
Return type: Boolean
enum_in
Description: Specifies the enumeration comparison function, which is used to determine whether an element is in an enumeration class.
Parameter: cstring, oid
Return type: anyenum
enum_larger
Description: Specifies the enumeration comparison function, which is used to implement the greater-than sign (>).
Parameter: anyenum, anyenum
Return type: anyenum
enum_last
Description: Returns the last element in the enumeration class.
Parameter: anyenum
Return type: anyenum
enum_le
Description: Specifies the enumeration comparison function, which is used to implement the less-than sign (<) and equal sign (=).
Parameter: anyenum, anyenum
Return type: Boolean
enum_lt
Description: Specifies the enumeration comparison function, which is used to implement the less-than sign (<).
Parameter: anyenum, anyenum
Return type: Boolean
enum_smaller
Description: Specifies the enumeration comparison function, which is used to implement the less-than sign (<).
Parameter: anyenum, anyenum
Return type: Boolean
node_oid_name
Description: Not supported.
Parameter: oid
Return type: cstring
pg_buffercache_pages
Description: Reads status data from a shared buffer.
Parameter: nan
Return type: setof record. The following table describes the return columns.
Table 1 Return column description
pg_check_xidlimit
Description: Checks whether nextxid is greater than or equal to xidwarnlimit.
Parameter: nan
Return type: Boolean
pg_comm_delay
Description: Displays the delay status of the communication library of a single DN.
Parameter: nan
Return type: text, text, integer, integer, integer, integer
pg_comm_recv_stream
Description: Displays the receiving stream status of all communication libraries on a single DN.
Parameter: nan
Return type: text, bigint, text, bigint, integer, integer, integer, text, bigint, integer, integer, integer, bigint, bigint, bigint, bigint, bigint
pg_comm_send_stream
Description: Displays the sending stream status of all communication libraries on a single DN.
Parameter: nan
Return type: text, bigint, text, bigint, integer, integer, integer, text, bigint, integer, integer, integer, bigint, bigint, bigint, bigint, bigint
pg_comm_status
Description: Displays the communication status of a single DN.
Parameter: nan
Return type: text, integer, integer, bigint, bigint, bigint, bigint, bigint, integer, integer, integer, integer, integer
pg_log_comm_status
Description: Prints some logs on the DN.
Parameter: nan
Return type: Boolean
pg_parse_clog
Description: Parses clog to obtain the status of xid.
Parameter: nan
Return type: xid xid, status text
pg_pool_ping
Description: Sets PoolerPing.
Parameter: Boolean
Return type: SETOF boolean
pg_resume_bkp_flag
Description: Obtains the delay xlong flag for backup and restoration.
Parameter: slot_name name
Return type: start_backup_flag boolean, to_delay boolean, ddl_delay_recycle_ptr text, rewind_time text
pgfadvise_DONTNEED
Description: This function set DONTNEED flag on the current relation. It means that the Operating System will first unload pages of the file if it need to free some memory. Main idea is to unload files when they are not usefull anymore (instead of perhaps more interesting pages)
Parameter: a table name or an index name, the table can be partition table or subpartition table. Column-store tables and segment-page tables are not supported.
Example:
cedric=# select * from pgfadvise_dontneed('pgbench_accounts'); relpath | os_page_size | rel_os_pages | os_pages_free --------------------+--------------+--------------+--------------- base/11874/16447 | 4096 | 262144 | 342071 base/11874/16447.1 | 4096 | 65726 | 408103
pgfadvise_WILLNEED
Description: This function set WILLNEED flag on the current relation. It means that the Operating Sytem will try to load as much pages as possible of the relation. Main idea is to preload files on server startup, perhaps using cache hit/miss ratio or most required relations/indexes.
Parameter: a table name or an index name, the table can be partition table or subpartition table. Column-store tables and segment-page tables are not supported.
Example:
cedric=# select * from pgfadvise_willneed('pgbench_accounts'); relpath | os_page_size | rel_os_pages | os_pages_free --------------------+--------------+--------------+--------------- base/11874/16447 | 4096 | 262144 | 80650 base/11874/16447.1 | 4096 | 65726 | 80650
pgfadvise_NORMAL
Description: Sets the NORMAL flag for the current relationship.
pgfadvise_SEQUENTIAL
Description: Sets the SEQUENTIAL flag for the current relationship.
pgfadvise_RANDOM
Description: Sets the RANDOM flag for the current relationship.
pgfadvise_loader
Description: Allows direct interaction with the page cache. It may be used to load and/or unload a page from memory according to varbit representing a mapping of the page to be loaded/unloaded.
Parameters:
- The first parameter specifies the table name or index name. Partitioned tables and level-2 partitioned tables are supported. Column-store tables and segment-page tables are not supported.
- The second parameter is forkname. The data of each relationship is stored in a so-called fork. Generally, the default value of forkname is main. This parameter can be omitted.
- The third parameter specifies a relationship type. A character needs to be transferred. For a common relationship, the value of this parameter is 'r'. For a partitioned table, the value of this parameter is 'p'. For a level-2 partitioned table, the value of this parameter is 's'.
- The fourth parameter: For a partition table, this parameter indicates the name of the partition. For a level-2 partitioned table, this parameter indicates the name of the level-2 partition. For an ordinary table, set this parameter to NULL. If other values are transferred, the query of the ordinary table is not affected.
- The fifth parameter specifies the segment number.
- The sixth parameter returns a Boolean value, indicating whether to perform the load operation.
- The seventh parameter returns a Boolean value, indicating whether to perform the unload operation.
- The eighth parameter is databit. This parameter is generally obtained by using pgfincore().
Example: The relationship name is pgbench_accounts, the segment number is 0, and any varbit mapping is used.
-- Loading and unloading cedric=# select * from pgfadvise_loader('pgbench_accounts', 'r', NULL, 0, true, true, B'111000'); relpath | os_page_size | os_pages_free | pages_loaded | pages_unloaded ------------------+--------------+---------------+--------------+---------------- base/11874/16447 | 4096 | 408376 | 3 | 3 -- Loading cedric=# select * from pgfadvise_loader('pgbench_accounts', 'r', NULL, 0, true, false, B'111000'); relpath | os_page_size | os_pages_free | pages_loaded | pages_unloaded ------------------+--------------+---------------+--------------+---------------- base/11874/16447 | 4096 | 408370 | 3 | 0 -- Unloading cedric=# select * from pgfadvise_loader('pgbench_accounts', 'r', NULL, 0, false, true, B'111000'); relpath | os_page_size | os_pages_free | pages_loaded | pages_unloaded ------------------+--------------+---------------+--------------+---------------- base/11874/16447 | 4096 | 408370 | 0 | 3 -- This function can be used to restore the status of a table in the operating system cache. -- Snapshot cedric=# create table pgfincore_snapshot as cedric-# select 'pgbench_accounts'::text as relname,*,now() as date_snapshot cedric-# from pgfincore('pgbench_accounts',true); -- Restore cedric=# select * from pgfadvise_loader('pgbench_accounts', 'r', NULL, 0, true, true, (select databit from pgfincore_snapshot where relname='pgbench_accounts' and segment = 0)); relpath | os_page_size | os_pages_free | pages_loaded | pages_unloaded ------------------+--------------+---------------+--------------+---------------- base/11874/16447 | 4096 | 80867 | 262144 | 0
pgfincore
Description: Provides information about the file system cache (page cache).
Parameter: table name or index name. Partitioned tables and level-2 partitioned tables are supported. Column-store tables and segment-page tables are not supported.
Example:
cedric=# select * from pgfincore('pgbench_accounts'); relpath | segment | os_page_size | rel_os_pages | pages_mem | group_mem | os_pages_free | databit | pages_dirty | group_dirty --------------------+---------+--------------+--------------+-----------+-----------+---------------+---------+-------------+------------- base/11874/16447 | 0 | 4096 | 262144 | 3 | 1 | 408444 | | 0 | 0 base/11874/16447.1 | 1 | 4096 | 65726 | 0 | 0 | 408444 | | 0 | 0
For a specified relationship, the function returns the following column:
- relpath: path of the relationship.
- segment: number of the segment to be analyzed.
- os_page_size: size of a page.
- rel_os_pages: total number of pages of the relationship.
- pages_mem: total number of pages of the relationship in the page cache. (not from the PostgreSQL shared buffer, but from the operating system cache).
- group_mem: number of groups of adjacent pages_mem.
- os_page_free: number of idle pages in the OS page cache.
- databit: varbit mapping of the file. To output this column, use pgfincore('pgbench_accounts', true) to activate it. If no data is inserted into a table and true is used to activate the table, no value is displayed for this column.
- pages_dirty: If the HAVE_FINCORE constant is defined, the platform provides related information, which is similar to pages_mem except for dirty pages.
- group_dirty: If the HAVE_FINCORE constant is defined, the platform provides related information, which is similar to group_mem except for dirty pages.
pgsysconf
Description: Outputs the size of the operating system block and the number of free pages in the operating system page buffer.
Example:
cedric=# select * from pgsysconf(); os_page_size | os_pages_free | os_total_pages --------------+---------------+---------------- 4096 | 80431 | 4094174
pgsysconf_pretty
Description: The function is similar to the preceding function. The difference is that the function converts the unit for easy reading.
Example:
cedric=# select * from pgsysconf_pretty(); os_page_size | os_pages_free | os_total_pages --------------+---------------+---------------- 4096 bytes | 314 MB | 16 GB
pgfincore_drawer
Description: A very simple renderer. This function requires a varbit parameter. Generally, the value of this parameter comes from the databit return column of the pgfincore function. The value of the databit column consists of 0 and 1. If the value is 0, it indicates that the page is not in the page cache of the operating system. If the value is 1, it indicates that the page is in the page cache of the operating system.
Example:
cedric=# select * from pgfincore_drawer(B'000111'); drawer -------------- ... cedric=# select * from pgfincore_drawer(B'111000'); drawer -------------- ...
psortoptions
Description: Returns the psort attribute.
Parameter: text[], boolean
Return type: bytea
xideq4
Description: Compares two values of the xid type to check whether they are the same.
Parameter: xid32, xid32
Return type: Boolean
xideqint8
Description: Compares values of the xid type and int8 type to check whether they are the same.
Parameter: xid, bigint
Return type: Boolean
xidlt
Description: Returns whether xid1 < xid2 is true.
Parameter: xid, xid
Return type: Boolean
xidlt4
Description: Returns whether xid1 < xid2 is true.
Parameter: xid32, xid32
Return type: Boolean