summaryrefslogtreecommitdiff
path: root/doc/src/sgml/ref/discard.sgml
blob: d3436a303b3b424f40c5f388d602c4c1169edfd7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/discard.sgml,v 1.6 2010/04/03 07:23:00 petere Exp $
PostgreSQL documentation
-->

<refentry id="SQL-DISCARD">
 <refmeta>
  <refentrytitle>DISCARD</refentrytitle>
  <manvolnum>7</manvolnum>
  <refmiscinfo>SQL - Language Statements</refmiscinfo>
 </refmeta>

 <refnamediv>
  <refname>DISCARD</refname>
  <refpurpose>discard session 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.
      Currently, this has the same effect as executing the following sequence
      of statements:
<programlisting>
SET SESSION AUTHORIZATION DEFAULT;
RESET ALL;
DEALLOCATE ALL;
CLOSE ALL;
UNLISTEN *;
SELECT pg_advisory_unlock_all();
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>