Commit 28d8b42c authored by Jan Wieck's avatar Jan Wieck

Speedup of PL/pgSQL by calling ExecEvalExpr() directly

instead of SPI_execp() for simple expressions.

Jan
parent d611ccb8
...@@ -3,25 +3,16 @@ ...@@ -3,25 +3,16 @@
* spi.c-- * spi.c--
* Server Programming Interface * Server Programming Interface
* *
* $Id: spi.c,v 1.31 1999/01/27 00:36:21 tgl Exp $ * $Id: spi.c,v 1.32 1999/01/27 16:15:20 wieck Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "executor/spi.h" #include "executor/spi.h"
#include "executor/spi_priv.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "access/printtup.h" #include "access/printtup.h"
#include "fmgr.h" #include "fmgr.h"
typedef struct
{
QueryTreeList *qtlist; /* malloced */
uint32 processed; /* by Executor */
SPITupleTable *tuptable;
Portal portal; /* portal per procedure */
MemoryContext savedcxt;
CommandId savedId;
} _SPI_connection;
static Portal _SPI_portal = (Portal) NULL; static Portal _SPI_portal = (Portal) NULL;
static _SPI_connection *_SPI_stack = NULL; static _SPI_connection *_SPI_stack = NULL;
static _SPI_connection *_SPI_current = NULL; static _SPI_connection *_SPI_current = NULL;
...@@ -32,24 +23,12 @@ uint32 SPI_processed = 0; ...@@ -32,24 +23,12 @@ uint32 SPI_processed = 0;
SPITupleTable *SPI_tuptable; SPITupleTable *SPI_tuptable;
int SPI_result; int SPI_result;
typedef struct
{
QueryTreeList *qtlist;
List *ptlist;
int nargs;
Oid *argtypes;
} _SPI_plan;
static int _SPI_execute(char *src, int tcount, _SPI_plan *plan); static int _SPI_execute(char *src, int tcount, _SPI_plan *plan);
static int _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount); static int _SPI_pquery(QueryDesc *queryDesc, EState *state, int tcount);
static int _SPI_execute_plan(_SPI_plan *plan, static int _SPI_execute_plan(_SPI_plan *plan,
Datum *Values, char *Nulls, int tcount); Datum *Values, char *Nulls, int tcount);
#define _SPI_CPLAN_CURCXT 0
#define _SPI_CPLAN_PROCXT 1
#define _SPI_CPLAN_TOPCXT 2
static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location); static _SPI_plan *_SPI_copy_plan(_SPI_plan *plan, int location);
static int _SPI_begin_call(bool execmem); static int _SPI_begin_call(bool execmem);
...@@ -178,6 +157,18 @@ SPI_finish() ...@@ -178,6 +157,18 @@ SPI_finish()
} }
void
SPI_push(void)
{
_SPI_curid++;
}
void
SPI_pop(void)
{
_SPI_curid--;
}
int int
SPI_exec(char *src, int tcount) SPI_exec(char *src, int tcount)
{ {
......
...@@ -72,6 +72,8 @@ extern int SPI_result; ...@@ -72,6 +72,8 @@ extern int SPI_result;
extern int SPI_connect(void); extern int SPI_connect(void);
extern int SPI_finish(void); extern int SPI_finish(void);
extern void SPI_push(void);
extern void SPI_pop(void);
extern int SPI_exec(char *src, int tcount); extern int SPI_exec(char *src, int tcount);
extern int SPI_execp(void *plan, Datum *values, char *Nulls, int tcount); extern int SPI_execp(void *plan, Datum *values, char *Nulls, int tcount);
extern void *SPI_prepare(char *src, int nargs, Oid *argtypes); extern void *SPI_prepare(char *src, int nargs, Oid *argtypes);
......
/*-------------------------------------------------------------------------
*
* spi.c--
* Server Programming Interface private declarations
*
* $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.1 1999/01/27 16:15:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef SPI_PRIV_H
#define SPI_PRIV_H
#include "catalog/pg_type.h"
#include "access/printtup.h"
typedef struct
{
QueryTreeList *qtlist; /* malloced */
uint32 processed; /* by Executor */
SPITupleTable *tuptable;
Portal portal; /* portal per procedure */
MemoryContext savedcxt;
CommandId savedId;
} _SPI_connection;
typedef struct
{
QueryTreeList *qtlist;
List *ptlist;
int nargs;
Oid *argtypes;
} _SPI_plan;
#define _SPI_CPLAN_CURCXT 0
#define _SPI_CPLAN_PROCXT 1
#define _SPI_CPLAN_TOPCXT 2
#endif /* SPI_PRIV_H */
This diff is collapsed.
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* procedural language * procedural language
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.2 1998/09/01 04:40:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/plpgsql.h,v 1.3 1999/01/27 16:15:22 wieck Exp $
* *
* This software is copyrighted by Jan Wieck - Hamburg. * This software is copyrighted by Jan Wieck - Hamburg.
* *
...@@ -143,6 +143,8 @@ typedef struct ...@@ -143,6 +143,8 @@ typedef struct
int exprno; int exprno;
char *query; char *query;
void *plan; void *plan;
Node *plan_simple_expr;
Oid plan_simple_type;
Oid *plan_argtypes; Oid *plan_argtypes;
int nparams; int nparams;
int params[1]; int params[1];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment