? .cscope.out
? .gdb_history
? .pc
? .vimrc
? desc.txt
? patches
? rscope
? ssizecheck.py
? xfind
? ytest
? zconf
? zconf22
? zconf23
? zconf24
? zconf25
? zmake
? zmake22
? zmake23
? zmake25
? src/pl/plpython/Makefile.test
Index: doc/src/sgml/ref/close.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/close.sgml,v
retrieving revision 1.24
diff -p -u -c -r1.24 close.sgml
*** doc/src/sgml/ref/close.sgml	16 Sep 2006 00:30:17 -0000	1.24
--- doc/src/sgml/ref/close.sgml	8 Apr 2007 07:59:23 -0000
*************** PostgreSQL documentation
*** 26,31 ****
--- 26,32 ----
   <refsynopsisdiv>
  <synopsis>
  CLOSE <replaceable class="PARAMETER">name</replaceable>
+ CLOSE ALL
  </synopsis>
   </refsynopsisdiv>
  
*************** CLOSE <replaceable class="PARAMETER">nam
*** 63,68 ****
--- 64,79 ----
       </para>
      </listitem>
     </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>ALL</literal></term>
+     <listitem>
+      <para>
+       Means that all cursors in this session should be released.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
    </variablelist>
   </refsect1>
  
Index: doc/src/sgml/ref/deallocate.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/deallocate.sgml,v
retrieving revision 1.9
diff -p -u -c -r1.9 deallocate.sgml
*** doc/src/sgml/ref/deallocate.sgml	16 Sep 2006 00:30:18 -0000	1.9
--- doc/src/sgml/ref/deallocate.sgml	8 Apr 2007 07:59:23 -0000
*************** PostgreSQL documentation
*** 26,31 ****
--- 26,32 ----
   <refsynopsisdiv>
  <synopsis>
  DEALLOCATE [ PREPARE ] <replaceable class="parameter">name</replaceable>
+ DEALLOCATE ALL
  </synopsis>
   </refsynopsisdiv>
  
*************** DEALLOCATE [ PREPARE ] <replaceable clas
*** 65,71 ****
--- 66,82 ----
       </para>
      </listitem>
     </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>ALL</literal></term>
+     <listitem>
+      <para>
+       Means that all prepared statement should be released.
+      </para>
+     </listitem>
+    </varlistentry>
    </variablelist>
+ 
   </refsect1>
  
   <refsect1>
Index: doc/src/sgml/ref/reset.sgml
===================================================================
RCS file: /projects/cvsroot/pgsql/doc/src/sgml/ref/reset.sgml,v
retrieving revision 1.32
diff -p -u -c -r1.32 reset.sgml
*** doc/src/sgml/ref/reset.sgml	16 Sep 2006 00:30:19 -0000	1.32
--- doc/src/sgml/ref/reset.sgml	8 Apr 2007 07:59:23 -0000
*************** PostgreSQL documentation
*** 22,27 ****
--- 22,28 ----
  <synopsis>
  RESET <replaceable class="PARAMETER">configuration_parameter</replaceable>
  RESET ALL
+ RESET { SESSION | PLANS | TEMP | TEMPORARY }
  </synopsis>
   </refsynopsisdiv>
    
*************** SET <replaceable class="parameter">confi
*** 52,57 ****
--- 53,69 ----
     See the <command>SET</> reference page for details on the
     transaction behavior of <command>RESET</>.
    </para>
+ 
+   <para>
+    <command>RESET</> can be used for releasing internal resources that are
+    usually freed at the end of session.  <command>RESET TEMP</>
+    drops all temporary tables created in current session.
+    <command>RESET PLANS</> releases all internally cached plans.
+   </para>
+   <para>
+    <command>RESET SESSION</> releases all externally visible resources
+    for current session.
+   </para>
   </refsect1>
  
   <refsect1>
*************** SET <replaceable class="parameter">confi
*** 76,81 ****
--- 88,131 ----
       </para>
      </listitem>
     </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>TEMP, TEMPORARY</literal></term>
+     <listitem>
+      <para>
+       Drop all temporary tables created in current session.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>PLANS</literal></term>
+     <listitem>
+      <para>
+       Release all cached query plans.
+      </para>
+     </listitem>
+    </varlistentry>
+ 
+    <varlistentry>
+     <term><literal>SESSION</literal></term>
+     <listitem>
+      <para>
+       Release all resources for current session.
+       The effect is same as executing following command sequence:
+ <synopsis>
+ SET SESSION AUTHORIZATION DEFAULT;
+ RESET ALL;
+ DEALLOCATE ALL;
+ CLOSE ALL;
+ UNLISTEN *;
+ RESET PLANS;
+ RESET TEMP;
+ </synopsis>
+      </para>
+     </listitem>
+    </varlistentry>
+ 
    </variablelist>
   </refsect1>
  
Index: src/backend/catalog/namespace.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/catalog/namespace.c,v
retrieving revision 1.93
diff -p -u -c -r1.93 namespace.c
*** src/backend/catalog/namespace.c	23 Mar 2007 19:53:51 -0000	1.93
--- src/backend/catalog/namespace.c	8 Apr 2007 07:59:23 -0000
*************** InitTempTableNamespace(void)
*** 1941,1946 ****
--- 1941,1966 ----
  }
  
  /*
+  * Clear all temp tables from out temp namespace.
+  */
+ void
+ ResetTempTableNamespace(void)
+ {
+ 	char		namespaceName[NAMEDATALEN];
+ 	Oid			namespaceId;
+ 
+ 	/* find oid */
+ 	snprintf(namespaceName, sizeof(namespaceName), "pg_temp_%d", MyBackendId);
+ 	namespaceId = GetSysCacheOid(NAMESPACENAME,
+ 								 CStringGetDatum(namespaceName),
+ 								 0, 0, 0);
+ 
+ 	/* clean if exists */
+ 	if (OidIsValid(namespaceId))
+ 		RemoveTempRelations(namespaceId);
+ }
+ 
+ /*
   * End-of-transaction cleanup for namespaces.
   */
  void
Index: src/backend/commands/async.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/async.c,v
retrieving revision 1.135
diff -p -u -c -r1.135 async.c
*** src/backend/commands/async.c	5 Jan 2007 22:19:25 -0000	1.135
--- src/backend/commands/async.c	8 Apr 2007 07:59:23 -0000
*************** static bool unlistenExitRegistered = fal
*** 127,133 ****
  bool		Trace_notify = false;
  
  
- static void Async_UnlistenAll(void);
  static void Async_UnlistenOnExit(int code, Datum arg);
  static void ProcessIncomingNotify(void);
  static void NotifyMyFrontEnd(char *relname, int32 listenerPID);
--- 127,132 ----
*************** Async_Unlisten(const char *relname)
*** 335,341 ****
   *
   *--------------------------------------------------------------
   */
! static void
  Async_UnlistenAll(void)
  {
  	Relation	lRel;
--- 334,340 ----
   *
   *--------------------------------------------------------------
   */
! void
  Async_UnlistenAll(void)
  {
  	Relation	lRel;
Index: src/backend/commands/portalcmds.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/portalcmds.c,v
retrieving revision 1.62
diff -p -u -c -r1.62 portalcmds.c
*** src/backend/commands/portalcmds.c	13 Mar 2007 00:33:39 -0000	1.62
--- src/backend/commands/portalcmds.c	8 Apr 2007 07:59:23 -0000
*************** PerformPortalClose(const char *name)
*** 236,246 ****
  {
  	Portal		portal;
  
  	/*
  	 * Disallow empty-string cursor name (conflicts with protocol-level
  	 * unnamed portal).
  	 */
! 	if (!name || name[0] == '\0')
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_CURSOR_NAME),
  				 errmsg("invalid cursor name: must not be empty")));
--- 236,253 ----
  {
  	Portal		portal;
  
+ 	/* NULL means CLOSE ALL */
+ 	if (name == NULL)
+ 	{
+ 		PortalHashTableDeleteAll();
+ 		return;
+ 	}
+ 
  	/*
  	 * Disallow empty-string cursor name (conflicts with protocol-level
  	 * unnamed portal).
  	 */
! 	if (name[0] == '\0')
  		ereport(ERROR,
  				(errcode(ERRCODE_INVALID_CURSOR_NAME),
  				 errmsg("invalid cursor name: must not be empty")));
Index: src/backend/commands/prepare.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/prepare.c,v
retrieving revision 1.70
diff -p -u -c -r1.70 prepare.c
*** src/backend/commands/prepare.c	13 Mar 2007 00:33:39 -0000	1.70
--- src/backend/commands/prepare.c	8 Apr 2007 07:59:24 -0000
*************** FetchPreparedStatementTargetList(Prepare
*** 575,581 ****
  void
  DeallocateQuery(DeallocateStmt *stmt)
  {
! 	DropPreparedStatement(stmt->name, true);
  }
  
  /*
--- 575,584 ----
  void
  DeallocateQuery(DeallocateStmt *stmt)
  {
! 	if (stmt->name)
! 		DropPreparedStatement(stmt->name, true);
! 	else
! 		DropAllPreparedStatements();
  }
  
  /*
*************** DropPreparedStatement(const char *stmt_n
*** 602,607 ****
--- 605,635 ----
  }
  
  /*
+  * Drop all cached statements.
+  */
+ void
+ DropAllPreparedStatements(void)
+ {
+ 	HASH_SEQ_STATUS seq;
+ 	PreparedStatement *entry;
+ 
+ 	/* nothing cached */
+ 	if (!prepared_queries)
+ 		return;
+ 
+ 	/* walk over cache */
+ 	hash_seq_init(&seq, prepared_queries);
+ 	while ((entry = hash_seq_search(&seq)) != NULL)
+ 	{
+ 		/* Release the plancache entry */
+ 		DropCachedPlan(entry->plansource);
+ 
+ 		/* Now we can remove the hash table entry */
+ 		hash_search(prepared_queries, entry->stmt_name, HASH_REMOVE, NULL);
+ 	}
+ }
+ 
+ /*
   * Implements the 'EXPLAIN EXECUTE' utility statement.
   */
  void
Index: src/backend/parser/gram.y
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.587
diff -p -u -c -r2.587 gram.y
*** src/backend/parser/gram.y	8 Apr 2007 00:26:34 -0000	2.587
--- src/backend/parser/gram.y	8 Apr 2007 07:59:25 -0000
*************** ClosePortalStmt:
*** 1667,1672 ****
--- 1667,1678 ----
  					n->portalname = $2;
  					$$ = (Node *)n;
  				}
+ 			| CLOSE ALL
+ 				{
+ 					ClosePortalStmt *n = makeNode(ClosePortalStmt);
+ 					n->portalname = NULL;
+ 					$$ = (Node *)n;
+ 				}
  		;
  
  
*************** DeallocateStmt: DEALLOCATE name
*** 5591,5596 ****
--- 5597,5614 ----
  						n->name = $3;
  						$$ = (Node *) n;
  					}
+ 				| DEALLOCATE ALL
+ 					{
+ 						DeallocateStmt *n = makeNode(DeallocateStmt);
+ 						n->name = NULL;
+ 						$$ = (Node *) n;
+ 					}
+ 				| DEALLOCATE PREPARE ALL
+ 					{
+ 						DeallocateStmt *n = makeNode(DeallocateStmt);
+ 						n->name = NULL;
+ 						$$ = (Node *) n;
+ 					}
  		;
  
  /*****************************************************************************
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/tcop/utility.c,v
retrieving revision 1.276
diff -p -u -c -r1.276 utility.c
*** src/backend/tcop/utility.c	2 Apr 2007 03:49:39 -0000	1.276
--- src/backend/tcop/utility.c	8 Apr 2007 07:59:25 -0000
*************** ProcessUtility(Node *parsetree,
*** 990,996 ****
  			{
  				VariableResetStmt *n = (VariableResetStmt *) parsetree;
  
! 				ResetPGVariable(n->name);
  			}
  			break;
  
--- 990,996 ----
  			{
  				VariableResetStmt *n = (VariableResetStmt *) parsetree;
  
! 				ResetPGVariable(n->name, isTopLevel);
  			}
  			break;
  
*************** CreateCommandTag(Node *parsetree)
*** 1387,1393 ****
  			break;
  
  		case T_ClosePortalStmt:
! 			tag = "CLOSE CURSOR";
  			break;
  
  		case T_FetchStmt:
--- 1387,1399 ----
  			break;
  
  		case T_ClosePortalStmt:
! 			{
! 				ClosePortalStmt *stmt = (ClosePortalStmt *)parsetree;
! 				if (stmt->portalname == NULL)
! 					tag = "CLOSE CURSOR ALL";
! 				else
! 					tag = "CLOSE CURSOR";
! 			}
  			break;
  
  		case T_FetchStmt:
*************** CreateCommandTag(Node *parsetree)
*** 1746,1752 ****
  			break;
  
  		case T_VariableResetStmt:
! 			tag = "RESET";
  			break;
  
  		case T_CreateTrigStmt:
--- 1752,1764 ----
  			break;
  
  		case T_VariableResetStmt:
! 			{
! 				VariableResetStmt *stmt = (VariableResetStmt *)parsetree;
! 				if (pg_strcasecmp(stmt->name, "session") == 0)
! 					tag = "RESET SESSION";
! 				else
! 					tag = "RESET";
! 			}
  			break;
  
  		case T_CreateTrigStmt:
*************** CreateCommandTag(Node *parsetree)
*** 1856,1862 ****
  			break;
  
  		case T_DeallocateStmt:
! 			tag = "DEALLOCATE";
  			break;
  
  		/* already-planned queries */
--- 1868,1880 ----
  			break;
  
  		case T_DeallocateStmt:
! 			{
! 				DeallocateStmt *stmt = (DeallocateStmt *)parsetree;
! 				if (stmt->name == NULL)
! 					tag = "DEALLOCATE ALL";
! 				else
! 					tag = "DEALLOCATE";
! 			}
  			break;
  
  		/* already-planned queries */
Index: src/backend/utils/cache/plancache.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/cache/plancache.c,v
retrieving revision 1.5
diff -p -u -c -r1.5 plancache.c
*** src/backend/utils/cache/plancache.c	26 Mar 2007 00:36:19 -0000	1.5
--- src/backend/utils/cache/plancache.c	8 Apr 2007 07:59:26 -0000
*************** PlanCacheCallback(Datum arg, Oid relid)
*** 881,886 ****
--- 881,895 ----
  }
  
  /*
+  * ResetPlanCache: drop all cached plans.
+  */
+ void
+ ResetPlanCache(void)
+ {
+ 	PlanCacheCallback((Datum)0, InvalidOid);
+ }
+ 
+ /*
   * ScanQueryForRelids callback function for PlanCacheCallback
   */
  static void
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.383
diff -p -u -c -r1.383 guc.c
*** src/backend/utils/misc/guc.c	19 Mar 2007 23:38:30 -0000	1.383
--- src/backend/utils/misc/guc.c	8 Apr 2007 07:59:27 -0000
***************
*** 32,37 ****
--- 32,38 ----
  #include "access/xact.h"
  #include "catalog/namespace.h"
  #include "commands/async.h"
+ #include "commands/prepare.h"
  #include "commands/vacuum.h"
  #include "commands/variable.h"
  #include "commands/trigger.h"
***************
*** 61,66 ****
--- 62,68 ----
  #include "utils/memutils.h"
  #include "utils/pg_locale.h"
  #include "utils/plancache.h"
+ #include "utils/portal.h"
  #include "utils/ps_status.h"
  #include "utils/tzparser.h"
  #include "utils/xml.h"
*************** GetPGVariableResultDesc(const char *name
*** 4952,4964 ****
  }
  
  /*
   * RESET command
   */
  void
! ResetPGVariable(const char *name)
  {
  	if (pg_strcasecmp(name, "all") == 0)
  		ResetAllOptions();
  	else
  		set_config_option(name,
  						  NULL,
--- 4954,4998 ----
  }
  
  /*
+  * RESET SESSION command.
+  */
+ static void
+ ResetSession(bool isTopLevel)
+ {
+ 	/* disallow active tx */
+ 	PreventTransactionChain(isTopLevel, "RESET SESSION");
+ 
+ 	/* SET SESSION AUTHORIZATION DEFAULT; */
+ 	SetPGVariable("session_authorization", NIL, false);
+ 	/* RESET ALL; */
+ 	ResetAllOptions();
+ 	/* DEALLOCATE ALL; */
+ 	DropAllPreparedStatements();
+ 	/* CLOSE ALL */
+ 	PortalHashTableDeleteAll();
+ 	/* UNLISTEN *; */
+ 	Async_UnlistenAll();
+ 	/* RESET PLANS */
+ 	ResetPlanCache();
+ 	/* RESET TEMP */
+ 	ResetTempTableNamespace();
+ }
+ 
+ /*
   * RESET command
   */
  void
! ResetPGVariable(const char *name, bool isTopLevel)
  {
  	if (pg_strcasecmp(name, "all") == 0)
  		ResetAllOptions();
+ 	else if (pg_strcasecmp(name, "session") == 0)
+ 		ResetSession(isTopLevel);
+ 	else if (pg_strcasecmp(name, "temp") == 0
+ 			 || pg_strcasecmp(name, "temporary") == 0)
+ 		ResetTempTableNamespace();
+ 	else if (pg_strcasecmp(name, "plans") == 0)
+ 		ResetPlanCache();
  	else
  		set_config_option(name,
  						  NULL,
Index: src/backend/utils/mmgr/portalmem.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v
retrieving revision 1.100
diff -p -u -c -r1.100 portalmem.c
*** src/backend/utils/mmgr/portalmem.c	13 Mar 2007 00:33:42 -0000	1.100
--- src/backend/utils/mmgr/portalmem.c	8 Apr 2007 07:59:27 -0000
*************** PortalDrop(Portal portal, bool isTopComm
*** 452,457 ****
--- 452,480 ----
  	pfree(portal);
  }
  
+ /*
+  * Delete all declared cursors.
+  *
+  * Used by commands: CLOSE ALL, RESET SESSION
+  */
+ void
+ PortalHashTableDeleteAll(void)
+ {
+ 	HASH_SEQ_STATUS status;
+ 	PortalHashEnt *hentry;
+ 
+ 	if (PortalHashTable == NULL)
+ 		return;
+ 
+ 	hash_seq_init(&status, PortalHashTable);
+ 	while ((hentry = hash_seq_search(&status)) != NULL)
+ 	{
+ 		Portal portal = hentry->portal;
+ 		if (portal->status != PORTAL_ACTIVE)
+ 			PortalDrop(portal, false);
+ 	}
+ }
+ 
  
  /*
   * Pre-commit processing for portals.
Index: src/include/catalog/namespace.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/catalog/namespace.h,v
retrieving revision 1.45
diff -p -u -c -r1.45 namespace.h
*** src/include/catalog/namespace.h	23 Mar 2007 19:53:52 -0000	1.45
--- src/include/catalog/namespace.h	8 Apr 2007 07:59:27 -0000
*************** extern char *namespace_search_path;
*** 100,103 ****
--- 100,105 ----
  
  extern List *fetch_search_path(bool includeImplicit);
  
+ extern void ResetTempTableNamespace(void);
+ 
  #endif   /* NAMESPACE_H */
Index: src/include/commands/async.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/commands/async.h,v
retrieving revision 1.34
diff -p -u -c -r1.34 async.h
*** src/include/commands/async.h	5 Jan 2007 22:19:53 -0000	1.34
--- src/include/commands/async.h	8 Apr 2007 07:59:27 -0000
*************** extern bool Trace_notify;
*** 19,24 ****
--- 19,25 ----
  extern void Async_Notify(const char *relname);
  extern void Async_Listen(const char *relname);
  extern void Async_Unlisten(const char *relname);
+ extern void Async_UnlistenAll(void);
  
  /* perform (or cancel) outbound notify processing at transaction commit */
  extern void AtCommit_Notify(void);
Index: src/include/commands/prepare.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/commands/prepare.h,v
retrieving revision 1.25
diff -p -u -c -r1.25 prepare.h
*** src/include/commands/prepare.h	13 Mar 2007 00:33:43 -0000	1.25
--- src/include/commands/prepare.h	8 Apr 2007 07:59:27 -0000
*************** extern void DropPreparedStatement(const 
*** 59,62 ****
--- 59,64 ----
  extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
  extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
  
+ void DropAllPreparedStatements(void);
+ 
  #endif   /* PREPARE_H */
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.344
diff -p -u -c -r1.344 parsenodes.h
*** src/include/nodes/parsenodes.h	2 Apr 2007 03:49:41 -0000	1.344
--- src/include/nodes/parsenodes.h	8 Apr 2007 07:59:27 -0000
*************** typedef struct ClosePortalStmt
*** 1451,1456 ****
--- 1451,1457 ----
  {
  	NodeTag		type;
  	char	   *portalname;		/* name of the portal (cursor) */
+ 								/* NULL means CLOSE ALL */
  } ClosePortalStmt;
  
  /* ----------------------
*************** typedef struct DeallocateStmt
*** 1981,1986 ****
--- 1982,1988 ----
  {
  	NodeTag		type;
  	char	   *name;			/* The name of the plan to remove */
+ 								/* NULL means DEALLOCATE ALL */
  } DeallocateStmt;
  
  /*
Index: src/include/utils/guc.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/guc.h,v
retrieving revision 1.80
diff -p -u -c -r1.80 guc.h
*** src/include/utils/guc.h	6 Mar 2007 02:06:15 -0000	1.80
--- src/include/utils/guc.h	8 Apr 2007 07:59:28 -0000
*************** extern int	GetNumConfigOptions(void);
*** 201,207 ****
  extern void SetPGVariable(const char *name, List *args, bool is_local);
  extern void GetPGVariable(const char *name, DestReceiver *dest);
  extern TupleDesc GetPGVariableResultDesc(const char *name);
! extern void ResetPGVariable(const char *name);
  
  extern char *flatten_set_variable_args(const char *name, List *args);
  
--- 201,207 ----
  extern void SetPGVariable(const char *name, List *args, bool is_local);
  extern void GetPGVariable(const char *name, DestReceiver *dest);
  extern TupleDesc GetPGVariableResultDesc(const char *name);
! extern void ResetPGVariable(const char *name, bool isTopLevel);
  
  extern char *flatten_set_variable_args(const char *name, List *args);
  
Index: src/include/utils/plancache.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/plancache.h,v
retrieving revision 1.4
diff -p -u -c -r1.4 plancache.h
*** src/include/utils/plancache.h	23 Mar 2007 19:53:52 -0000	1.4
--- src/include/utils/plancache.h	8 Apr 2007 07:59:28 -0000
*************** extern void ReleaseCachedPlan(CachedPlan
*** 105,108 ****
--- 105,110 ----
  extern TupleDesc PlanCacheComputeResultDesc(List *stmt_list);
  extern bool HaveCachedPlans(void);
  
+ extern void ResetPlanCache(void);
+ 
  #endif   /* PLANCACHE_H */
Index: src/include/utils/portal.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/utils/portal.h,v
retrieving revision 1.74
diff -p -u -c -r1.74 portal.h
*** src/include/utils/portal.h	13 Mar 2007 00:33:43 -0000	1.74
--- src/include/utils/portal.h	8 Apr 2007 07:59:28 -0000
*************** extern void PortalDefineQuery(Portal por
*** 212,216 ****
--- 212,217 ----
  				  CachedPlan *cplan);
  extern Node *PortalListGetPrimaryStmt(List *stmts);
  extern void PortalCreateHoldStore(Portal portal);
+ extern void PortalHashTableDeleteAll(void);
  
  #endif   /* PORTAL_H */
Index: src/test/regress/expected/guc.out
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/expected/guc.out,v
retrieving revision 1.2
diff -p -u -c -r1.2 guc.out
*** src/test/regress/expected/guc.out	13 Aug 2006 19:31:06 -0000	1.2
--- src/test/regress/expected/guc.out	8 Apr 2007 07:59:28 -0000
*************** SELECT '2006-08-13 12:34:56'::timestampt
*** 425,427 ****
--- 425,527 ----
   Sun Aug 13 12:34:56 2006 PDT
  (1 row)
  
+ --
+ -- Test RESET TEMP
+ --
+ CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS;
+ SELECT relname FROM pg_class WHERE relname = 'reset_test';
+   relname   
+ ------------
+  reset_test
+ (1 row)
+ 
+ RESET TEMP;
+ SELECT relname FROM pg_class WHERE relname = 'reset_test';
+  relname 
+ ---------
+ (0 rows)
+ 
+ --
+ -- Test RESET SESSION
+ --
+ -- do changes
+ DECLARE foo CURSOR WITH HOLD FOR SELECT 1;
+ PREPARE foo AS SELECT 1;
+ LISTEN foo_event;
+ SET vacuum_cost_delay = 13;
+ CREATE TEMP TABLE tmp_foo (data text) ON COMMIT DELETE ROWS;
+ CREATE ROLE temp_reset_user;
+ SET SESSION AUTHORIZATION temp_reset_user;
+ -- look changes
+ SELECT relname FROM pg_listener;
+   relname  
+ -----------
+  foo_event
+ (1 row)
+ 
+ SELECT name FROM pg_prepared_statements;
+  name 
+ ------
+  foo
+ (1 row)
+ 
+ SELECT name FROM pg_cursors;
+  name 
+ ------
+  foo
+ (1 row)
+ 
+ SHOW vacuum_cost_delay;
+  vacuum_cost_delay 
+ -------------------
+  13ms
+ (1 row)
+ 
+ SELECT relname from pg_class where relname = 'tmp_foo';
+  relname 
+ ---------
+  tmp_foo
+ (1 row)
+ 
+ SELECT current_user = 'temp_reset_user';
+  ?column? 
+ ----------
+  t
+ (1 row)
+ 
+ -- big RESET
+ RESET SESSION;
+ -- look again
+ SELECT relname FROM pg_listener;
+  relname 
+ ---------
+ (0 rows)
+ 
+ SELECT name FROM pg_prepared_statements;
+  name 
+ ------
+ (0 rows)
+ 
+ SELECT name FROM pg_cursors;
+  name 
+ ------
+ (0 rows)
+ 
+ SHOW vacuum_cost_delay;
+  vacuum_cost_delay 
+ -------------------
+  0
+ (1 row)
+ 
+ SELECT relname from pg_class where relname = 'tmp_foo';
+  relname 
+ ---------
+ (0 rows)
+ 
+ SELECT current_user = 'temp_reset_user';
+  ?column? 
+ ----------
+  f
+ (1 row)
+ 
+ DROP ROLE temp_reset_user;
Index: src/test/regress/expected/portals.out
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/expected/portals.out,v
retrieving revision 1.11
diff -p -u -c -r1.11 portals.out
*** src/test/regress/expected/portals.out	27 Feb 2006 16:09:50 -0000	1.11
--- src/test/regress/expected/portals.out	8 Apr 2007 07:59:29 -0000
*************** EXECUTE cprep;
*** 869,871 ****
--- 869,901 ----
   c2   | declare c2 cursor with hold for select count_tt1_v(), count_tt1_s(); | t           | f         | f
  (1 row)
  
+ -- test CLOSE ALL;
+ SELECT name FROM pg_cursors ORDER BY 1;
+  name 
+ ------
+  c2
+ (1 row)
+ 
+ CLOSE ALL;
+ SELECT name FROM pg_cursors ORDER BY 1;
+  name 
+ ------
+ (0 rows)
+ 
+ BEGIN;
+ DECLARE foo1 CURSOR WITH HOLD FOR SELECT 1;
+ DECLARE foo2 CURSOR WITHOUT HOLD FOR SELECT 1;
+ SELECT name FROM pg_cursors ORDER BY 1;
+  name 
+ ------
+  foo1
+  foo2
+ (2 rows)
+ 
+ CLOSE ALL;
+ SELECT name FROM pg_cursors ORDER BY 1;
+  name 
+ ------
+ (0 rows)
+ 
+ COMMIT;
Index: src/test/regress/expected/prepare.out
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/expected/prepare.out,v
retrieving revision 1.12
diff -p -u -c -r1.12 prepare.out
*** src/test/regress/expected/prepare.out	21 Dec 2006 16:05:16 -0000	1.12
--- src/test/regress/expected/prepare.out	8 Apr 2007 07:59:29 -0000
*************** SELECT name, statement, parameter_types 
*** 166,168 ****
--- 166,176 ----
        :     SELECT * FROM road WHERE thepath = $1;                         
  (5 rows)
  
+ -- test DEALLOCATE ALL;
+ DEALLOCATE ALL;
+ SELECT name, statement, parameter_types FROM pg_prepared_statements
+     ORDER BY name;
+  name | statement | parameter_types 
+ ------+-----------+-----------------
+ (0 rows)
+ 
Index: src/test/regress/sql/guc.sql
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/sql/guc.sql,v
retrieving revision 1.2
diff -p -u -c -r1.2 guc.sql
*** src/test/regress/sql/guc.sql	13 Aug 2006 19:31:06 -0000	1.2
--- src/test/regress/sql/guc.sql	8 Apr 2007 07:59:29 -0000
*************** SELECT '2006-08-13 12:34:56'::timestampt
*** 123,125 ****
--- 123,164 ----
  RESET datestyle;
  SHOW datestyle;
  SELECT '2006-08-13 12:34:56'::timestamptz;
+ 
+ --
+ -- Test RESET TEMP
+ --
+ CREATE TEMP TABLE reset_test ( data text ) ON COMMIT DELETE ROWS;
+ SELECT relname FROM pg_class WHERE relname = 'reset_test';
+ RESET TEMP;
+ SELECT relname FROM pg_class WHERE relname = 'reset_test';
+ 
+ --
+ -- Test RESET SESSION
+ --
+ 
+ -- do changes
+ DECLARE foo CURSOR WITH HOLD FOR SELECT 1;
+ PREPARE foo AS SELECT 1;
+ LISTEN foo_event;
+ SET vacuum_cost_delay = 13;
+ CREATE TEMP TABLE tmp_foo (data text) ON COMMIT DELETE ROWS;
+ CREATE ROLE temp_reset_user;
+ SET SESSION AUTHORIZATION temp_reset_user;
+ -- look changes
+ SELECT relname FROM pg_listener;
+ SELECT name FROM pg_prepared_statements;
+ SELECT name FROM pg_cursors;
+ SHOW vacuum_cost_delay;
+ SELECT relname from pg_class where relname = 'tmp_foo';
+ SELECT current_user = 'temp_reset_user';
+ -- big RESET
+ RESET SESSION;
+ -- look again
+ SELECT relname FROM pg_listener;
+ SELECT name FROM pg_prepared_statements;
+ SELECT name FROM pg_cursors;
+ SHOW vacuum_cost_delay;
+ SELECT relname from pg_class where relname = 'tmp_foo';
+ SELECT current_user = 'temp_reset_user';
+ DROP ROLE temp_reset_user;
+ 
Index: src/test/regress/sql/portals.sql
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/sql/portals.sql,v
retrieving revision 1.8
diff -p -u -c -r1.8 portals.sql
*** src/test/regress/sql/portals.sql	27 Feb 2006 16:09:50 -0000	1.8
--- src/test/regress/sql/portals.sql	8 Apr 2007 07:59:29 -0000
*************** ROLLBACK;
*** 303,305 ****
--- 303,320 ----
  PREPARE cprep AS
    SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors;
  EXECUTE cprep;
+ 
+ -- test CLOSE ALL;
+ SELECT name FROM pg_cursors ORDER BY 1;
+ CLOSE ALL;
+ SELECT name FROM pg_cursors ORDER BY 1;
+ BEGIN;
+ DECLARE foo1 CURSOR WITH HOLD FOR SELECT 1;
+ DECLARE foo2 CURSOR WITHOUT HOLD FOR SELECT 1;
+ SELECT name FROM pg_cursors ORDER BY 1;
+ CLOSE ALL;
+ SELECT name FROM pg_cursors ORDER BY 1;
+ COMMIT;
+ 
+ 
+ 
Index: src/test/regress/sql/prepare.sql
===================================================================
RCS file: /projects/cvsroot/pgsql/src/test/regress/sql/prepare.sql,v
retrieving revision 1.4
diff -p -u -c -r1.4 prepare.sql
*** src/test/regress/sql/prepare.sql	15 Jan 2006 22:18:47 -0000	1.4
--- src/test/regress/sql/prepare.sql	8 Apr 2007 07:59:29 -0000
*************** PREPARE q7(unknown) AS
*** 68,70 ****
--- 68,76 ----
  
  SELECT name, statement, parameter_types FROM pg_prepared_statements
      ORDER BY name;
+ 
+ -- test DEALLOCATE ALL;
+ DEALLOCATE ALL;
+ SELECT name, statement, parameter_types FROM pg_prepared_statements
+     ORDER BY name;
+ 