mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
RESET SESSION, plus related new DDL commands. Patch from Marko Kreen,
reviewed by Neil Conway. This patch adds the following DDL command variants: RESET SESSION, RESET TEMP, RESET PLANS, CLOSE ALL, and DEALLOCATE ALL. RESET SESSION is intended for use by connection pool software and the like, in order to reset a client session to something close to its initial state. Note that while most of these command variants can be executed inside a transaction block (but are not transaction-aware!), RESET SESSION cannot. While this is inconsistent, it is intended to catch programmer mistakes: RESET SESSION in an open transaction block is probably unintended.
This commit is contained in:
parent
e6e47f278d
commit
d13e903bea
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ PostgreSQL documentation
|
|||||||
|
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<synopsis>
|
<synopsis>
|
||||||
CLOSE <replaceable class="PARAMETER">name</replaceable>
|
CLOSE { <replaceable class="PARAMETER">name</replaceable> | ALL }
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
@ -44,10 +44,10 @@ CLOSE <replaceable class="PARAMETER">name</replaceable>
|
|||||||
transaction is terminated by <command>COMMIT</command> or
|
transaction is terminated by <command>COMMIT</command> or
|
||||||
<command>ROLLBACK</command>. A holdable cursor is implicitly
|
<command>ROLLBACK</command>. A holdable cursor is implicitly
|
||||||
closed if the transaction that created it aborts via
|
closed if the transaction that created it aborts via
|
||||||
<command>ROLLBACK</command>. If the creating transaction successfully
|
<command>ROLLBACK</command>. If the creating transaction
|
||||||
commits, the holdable
|
successfully commits, the holdable cursor remains open until an
|
||||||
cursor remains open until an explicit <command>CLOSE</command> is
|
explicit <command>CLOSE</command> is executed, or the client
|
||||||
executed, or the client disconnects.
|
disconnects.
|
||||||
</para>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
@ -63,6 +63,16 @@ CLOSE <replaceable class="PARAMETER">name</replaceable>
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><literal>ALL</literal></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Close all open cursors.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
@ -98,7 +108,9 @@ CLOSE liahona;
|
|||||||
<title>Compatibility</title>
|
<title>Compatibility</title>
|
||||||
|
|
||||||
<para>
|
<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>
|
</para>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ PostgreSQL documentation
|
|||||||
|
|
||||||
<refsynopsisdiv>
|
<refsynopsisdiv>
|
||||||
<synopsis>
|
<synopsis>
|
||||||
DEALLOCATE [ PREPARE ] <replaceable class="parameter">name</replaceable>
|
DEALLOCATE [ PREPARE ] { <replaceable class="parameter">name</replaceable> | ALL }
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
@ -65,6 +65,15 @@ DEALLOCATE [ PREPARE ] <replaceable class="parameter">name</replaceable>
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><literal>ALL</literal></term>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Deallocate all prepared statements.
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -22,9 +22,10 @@ PostgreSQL documentation
|
|||||||
<synopsis>
|
<synopsis>
|
||||||
RESET <replaceable class="PARAMETER">configuration_parameter</replaceable>
|
RESET <replaceable class="PARAMETER">configuration_parameter</replaceable>
|
||||||
RESET ALL
|
RESET ALL
|
||||||
|
RESET { PLANS | SESSION | TEMP | TEMPORARY }
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</refsynopsisdiv>
|
</refsynopsisdiv>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Description</title>
|
<title>Description</title>
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ SET <replaceable class="parameter">configuration_parameter</replaceable> TO DEFA
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
The default value is defined as the value that the parameter would
|
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
|
current session. The actual source of this value might be a
|
||||||
compiled-in default, the configuration file, command-line options,
|
compiled-in default, the configuration file, command-line options,
|
||||||
or per-database or per-user default settings. See <xref
|
or per-database or per-user default settings. See <xref
|
||||||
@ -52,6 +53,15 @@ SET <replaceable class="parameter">configuration_parameter</replaceable> TO DEFA
|
|||||||
See the <command>SET</> reference page for details on the
|
See the <command>SET</> reference page for details on the
|
||||||
transaction behavior of <command>RESET</>.
|
transaction behavior of <command>RESET</>.
|
||||||
</para>
|
</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>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
@ -76,9 +86,56 @@ SET <replaceable class="parameter">configuration_parameter</replaceable> TO DEFA
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</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>
|
</variablelist>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
<refsect1>
|
||||||
|
<title>Notes</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<command>RESET SESSION</> cannot be executed inside a transaction block.
|
||||||
|
</para>
|
||||||
|
</refsect1>
|
||||||
|
|
||||||
<refsect1>
|
<refsect1>
|
||||||
<title>Examples</title>
|
<title>Examples</title>
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1940,6 +1940,26 @@ InitTempTableNamespace(void)
|
|||||||
baseSearchPathValid = false; /* need to rebuild list */
|
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.
|
* End-of-transaction cleanup for namespaces.
|
||||||
*/
|
*/
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -127,7 +127,6 @@ static bool unlistenExitRegistered = false;
|
|||||||
bool Trace_notify = false;
|
bool Trace_notify = false;
|
||||||
|
|
||||||
|
|
||||||
static void Async_UnlistenAll(void);
|
|
||||||
static void Async_UnlistenOnExit(int code, Datum arg);
|
static void Async_UnlistenOnExit(int code, Datum arg);
|
||||||
static void ProcessIncomingNotify(void);
|
static void ProcessIncomingNotify(void);
|
||||||
static void NotifyMyFrontEnd(char *relname, int32 listenerPID);
|
static void NotifyMyFrontEnd(char *relname, int32 listenerPID);
|
||||||
@ -335,7 +334,7 @@ Async_Unlisten(const char *relname)
|
|||||||
*
|
*
|
||||||
*--------------------------------------------------------------
|
*--------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
Async_UnlistenAll(void)
|
Async_UnlistenAll(void)
|
||||||
{
|
{
|
||||||
Relation lRel;
|
Relation lRel;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -236,11 +236,18 @@ PerformPortalClose(const char *name)
|
|||||||
{
|
{
|
||||||
Portal portal;
|
Portal portal;
|
||||||
|
|
||||||
|
/* NULL means CLOSE ALL */
|
||||||
|
if (name == NULL)
|
||||||
|
{
|
||||||
|
PortalHashTableDeleteAll();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disallow empty-string cursor name (conflicts with protocol-level
|
* Disallow empty-string cursor name (conflicts with protocol-level
|
||||||
* unnamed portal).
|
* unnamed portal).
|
||||||
*/
|
*/
|
||||||
if (!name || name[0] == '\0')
|
if (name[0] == '\0')
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INVALID_CURSOR_NAME),
|
(errcode(ERRCODE_INVALID_CURSOR_NAME),
|
||||||
errmsg("invalid cursor name: must not be empty")));
|
errmsg("invalid cursor name: must not be empty")));
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
|
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -575,7 +575,10 @@ FetchPreparedStatementTargetList(PreparedStatement *stmt)
|
|||||||
void
|
void
|
||||||
DeallocateQuery(DeallocateStmt *stmt)
|
DeallocateQuery(DeallocateStmt *stmt)
|
||||||
{
|
{
|
||||||
DropPreparedStatement(stmt->name, true);
|
if (stmt->name)
|
||||||
|
DropPreparedStatement(stmt->name, true);
|
||||||
|
else
|
||||||
|
DropAllPreparedStatements();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -601,6 +604,31 @@ DropPreparedStatement(const char *stmt_name, bool showError)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
* Implements the 'EXPLAIN EXECUTE' utility statement.
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -1667,6 +1667,12 @@ ClosePortalStmt:
|
|||||||
n->portalname = $2;
|
n->portalname = $2;
|
||||||
$$ = (Node *)n;
|
$$ = (Node *)n;
|
||||||
}
|
}
|
||||||
|
| CLOSE ALL
|
||||||
|
{
|
||||||
|
ClosePortalStmt *n = makeNode(ClosePortalStmt);
|
||||||
|
n->portalname = NULL;
|
||||||
|
$$ = (Node *)n;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
@ -5591,6 +5597,18 @@ DeallocateStmt: DEALLOCATE name
|
|||||||
n->name = $3;
|
n->name = $3;
|
||||||
$$ = (Node *) n;
|
$$ = (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;
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -990,7 +990,7 @@ ProcessUtility(Node *parsetree,
|
|||||||
{
|
{
|
||||||
VariableResetStmt *n = (VariableResetStmt *) parsetree;
|
VariableResetStmt *n = (VariableResetStmt *) parsetree;
|
||||||
|
|
||||||
ResetPGVariable(n->name);
|
ResetPGVariable(n->name, isTopLevel);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1387,7 +1387,13 @@ CreateCommandTag(Node *parsetree)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case T_ClosePortalStmt:
|
case T_ClosePortalStmt:
|
||||||
tag = "CLOSE CURSOR";
|
{
|
||||||
|
ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree;
|
||||||
|
if (stmt->portalname == NULL)
|
||||||
|
tag = "CLOSE CURSOR ALL";
|
||||||
|
else
|
||||||
|
tag = "CLOSE CURSOR";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_FetchStmt:
|
case T_FetchStmt:
|
||||||
@ -1746,7 +1752,13 @@ CreateCommandTag(Node *parsetree)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case T_VariableResetStmt:
|
case T_VariableResetStmt:
|
||||||
tag = "RESET";
|
{
|
||||||
|
VariableResetStmt *stmt = (VariableResetStmt *) parsetree;
|
||||||
|
if (pg_strcasecmp(stmt->name, "session") == 0)
|
||||||
|
tag = "RESET SESSION";
|
||||||
|
else
|
||||||
|
tag = "RESET";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_CreateTrigStmt:
|
case T_CreateTrigStmt:
|
||||||
@ -1856,7 +1868,13 @@ CreateCommandTag(Node *parsetree)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case T_DeallocateStmt:
|
case T_DeallocateStmt:
|
||||||
tag = "DEALLOCATE";
|
{
|
||||||
|
DeallocateStmt *stmt = (DeallocateStmt *) parsetree;
|
||||||
|
if (stmt->name == NULL)
|
||||||
|
tag = "DEALLOCATE ALL";
|
||||||
|
else
|
||||||
|
tag = "DEALLOCATE";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* already-planned queries */
|
/* already-planned queries */
|
||||||
|
11
src/backend/utils/cache/plancache.c
vendored
11
src/backend/utils/cache/plancache.c
vendored
@ -33,7 +33,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -880,6 +880,15 @@ PlanCacheCallback(Datum arg, Oid relid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ResetPlanCache: drop all cached plans.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ResetPlanCache(void)
|
||||||
|
{
|
||||||
|
PlanCacheCallback((Datum) 0, InvalidOid);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* ScanQueryForRelids callback function for PlanCacheCallback
|
* ScanQueryForRelids callback function for PlanCacheCallback
|
||||||
*/
|
*/
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*--------------------------------------------------------------------
|
*--------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -32,6 +32,7 @@
|
|||||||
#include "access/xact.h"
|
#include "access/xact.h"
|
||||||
#include "catalog/namespace.h"
|
#include "catalog/namespace.h"
|
||||||
#include "commands/async.h"
|
#include "commands/async.h"
|
||||||
|
#include "commands/prepare.h"
|
||||||
#include "commands/vacuum.h"
|
#include "commands/vacuum.h"
|
||||||
#include "commands/variable.h"
|
#include "commands/variable.h"
|
||||||
#include "commands/trigger.h"
|
#include "commands/trigger.h"
|
||||||
@ -61,6 +62,7 @@
|
|||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
#include "utils/pg_locale.h"
|
#include "utils/pg_locale.h"
|
||||||
#include "utils/plancache.h"
|
#include "utils/plancache.h"
|
||||||
|
#include "utils/portal.h"
|
||||||
#include "utils/ps_status.h"
|
#include "utils/ps_status.h"
|
||||||
#include "utils/tzparser.h"
|
#include "utils/tzparser.h"
|
||||||
#include "utils/xml.h"
|
#include "utils/xml.h"
|
||||||
@ -4951,14 +4953,45 @@ GetPGVariableResultDesc(const char *name)
|
|||||||
return tupdesc;
|
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
|
* RESET command
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ResetPGVariable(const char *name)
|
ResetPGVariable(const char *name, bool isTopLevel)
|
||||||
{
|
{
|
||||||
if (pg_strcasecmp(name, "all") == 0)
|
if (pg_strcasecmp(name, "all") == 0)
|
||||||
ResetAllOptions();
|
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
|
else
|
||||||
set_config_option(name,
|
set_config_option(name,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -452,6 +452,29 @@ PortalDrop(Portal portal, bool isTopCommit)
|
|||||||
pfree(portal);
|
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.
|
* Pre-commit processing for portals.
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -100,4 +100,6 @@ extern char *namespace_search_path;
|
|||||||
|
|
||||||
extern List *fetch_search_path(bool includeImplicit);
|
extern List *fetch_search_path(bool includeImplicit);
|
||||||
|
|
||||||
|
extern void ResetTempTableNamespace(void);
|
||||||
|
|
||||||
#endif /* NAMESPACE_H */
|
#endif /* NAMESPACE_H */
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -19,6 +19,7 @@ extern bool Trace_notify;
|
|||||||
extern void Async_Notify(const char *relname);
|
extern void Async_Notify(const char *relname);
|
||||||
extern void Async_Listen(const char *relname);
|
extern void Async_Listen(const char *relname);
|
||||||
extern void Async_Unlisten(const char *relname);
|
extern void Async_Unlisten(const char *relname);
|
||||||
|
extern void Async_UnlistenAll(void);
|
||||||
|
|
||||||
/* perform (or cancel) outbound notify processing at transaction commit */
|
/* perform (or cancel) outbound notify processing at transaction commit */
|
||||||
extern void AtCommit_Notify(void);
|
extern void AtCommit_Notify(void);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2002-2007, PostgreSQL Global Development Group
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -59,4 +59,6 @@ extern void DropPreparedStatement(const char *stmt_name, bool showError);
|
|||||||
extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
|
extern TupleDesc FetchPreparedStatementResultDesc(PreparedStatement *stmt);
|
||||||
extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
|
extern List *FetchPreparedStatementTargetList(PreparedStatement *stmt);
|
||||||
|
|
||||||
|
void DropAllPreparedStatements(void);
|
||||||
|
|
||||||
#endif /* PREPARE_H */
|
#endif /* PREPARE_H */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1451,6 +1451,7 @@ typedef struct ClosePortalStmt
|
|||||||
{
|
{
|
||||||
NodeTag type;
|
NodeTag type;
|
||||||
char *portalname; /* name of the portal (cursor) */
|
char *portalname; /* name of the portal (cursor) */
|
||||||
|
/* NULL means CLOSE ALL */
|
||||||
} ClosePortalStmt;
|
} ClosePortalStmt;
|
||||||
|
|
||||||
/* ----------------------
|
/* ----------------------
|
||||||
@ -1981,6 +1982,7 @@ typedef struct DeallocateStmt
|
|||||||
{
|
{
|
||||||
NodeTag type;
|
NodeTag type;
|
||||||
char *name; /* The name of the plan to remove */
|
char *name; /* The name of the plan to remove */
|
||||||
|
/* NULL means DEALLOCATE ALL */
|
||||||
} DeallocateStmt;
|
} DeallocateStmt;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
||||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
* 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
|
#ifndef GUC_H
|
||||||
@ -201,7 +201,7 @@ extern int GetNumConfigOptions(void);
|
|||||||
extern void SetPGVariable(const char *name, List *args, bool is_local);
|
extern void SetPGVariable(const char *name, List *args, bool is_local);
|
||||||
extern void GetPGVariable(const char *name, DestReceiver *dest);
|
extern void GetPGVariable(const char *name, DestReceiver *dest);
|
||||||
extern TupleDesc GetPGVariableResultDesc(const char *name);
|
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);
|
extern char *flatten_set_variable_args(const char *name, List *args);
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -105,4 +105,6 @@ extern void ReleaseCachedPlan(CachedPlan *plan, bool useResOwner);
|
|||||||
extern TupleDesc PlanCacheComputeResultDesc(List *stmt_list);
|
extern TupleDesc PlanCacheComputeResultDesc(List *stmt_list);
|
||||||
extern bool HaveCachedPlans(void);
|
extern bool HaveCachedPlans(void);
|
||||||
|
|
||||||
|
extern void ResetPlanCache(void);
|
||||||
|
|
||||||
#endif /* PLANCACHE_H */
|
#endif /* PLANCACHE_H */
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* 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 $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -212,5 +212,6 @@ extern void PortalDefineQuery(Portal portal,
|
|||||||
CachedPlan *cplan);
|
CachedPlan *cplan);
|
||||||
extern Node *PortalListGetPrimaryStmt(List *stmts);
|
extern Node *PortalListGetPrimaryStmt(List *stmts);
|
||||||
extern void PortalCreateHoldStore(Portal portal);
|
extern void PortalCreateHoldStore(Portal portal);
|
||||||
|
extern void PortalHashTableDeleteAll(void);
|
||||||
|
|
||||||
#endif /* PORTAL_H */
|
#endif /* PORTAL_H */
|
||||||
|
@ -425,3 +425,103 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
|
|||||||
Sun Aug 13 12:34:56 2006 PDT
|
Sun Aug 13 12:34:56 2006 PDT
|
||||||
(1 row)
|
(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;
|
||||||
|
@ -869,3 +869,33 @@ EXECUTE cprep;
|
|||||||
c2 | declare c2 cursor with hold for select count_tt1_v(), count_tt1_s(); | t | f | f
|
c2 | declare c2 cursor with hold for select count_tt1_v(), count_tt1_s(); | t | f | f
|
||||||
(1 row)
|
(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;
|
||||||
|
@ -166,3 +166,11 @@ SELECT name, statement, parameter_types FROM pg_prepared_statements
|
|||||||
: SELECT * FROM road WHERE thepath = $1;
|
: SELECT * FROM road WHERE thepath = $1;
|
||||||
(5 rows)
|
(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)
|
||||||
|
|
||||||
|
@ -123,3 +123,42 @@ SELECT '2006-08-13 12:34:56'::timestamptz;
|
|||||||
RESET datestyle;
|
RESET datestyle;
|
||||||
SHOW datestyle;
|
SHOW datestyle;
|
||||||
SELECT '2006-08-13 12:34:56'::timestamptz;
|
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;
|
||||||
|
|
||||||
|
@ -303,3 +303,18 @@ ROLLBACK;
|
|||||||
PREPARE cprep AS
|
PREPARE cprep AS
|
||||||
SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors;
|
SELECT name, statement, is_holdable, is_binary, is_scrollable FROM pg_cursors;
|
||||||
EXECUTE cprep;
|
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;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -68,3 +68,9 @@ PREPARE q7(unknown) AS
|
|||||||
|
|
||||||
SELECT name, statement, parameter_types FROM pg_prepared_statements
|
SELECT name, statement, parameter_types FROM pg_prepared_statements
|
||||||
ORDER BY name;
|
ORDER BY name;
|
||||||
|
|
||||||
|
-- test DEALLOCATE ALL;
|
||||||
|
DEALLOCATE ALL;
|
||||||
|
SELECT name, statement, parameter_types FROM pg_prepared_statements
|
||||||
|
ORDER BY name;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user