Commit 9ff695c9 authored by Tom Lane's avatar Tom Lane

Make SPI's execution of querystrings follow the rules agreed to for

command status at the interactive level.  SPI_processed, etc are set
in the same way as the returned command status would have been set if
the same querystring were issued interactively.  Per gripe from
Michael Paesold 25-Sep-02.
parent ba0edcf4
This diff is collapsed.
......@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.302 2002/10/14 22:14:35 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.303 2002/10/14 23:49:20 tgl Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
......@@ -119,8 +119,6 @@ int XfuncMode = 0;
static int InteractiveBackend(StringInfo inBuf);
static int SocketBackend(StringInfo inBuf);
static int ReadCommand(StringInfo inBuf);
static List *pg_parse_query(StringInfo query_string, Oid *typev, int nargs);
static List *pg_analyze_and_rewrite(Node *parsetree);
static void start_xact_command(void);
static void finish_xact_command(bool forceCommit);
static void SigHupHandler(SIGNAL_ARGS);
......@@ -367,7 +365,7 @@ pg_parse_and_rewrite(char *query_string, /* string to execute */
* we've seen a COMMIT or ABORT command; when we are in abort state, other
* commands are not processed any further than the raw parse stage.
*/
static List *
List *
pg_parse_query(StringInfo query_string, Oid *typev, int nargs)
{
List *raw_parsetree_list;
......@@ -395,7 +393,7 @@ pg_parse_query(StringInfo query_string, Oid *typev, int nargs)
*
* NOTE: for reasons mentioned above, this must be separate from raw parsing.
*/
static List *
List *
pg_analyze_and_rewrite(Node *parsetree)
{
List *querytree_list;
......@@ -1769,7 +1767,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.302 $ $Date: 2002/10/14 22:14:35 $\n");
puts("$Revision: 1.303 $ $Date: 2002/10/14 23:49:20 $\n");
}
/*
......
/*-------------------------------------------------------------------------
*
* spi.c
* spi_priv.h
* Server Programming Interface private declarations
*
* $Header: /cvsroot/pgsql/src/include/executor/spi_priv.h,v 1.12 2002/05/21 22:05:55 tgl Exp $
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: spi_priv.h,v 1.13 2002/10/14 23:49:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -12,9 +15,9 @@
#include "executor/spi.h"
typedef struct
{
List *qtlist;
uint32 processed; /* by Executor */
SPITupleTable *tuptable;
MemoryContext procCxt; /* procedure context */
......@@ -24,13 +27,20 @@ typedef struct
typedef struct
{
/* context containing _SPI_plan itself as well as subsidiary structures */
MemoryContext plancxt;
/* List of List of querytrees; one sublist per original parsetree */
List *qtlist;
/* List of plan trees --- length == # of querytrees, but flat list */
List *ptlist;
/* Argument types, if a prepared plan */
int nargs;
Oid *argtypes;
/* Command type of last original parsetree */
CmdType origCmdType;
} _SPI_plan;
#define _SPI_CPLAN_CURCXT 0
#define _SPI_CPLAN_PROCXT 1
#define _SPI_CPLAN_TOPCXT 2
......
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: tcopprot.h,v 1.49 2002/06/20 20:29:52 momjian Exp $
* $Id: tcopprot.h,v 1.50 2002/10/14 23:49:20 tgl Exp $
*
* OLD COMMENTS
* This file was created so that other c files could get the two
......@@ -35,12 +35,15 @@ extern bool ShowPortNumber;
#ifndef BOOTSTRAP_INCLUDE
extern List *pg_parse_query(StringInfo query_string, Oid *typev, int nargs);
extern List *pg_analyze_and_rewrite(Node *parsetree);
extern List *pg_parse_and_rewrite(char *query_string,
Oid *typev, int nargs);
extern Plan *pg_plan_query(Query *querytree);
extern void pg_exec_query_string(StringInfo query_string,
CommandDest dest,
MemoryContext parse_context);
#endif /* BOOTSTRAP_INCLUDE */
extern void die(SIGNAL_ARGS);
......
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