|
- current_catalog
- name
- name of current database (called catalog
in the SQL standard)
+ Function
+
+ Description
+
+
+
|
- current_database()
- name
- name of current database
+
+
+ current_catalog
+ name
+
+
+
+ current_database ()
+ name
+
+ Returns the name of the current database. (Databases are
+ called catalogs
in the SQL standard,
+ so current_catalog is the standard's
+ spelling.)
+
|
- current_query()
- text
- text of the currently executing query, as submitted
- by the client (might contain more than one statement)
+
+
+ current_query ()
+ text
+
+ Returns the text of the currently executing query, as submitted
+ by the client (which might contain more than one statement).
+
|
- current_role
- name
- equivalent to current_user
+
+
+ current_role
+ name
+
+ This is equivalent to current_user.
+
|
- current_schema[()]
- name
- name of current schema
+
+
+
+ current
+
+ current_schema
+ name
+
+ current_schema ()
+ name
+
+ Returns the name of the schema that is first in the search path (or a
+ null value if the search path is empty). This is the schema that will
+ be used for any tables or other named objects that are created without
+ specifying a target schema.
+
|
- current_schemas(boolean)
- name[]
- names of schemas in search path, optionally including implicit schemas
+
+
+
+ current
+
+
current_schemas (
include_implicit boolean )
+ name[]
+
+ Returns an array of the names of all schemas presently in the
+ effective search path, in their priority order. (Items in the current
+ setting that do not correspond to
+ existing, searchable schemas are omitted.) If the Boolean argument
+ is true, then implicitly-searched system schemas
+ such as pg_catalog are included in the result.
+
|
- current_user
- name
- user name of current execution context
+
+
+
+ current
+
+ current_user
+ name
+
+ Returns the user name of the current execution context.
+
|
- inet_client_addr()
- inet
- address of the remote connection
+
+
+ inet_client_addr ()
+ inet
+
+ Returns the IP address of the current client,
+ or NULL if the current connection is via a
+ Unix-domain socket.
+
|
- inet_client_port()
- int
- port of the remote connection
+
+
+ inet_client_port ()
+ integer
+
+ Returns the IP port number of the current client,
+ or NULL if the current connection is via a
+ Unix-domain socket.
+
|
- inet_server_addr()
- inet
- address of the local connection
+
+
+ inet_server_addr ()
+ inet
+
+ Returns the IP address on which the server accepted the current
+ connection,
+ or NULL if the current connection is via a
+ Unix-domain socket.
+
|
- inet_server_port()
- int
- port of the local connection
+
+
+ inet_server_port ()
+ integer
+
+ Returns the IP port number on which the server accepted the current
+ connection,
+ or NULL if the current connection is via a
+ Unix-domain socket.
+
|
-
- pg_backend_pid()
- int
-
- Process ID of the server process attached to the current session
-
+
+
+ pg_backend_pid ()
+ integer
+
+ Returns the process ID of the server process attached to the current
+ session.
+
|
- pg_blocking_pids(int)
- int[]
- Process ID(s) that are blocking specified server process ID from acquiring a lock
+
+
+ pg_blocking_pids ( integer )
+ integer[]
+
+ Returns an array of the process ID(s) of the sessions that are
+ blocking the server process with the specified process ID from
+ acquiring a lock, or an empty array if there is no such server process
+ or it is not blocked.
+
+ One server process blocks another if it either holds a lock that
+ conflicts with the blocked process's lock request (hard block), or is
+ waiting for a lock that would conflict with the blocked process's lock
+ request and is ahead of it in the wait queue (soft block). When using
+ parallel queries the result always lists client-visible process IDs
+ (that is, pg_backend_pid results) even if the
+ actual lock is held or awaited by a child worker process. As a result
+ of that, there may be duplicated PIDs in the result. Also note that
+ when a prepared transaction holds a conflicting lock, it will be
+ represented by a zero process ID.
+
+ Frequent calls to this function could have some impact on database
+ performance, because it needs exclusive access to the lock manager's
+ shared state for a short time.
+
|
- pg_conf_load_time()
- timestamp with time zone
- configuration load time
+
+
+ pg_conf_load_time ()
+ timestamp with time zone
+
+ Returns the time when the server configuration files were last loaded.
+ If the current session was alive at the time, this will be the time
+ when the session itself re-read the configuration files (so the
+ reading will vary a little in different sessions). Otherwise it is
+ the time when the postmaster process re-read the configuration files.
+
|
- pg_current_logfile(text)
- text
- Primary log file name, or log in the requested format,
- currently in use by the logging collector
+
+
+
+ pg_current_logfile function
+
+
+ and the pg_current_logfile function
+
+
+ current_logfiles file and the pg_current_logfile
+ function
+
+ pg_current_logfile ( text )
+ text
+
+ Returns the path name of the log file currently in use by the logging
+ collector. The path includes the
+ directory and the individual log file name. The result
+ is NULL if the logging collector is disabled.
+ When multiple log files exist, each in a different
+ format, pg_current_logfile without an argument
+ returns the path of the file having the first format found in the
+ ordered list: stderr,
+ csvlog. NULL is returned
+ if no log file has any of these formats.
+ To request information about a specific log file format, supply
+ either csvlog or stderr as the
+ value of the optional parameter. The result is NULL
+ if the log format requested is not configured in
+ .
+ The result reflects the contents of
+ the current_logfiles file.
+
|
- pg_my_temp_schema()
- oid
- OID of session's temporary schema, or 0 if none
+
+
+ pg_my_temp_schema ()
+ oid
+
+ Returns the OID of the current session's temporary schema, or zero if
+ it has none (because it has not created any temporary tables).
+
|
- pg_is_other_temp_schema(oid)
- boolean
- is schema another session's temporary schema?
+
+
pg_is_other_temp_schema
+
+ pg_is_other_temp_schema ( oid )
+ boolean
+
+ Returns true if the given OID is the OID of another session's
+ temporary schema. (This can be useful, for example, to exclude other
+ sessions' temporary tables from a catalog display.)
+
|
- pg_jit_available()
- boolean
-
is JIT compilation available in this session
- (see
)? Returns
false if
- linkend="guc-jit"/> is set to false.
+
+
+ pg_jit_available ()
+ boolean
+
+ Returns true if
JIT compilation is available in
+ this session (see ).
+ Returns false if is set to false, or if the
+ feature was not enabled at compile time.
+
|
- pg_listening_channels()
- setof text
- channel names that the session is currently listening on
+
+
+ pg_listening_channels ()
+ setof text
+
+ Returns the set of names of asynchronous notification channels that
+ the current session is listening to.
+
|
- pg_notification_queue_usage()
- double
- fraction of the asynchronous notification queue currently occupied (0–1)
+
+
pg_notification_queue_usage
+
+ pg_notification_queue_usage ()
+ double precision
+
+ Returns the fraction (0–1) of the asynchronous notification
+ queue's maximum size that is currently occupied by notifications that
+ are waiting to be processed.
+ See and
+ for more information.
+
|
- pg_postmaster_start_time()
- timestamp with time zone
- server start time
+
+
pg_postmaster_start_time
+
+ pg_postmaster_start_time ()
+ timestamp with time zone
+
+ Returns the time when the server started.
+
|
- pg_safe_snapshot_blocking_pids(int)
- int[]
- Process ID(s) that are blocking specified server process ID from acquiring a safe snapshot
+
+
pg_safe_snapshot_blocking_pids
+
+ pg_safe_snapshot_blocking_pids ( integer )
+ integer[]
+
+ Returns an array of the process ID(s) of the sessions that are blocking
+ the server process with the specified process ID from acquiring a safe
+ snapshot, or an empty array if there is no such server process or it
+ is not blocked.
+
+ A session running a SERIALIZABLE transaction blocks
+ a SERIALIZABLE READ ONLY DEFERRABLE transaction
+ from acquiring a snapshot until the latter determines that it is safe
+ to avoid taking any predicate locks. See
+ for more information about
+ serializable and deferrable transactions.
+
+ Frequent calls to this function could have some impact on database
+ performance, because it needs access to the predicate lock manager's
+ shared state for a short time.
+
|
- pg_trigger_depth()
- int
-
current nesting level of PostgreSQL triggers
- (0 if not called, directly or indirectly, from inside a trigger)
+
+
+ pg_trigger_depth ()
+ integer
+
+ Returns the current nesting level
+ of
PostgreSQL triggers (0 if not called,
+ directly or indirectly, from inside a trigger).
+
|
- session_user
- name
- session user name
+
+
+ session_user
+ name
+
+ Returns the session user's name.
+
|
- user
- name
- equivalent to current_user
+
+
+ user
+ name
+
+ This is equivalent to current_user.
+
|
- version()
- text
-
PostgreSQL version information. See also for a machine-readable version.
+
+
+ version ()
+ text
+
+ Returns a string describing the
PostgreSQL
+ server's version. You can also get this information from
+ , or for a machine-readable
+ version use . Software
+ developers should use server_version_num (available
+ since 8.2) or instead of
+ parsing the text version.
+
session_user,
and user have special syntactic status
in
SQL: they must be called without trailing
- parentheses. (In PostgreSQL, parentheses can optionally be used with
- current_schema, but not with the others.)
+ parentheses. In PostgreSQL, parentheses can optionally be used with
+ current_schema, but not with the others.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- current
-
-
-
- current
-
-
-
-
-
-
- current
-
-
-
-
-
The session_user is normally the user who initiated
the current database connection; but superusers can change this setting
does not, since it unifies users and roles into a single kind of entity.)
- current_schema returns the name of the schema that is
- first in the search path (or a null value if the search path is
- empty). This is the schema that will be used for any tables or
- other named objects that are created without specifying a target schema.
- current_schemas(boolean) returns an array of the names of all
- schemas presently in the search path. The Boolean option determines whether or not
- implicitly included system schemas such as pg_catalog are included in the
- returned search path.
-
-
-
- The search path can be altered at run time. The command is:
-SET search_path TO schema , schema, ...
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- inet_client_addr returns the IP address of the
- current client, and inet_client_port returns the
- port number.
- inet_server_addr returns the IP address on which
- the server accepted the current connection, and
- inet_server_port returns the port number.
- All these functions return NULL if the current connection is via a
- Unix-domain socket.
-
-
-
-
-
- pg_blocking_pids returns an array of the process IDs
- of the sessions that are blocking the server process with the specified
- process ID, or an empty array if there is no such server process or it is
- not blocked. One server process blocks another if it either holds a lock
- that conflicts with the blocked process's lock request (hard block), or is
- waiting for a lock that would conflict with the blocked process's lock
- request and is ahead of it in the wait queue (soft block). When using
- parallel queries the result always lists client-visible process IDs (that
- is, pg_backend_pid results) even if the actual lock is held
- or awaited by a child worker process. As a result of that, there may be
- duplicated PIDs in the result. Also note that when a prepared transaction
- holds a conflicting lock, it will be represented by a zero process ID in
- the result of this function.
- Frequent calls to this function could have some impact on database
- performance, because it needs exclusive access to the lock manager's
- shared state for a short time.
-
-
-
-
-
- pg_conf_load_time returns the
- timestamp with time zone when the
- server configuration files were last loaded.
- (If the current session was alive at the time, this will be the time
- when the session itself re-read the configuration files, so the
- reading will vary a little in different sessions. Otherwise it is
- the time when the postmaster process re-read the configuration files.)
-
-
-
-
-
-
- pg_current_logfile function
-
-
-
- and the pg_current_logfile function
-
-
-
- current_logfiles file and the pg_current_logfile
- function
-
-
- pg_current_logfile returns, as text,
- the path of the log file(s) currently in use by the logging collector.
- The path includes the directory
- and the log file name. Log collection must be enabled or the return value
- is NULL. When multiple log files exist, each in a
- different format, pg_current_logfile called
- without arguments returns the path of the file having the first format
- found in the ordered list: stderr, csvlog.
- NULL is returned when no log file has any of these
- formats. To request a specific file format supply, as text,
- either csvlog or stderr as the value of the
- optional parameter. The return value is NULL when the
- log format requested is not a configured
- . The
- pg_current_logfile reflects the contents of the
- current_logfiles file.
-
-
-
-
-
-
-
pg_is_other_temp_schema
-
-
- pg_my_temp_schema returns the OID of the current
- session's temporary schema, or zero if it has none (because it has not
- created any temporary tables).
- pg_is_other_temp_schema returns true if the
- given OID is the OID of another session's temporary schema.
- (This can be useful, for example, to exclude other sessions' temporary
- tables from a catalog display.)
-
-
-
-
-
-
-
pg_notification_queue_usage
-
-
- pg_listening_channels returns a set of names of
- asynchronous notification channels that the current session is listening
- to. pg_notification_queue_usage returns the
- fraction of the total available space for notifications currently
- occupied by notifications that are waiting to be processed, as a
- double in the range 0–1.
- See and
- for more information.
-
-
-
-
pg_postmaster_start_time
-
-
- pg_postmaster_start_time returns the
- timestamp with time zone when the
- server started.
-
-
-
-
pg_safe_snapshot_blocking_pids
-
-
- pg_safe_snapshot_blocking_pids returns an array of
- the process IDs of the sessions that are blocking the server process with
- the specified process ID from acquiring a safe snapshot, or an empty array
- if there is no such server process or it is not blocked. A session
- running a SERIALIZABLE transaction blocks
- a SERIALIZABLE READ ONLY DEFERRABLE transaction from
- acquiring a snapshot until the latter determines that it is safe to avoid
- taking any predicate locks. See for
- more information about serializable and deferrable transactions. Frequent
- calls to this function could have some impact on database performance,
- because it needs access to the predicate lock manager's shared
- state for a short time.
-
-
-
-
-
- version returns a string describing the
-
PostgreSQL server's version. You can also
- get this information from or
- for a machine-readable version, .
- Software developers should use server_version_num
- (available since 8.2) or instead
- of parsing the text version.
-
-
querying
lists functions that
- allow the user to query object access privileges programmatically.
- See for more information about
- privileges.
+ allow querying object access privileges programmatically.
+ (See for more information about
+ privileges.)
+ In these functions, the user whose privileges are being inquired about
+ can be specified by name or by OID
+ (pg_authid.oid), or if
+ the name is given as public then the privileges of the
+ PUBLIC pseudo-role are checked. Also, the
user
+ argument can be omitted entirely, in which case
+ the current_user is assumed.
+ The object that is being inquired about can be specified either by name or
+ by OID, too. When specifying by name, a schema name can be included if
+ relevant.
+ The access privilege of interest is specified by a text string, which must
+ evaluate to one of the appropriate privilege keywords for the object's type
+ (e.g., SELECT). Optionally, WITH GRANT
+ OPTION can be added to a privilege type to test whether the
+ privilege is held with grant option. Also, multiple privilege types can be
+ listed separated by commas, in which case the result will be true if any of
+ the listed privileges is held. (Case of the privilege string is not
+ significant, and extra whitespace is allowed between but not within
+ privilege names.)
+ Some examples:
+SELECT has_table_privilege('myschema.mytable', 'select');
+SELECT has_table_privilege('joe', 'mytable', 'INSERT, SELECT WITH GRANT OPTION');
+
Access Privilege Inquiry Functions
- 3">
+ 1">
- Name Return Type Description
+ |
+ Function
+
+ Description
+
+
|
-
has_any_column_privilege(user,
-
- boolean
- does user have privilege for any column of table
-
- |
-
has_any_column_privilege(table,
-
- boolean
- does current user have privilege for any column of table
+
+
has_any_column_privilege
+
+ has_any_column_privilege (
+ boolean
+
+ Does user have privilege for any column of table?
+ This succeeds either if the privilege is held for the whole table, or
+ if there is a column-level grant of the privilege for at least one
+ column.
+ Allowable privilege types are
+ SELECT, INSERT,
+ UPDATE, and REFERENCES.
+
+
|
-
has_column_privilege(user,
-
- boolean
- does user have privilege for column
+
+
+ has_column_privilege (
+
column text or
smallint,
+ boolean
+
+ Does user have privilege for the specified table column?
+ This succeeds either if the privilege is held for the whole table, or
+ if there is a column-level grant of the privilege for the column.
+ The column can be specified by name or by attribute number
+ (pg_attribute.attnum).
+ Allowable privilege types are
+ SELECT, INSERT,
+ UPDATE, and REFERENCES.
+
+
|
-
has_column_privilege(table,
-
- boolean
- does current user have privilege for column
+
+
+ has_database_privilege (
+ boolean
+
+ Does user have privilege for database?
+ Allowable privilege types are
+ CREATE,
+ CONNECT,
+ TEMPORARY, and
+ TEMP (which is equivalent to
+ TEMPORARY).
+
+
|
-
has_database_privilege(user,
-
- boolean
- does user have privilege for database
+
+
has_foreign_data_wrapper_privilege
+
+ has_foreign_data_wrapper_privilege (
+ boolean
+
+ Does user have privilege for foreign-data wrapper?
+ The only allowable privilege type is USAGE.
+
+
|
-
has_database_privilege(database,
-
- boolean
- does current user have privilege for database
+
+
+ has_function_privilege (
+ boolean
+
+ Does user have privilege for function?
+ The only allowable privilege type is EXECUTE.
+
+ When specifying a function by name rather than by OID, the allowed
+ input is the same as for the regprocedure data type (see
+ ).
+ An example is:
+SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
+
+
+
|
-
has_foreign_data_wrapper_privilege(user,
-
- boolean
- does user have privilege for foreign-data wrapper
+
+
+ has_language_privilege (
+ boolean
+
+ Does user have privilege for language?
+ The only allowable privilege type is USAGE.
+
+
|
-
has_foreign_data_wrapper_privilege(fdw,
-
- boolean
- does current user have privilege for foreign-data wrapper
+
+
+ has_schema_privilege (
+ boolean
+
+ Does user have privilege for schema?
+ Allowable privilege types are
+ CREATE and
+ USAGE.
+
+
|
-
has_function_privilege(user,
-
- boolean
- does user have privilege for function
+
+
+ has_sequence_privilege (
+ boolean
+
+ Does user have privilege for sequence?
+ Allowable privilege types are
+ USAGE,
+ SELECT, and
+ UPDATE.
+
+
|
-
has_function_privilege(function,
-
- boolean
- does current user have privilege for function
-
- |
-
has_language_privilege(user,
-
- boolean
- does user have privilege for language
-
- |
-
has_language_privilege(language,
-
- boolean
- does current user have privilege for language
-
- |
-
has_schema_privilege(user,
-
- boolean
- does user have privilege for schema
-
- |
-
has_schema_privilege(schema,
-
- boolean
- does current user have privilege for schema
-
- |
-
has_sequence_privilege(user,
-
- boolean
- does user have privilege for sequence
-
- |
-
has_sequence_privilege(sequence,
-
- boolean
- does current user have privilege for sequence
-
- |
-
has_server_privilege(user,
-
- boolean
- does user have privilege for foreign server
-
- |
-
has_server_privilege(server,
-
- boolean
- does current user have privilege for foreign server
-
- |
-
has_table_privilege(user,
-
- boolean
- does user have privilege for table
-
- |
-
has_table_privilege(table,
-
- boolean
- does current user have privilege for table
-
- |
-
has_tablespace_privilege(user,
-
- boolean
- does user have privilege for tablespace
-
- |
-
has_tablespace_privilege(tablespace,
-
- boolean
- does current user have privilege for tablespace
+
+
+ has_server_privilege (
+ boolean
+
+ Does user have privilege for foreign server?
+ The only allowable privilege type is USAGE.
+
+
|
-
has_type_privilege(user,
-
- boolean
- does user have privilege for type
+
+
+ has_table_privilege (
+ boolean
+
+ Does user have privilege for table?
+ Allowable privilege types
+ are SELECT, INSERT,
+ UPDATE, DELETE,
+ TRUNCATE, REFERENCES,
+ and TRIGGER.
+
+
|
-
has_type_privilege(type,
-
- boolean
- does current user have privilege for type
+
+
has_tablespace_privilege
+
+ has_tablespace_privilege (
+
tablespace text or
oid,
+ boolean
+
+ Does user have privilege for tablespace?
+ The only allowable privilege type is CREATE.
+
+
|
-
- boolean
- does user have privilege for role
+
+
+ has_type_privilege (
+ boolean
+
+ Does user have privilege for data type?
+ The only allowable privilege type is USAGE.
+ When specifying a type by name rather than by OID, the allowed input
+ is the same as for the regtype data type (see
+ ).
+
+
|
-
- boolean
- does current user have privilege for role
+
+
+ pg_has_role (
+ boolean
+
+ Does user have privilege for role?
+ Allowable privilege types are
+ MEMBER and USAGE.
+ MEMBER denotes direct or indirect membership in
+ the role (that is, the right to do SET ROLE), while
+ USAGE denotes whether the privileges of the role
+ are immediately available without doing SET ROLE.
+ This function does not allow the special case of
+ setting
user to
public,
+ because the PUBLIC pseudo-role can never be a member of real roles.
+
+
|
-
row_security_active(table)
-
- boolean
- does current user have row level security active for table
+
+
+ row_security_active (
+ boolean
+
+ Is row-level security active for the specified table in the context of
+ the current user and current environment?
+
-
-
has_any_column_privilege
-
-
-
-
-
-
-
-
-
has_foreign_data_wrapper_privilege
-
-
-
-
-
-
-
-
-
-
-
-
-
has_tablespace_privilege
-
-
-
-
-
-
-
-
- has_table_privilege checks whether a user
- can access a table in a particular way. The user can be
- specified by name, by OID (pg_authid.oid),
- public to indicate the PUBLIC pseudo-role, or if the argument is
- omitted
- current_user is assumed. The table can be specified
- by name or by OID. (Thus, there are actually six variants of
- has_table_privilege, which can be distinguished by
- the number and types of their arguments.) When specifying by name,
- the name can be schema-qualified if necessary.
- The desired access privilege type
- is specified by a text string, which must evaluate to one of the
- values SELECT, INSERT,
- UPDATE, DELETE, TRUNCATE,
- REFERENCES, or TRIGGER. Optionally,
- WITH GRANT OPTION can be added to a privilege type to test
- whether the privilege is held with grant option. Also, multiple privilege
- types can be listed separated by commas, in which case the result will
- be true if any of the listed privileges is held.
- (Case of the privilege string is not significant, and extra whitespace
- is allowed between but not within privilege names.)
- Some examples:
-SELECT has_table_privilege('myschema.mytable', 'select');
-SELECT has_table_privilege('joe', 'mytable', 'INSERT, SELECT WITH GRANT OPTION');
-
-
-
- has_sequence_privilege checks whether a user
- can access a sequence in a particular way. The possibilities for its
- arguments are analogous to has_table_privilege.
- The desired access privilege type must evaluate to one of
- USAGE,
- SELECT, or
- UPDATE.
-
-
- has_any_column_privilege checks whether a user can
- access any column of a table in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege,
- except that the desired access privilege type must evaluate to some
- combination of
- SELECT,
- INSERT,
- UPDATE, or
- REFERENCES. Note that having any of these privileges
- at the table level implicitly grants it for each column of the table,
- so has_any_column_privilege will always return
- true if has_table_privilege does for the same
- arguments. But has_any_column_privilege also succeeds if
- there is a column-level grant of the privilege for at least one column.
-
-
- has_column_privilege checks whether a user
- can access a column in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege,
- with the addition that the column can be specified either by name
- or attribute number.
- The desired access privilege type must evaluate to some combination of
- SELECT,
- INSERT,
- UPDATE, or
- REFERENCES. Note that having any of these privileges
- at the table level implicitly grants it for each column of the table.
-
-
- has_database_privilege checks whether a user
- can access a database in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- The desired access privilege type must evaluate to some combination of
- CREATE,
- CONNECT,
- TEMPORARY, or
- TEMP (which is equivalent to
- TEMPORARY).
-
-
- has_function_privilege checks whether a user
- can access a function in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- When specifying a function by a text string rather than by OID,
- the allowed input is the same as for the regprocedure data type
- (see ).
- The desired access privilege type must evaluate to
- EXECUTE.
- An example is:
-SELECT has_function_privilege('joeuser', 'myfunc(int, text)', 'execute');
-
-
-
- has_foreign_data_wrapper_privilege checks whether a user
- can access a foreign-data wrapper in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- The desired access privilege type must evaluate to
- USAGE.
-
-
- has_language_privilege checks whether a user
- can access a procedural language in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- The desired access privilege type must evaluate to
- USAGE.
-
-
- has_schema_privilege checks whether a user
- can access a schema in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- The desired access privilege type must evaluate to some combination of
- CREATE or
- USAGE.
-
-
- has_server_privilege checks whether a user
- can access a foreign server in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- The desired access privilege type must evaluate to
- USAGE.
-
-
- has_tablespace_privilege checks whether a user
- can access a tablespace in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- The desired access privilege type must evaluate to
- CREATE.
-
-
- has_type_privilege checks whether a user
- can access a type in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege.
- When specifying a type by a text string rather than by OID,
- the allowed input is the same as for the regtype data type
- (see ).
- The desired access privilege type must evaluate to
- USAGE.
-
-
- pg_has_role checks whether a user
- can access a role in a particular way.
- Its argument possibilities
- are analogous to has_table_privilege,
- except that public is not allowed as a user name.
- The desired access privilege type must evaluate to some combination of
- MEMBER or
- USAGE.
- MEMBER denotes direct or indirect membership in
- the role (that is, the right to do SET ROLE), while
- USAGE denotes whether the privileges of the role
- are immediately available without doing SET ROLE.
-
-
- row_security_active checks whether row level
- security is active for the specified table in the context of the
- current_user and environment. The table can
- be specified by name or by OID.
-
-
shows the operators
available for the aclitem type, which is the catalog
for information about how to read access privilege values.
-
-
-
-
-
-
-
-
-
-
-
aclitem Operators
- 4">
+ 1">
|
- Operator
- Description
- Example
- Result
+ Operator
+
+ Description
+
+ Example(s)
+
-
+
|
- =
- equal
- 'calvin=r*w/hobbes'::aclitem = 'calvin=r*w*/hobbes'::aclitem
- f
+
+
+ aclitem = aclitem
+ boolean
+
+ Are aclitems equal? (Notice that
+ type aclitem lacks the usual set of comparison
+ operators; it has only equality. In turn, aclitem
+ arrays can only be compared for equality.)
+
+ 'calvin=r*w/hobbes'::aclitem = 'calvin=r*w*/hobbes'::aclitem
+ f
+
|
- @>
- contains element
- '{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] @> 'calvin=r*w/hobbes'::aclitem
- t
+
+
+ aclitem[] @> aclitem
+ boolean
+
+ Does array contain the specified privileges? (This is true if there
+ is an array entry that matches the aclitem's grantee and
+ grantor, and has at least the specified set of privileges.)
+
+ '{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] @> 'calvin=r*/hobbes'::aclitem
+ t
+
|
- ~
- contains element
- '{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] ~ 'calvin=r*w/hobbes'::aclitem
- t
+ aclitem[] ~ aclitem
+ boolean
+
+ This is a deprecated alias for @>.
+
+ '{calvin=r*w/hobbes,hobbes=r*w*/postgres}'::aclitem[] ~ 'calvin=r*/hobbes'::aclitem
+ t
+
-
aclitem Functions
- 3">
+ 1">
- Name Return Type Description
+ |
+ Function
+
+ Description
+
+
+
|
- aclitem[]
-
get the default access privileges for an object belonging to ownerId
+
+
+ acldefault (
+ aclitem[]
+
+ Constructs an aclitem array holding the default access
+ privileges for an object of type
type belonging
+ to the role with OID
ownerId. This represents
+ the access privileges that will be assumed when an object's ACL entry
+ is null. (The default access privileges are described in
+ .)
+ The
type parameter must be one of
+ 'c' for COLUMN,
+ 'r' for TABLE and table-like objects,
+ 's' for SEQUENCE,
+ 'd' for DATABASE,
+ 'f' for FUNCTION or PROCEDURE,
+ 'l' for LANGUAGE,
+ 'L' for LARGE OBJECT,
+ 'n' for SCHEMA,
+ 't' for TABLESPACE,
+ 'F' for FOREIGN DATA WRAPPER,
+ 'S' for FOREIGN SERVER,
+ or
+ 'T' for TYPE or DOMAIN.
+
+
|
- setof record
- get aclitem array as tuples
-
+
+
+ aclexplode ( aclitem[] )
+ setof record
+
+ Returns the aclitem array as a set of rows.
+ If the grantee is the pseudo-role PUBLIC, it is represented by zero in
+ the
grantee column. Each granted privilege is
+ represented as SELECT, INSERT,
+ etc. Note that each privilege is broken out as a separate row, so
+ only one keyword appears in the
privilege_type
+ column.
+
+
+
|
-
makeaclitem(grantee, grantor, privilege, grantable)
- aclitem
- build an aclitem from input
+
+
+ makeaclitem (
+ aclitem
+
+ Constructs an aclitem with the given properties.
+
- acldefault returns the built-in default access
- privileges for an object of type
type belonging to
- role
ownerId. These represent the access
- privileges that will be assumed when an object's ACL entry is null.
- (The default access privileges are described in .)
- The
type parameter is a
CHAR: write
- 'c' for COLUMN,
- 'r' for TABLE and table-like objects,
- 's' for SEQUENCE,
- 'd' for DATABASE,
- 'f' for FUNCTION or PROCEDURE,
- 'l' for LANGUAGE,
- 'L' for LARGE OBJECT,
- 'n' for SCHEMA,
- 't' for TABLESPACE,
- 'F' for FOREIGN DATA WRAPPER,
- 'S' for FOREIGN SERVER,
- or
- 'T' for TYPE or DOMAIN.
-
-
- aclexplode returns an aclitem array
- as a set of rows. Output columns are grantor oid,
- grantee oid (0 for PUBLIC),
- granted privilege as text (SELECT, ...)
- and whether the privilege is grantable as boolean.
- makeaclitem performs the inverse operation.
-
-
shows functions that
determine whether a certain object is visible in the
containing schema is in the search path and no table of the same
name appears earlier in the search path. This is equivalent to the
statement that the table can be referenced by name without explicit
- schema qualification. To list the names of all visible tables:
+ schema qualification. Thus, to list the names of all visible tables:
SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
+ For functions and operators, an object in the search path is said to be
+ visible if there is no object of the same name and argument data
+ type(s) earlier in the path. For operator classes and families,
+ both the name and the associated index access method are considered.
Schema Visibility Inquiry Functions
- 3">
+ 1">
- Name Return Type Description
+ |
+ Function
+
+ Description
+
+
|
-
pg_collation_is_visible(collation_oid)
-
- boolean
- is collation visible in search path
+
+
pg_collation_is_visible
+
+
pg_collation_is_visible (
collation oid )
+ boolean
+
+ Is collation visible in search path?
+
+
|
-
pg_conversion_is_visible(conversion_oid)
-
- boolean
- is conversion visible in search path
+
+
pg_conversion_is_visible
+
+
pg_conversion_is_visible (
conversion oid )
+ boolean
+
+ Is conversion visible in search path?
+
+
|
-
pg_function_is_visible(function_oid)
-
- boolean
- is function visible in search path
+
+
+
pg_function_is_visible (
function oid )
+ boolean
+
+ Is function visible in search path?
+ (This also works for procedures and aggregates.)
+
+
|
-
pg_opclass_is_visible(opclass_oid)
-
- boolean
- is operator class visible in search path
+
+
+
pg_opclass_is_visible (
opclass oid )
+ boolean
+
+ Is operator class visible in search path?
+
+
|
-
pg_operator_is_visible(operator_oid)
-
- boolean
- is operator visible in search path
+
+
+
pg_operator_is_visible (
operator oid )
+ boolean
+
+ Is operator visible in search path?
+
+
|
-
pg_opfamily_is_visible(opclass_oid)
-
- boolean
- is operator family visible in search path
+
+
+
pg_opfamily_is_visible (
opclass oid )
+ boolean
+
+ Is operator family visible in search path?
+
+
|
-
pg_statistics_obj_is_visible(stat_oid)
-
- boolean
- is statistics object visible in search path
+
+
pg_statistics_obj_is_visible
+
+
pg_statistics_obj_is_visible (
stat oid )
+ boolean
+
+ Is statistics object visible in search path?
+
+
|
-
pg_table_is_visible(table_oid)
-
- boolean
- is table visible in search path
+
+
+
pg_table_is_visible (
table oid )
+ boolean
+
+ Is table visible in search path?
+ (This works for all types of relations, including views, materialized
+ views, indexes, sequences and foreign tables.)
+
+
|
-
pg_ts_config_is_visible(config_oid)
-
- boolean
- is text search configuration visible in search path
+
+
pg_ts_config_is_visible
+
+
pg_ts_config_is_visible (
config oid )
+ boolean
+
+ Is text search configuration visible in search path?
+
+
|
-
pg_ts_dict_is_visible(dict_oid)
-
- boolean
- is text search dictionary visible in search path
+
+
+
pg_ts_dict_is_visible (
dict oid )
+ boolean
+
+ Is text search dictionary visible in search path?
+
+
|
-
pg_ts_parser_is_visible(parser_oid)
-
- boolean
- is text search parser visible in search path
+
+
pg_ts_parser_is_visible
+
+
pg_ts_parser_is_visible (
parser oid )
+ boolean
+
+ Is text search parser visible in search path?
+
+
|
-
pg_ts_template_is_visible(template_oid)
-
- boolean
- is text search template visible in search path
+
+
pg_ts_template_is_visible
+
+
pg_ts_template_is_visible (
template oid )
+ boolean
+
+ Is text search template visible in search path?
+
+
|
-
pg_type_is_visible(type_oid)
-
- boolean
- is type (or domain) visible in search path
+
+
+
pg_type_is_visible (
type oid )
+ boolean
+
+ Is type (or domain) visible in search path?
+
-
-
pg_collation_is_visible
-
-
-
pg_conversion_is_visible
-
-
-
-
-
-
-
-
-
-
-
pg_statistics_obj_is_visible
-
-
-
-
-
pg_ts_config_is_visible
-
-
-
-
-
pg_ts_parser_is_visible
-
-
-
pg_ts_template_is_visible
-
-
-
-
- Each function performs the visibility check for one type of database
- object. Note that pg_table_is_visible can also be used
- with views, materialized views, indexes, sequences and foreign tables;
- pg_function_is_visible can also be used with
- procedures and aggregates;
- pg_type_is_visible can also be used with domains.
- For functions and operators, an object in
- the search path is visible if there is no object of the same name
- and argument data type(s) earlier in the path. For operator
- classes, both name and associated index access method are considered.
-
-
All these functions require object OIDs to identify the object to be
checked. If you want to test an object by name, it is convenient to use
type name in this way — if the name can be recognized at all, it must be visible.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
pg_get_function_arguments
-
-
-
-
pg_get_function_identity_arguments
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
pg_get_statisticsobjdef
-
-
-
-
-
-
-
-
-
-
-
-
-
pg_index_column_has_property
-
-
-
-
-
-
-
pg_indexam_has_property
-
-
-
-
-
-
-
pg_tablespace_databases
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
lists functions that
extract information from the system catalogs.
System Catalog Information Functions
- 3">
+ 1">
- Name Return Type Description
+ |
+ Function
+
+ Description
+
+
|
-
format_type(type_oid, typemod)
- text
- get SQL name of a data type
-
- |
-
pg_get_constraintdef(constraint_oid)
- text
- get definition of a constraint
-
- |
-
pg_get_constraintdef(constraint_oid, pretty_bool)
- text
- get definition of a constraint
-
- |
-
pg_get_expr(pg_node_tree, relation_oid)
- text
- decompile internal form of an expression, assuming that any Vars
- in it refer to the relation indicated by the second parameter
-
- |
-
pg_get_expr(pg_node_tree, relation_oid, pretty_bool)
- text
- decompile internal form of an expression, assuming that any Vars
- in it refer to the relation indicated by the second parameter
-
- |
-
pg_get_functiondef(func_oid)
- text
- get definition of a function or procedure
-
- |
-
pg_get_function_arguments(func_oid)
- text
- get argument list of function's or procedure's definition (with default values)
-
- |
-
pg_get_function_identity_arguments(func_oid)
- text
- get argument list to identify a function or procedure (without default values)
+
+
+
format_type (
type oid,
typemod integer )
+ text
+
+ Returns the SQL name for a data type that is identified by its type
+ OID and possibly a type modifier. Pass NULL for the type modifier if
+ no specific modifier is known.
+
+
|
-
pg_get_function_result(func_oid)
- text
- get RETURNS clause for function (returns null for a procedure)
+
+
+
pg_get_constraintdef (
constraint oid , pretty boolean )
+ text
+
+ Reconstructs the creating command for a constraint.
+ (This is a decompiled reconstruction, not the original text
+ of the command.)
+
+
|
-
pg_get_indexdef(index_oid)
- text
- get CREATE INDEX command for index
+
+
+
pg_get_expr (
expr pg_node_tree,
relation oid , pretty boolean )
+ text
+
+ Decompiles the internal form of an expression stored in the system
+ catalogs, such as the default value for a column. If the expression
+ might contain Vars, specify the OID of the relation they refer to as
+ the second parameter; if no Vars are expected, passing zero is
+ sufficient.
+
+
|
-
pg_get_indexdef(index_oid, column_no, pretty_bool)
- text
- get CREATE INDEX command for index,
- or definition of just one index column when
+
+
+
pg_get_functiondef (
func oid )
+ text
+
+ Reconstructs the creating command for a function or procedure.
+ (This is a decompiled reconstruction, not the original text
+ of the command.)
+ The result is a complete CREATE OR REPLACE FUNCTION
+ or CREATE OR REPLACE PROCEDURE statement.
+
+
|
- pg_get_keywords()
- setof record
- get list of SQL keywords and their categories
+
+
pg_get_function_arguments
+
+
pg_get_function_arguments (
func oid )
+ text
+
+ Reconstructs the argument list of a function or procedure, in the form
+ it would need to appear in within CREATE FUNCTION
+ (including default values).
+
+
|
-
pg_get_ruledef(rule_oid)
- text
- get CREATE RULE command for rule
+
+
pg_get_function_identity_arguments
+
+
pg_get_function_identity_arguments (
func oid )
+ text
+
+ Reconstructs the argument list necessary to identify a function or
+ procedure, in the form it would need to appear in within commands such
+ as ALTER FUNCTION. This form omits default values.
+
+
|
-
pg_get_ruledef(rule_oid, pretty_bool)
- text
- get CREATE RULE command for rule
+
+
+
pg_get_function_result (
func oid )
+ text
+
+ Reconstructs the RETURNS clause of a function, in
+ the form it would need to appear in within CREATE
+ FUNCTION. Returns NULL for a procedure.
+
+
|
-
pg_get_serial_sequence(table_name, column_name)
- text
- get name of the sequence that a serial or identity column uses
+
+
+
pg_get_indexdef (
index oid , column integer, pretty boolean )
+ text
+
+ Reconstructs the creating command for an index.
+ (This is a decompiled reconstruction, not the original text
+ of the command.) If
column is supplied and is
+ not zero, only the definition of that column is reconstructed.
+
+
|
-
pg_get_statisticsobjdef(statobj_oid)
- text
- get CREATE STATISTICS command for extended statistics object
+
+
+ pg_get_keywords ()
+ setof record
+
+ Returns a set of records describing the SQL keywords recognized by the
+ server. The
word column contains the
+ keyword. The
catcode column contains a
+ category code: U for an unreserved
+ keyword, C for a keyword that can be a column
+ name, T for a keyword that can be a type or
+ function name, or R for a fully reserved keyword.
+ The
catdesc column contains a
+ possibly-localized string describing the category.
+
+
|
-
pg_get_triggerdef(trigger_oid)
- text
- get CREATE [ CONSTRAINT ] TRIGGER command for trigger
+
+
+
pg_get_ruledef (
rule oid , pretty boolean )
+ text
+
+ Reconstructs the creating command for a rule.
+ (This is a decompiled reconstruction, not the original text
+ of the command.)
+
+
|
-
pg_get_triggerdef(trigger_oid, pretty_bool)
- text
- get CREATE [ CONSTRAINT ] TRIGGER command for trigger
+
+
+
pg_get_serial_sequence (
table text,
column text )
+ text
+
+ Returns the name of the sequence associated with a column,
+ or NULL if no sequence is associated with the column.
+ If the column is an identity column, the associated sequence is the
+ sequence internally created for that column.
+ For columns created using one of the serial types
+ (serial, smallserial, bigserial),
+ it is the sequence created for that serial column definition.
+ In the latter case, the association can be modified or removed
+ with ALTER SEQUENCE OWNED BY.
+ (This function probably should have been
+ called pg_get_owned_sequence; its current name
+ reflects the fact that it has historically been used with serial-type
+ columns.) The first parameter is a table name with optional
+ schema, and the second parameter is a column name. Because the first
+ parameter potentially contains both schema and table names, it is
+ parsed per usual SQL rules, meaning it is lower-cased by default.
+ The second parameter, being just a column name, is treated literally
+ and so has its case preserved. The result is suitably formatted
+ for passing to the sequence functions (see
+ ).
+
+ A typical use is in reading the current value of the sequence for an
+ identity or serial column, for example:
+SELECT currval(pg_get_serial_sequence('sometable', 'id'));
+
+
+
|
-
pg_get_userbyid(role_oid)
- name
- get role name with given OID
+
+
pg_get_statisticsobjdef
+
+
pg_get_statisticsobjdef (
statobj oid )
+ text
+
+ Reconstructs the creating command for an extended statistics object.
+ (This is a decompiled reconstruction, not the original text
+ of the command.)
+
+
|
-
pg_get_viewdef(view_name)
- text
- get underlying SELECT command for view or materialized view (deprecated)
+
+
+
pg_get_triggerdef (
trigger oid , pretty boolean )
+ text
+
+ Reconstructs the creating command for a trigger.
+ (This is a decompiled reconstruction, not the original text
+ of the command.)
+
+
|
-
pg_get_viewdef(view_name, pretty_bool)
- text
- get underlying SELECT command for view or materialized view (deprecated)
+
+
+
pg_get_userbyid (
role oid )
+ name
+
+ Returns a role's name given its OID.
+
+
|
-
pg_get_viewdef(view_oid)
- text
- get underlying SELECT command for view or materialized view
+
+
+
pg_get_viewdef (
view oid , pretty boolean )
+ text
+
+ Reconstructs the underlying SELECT command for a
+ view or materialized view. (This is a decompiled reconstruction, not
+ the original text of the command.)
+
+
|
-
pg_get_viewdef(view_oid, pretty_bool)
- text
- get underlying SELECT command for view or materialized view
+
pg_get_viewdef (
view oid,
wrap_column integer )
+ text
+
+ Reconstructs the underlying SELECT command for a
+ view or materialized view. (This is a decompiled reconstruction, not
+ the original text of the command.) In this form of the function,
+ pretty-printing is always enabled, and long lines are wrapped to try
+ to keep them shorter than the specified number of columns.
+
+
|
-
pg_get_viewdef(view_oid, wrap_column_int)
- text
- get underlying SELECT command for view or
- materialized view; lines with fields are wrapped to specified
- number of columns, pretty-printing is implied
+
pg_get_viewdef (
view text , pretty boolean )
+ text
+
+ Reconstructs the underlying SELECT command for a
+ view or materialized view, working from a textual name for the view
+ rather than its OID. (This is deprecated; use the OID variant
+ instead.)
+
+
|
-
pg_index_column_has_property(index_oid, column_no, prop_name)
- boolean
- test whether an index column has a specified property
+
+
pg_index_column_has_property
+
+
pg_index_column_has_property (
index regclass,
column integer,
property text )
+ boolean
+
+ Tests whether an index column has the named property.
+ Common index column properties are listed in
+ .
+ (Note that extension access methods can define additional property
+ names for their indexes.)
+ NULL is returned if the property name is not known
+ or does not apply to the particular object, or if the OID or column
+ number does not identify a valid object.
+
+
|
-
pg_index_has_property(index_oid, prop_name)
- boolean
- test whether an index has a specified property
+
+
+
pg_index_has_property (
index regclass,
property text )
+ boolean
+
+ Tests whether an index has the named property.
+ Common index properties are listed in
+ .
+ (Note that extension access methods can define additional property
+ names for their indexes.)
+ NULL is returned if the property name is not known
+ or does not apply to the particular object, or if the OID does not
+ identify a valid object.
+
+
|
-
pg_indexam_has_property(am_oid, prop_name)
- boolean
- test whether an index access method has a specified property
+
+
pg_indexam_has_property
+
+
pg_indexam_has_property (
am oid,
property text )
+ boolean
+
+ Tests whether an index access method has the named property.
+ Access method properties are listed in
+ .
+ NULL is returned if the property name is not known
+ or does not apply to the particular object, or if the OID does not
+ identify a valid object.
+
+
|
-
pg_options_to_table(reloptions)
- setof record
- get the set of storage option name/value pairs
+
+
+
pg_options_to_table (
reloptions text[] )
+ setof record
+
+ Returns the set of storage options represented by a value from
+ pg_class.reloptions or
+ pg_attribute.attoptions.
+
+
|
-
pg_tablespace_databases(tablespace_oid)
- setof oid
- get the set of database OIDs that have objects in the tablespace
+
+
pg_tablespace_databases
+
+
pg_tablespace_databases (
tablespace oid )
+ setof oid
+
+ Returns the set of OIDs of databases that have objects stored in the
+ specified tablespace. If this function returns any rows, the
+ tablespace is not empty and cannot be dropped. To identify the specific
+ objects populating the tablespace, you will need to connect to the
+ database(s) identified by pg_tablespace_databases
+ and query their pg_class catalogs.
+
+
|
-
pg_tablespace_location(tablespace_oid)
- text
- get the path in the file system that this tablespace is located in
+
+
+
pg_tablespace_location (
tablespace oid )
+ text
+
+ Returns the file system path that this tablespace is located in.
+
+
|
- regtype
- get the data type of any value
+
+
+ pg_typeof ( "any" )
+ regtype
+
+ Returns the OID of the data type of the value that is passed to it.
+ This can be helpful for troubleshooting or dynamically constructing
+ SQL queries. The function is declared as
+ returning regtype, which is an OID alias type (see
+ ); this means that it is the same as an
+ OID for comparison purposes but displays as a type name.
+
+ For example:
+SELECT pg_typeof(33);
+ pg_typeof
+-----------
+ integer
+
+SELECT typlen FROM pg_type WHERE oid = pg_typeof(33);
+ typlen
+--------
+ 4
+
+
+
|
- text
- get the collation of the argument
+
+
+ COLLATION FOR ( "any" )
+ text
+
+ Returns the name of the collation of the value that is passed to it.
+ The value is quoted and schema-qualified if necessary. If no
+ collation was derived for the argument expression,
+ then NULL is returned. If the argument is not of a
+ collatable data type, then an error is raised.
+
+ For example:
+SELECT collation for (description) FROM pg_description LIMIT 1;
+ pg_collation_for
+------------------
+ "default"
+
+SELECT collation for ('foo' COLLATE "de_DE");
+ pg_collation_for
+------------------
+ "de_DE"
+
+
+
|
- regclass
- get the OID of the named relation
+
+
+ to_regclass ( text )
+ regclass
+
+ Translates a textual relation name to its OID. A similar result is
+ obtained by casting the string to type regclass (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
-
to_regcollation(coll_name)
- regcollation
- get the OID of the named collation
+
+
+ to_regcollation ( text )
+ regcollation
+
+ Translates a textual collation name to its OID. A similar result is
+ obtained by casting the string to type regcollation (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
-
to_regnamespace(schema_name)
- regnamespace
- get the OID of the named schema
+
+
+ to_regnamespace ( text )
+ regnamespace
+
+ Translates a textual schema name to its OID. A similar result is
+ obtained by casting the string to type regnamespace (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
-
to_regoper(operator_name)
- regoper
- get the OID of the named operator
+
+
+ to_regoper ( text )
+ regoper
+
+ Translates a textual operator name to its OID. A similar result is
+ obtained by casting the string to type regoper (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found or is ambiguous. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
-
to_regoperator(operator_name)
- regoperator
- get the OID of the named operator
+
+
+ to_regoperator ( text )
+ regoperator
+
+ Translates a textual operator name (with parameter types) to its OID. A similar result is
+ obtained by casting the string to type regoperator (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
- regrole
- get the OID of the named role
+
+
+ to_regproc ( text )
+ regproc
+
+ Translates a textual function or procedure name to its OID. A similar result is
+ obtained by casting the string to type regproc (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found or is ambiguous. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
- regproc
- get the OID of the named function
+
+
+ to_regprocedure ( text )
+ regprocedure
+
+ Translates a textual function or procedure name (with argument types) to its OID. A similar result is
+ obtained by casting the string to type regprocedure (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
-
to_regprocedure(func_name)
- regprocedure
- get the OID of the named function
+
+
+ to_regrole ( text )
+ regrole
+
+ Translates a textual role name to its OID. A similar result is
+ obtained by casting the string to type regrole (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
+
|
- regtype
- get the OID of the named type
+
+
+ to_regtype ( text )
+ regtype
+
+ Translates a textual type name to its OID. A similar result is
+ obtained by casting the string to type regtype (see
+ ); however, this function will return
+ NULL rather than throwing an error if the name is
+ not found. Also unlike the cast, this does not accept
+ a numeric OID as input.
+
- format_type returns the SQL name of a data type that
- is identified by its type OID and possibly a type modifier. Pass NULL
- for the type modifier if no specific modifier is known.
-
-
- pg_get_keywords returns a set of records describing
- the SQL keywords recognized by the server. The word column
- contains the keyword. The catcode column contains a
- category code: U for unreserved, C for column name,
- T for type or function name, or R for reserved.
- The catdesc column contains a possibly-localized string
- describing the category.
-
-
- pg_get_constraintdef,
- pg_get_indexdef, pg_get_ruledef,
- pg_get_statisticsobjdef, and
- pg_get_triggerdef, respectively reconstruct the
- creating command for a constraint, index, rule, extended statistics object,
- or trigger. (Note that this is a decompiled reconstruction, not the
- original text of the command.) pg_get_expr decompiles
- the internal form of an individual expression, such as the default value
- for a column. It can be useful when examining the contents of system
- catalogs. If the expression might contain Vars, specify the OID of the
- relation they refer to as the second parameter; if no Vars are expected,
- zero is sufficient. pg_get_viewdef reconstructs the
- SELECT query that defines a view. Most of these functions come
- in two variants, one of which can optionally pretty-print
the
- result. The pretty-printed format is more readable, but the default format
+ Most of the functions that reconstruct (decompile) database objects
+ have an optional
pretty flag, which
+ if true causes the result to
+ be pretty-printed
. Pretty-printing suppresses unnecessary
+ parentheses and adds whitespace for legibility.
+ The pretty-printed format is more readable, but the default format
is more likely to be interpreted the same way by future versions of
-
PostgreSQL; avoid using pretty-printed output for dump
- purposes. Passing false for the pretty-print parameter yields
- the same result as the variant that does not have the parameter at all.
-
-
- pg_get_functiondef returns a complete
- CREATE OR REPLACE FUNCTION statement for a function.
- pg_get_function_arguments returns the argument list
- of a function, in the form it would need to appear in within
- CREATE FUNCTION.
- pg_get_function_result similarly returns the
- appropriate RETURNS clause for the function.
- pg_get_function_identity_arguments returns the
- argument list necessary to identify a function, in the form it
- would need to appear in within ALTER FUNCTION, for
- instance. This form omits default values.
-
-
- pg_get_serial_sequence returns the name of the
- sequence associated with a column, or NULL if no sequence is associated
- with the column. If the column is an identity column, the associated
- sequence is the sequence internally created for the identity column. For
- columns created using one of the serial types
- (serial, smallserial, bigserial), it
- is the sequence created for that serial column definition. In the latter
- case, this association can be modified or removed with ALTER
- SEQUENCE OWNED BY. (The function probably should have been called
- pg_get_owned_sequence; its current name reflects the
- fact that it has typically been used with serial
- or bigserial columns.) The first input parameter is a table name
- with optional schema, and the second parameter is a column name. Because
- the first parameter is potentially a schema and table, it is not treated as
- a double-quoted identifier, meaning it is lower cased by default, while the
- second parameter, being just a column name, is treated as double-quoted and
- has its case preserved. The function returns a value suitably formatted
- for passing to sequence functions
- (see ). A typical use is in reading the
- current value of a sequence for an identity or serial column, for example:
-SELECT currval(pg_get_serial_sequence('sometable', 'id'));
-
-
-
- pg_get_userbyid extracts a role's name given
- its OID.
-
-
- pg_index_column_has_property,
- pg_index_has_property, and
- pg_indexam_has_property return whether the
- specified index column, index, or index access method possesses the named
- property. NULL is returned if the property name is not
- known or does not apply to the particular object, or if the OID or column
- number does not identify a valid object. Refer to
- for column properties,
- for index properties, and
- for access method properties.
- (Note that extension access methods can define additional property names
- for their indexes.)
+
PostgreSQL; so avoid using pretty-printed output
+ for dump purposes. Passing false for
+ the
pretty parameter yields the same result as
+ omitting the parameter.
- pg_options_to_table returns the set of storage
- option name/value pairs
- (option_name/option_value) when passed
- pg_class.reloptions or
- pg_attribute.attoptions.
-
-
- pg_tablespace_databases allows a tablespace to be
- examined. It returns the set of OIDs of databases that have objects stored
- in the tablespace. If this function returns any rows, the tablespace is not
- empty and cannot be dropped. To display the specific objects populating the
- tablespace, you will need to connect to the databases identified by
- pg_tablespace_databases and query their
- pg_class catalogs.
-
-
- pg_typeof returns the OID of the data type of the
- value that is passed to it. This can be helpful for troubleshooting or
- dynamically constructing SQL queries. The function is declared as
- returning regtype, which is an OID alias type (see
- ); this means that it is the same as an
- OID for comparison purposes but displays as a type name. For example:
-SELECT pg_typeof(33);
-
- pg_typeof
------------
- integer
-(1 row)
-
-SELECT typlen FROM pg_type WHERE oid = pg_typeof(33);
- typlen
---------
- 4
-(1 row)
-
-
-
- The expression collation for returns the collation of the
- value that is passed to it. Example:
-SELECT collation for (description) FROM pg_description LIMIT 1;
- pg_collation_for
-------------------
- "default"
-(1 row)
-
-SELECT collation for ('foo' COLLATE "de_DE");
- pg_collation_for
-------------------
- "de_DE"
-(1 row)
-
- The value might be quoted and schema-qualified. If no collation is derived
- for the argument expression, then a null value is returned. If the argument
- is not of a collatable data type, then an error is raised.
-
-
- The functions to_regclass, to_regcollation,
- to_regnamespace, to_regoper,
- to_regoperator, to_regrole,
- to_regproc, to_regprocedure and
- to_regtype translate relation, collation, schema,
- operator, role, function, and type names (given as text) to
- objects of the corresponding
reg* type (see
- linkend="datatype-oid"/> about the types). These functions differ from a
- cast from text in that they don't accept a numeric OID, and that they
- return null rather than throwing an error if the name is not found (or, for
- to_regproc and to_regoper, if the
- given name matches multiple objects).
-
-
-
-
-
-
-
-
-
-
pg_identify_object_as_address
-
-
-
-
-
lists functions related to
database object identification and addressing.
Object Information and Addressing Functions
- 3">
+ 1">
- Name Return Type Description
+ |
+ Function
+
+ Description
+
+
|
-
pg_describe_object(classid oid, objid oid, objsubid integer)
- text
- get description of a database object
+
+
+
pg_describe_object (
classid oid,
objid oid,
objsubid integer )
+ text
+
+ Returns a textual description of a database object identified by
+ catalog OID, object OID, and sub-object ID (such as a column number
+ within a table; the sub-object ID is zero when referring to a whole
+ object). This description is intended to be human-readable, and might
+ be translated, depending on server configuration. This is especially
+ useful to determine the identity of an object referenced in the
+ pg_depend catalog.
+
+
|
-
pg_identify_object(classid oid, objid oid, objsubid integer)
-
type text, schema text, name text, identity text
- get identity of a database object
+
+
+
pg_identify_object (
classid oid,
objid oid,
objsubid integer )
+ record
+
+ Returns a row containing enough information to uniquely identify the
+ database object specified by catalog OID, object OID and sub-object
+ ID.
+ This information is intended to be machine-readable, and is never
+ translated.
+
type identifies the type of database object;
+
schema is the schema name that the object
+ belongs in, or NULL for object types that do not
+ belong to schemas;
+
name is the name of the object, quoted if
+ necessary, if the name (along with schema name, if pertinent) is
+ sufficient to uniquely identify the object,
+ otherwise NULL;
+
identity is the complete object identity, with
+ the precise format depending on object type, and each name within the
+ format being schema-qualified and quoted as necessary.
+
+
|
-
pg_identify_object_as_address(classid oid, objid oid, objsubid integer)
-
type text, object_names text[], object_args text[]
- get external representation of a database object's address
+
+
pg_identify_object_as_address
+
+
pg_identify_object_as_address (
classid oid,
objid oid,
objsubid integer )
+ record
+
+ Returns a row containing enough information to uniquely identify the
+ database object specified by catalog OID, object OID and sub-object
+ ID.
+ The returned information is independent of the current server, that
+ is, it could be used to identify an identically named object in
+ another server.
+
type identifies the type of database object;
+ are text arrays that together form a reference to the object.
+ These three values can be passed
+ to pg_get_object_address to obtain the internal
+ address of the object.
+
+
|
-
pg_get_object_address(type text, object_names text[], object_args text[])
-
classid oid, objid oid, objsubid integer
- get address of a database object from its external representation
+
+
+
pg_get_object_address (
type text,
object_names text[],
object_args text[] )
+ record
+
+ Returns a row containing enough information to uniquely identify the
+ database object specified by a type code and object name and argument
+ arrays.
+ The returned values are the ones that would be used in system catalogs
+ such as pg_depend; they can be passed to
+ other system functions such as pg_describe_object
+ or pg_identify_object.
+
classid is the OID of the system catalog
+ containing the object;
+
objid is the OID of the object itself, and
+
objsubid is the sub-object ID, or zero if none.
+ This function is the inverse
+ of pg_identify_object_as_address.
+
- pg_describe_object returns a textual description of a database
- object specified by catalog OID, object OID, and sub-object ID (such as
- a column number within a table; the sub-object ID is zero when referring
- to a whole object).
- This description is intended to be human-readable, and might be translated,
- depending on server configuration.
- This is useful to determine the identity of an object as stored in the
- pg_depend catalog.
-
-
- pg_identify_object returns a row containing enough information
- to uniquely identify the database object specified by catalog OID, object OID and
- sub-object ID. This information is intended to be machine-readable,
- and is never translated.
-
type identifies the type of database object;
-
schema is the schema name that the object belongs in, or
- NULL for object types that do not belong to schemas;
-
name is the name of the object, quoted if necessary,
- if the name (along with schema name, if pertinent) is sufficient to
- uniquely identify the object, otherwise NULL;
-
identity is the complete object identity, with the
- precise format depending on object type, and each name within the format
- being schema-qualified and quoted as necessary.
-
-
- pg_identify_object_as_address returns a row containing
- enough information to uniquely identify the database object specified by
- catalog OID, object OID and sub-object ID. The returned
- information is independent of the current server, that is, it could be used
- to identify an identically named object in another server.
-
type identifies the type of database object;
-
object_names and
object_args
- are text arrays that together form a reference to the object.
- These three values can be passed to
- pg_get_object_address to obtain the internal address
- of the object.
- This function is the inverse of pg_get_object_address.
-
-
- pg_get_object_address returns a row containing enough
- information to uniquely identify the database object specified by its
- type and object name and argument arrays. The returned values are the
- ones that would be used in system catalogs such as pg_depend
- and can be passed to other system functions such as
- pg_identify_object or pg_describe_object.
-
classid is the OID of the system catalog containing the
- object;
-
objid is the OID of the object itself, and
-
objsubid is the sub-object ID, or zero if none.
- This function is the inverse of pg_identify_object_as_address.
-
-
-
-
-
-
-
-
-
-
-
about database objects
Comment Information Functions
- 3">
+ 1">
- Name Return Type Description
+ |
+ Function
+
+ Description
+
+
|
-
>col_description(table_oid, column_number)>
- text>
- get comment for a table columnry>
- >
- |
-
obj_description(object_oid, catalog_name)>
- <entry>text>
- <entry>get comment for a database object>
-
- |
-
obj_description(object_oid)
- text
- <entry>get comment for a database object (deprecated)
+
role="func_table_entry">>
+ >
+ >
+
col_description (
table oid,
column integer )
+ text>
+ </para>
+ <para>
+ Returns the comment for a table column, which is specified by the OID
+ of its table and its column number.
+ (obj_description cannot be used for table
+ columns, since columns do not have OIDs of their own.)
+ </para>
+
|
-
shobj_description(object_oid, catalog_name)
- text
- get comment for a shared database object
+
+
+
obj_description (
object oid,
catalog name )
+ text
+
+ Returns the comment for a database object specified by its OID and the
+ name of the containing system catalog. For
+ example, obj_description(123456, 'pg_class') would
+ retrieve the comment for the table with OID 123456.
+
-
-
-
-
- col_description returns the comment for a table
- column, which is specified by the OID of its table and its column number.
- (obj_description cannot be used for table columns
- since columns do not have OIDs of their own.)
-
-
- The two-parameter form of obj_description returns the
- comment for a database object specified by its OID and the name of the
- containing system catalog. For example,
- obj_description(123456,'pg_class')
- would retrieve the comment for the table with OID 123456.
- The one-parameter form of obj_description requires only
- the object OID. It is deprecated since there is no guarantee that
- OIDs are unique across different system catalogs; therefore, the wrong
- comment might be returned.
-
-
- shobj_description is used just like
- obj_description except it is used for retrieving
- comments on shared objects. Some system catalogs are global to all
- databases within each cluster, and the descriptions for objects in them
- are stored globally as well.
-
-
-
-
-
-
-
pg_current_xact_id_if_assigned
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
txid_current_if_assigned
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
txid_visible_in_snapshot
-
+ |
+
obj_description (
object oid )
+ text
+
+ Returns the comment for a database object specified by its OID alone.
+ This is deprecated since there is no guarantee
+ that OIDs are unique across different system catalogs; therefore, the
+ wrong comment might be returned.
+
+
-
-
+ |
+
+
+
shobj_description (
object oid,
catalog name )
+ text
+
+ Returns the comment for a shared database object specified by its OID
+ and the name of the containing system catalog. This is just
+ like obj_description except that it is used for
+ retrieving comments on shared objects (that is, databases, roles, and
+ tablespaces). Some system catalogs are global to all databases within
+ each cluster, and the descriptions for objects in them are stored
+ globally as well.
+
+
+