pg_prepared_statements
是一个列出当前会话中所有可用预处理语句的系统目录视图。
pg_prepared_statements
在PostgreSQL 8.2中添加。
按PostgreSQL版本定义
pg_prepared_statements (PostgreSQL 17)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | result_types | regtype[] | | | from_sql | boolean | | | generic_plans | bigint | | | custom_plans | bigint | | |
pg_prepared_statements (PostgreSQL 16)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | result_types | regtype[] | | | from_sql | boolean | | | generic_plans | bigint | | | custom_plans | bigint | | |
pg_prepared_statements (PostgreSQL 15)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | from_sql | boolean | | | generic_plans | bigint | | | custom_plans | bigint | | |
pg_prepared_statements (PostgreSQL 14)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | from_sql | boolean | | | generic_plans | bigint | | | custom_plans | bigint | | |
pg_prepared_statements (PostgreSQL 13)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | from_sql | boolean | | |
pg_prepared_statements (PostgreSQL 12)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | from_sql | boolean | | |
pg_prepared_statements (PostgreSQL 11)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | from_sql | boolean | | |
pg_prepared_statements (PostgreSQL 10)
View "pg_catalog.pg_prepared_statements" Column | Type | Collation | Nullable | Default -----------------+--------------------------+-----------+----------+--------- name | text | | | statement | text | | | prepare_time | timestamp with time zone | | | parameter_types | regtype[] | | | from_sql | boolean | | |
pg_prepared_statements (PostgreSQL 9.6)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 9.5)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 9.4)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 9.3)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 9.2)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 9.1)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 9.0)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean |
pg_prepared_statements (PostgreSQL 8.4)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean | View definition: SELECT p.name, p.statement, p.prepare_time, p.parameter_types, p.from_sql FROM pg_prepared_statement() p(name, statement, prepare_time, parameter_types, from_sql);
pg_prepared_statements (PostgreSQL 8.3)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean | View definition: SELECT p.name, p.statement, p.prepare_time, p.parameter_types, p.from_sql FROM pg_prepared_statement() p(name text, statement text, prepare_time timestamp with time zone, parameter_types regtype[], from_sql boolean);
pg_prepared_statements (PostgreSQL 8.2)
View "pg_catalog.pg_prepared_statements" Column | Type | Modifiers -----------------+--------------------------+----------- name | text | statement | text | prepare_time | timestamp with time zone | parameter_types | regtype[] | from_sql | boolean | View definition: SELECT p.name, p."statement", p.prepare_time, p.parameter_types, p.from_sql FROM pg_prepared_statement() p(name text, "statement" text, prepare_time timestamp with time zone, parameter_types regtype[], from_sql boolean);
更改历史记录
- PostgreSQL 16
- 添加了列
result_types
(提交 84ad713c)
- 添加了列
- PostgreSQL 14
- PostgreSQL 8.2
- 添加 (提交 44b928e8)
示例
来自pg_prepared_statements
的示例行
postgres=# PREPARE fooplan (int, text) AS INSERT INTO foo VALUES($1, $2); postgres=# SELECT * FROM pg_prepared_statements\gx -[ RECORD 1 ]---+------------------------------- name | fooplan statement | PREPARE fooplan (int, text) AS+ | SELECT $1, $2 FROM foo; prepare_time | 2022-05-01 08:12:58.982591+01 parameter_types | {integer,text} from_sql | t generic_plans | 0 custom_plans | 0
参考文献
- PostgreSQL文档: pg_prepared_statements