<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/close.sgml,v 1.24 2006/09/16 00:30:17 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/close.sgml,v 1.25 2007/04/12 06:53:45 neilc Exp $
PostgreSQL documentation
-->
<refsynopsisdiv>
<synopsis>
-CLOSE <replaceable class="PARAMETER">name</replaceable>
+CLOSE { <replaceable class="PARAMETER">name</replaceable> | ALL }
</synopsis>
</refsynopsisdiv>
transaction is terminated by <command>COMMIT</command> or
<command>ROLLBACK</command>. A holdable cursor is implicitly
closed if the transaction that created it aborts via
- <command>ROLLBACK</command>. If the creating transaction successfully
- commits, the holdable
- cursor remains open until an explicit <command>CLOSE</command> is
- executed, or the client disconnects.
+ <command>ROLLBACK</command>. If the creating transaction
+ successfully commits, the holdable cursor remains open until an
+ explicit <command>CLOSE</command> is executed, or the client
+ disconnects.
</para>
</refsect1>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><literal>ALL</literal></term>
+ <listitem>
+ <para>
+ Close all open cursors.
+ </para>
+ </listitem>
+ </varlistentry>
+
</variablelist>
</refsect1>
<title>Compatibility</title>
<para>
- <command>CLOSE</command> is fully conforming with the SQL standard.
+ <command>CLOSE</command> is fully conforming with the SQL
+ standard. <command>CLOSE ALL</> is a <productname>PostgreSQL</>
+ extension.
</para>
</refsect1>
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/deallocate.sgml,v 1.9 2006/09/16 00:30:18 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/deallocate.sgml,v 1.10 2007/04/12 06:53:46 neilc Exp $
PostgreSQL documentation
-->
<refsynopsisdiv>
<synopsis>
-DEALLOCATE [ PREPARE ] <replaceable class="parameter">name</replaceable>
+DEALLOCATE [ PREPARE ] { <replaceable class="parameter">name</replaceable> | ALL }
</synopsis>
</refsynopsisdiv>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><literal>ALL</literal></term>
+ <listitem>
+ <para>
+ Deallocate all prepared statements.
+ </para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect1>
<!--
-$PostgreSQL: pgsql/doc/src/sgml/ref/reset.sgml,v 1.32 2006/09/16 00:30:19 momjian Exp $
+$PostgreSQL: pgsql/doc/src/sgml/ref/reset.sgml,v 1.33 2007/04/12 06:53:46 neilc Exp $
PostgreSQL documentation
-->
<synopsis>
RESET <replaceable class="PARAMETER">configuration_parameter</replaceable>
RESET ALL
+RESET { PLANS | SESSION | TEMP | TEMPORARY }
</synopsis>
</refsynopsisdiv>
-
+
<refsect1>
<title>Description</title>
<para>
The default value is defined as the value that the parameter would
- have had, had no <command>SET</> ever been issued for it in the
+ have had, if no <command>SET</> ever been issued for it in the
current session. The actual source of this value might be a
compiled-in default, the configuration file, command-line options,
or per-database or per-user default settings. See <xref
See the <command>SET</> reference page for details on the
transaction behavior of <command>RESET</>.
</para>
+
+ <para>
+ <command>RESET</> can also be used to release internal resources
+ that are usually released at the end of session. <command>RESET
+ TEMP</> drops all temporary tables created in the current session.
+ <command>RESET PLANS</> releases all internally cached plans.
+ <command>RESET SESSION</> releases all externally visible temporary
+ resources associated with the current session.
+ </para>
</refsect1>
<refsect1>
</para>
</listitem>
</varlistentry>
+
+ <varlistentry>
+ <term><literal>TEMP, TEMPORARY</literal></term>
+ <listitem>
+ <para>
+ Drops all temporary tables created in the current session.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>PLANS</literal></term>
+ <listitem>
+ <para>
+ Releases all cached query plans.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>SESSION</literal></term>
+ <listitem>
+ <para>
+ Releases all temporary resources associated with the current
+ session. This has the same effect as executing the 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>
+ <refsect1>
+ <title>Notes</title>
+
+ <para>
+ <command>RESET SESSION</> cannot be executed inside a transaction block.
+ </para>
+ </refsect1>
+
<refsect1>
<title>Examples</title>
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.93 2007/03/23 19:53:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.94 2007/04/12 06:53:46 neilc Exp $
*
*-------------------------------------------------------------------------
*/
baseSearchPathValid = false; /* need to rebuild list */
}
+/*
+ * Remove all temp tables from the temporary 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.
*/
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.135 2007/01/05 22:19:25 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.136 2007/04/12 06:53:46 neilc Exp $
*
*-------------------------------------------------------------------------
*/
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);
*
*--------------------------------------------------------------
*/
-static void
+void
Async_UnlistenAll(void)
{
Relation lRel;
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.62 2007/03/13 00:33:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.63 2007/04/12 06:53:46 neilc Exp $
*
*-------------------------------------------------------------------------
*/
{
Portal portal;
+ /* NULL means CLOSE ALL */
+ if (name == NULL)
+ {
+ PortalHashTableDeleteAll();
+ return;
+ }
+
/*
* Disallow empty-string cursor name (conflicts with protocol-level
* unnamed portal).
*/
- if (!name || name[0] == '\0')
+ if (name[0] == '\0')
ereport(ERROR,
(errcode(ERRCODE_INVALID_CURSOR_NAME),
errmsg("invalid cursor name: must not be empty")));
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.70 2007/03/13 00:33:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.71 2007/04/12 06:53:46 neilc Exp $
*
*-------------------------------------------------------------------------
*/
void
DeallocateQuery(DeallocateStmt *stmt)
{
- DropPreparedStatement(stmt->name, true);
+ if (stmt->name)
+ DropPreparedStatement(stmt->name, true);
+ else
+ DropAllPreparedStatements();
}
/*
}
}
+/*
+ * 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.
*/
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.587 2007/04/08 00:26:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.588 2007/04/12 06:53:46 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
n->portalname = $2;
$$ = (Node *)n;
}
+ | CLOSE ALL
+ {
+ ClosePortalStmt *n = makeNode(ClosePortalStmt);
+ n->portalname = NULL;
+ $$ = (Node *)n;
+ }
;
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;
+ }
;
/*****************************************************************************
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.276 2007/04/02 03:49:39 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/tcop/utility.c,v 1.277 2007/04/12 06:53:47 neilc Exp $
*
*-------------------------------------------------------------------------
*/
{
VariableResetStmt *n = (VariableResetStmt *) parsetree;
- ResetPGVariable(n->name);
+ ResetPGVariable(n->name, isTopLevel);
}
break;
break;
case T_ClosePortalStmt:
- tag = "CLOSE CURSOR";
+ {
+ ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree;
+ if (stmt->portalname == NULL)
+ tag = "CLOSE CURSOR ALL";
+ else
+ tag = "CLOSE CURSOR";
+ }
break;
case T_FetchStmt:
break;
case T_VariableResetStmt:
- tag = "RESET";
+ {
+ VariableResetStmt *stmt = (VariableResetStmt *) parsetree;
+ if (pg_strcasecmp(stmt->name, "session") == 0)
+ tag = "RESET SESSION";
+ else
+ tag = "RESET";
+ }
break;
case T_CreateTrigStmt:
break;
case T_DeallocateStmt:
- tag = "DEALLOCATE";
+ {
+ DeallocateStmt *stmt = (DeallocateStmt *) parsetree;
+ if (stmt->name == NULL)
+ tag = "DEALLOCATE ALL";
+ else
+ tag = "DEALLOCATE";
+ }
break;
/* already-planned queries */
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.5 2007/03/26 00:36:19 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/cache/plancache.c,v 1.6 2007/04/12 06:53:47 neilc Exp $
*
*-------------------------------------------------------------------------
*/
}
}
+/*
+ * ResetPlanCache: drop all cached plans.
+ */
+void
+ResetPlanCache(void)
+{
+ PlanCacheCallback((Datum) 0, InvalidOid);
+}
+
/*
* ScanQueryForRelids callback function for PlanCacheCallback
*/
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.383 2007/03/19 23:38:30 wieck Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.384 2007/04/12 06:53:47 neilc Exp $
*
*--------------------------------------------------------------------
*/
#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"
#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"
return tupdesc;
}
+/*
+ * RESET SESSION command.
+ */
+static void
+ResetSession(bool isTopLevel)
+{
+ /*
+ * Disallow RESET SESSION in a transaction block. This is arguably
+ * inconsistent (we don't make a similar check in the command
+ * sequence that RESET SESSION is equivalent to), but the idea is
+ * to catch mistakes: RESET SESSION inside a transaction block
+ * would leave the transaction still uncommitted.
+ */
+ PreventTransactionChain(isTopLevel, "RESET SESSION");
+
+ SetPGVariable("session_authorization", NIL, false);
+ ResetAllOptions();
+ DropAllPreparedStatements();
+ PortalHashTableDeleteAll();
+ Async_UnlistenAll();
+ ResetPlanCache();
+ ResetTempTableNamespace();
+}
+
/*
* RESET command
*/
void
-ResetPGVariable(const char *name)
+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,
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.100 2007/03/13 00:33:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/mmgr/portalmem.c,v 1.101 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
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.
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.45 2007/03/23 19:53:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.46 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
extern List *fetch_search_path(bool includeImplicit);
+extern void ResetTempTableNamespace(void);
+
#endif /* NAMESPACE_H */
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/async.h,v 1.34 2007/01/05 22:19:53 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/commands/async.h,v 1.35 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
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);
*
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.25 2007/03/13 00:33:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/prepare.h,v 1.26 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
+void DropAllPreparedStatements(void);
+
#endif /* PREPARE_H */
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.344 2007/04/02 03:49:41 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.345 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
{
NodeTag type;
char *portalname; /* name of the portal (cursor) */
+ /* NULL means CLOSE ALL */
} ClosePortalStmt;
/* ----------------------
{
NodeTag type;
char *name; /* The name of the plan to remove */
+ /* NULL means DEALLOCATE ALL */
} DeallocateStmt;
/*
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
- * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.80 2007/03/06 02:06:15 momjian Exp $
+ * $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.81 2007/04/12 06:53:48 neilc Exp $
*--------------------------------------------------------------------
*/
#ifndef GUC_H
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 void ResetPGVariable(const char *name, bool isTopLevel);
extern char *flatten_set_variable_args(const char *name, List *args);
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.4 2007/03/23 19:53:52 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/plancache.h,v 1.5 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
extern TupleDesc PlanCacheComputeResultDesc(List *stmt_list);
extern bool HaveCachedPlans(void);
+extern void ResetPlanCache(void);
+
#endif /* PLANCACHE_H */
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.74 2007/03/13 00:33:43 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/utils/portal.h,v 1.75 2007/04/12 06:53:48 neilc Exp $
*
*-------------------------------------------------------------------------
*/
CachedPlan *cplan);
extern Node *PortalListGetPrimaryStmt(List *stmts);
extern void PortalCreateHoldStore(Portal portal);
+extern void PortalHashTableDeleteAll(void);
#endif /* PORTAL_H */
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;
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;
: 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)
+
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;
+
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;
+
+
+
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;
+