OSDN Git Service

Add a new system view, pg_cursors, that displays the currently available
authorNeil Conway <neilc@samurai.com>
Wed, 18 Jan 2006 06:49:30 +0000 (06:49 +0000)
committerNeil Conway <neilc@samurai.com>
Wed, 18 Jan 2006 06:49:30 +0000 (06:49 +0000)
commit33e06ebccbc21677be6dbc112e3d150bd13b17cb
treeb55b21dfeefca076512b2cc8f597eace12f3eeb4
parent558bc2584d7e79801acb8344b79838cd3511915b
Add a new system view, pg_cursors, that displays the currently available
cursors. Patch from Joachim Wieland, review and ediorialization by Neil
Conway. The view lists cursors defined by DECLARE CURSOR, using SPI, or
via the Bind message of the frontend/backend protocol. This means the
view does not list the unnamed portal or the portal created to implement
EXECUTE. Because we do list SPI portals, there might be more rows in
this view than you might expect if you are using SPI implicitly (e.g.
via a procedural language).

Per recent discussion on -hackers, the query string included in the
view for cursors defined by DECLARE CURSOR is based on
debug_query_string. That means it is not accurate if multiple queries
separated by semicolons are submitted as one query string. However,
there doesn't seem a trivial fix for that: debug_query_string
is better than nothing. I also changed SPI_cursor_open() to include
the source text for the portal it creates: AFAICS there is no reason
not to do this.

Update the documentation and regression tests, bump the catversion.
17 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/protocol.sgml
doc/src/sgml/ref/close.sgml
doc/src/sgml/ref/declare.sgml
src/backend/catalog/system_views.sql
src/backend/commands/portalcmds.c
src/backend/commands/prepare.c
src/backend/executor/spi.c
src/backend/tcop/postgres.c
src/backend/utils/mmgr/portalmem.c
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/utils/builtins.h
src/include/utils/portal.h
src/test/regress/expected/portals.out
src/test/regress/expected/rules.out
src/test/regress/sql/portals.sql