PostgreSQL Source Code  git master
discard.c File Reference
#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/sequence.h"
#include "utils/guc.h"
#include "utils/portal.h"
Include dependency graph for discard.c:

Go to the source code of this file.


static void DiscardAll (bool isTopLevel)
void DiscardCommand (DiscardStmt *stmt, bool isTopLevel)

Function Documentation

◆ DiscardAll()

static void DiscardAll ( bool  isTopLevel)

Definition at line 57 of file discard.c.

References Async_UnlistenAll(), DropAllPreparedStatements(), LockReleaseAll(), NIL, PortalHashTableDeleteAll(), PreventInTransactionBlock(), ResetAllOptions(), ResetPlanCache(), ResetSequenceCaches(), ResetTempTableNamespace(), SetPGVariable(), and USER_LOCKMETHOD.

Referenced by DiscardCommand().

58 {
59  /*
60  * Disallow DISCARD ALL in a transaction block. This is arguably
61  * inconsistent (we don't make a similar check in the command sequence
62  * that DISCARD ALL is equivalent to), but the idea is to catch mistakes:
63  * DISCARD ALL inside a transaction block would leave the transaction
64  * still uncommitted.
65  */
66  PreventInTransactionBlock(isTopLevel, "DISCARD ALL");
68  /* Closing portals might run user-defined code, so do that first. */
70  SetPGVariable("session_authorization", NIL, false);
78 }
void ResetTempTableNamespace(void)
Definition: namespace.c:4306
#define NIL
Definition: pg_list.h:65
void ResetAllOptions(void)
Definition: guc.c:6024
void ResetPlanCache(void)
Definition: plancache.c:2149
Definition: lock.h:130
void PreventInTransactionBlock(bool isTopLevel, const char *stmtType)
Definition: xact.c:3393
void ResetSequenceCaches(void)
Definition: sequence.c:1909
void PortalHashTableDeleteAll(void)
Definition: portalmem.c:607
void LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks)
Definition: lock.c:2180
void Async_UnlistenAll(void)
Definition: async.c:804
void SetPGVariable(const char *name, List *args, bool is_local)
Definition: guc.c:8865
void DropAllPreparedStatements(void)
Definition: prepare.c:574

◆ DiscardCommand()

void DiscardCommand ( DiscardStmt stmt,
bool  isTopLevel 

Definition at line 31 of file discard.c.

References DISCARD_ALL, DISCARD_PLANS, DISCARD_SEQUENCES, DISCARD_TEMP, DiscardAll(), elog, ERROR, ResetPlanCache(), ResetSequenceCaches(), ResetTempTableNamespace(), and DiscardStmt::target.

Referenced by standard_ProcessUtility().

32 {
33  switch (stmt->target)
34  {
35  case DISCARD_ALL:
36  DiscardAll(isTopLevel);
37  break;
41  break;
45  break;
47  case DISCARD_TEMP:
49  break;
51  default:
52  elog(ERROR, "unrecognized DISCARD target: %d", stmt->target);
53  }
54 }
void ResetTempTableNamespace(void)
Definition: namespace.c:4306
#define ERROR
Definition: elog.h:46
void ResetPlanCache(void)
Definition: plancache.c:2149
void ResetSequenceCaches(void)
Definition: sequence.c:1909
DiscardMode target
Definition: parsenodes.h:3452
static void DiscardAll(bool isTopLevel)
Definition: discard.c:57
#define elog(elevel,...)
Definition: elog.h:232