mirror of
https://github.com/postgres/postgres.git
synced 2025-07-08 11:42:09 +03:00
Rename the newly-added commands for discarding session state.
RESET SESSION, RESET PLANS, and RESET TEMP are now DISCARD ALL, DISCARD PLANS, and DISCARD TEMP, respectively. This is to avoid confusion with the pre-existing RESET variants: the DISCARD commands are not actually similar to RESET. Patch from Marko Kreen, with some minor editorialization.
This commit is contained in:
71
src/backend/commands/discard.c
Normal file
71
src/backend/commands/discard.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* discard.c
|
||||
* The implementation of the DISCARD command
|
||||
*
|
||||
* Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/discard.c,v 1.1 2007/04/26 16:13:10 neilc 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();
|
||||
ResetPlanCache();
|
||||
ResetTempTableNamespace();
|
||||
}
|
Reference in New Issue
Block a user