doc: ALTER DEFAULT PRIVILEGES does not affect inherited roles
[pgsql.git] / doc / src / sgml / ref / discard.sgml
blobbf44c523cac62e94add43451aa9ff7936aacd06a
1 <!--
2 doc/src/sgml/ref/discard.sgml
3 PostgreSQL documentation
4 -->
6 <refentry id="sql-discard">
7 <indexterm zone="sql-discard">
8 <primary>DISCARD</primary>
9 </indexterm>
11 <refmeta>
12 <refentrytitle>DISCARD</refentrytitle>
13 <manvolnum>7</manvolnum>
14 <refmiscinfo>SQL - Language Statements</refmiscinfo>
15 </refmeta>
17 <refnamediv>
18 <refname>DISCARD</refname>
19 <refpurpose>discard session state</refpurpose>
20 </refnamediv>
22 <refsynopsisdiv>
23 <synopsis>
24 DISCARD { ALL | PLANS | SEQUENCES | TEMPORARY | TEMP }
25 </synopsis>
26 </refsynopsisdiv>
28 <refsect1>
29 <title>Description</title>
31 <para>
32 <command>DISCARD</command> releases internal resources associated with a
33 database session. This command is useful for partially or fully
34 resetting the session's state. There are several subcommands to
35 release different types of resources; the <command>DISCARD ALL</command>
36 variant subsumes all the others, and also resets additional state.
37 </para>
38 </refsect1>
40 <refsect1>
41 <title>Parameters</title>
43 <variablelist>
45 <varlistentry>
46 <term><literal>PLANS</literal></term>
47 <listitem>
48 <para>
49 Releases all cached query plans, forcing re-planning to occur
50 the next time the associated prepared statement is used.
51 </para>
52 </listitem>
53 </varlistentry>
55 <varlistentry>
56 <term><literal>SEQUENCES</literal></term>
57 <listitem>
58 <para>
59 Discards all cached sequence-related state,
60 including <function>currval()</function>/<function>lastval()</function>
61 information and any preallocated sequence values that have not
62 yet been returned by <function>nextval()</function>.
63 (See <xref linkend="sql-createsequence"/> for a description of
64 preallocated sequence values.)
65 </para>
66 </listitem>
67 </varlistentry>
69 <varlistentry>
70 <term><literal>TEMPORARY</literal> or <literal>TEMP</literal></term>
71 <listitem>
72 <para>
73 Drops all temporary tables created in the current session.
74 </para>
75 </listitem>
76 </varlistentry>
78 <varlistentry>
79 <term><literal>ALL</literal></term>
80 <listitem>
81 <para>
82 Releases all temporary resources associated with the current
83 session and resets the session to its initial state.
84 Currently, this has the same effect as executing the following sequence
85 of statements:
86 <programlisting>
87 CLOSE ALL;
88 SET SESSION AUTHORIZATION DEFAULT;
89 RESET ALL;
90 DEALLOCATE ALL;
91 UNLISTEN *;
92 SELECT pg_advisory_unlock_all();
93 DISCARD PLANS;
94 DISCARD TEMP;
95 DISCARD SEQUENCES;
96 </programlisting></para>
97 </listitem>
98 </varlistentry>
100 </variablelist>
101 </refsect1>
103 <refsect1>
104 <title>Notes</title>
106 <para>
107 <command>DISCARD ALL</command> cannot be executed inside a transaction block.
108 </para>
109 </refsect1>
111 <refsect1>
112 <title>Compatibility</title>
114 <para>
115 <command>DISCARD</command> is a <productname>PostgreSQL</productname> extension.
116 </para>
117 </refsect1>
118 </refentry>