53.68. pg_cursors
В представлении pg_cursors перечисляются курсоры, доступные в данный момент. Курсоры могут быть созданы несколькими способами:
через оператор DECLARE в SQL
через сообщение Bind в клиент-серверном протоколе, как описано в Подразделе 54.2.3
через интерфейс программирования сервера (SPI, Server Programming Interface), как описано в Разделе 48.1
В представлении pg_cursors показываются курсоры, полученные любым способом. Курсор существует только на протяжении транзакции, в которой он определён, если только он не был объявлен с указанием WITH HOLD. Поэтому не удерживаемые курсоры показываются в этом представлении только пока не завершится создавшая их транзакция.
Примечание
Курсоры используются внутри системы для реализации некоторых компонентов Postgres Pro, таких как процедурные языки. Таким образом, в представлении pg_cursors могут быть курсоры, которые пользователи не создавали явно.
Таблица 53.69. Столбцы pg_cursors
| Имя | Тип | Описание |
|---|---|---|
name | text | Имя курсора |
statement | text | Дословная строка запроса, создавшего данный курсор |
is_holdable | boolean | True, если курсор удерживаемый (то есть, к нему можно обращаться после того, как будет зафиксирована транзакция, в которой он объявлен); в противном случае — false |
is_binary | boolean | True, если курсор был объявлен с указанием BINARY; в противном случае — false |
is_scrollable | boolean | True, если курсор прокручиваемый (то есть, позволяет получать строки непоследовательным образом); в противном случае — false |
creation_time | timestamptz | Время, в которое был объявлен курсор |
Представление pg_cursors доступно только для чтения.
53.68. pg_cursors
The pg_cursors view lists the cursors that are currently available. Cursors can be defined in several ways:
via the DECLARE statement in SQL
via the Bind message in the frontend/backend protocol, as described in Section 54.2.3
via the Server Programming Interface (SPI), as described in Section 48.1
The pg_cursors view displays cursors created by any of these means. Cursors only exist for the duration of the transaction that defines them, unless they have been declared WITH HOLD. Therefore non-holdable cursors are only present in the view until the end of their creating transaction.
Note
Cursors are used internally to implement some of the components of Postgres Pro, such as procedural languages. Therefore, the pg_cursors view might include cursors that have not been explicitly created by the user.
Table 53.69. pg_cursors Columns
| Name | Type | Description |
|---|---|---|
name | text | The name of the cursor |
statement | text | The verbatim query string submitted to declare this cursor |
is_holdable | boolean | true if the cursor is holdable (that is, it can be accessed after the transaction that declared the cursor has committed); false otherwise |
is_binary | boolean | true if the cursor was declared BINARY; false otherwise |
is_scrollable | boolean | true if the cursor is scrollable (that is, it allows rows to be retrieved in a nonsequential manner); false otherwise |
creation_time | timestamptz | The time at which the cursor was declared |
The pg_cursors view is read only.