diff options
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/async.c | 5 | ||||
-rw-r--r-- | src/backend/commands/portalcmds.c | 11 | ||||
-rw-r--r-- | src/backend/commands/prepare.c | 32 |
3 files changed, 41 insertions, 7 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index f96ff139643..55b99f8c922 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.135 2007/01/05 22:19:25 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/async.c,v 1.136 2007/04/12 06:53:46 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -127,7 +127,6 @@ static bool unlistenExitRegistered = false; bool Trace_notify = false; -static void Async_UnlistenAll(void); static void Async_UnlistenOnExit(int code, Datum arg); static void ProcessIncomingNotify(void); static void NotifyMyFrontEnd(char *relname, int32 listenerPID); @@ -335,7 +334,7 @@ Async_Unlisten(const char *relname) * *-------------------------------------------------------------- */ -static void +void Async_UnlistenAll(void) { Relation lRel; diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c index 98b200d2cff..d759ed4ac2d 100644 --- a/src/backend/commands/portalcmds.c +++ b/src/backend/commands/portalcmds.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.62 2007/03/13 00:33:39 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/portalcmds.c,v 1.63 2007/04/12 06:53:46 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -236,11 +236,18 @@ PerformPortalClose(const char *name) { Portal portal; + /* NULL means CLOSE ALL */ + if (name == NULL) + { + PortalHashTableDeleteAll(); + return; + } + /* * Disallow empty-string cursor name (conflicts with protocol-level * unnamed portal). */ - if (!name || name[0] == '\0') + if (name[0] == '\0') ereport(ERROR, (errcode(ERRCODE_INVALID_CURSOR_NAME), errmsg("invalid cursor name: must not be empty"))); 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 |