diff options
author | Neil Conway <neilc@samurai.com> | 2007-04-12 06:53:49 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2007-04-12 06:53:49 +0000 |
commit | d13e903beaecd45a3721e4c2a7f9ff842ce94a79 (patch) | |
tree | 3ded6910c6f451bb982fb5033735afd24927c5b6 /src/backend/commands/prepare.c | |
parent | e6e47f278d2ab0fc744b56fed86cc34299079037 (diff) |
RESET SESSION, plus related new DDL commands. Patch from Marko Kreen,
reviewed by Neil Conway. This patch adds the following DDL command
variants: RESET SESSION, RESET TEMP, RESET PLANS, CLOSE ALL, and
DEALLOCATE ALL. RESET SESSION is intended for use by connection
pool software and the like, in order to reset a client session
to something close to its initial state.
Note that while most of these command variants can be executed
inside a transaction block (but are not transaction-aware!),
RESET SESSION cannot. While this is inconsistent, it is intended
to catch programmer mistakes: RESET SESSION in an open transaction
block is probably unintended.
Diffstat (limited to 'src/backend/commands/prepare.c')
-rw-r--r-- | src/backend/commands/prepare.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 2c284cb9be0..fe1a8532f07 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2007, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.70 2007/03/13 00:33:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/prepare.c,v 1.71 2007/04/12 06:53:46 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -575,7 +575,10 @@ FetchPreparedStatementTargetList(PreparedStatement *stmt) void DeallocateQuery(DeallocateStmt *stmt) { - DropPreparedStatement(stmt->name, true); + if (stmt->name) + DropPreparedStatement(stmt->name, true); + else + DropAllPreparedStatements(); } /* @@ -602,6 +605,31 @@ DropPreparedStatement(const char *stmt_name, bool showError) } /* + * Drop all cached statements. + */ +void +DropAllPreparedStatements(void) +{ + HASH_SEQ_STATUS seq; + PreparedStatement *entry; + + /* nothing cached */ + if (!prepared_queries) + return; + + /* walk over cache */ + hash_seq_init(&seq, prepared_queries); + while ((entry = hash_seq_search(&seq)) != NULL) + { + /* Release the plancache entry */ + DropCachedPlan(entry->plansource); + + /* Now we can remove the hash table entry */ + hash_search(prepared_queries, entry->stmt_name, HASH_REMOVE, NULL); + } +} + +/* * Implements the 'EXPLAIN EXECUTE' utility statement. */ void |