From d13e903beaecd45a3721e4c2a7f9ff842ce94a79 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Thu, 12 Apr 2007 06:53:49 +0000 Subject: 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. --- src/backend/catalog/namespace.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/backend/catalog/namespace.c') diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 6baa9a798b..16853b3d79 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.93 2007/03/23 19:53:51 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.94 2007/04/12 06:53:46 neilc Exp $ * *------------------------------------------------------------------------- */ @@ -1940,6 +1940,26 @@ InitTempTableNamespace(void) baseSearchPathValid = false; /* need to rebuild list */ } +/* + * Remove all temp tables from the temporary namespace. + */ +void +ResetTempTableNamespace(void) +{ + char namespaceName[NAMEDATALEN]; + Oid namespaceId; + + /* find oid */ + snprintf(namespaceName, sizeof(namespaceName), "pg_temp_%d", MyBackendId); + namespaceId = GetSysCacheOid(NAMESPACENAME, + CStringGetDatum(namespaceName), + 0, 0, 0); + + /* clean if exists */ + if (OidIsValid(namespaceId)) + RemoveTempRelations(namespaceId); +} + /* * End-of-transaction cleanup for namespaces. */ -- cgit v1.2.1