mirror of https://github.com/postgres/postgres
RESET SESSION, RESET PLANS, and RESET TEMP are now DISCARD ALL, DISCARD PLANS, and DISCARD TEMP, respectively. This is to avoid confusion with the pre-existing RESET variants: the DISCARD commands are not actually similar to RESET. Patch from Marko Kreen, with some minor editorialization.REL8_3_STABLE
parent
5ea27a4b28
commit
16efdb5ec7
@ -0,0 +1,107 @@ |
||||
<!-- |
||||
$PostgreSQL: pgsql/doc/src/sgml/ref/discard.sgml,v 1.1 2007/04/26 16:13:09 neilc Exp $ |
||||
PostgreSQL documentation |
||||
--> |
||||
|
||||
<refentry id="SQL-DISCARD"> |
||||
<refmeta> |
||||
<refentrytitle id="SQL-DISCARD-TITLE">DISCARD</refentrytitle> |
||||
<refmiscinfo>SQL - Language Statements</refmiscinfo> |
||||
</refmeta> |
||||
|
||||
<refnamediv> |
||||
<refname>DISCARD</refname> |
||||
<refpurpose>Discard internal server state</refpurpose> |
||||
</refnamediv> |
||||
|
||||
<indexterm zone="sql-discard"> |
||||
<primary>DISCARD</primary> |
||||
</indexterm> |
||||
|
||||
<refsynopsisdiv> |
||||
<synopsis> |
||||
DISCARD { ALL | PLANS | TEMPORARY | TEMP } |
||||
</synopsis> |
||||
</refsynopsisdiv> |
||||
|
||||
<refsect1> |
||||
<title>Description</title> |
||||
|
||||
<para> |
||||
<command>DISCARD</> releases internal resources associated with a |
||||
database session. These resources are normally released at the end |
||||
of the session. |
||||
</para> |
||||
|
||||
<para> |
||||
<command>DISCARD TEMP</> drops all temporary tables created in the |
||||
current session. <command>DISCARD PLANS</> releases all internally |
||||
cached query plans. <command>DISCARD ALL</> resets a session to |
||||
its original state, discarding temporary resources and resetting |
||||
session-local configuration changes. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Parameters</title> |
||||
|
||||
<variablelist> |
||||
|
||||
<varlistentry> |
||||
<term><literal>TEMPORARY</literal> or <literal>TEMP</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>ALL</literal></term> |
||||
<listitem> |
||||
<para> |
||||
Releases all temporary resources associated with the current |
||||
session and resets the session to its initial state. This has |
||||
the same effect as executing the following sequence of |
||||
statements: |
||||
<programlisting> |
||||
SET SESSION AUTHORIZATION DEFAULT; |
||||
RESET ALL; |
||||
DEALLOCATE ALL; |
||||
CLOSE ALL; |
||||
UNLISTEN *; |
||||
DISCARD PLANS; |
||||
DISCARD TEMP; |
||||
</programlisting> |
||||
</para> |
||||
</listitem> |
||||
</varlistentry> |
||||
|
||||
</variablelist> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Notes</title> |
||||
|
||||
<para> |
||||
<command>DISCARD ALL</> cannot be executed inside a transaction block. |
||||
</para> |
||||
</refsect1> |
||||
|
||||
<refsect1> |
||||
<title>Compatibility</title> |
||||
|
||||
<para> |
||||
<command>DISCARD</command> is a <productname>PostgreSQL</productname> extension. |
||||
</para> |
||||
</refsect1> |
||||
</refentry> |
@ -0,0 +1,71 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* discard.c |
||||
* The implementation of the DISCARD command |
||||
* |
||||
* Copyright (c) 1996-2007, PostgreSQL Global Development Group |
||||
* |
||||
* |
||||
* IDENTIFICATION |
||||
* $PostgreSQL: pgsql/src/backend/commands/discard.c,v 1.1 2007/04/26 16:13:10 neilc Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#include "postgres.h" |
||||
|
||||
#include "access/xact.h" |
||||
#include "catalog/namespace.h" |
||||
#include "commands/async.h" |
||||
#include "commands/discard.h" |
||||
#include "commands/prepare.h" |
||||
#include "commands/variable.h" |
||||
#include "utils/plancache.h" |
||||
#include "utils/portal.h" |
||||
|
||||
static void DiscardAll(bool isTopLevel); |
||||
|
||||
/*
|
||||
* DISCARD { ALL | TEMP | PLANS } |
||||
*/ |
||||
void |
||||
DiscardCommand(DiscardStmt *stmt, bool isTopLevel) |
||||
{ |
||||
switch (stmt->target) |
||||
{ |
||||
case DISCARD_ALL: |
||||
DiscardAll(isTopLevel); |
||||
break; |
||||
|
||||
case DISCARD_PLANS: |
||||
ResetPlanCache(); |
||||
break; |
||||
|
||||
case DISCARD_TEMP: |
||||
ResetTempTableNamespace(); |
||||
break; |
||||
|
||||
default: |
||||
elog(ERROR, "unrecognized DISCARD target: %d", stmt->target); |
||||
} |
||||
} |
||||
|
||||
static void |
||||
DiscardAll(bool isTopLevel) |
||||
{ |
||||
/*
|
||||
* Disallow DISCARD ALL in a transaction block. This is arguably |
||||
* inconsistent (we don't make a similar check in the command |
||||
* sequence that DISCARD ALL is equivalent to), but the idea is |
||||
* to catch mistakes: DISCARD ALL inside a transaction block |
||||
* would leave the transaction still uncommitted. |
||||
*/ |
||||
PreventTransactionChain(isTopLevel, "DISCARD ALL"); |
||||
|
||||
SetPGVariable("session_authorization", NIL, false); |
||||
ResetAllOptions(); |
||||
DropAllPreparedStatements(); |
||||
PortalHashTableDeleteAll(); |
||||
Async_UnlistenAll(); |
||||
ResetPlanCache(); |
||||
ResetTempTableNamespace(); |
||||
} |
@ -0,0 +1,20 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* discard.h |
||||
* prototypes for discard.c. |
||||
* |
||||
* |
||||
* Copyright (c) 1996-2007, PostgreSQL Global Development Group |
||||
* |
||||
* $PostgreSQL: pgsql/src/include/commands/discard.h,v 1.1 2007/04/26 16:13:13 neilc Exp $ |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef DISCARD_H |
||||
#define DISCARD_H |
||||
|
||||
#include "nodes/parsenodes.h" |
||||
|
||||
extern void DiscardCommand(DiscardStmt *stmt, bool isTopLevel); |
||||
|
||||
#endif /* DISCARD_H */ |
Loading…
Reference in new issue