blob: 1febe29065b43255ddc0312ece9dec88efb2df91 (
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
|
/*-------------------------------------------------------------------------
*
* discard.c
* The implementation of the DISCARD command
*
* Copyright (c) 1996-2009, PostgreSQL Global Development Group
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/discard.c,v 1.6 2009/01/01 17:23:37 momjian 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();
LockReleaseAll(USER_LOCKMETHOD, true);
ResetPlanCache();
ResetTempTableNamespace();
}
|