PostgreSQL Source Code git master
Loading...
Searching...
No Matches
discard.c
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * discard.c
4 * The implementation of the DISCARD command
5 *
6 * Copyright (c) 1996-2026, PostgreSQL Global Development Group
7 *
8 *
9 * IDENTIFICATION
10 * src/backend/commands/discard.c
11 *
12 *-------------------------------------------------------------------------
13 */
14#include "postgres.h"
15
16#include "access/xact.h"
17#include "catalog/namespace.h"
18#include "commands/async.h"
19#include "commands/discard.h"
20#include "commands/prepare.h"
21#include "commands/sequence.h"
22#include "storage/lock.h"
23#include "utils/guc.h"
24#include "utils/portal.h"
25
26static void DiscardAll(bool isTopLevel);
27
28/*
29 * DISCARD { ALL | SEQUENCES | TEMP | PLANS }
30 */
31void
33{
34 switch (stmt->target)
35 {
36 case DISCARD_ALL:
38 break;
39
40 case DISCARD_PLANS:
42 break;
43
46 break;
47
48 case DISCARD_TEMP:
50 break;
51
52 default:
53 elog(ERROR, "unrecognized DISCARD target: %d", stmt->target);
54 }
55}
56
57static void
59{
60 /*
61 * Disallow DISCARD ALL in a transaction block. This is arguably
62 * inconsistent (we don't make a similar check in the command sequence
63 * that DISCARD ALL is equivalent to), but the idea is to catch mistakes:
64 * DISCARD ALL inside a transaction block would leave the transaction
65 * still uncommitted.
66 */
68
69 /* Closing portals might run user-defined code, so do that first. */
71 SetPGVariable("session_authorization", NIL, false);
79}
void Async_UnlistenAll(void)
Definition async.c:1078
void DropAllPreparedStatements(void)
Definition prepare.c:542
void ResetSequenceCaches(void)
Definition sequence.c:1906
static void DiscardAll(bool isTopLevel)
Definition discard.c:58
void DiscardCommand(DiscardStmt *stmt, bool isTopLevel)
Definition discard.c:32
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
void ResetAllOptions(void)
Definition guc.c:1910
void SetPGVariable(const char *name, List *args, bool is_local)
Definition guc_funcs.c:343
#define stmt
void LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks)
Definition lock.c:2319
#define USER_LOCKMETHOD
Definition locktag.h:26
void ResetTempTableNamespace(void)
Definition namespace.c:4716
@ DISCARD_ALL
@ DISCARD_PLANS
@ DISCARD_SEQUENCES
@ DISCARD_TEMP
#define NIL
Definition pg_list.h:68
void ResetPlanCache(void)
Definition plancache.c:2328
void PortalHashTableDeleteAll(void)
Definition portalmem.c:608
static int fb(int x)
void PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
Definition xact.c:3670