Supported Versions: Current (17) / 16 / 15 / 14 / 13
Development Versions: devel
Unsupported versions: 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

44.43. 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 45.2.3

  • via the Server Programming Interface (SPI), as described in Section 42.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 PostgreSQL, such as procedural languages. Therefore, the pg_cursors view might include cursors that have not been explicitly created by the user.

Table 44-43. 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.