From 66888f7424f7d6c7cea2c26e181054d1455d4e7a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 16 Apr 2007 01:14:58 +0000 Subject: Expose more cursor-related functionality in SPI: specifically, allow access to the planner's cursor-related planning options, and provide new FETCH/MOVE routines that allow access to the full power of those commands. Small refactoring of planner(), pg_plan_query(), and pg_plan_queries() APIs to make it convenient to pass the planning options down from SPI. This is the core-code portion of Pavel Stehule's patch for scrollable cursor support in plpgsql; I'll review and apply the plpgsql changes separately. --- src/include/executor/spi.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/include/executor/spi.h') diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index 80c8993c7c..c996f644c0 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.60 2007/03/25 23:27:59 tgl Exp $ + * $PostgreSQL: pgsql/src/include/executor/spi.h,v 1.61 2007/04/16 01:14:57 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -20,8 +20,8 @@ #include "postgres.h" /* - * These are not needed by this file, but used by other programs - * using SPI + * Most of these are not needed by this file, but may be used by + * user-written code that uses SPI */ #include "access/heapam.h" #include "access/xact.h" @@ -32,6 +32,7 @@ #include "executor/executor.h" #include "nodes/execnodes.h" #include "nodes/params.h" +#include "nodes/parsenodes.h" #include "nodes/plannodes.h" #include "nodes/primnodes.h" #include "nodes/relation.h" @@ -105,6 +106,8 @@ extern int SPI_execute_snapshot(SPIPlanPtr plan, Snapshot crosscheck_snapshot, bool read_only, long tcount); extern SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes); +extern SPIPlanPtr SPI_prepare_cursor(const char *src, int nargs, Oid *argtypes, + int cursorOptions); extern SPIPlanPtr SPI_saveplan(SPIPlanPtr plan); extern int SPI_freeplan(SPIPlanPtr plan); @@ -136,6 +139,8 @@ extern Portal SPI_cursor_open(const char *name, SPIPlanPtr plan, extern Portal SPI_cursor_find(const char *name); extern void SPI_cursor_fetch(Portal portal, bool forward, long count); extern void SPI_cursor_move(Portal portal, bool forward, long count); +extern void SPI_scroll_cursor_fetch(Portal, FetchDirection direction, long count); +extern void SPI_scroll_cursor_move(Portal, FetchDirection direction, long count); extern void SPI_cursor_close(Portal portal); extern void AtEOXact_SPI(bool isCommit); -- cgit v1.2.1