Commit 82eed4db authored by Tom Lane's avatar Tom Lane

Arrange to put TOAST tables belonging to temporary tables into special schemas

named pg_toast_temp_nnn, alongside the pg_temp_nnn schemas used for the temp
tables themselves.  This allows low-level code such as the relcache to
recognize that these tables are indeed temporary, which enables various
optimizations such as not WAL-logging changes and using local rather than
shared buffers for access.  Aside from obvious performance benefits, this
provides a solution to bug #3483, in which other backends unexpectedly held
open file references to temporary tables.  The scheme preserves the property
that TOAST tables are not in any schema that's normally in the search path,
so they don't conflict with user table names.

initdb forced because of changes in system view definitions.
parent fdb5b69e
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Originally by * Originally by
* B. Palmer, bpalmer@crimelabs.net 1-17-2001 * B. Palmer, bpalmer@crimelabs.net 1-17-2001
* $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.31 2007/07/15 22:54:20 tgl Exp $ * $PostgreSQL: pgsql/contrib/oid2name/oid2name.c,v 1.32 2007/07/25 22:16:17 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
...@@ -411,7 +411,7 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts) ...@@ -411,7 +411,7 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts)
" LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace " " LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace "
" LEFT JOIN pg_catalog.pg_database d ON d.datname = current_database()," " LEFT JOIN pg_catalog.pg_database d ON d.datname = current_database(),"
" pg_catalog.pg_tablespace t " " pg_catalog.pg_tablespace t "
"WHERE relkind IN ('r'%s) AND " "WHERE relkind IN ('r'%s%s) AND "
" %s" " %s"
" t.oid = CASE" " t.oid = CASE"
" WHEN reltablespace <> 0 THEN reltablespace" " WHEN reltablespace <> 0 THEN reltablespace"
...@@ -419,8 +419,9 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts) ...@@ -419,8 +419,9 @@ sql_exec_dumpalltables(PGconn *conn, struct options * opts)
" END " " END "
"ORDER BY relname", "ORDER BY relname",
opts->extended ? addfields : "", opts->extended ? addfields : "",
opts->indexes ? ", 'i', 'S', 't'" : "", opts->indexes ? ", 'i', 'S'" : "",
opts->systables ? "" : "n.nspname NOT IN ('pg_catalog', 'pg_toast', 'information_schema') AND"); opts->systables ? ", 't'" : "",
opts->systables ? "" : "n.nspname NOT IN ('pg_catalog', 'information_schema') AND n.nspname !~ '^pg_toast' AND");
sql_exec(conn, todo, opts->quiet); sql_exec(conn, todo, opts->quiet);
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.70 2007/03/25 19:45:14 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.71 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "access/transam.h" #include "access/transam.h"
#include "catalog/catalog.h" #include "catalog/catalog.h"
#include "catalog/indexing.h" #include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_auth_members.h" #include "catalog/pg_auth_members.h"
#include "catalog/pg_authid.h" #include "catalog/pg_authid.h"
#include "catalog/pg_database.h" #include "catalog/pg_database.h"
...@@ -196,15 +197,17 @@ IsSystemNamespace(Oid namespaceId) ...@@ -196,15 +197,17 @@ IsSystemNamespace(Oid namespaceId)
/* /*
* IsToastNamespace * IsToastNamespace
* True iff namespace is pg_toast. * True iff namespace is pg_toast or my temporary-toast-table namespace.
* *
* NOTE: the reason this isn't a macro is to avoid having to include * Note: this will return false for temporary-toast-table namespaces belonging
* catalog/pg_namespace.h in a lot of places. * to other backends. Those are treated the same as other backends' regular
* temp table namespaces, and access is prevented where appropriate.
*/ */
bool bool
IsToastNamespace(Oid namespaceId) IsToastNamespace(Oid namespaceId)
{ {
return namespaceId == PG_TOAST_NAMESPACE; return (namespaceId == PG_TOAST_NAMESPACE) ||
isTempToastNamespace(namespaceId);
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.96 2007/04/20 02:37:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.97 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -152,6 +152,9 @@ static List *overrideStack = NIL; ...@@ -152,6 +152,9 @@ static List *overrideStack = NIL;
* in a particular backend session (this happens when a CREATE TEMP TABLE * in a particular backend session (this happens when a CREATE TEMP TABLE
* command is first executed). Thereafter it's the OID of the temp namespace. * command is first executed). Thereafter it's the OID of the temp namespace.
* *
* myTempToastNamespace is the OID of the namespace for my temp tables' toast
* tables. It is set when myTempNamespace is, and is InvalidOid before that.
*
* myTempNamespaceSubID shows whether we've created the TEMP namespace in the * myTempNamespaceSubID shows whether we've created the TEMP namespace in the
* current subtransaction. The flag propagates up the subtransaction tree, * current subtransaction. The flag propagates up the subtransaction tree,
* so the main transaction will correctly recognize the flag if all * so the main transaction will correctly recognize the flag if all
...@@ -161,6 +164,8 @@ static List *overrideStack = NIL; ...@@ -161,6 +164,8 @@ static List *overrideStack = NIL;
*/ */
static Oid myTempNamespace = InvalidOid; static Oid myTempNamespace = InvalidOid;
static Oid myTempToastNamespace = InvalidOid;
static SubTransactionId myTempNamespaceSubID = InvalidSubTransactionId; static SubTransactionId myTempNamespaceSubID = InvalidSubTransactionId;
/* /*
...@@ -1599,9 +1604,35 @@ isTempNamespace(Oid namespaceId) ...@@ -1599,9 +1604,35 @@ isTempNamespace(Oid namespaceId)
return false; return false;
} }
/*
* isTempToastNamespace - is the given namespace my temporary-toast-table
* namespace?
*/
bool
isTempToastNamespace(Oid namespaceId)
{
if (OidIsValid(myTempToastNamespace) && myTempToastNamespace == namespaceId)
return true;
return false;
}
/*
* isTempOrToastNamespace - is the given namespace my temporary-table
* namespace or my temporary-toast-table namespace?
*/
bool
isTempOrToastNamespace(Oid namespaceId)
{
if (OidIsValid(myTempNamespace) &&
(myTempNamespace == namespaceId || myTempToastNamespace == namespaceId))
return true;
return false;
}
/* /*
* isAnyTempNamespace - is the given namespace a temporary-table namespace * isAnyTempNamespace - is the given namespace a temporary-table namespace
* (either my own, or another backend's)? * (either my own, or another backend's)? Temporary-toast-table namespaces
* are included, too.
*/ */
bool bool
isAnyTempNamespace(Oid namespaceId) isAnyTempNamespace(Oid namespaceId)
...@@ -1609,29 +1640,42 @@ isAnyTempNamespace(Oid namespaceId) ...@@ -1609,29 +1640,42 @@ isAnyTempNamespace(Oid namespaceId)
bool result; bool result;
char *nspname; char *nspname;
/* If the namespace name starts with "pg_temp_", say "true" */ /* True if the namespace name starts with "pg_temp_" or "pg_toast_temp_" */
nspname = get_namespace_name(namespaceId); nspname = get_namespace_name(namespaceId);
if (!nspname) if (!nspname)
return false; /* no such namespace? */ return false; /* no such namespace? */
result = (strncmp(nspname, "pg_temp_", 8) == 0); result = (strncmp(nspname, "pg_temp_", 8) == 0) ||
(strncmp(nspname, "pg_toast_temp_", 14) == 0);
pfree(nspname); pfree(nspname);
return result; return result;
} }
/* /*
* isOtherTempNamespace - is the given namespace some other backend's * isOtherTempNamespace - is the given namespace some other backend's
* temporary-table namespace? * temporary-table namespace (including temporary-toast-table namespaces)?
*/ */
bool bool
isOtherTempNamespace(Oid namespaceId) isOtherTempNamespace(Oid namespaceId)
{ {
/* If it's my own temp namespace, say "false" */ /* If it's my own temp namespace, say "false" */
if (isTempNamespace(namespaceId)) if (isTempOrToastNamespace(namespaceId))
return false; return false;
/* Else, if the namespace name starts with "pg_temp_", say "true" */ /* Else, if it's any temp namespace, say "true" */
return isAnyTempNamespace(namespaceId); return isAnyTempNamespace(namespaceId);
} }
/*
* GetTempToastNamespace - get the OID of my temporary-toast-table namespace,
* which must already be assigned. (This is only used when creating a toast
* table for a temp table, so we must have already done InitTempTableNamespace)
*/
Oid
GetTempToastNamespace(void)
{
Assert(OidIsValid(myTempToastNamespace));
return myTempToastNamespace;
}
/* /*
* GetOverrideSearchPath - fetch current search path definition in form * GetOverrideSearchPath - fetch current search path definition in form
...@@ -2006,6 +2050,7 @@ InitTempTableNamespace(void) ...@@ -2006,6 +2050,7 @@ InitTempTableNamespace(void)
{ {
char namespaceName[NAMEDATALEN]; char namespaceName[NAMEDATALEN];
Oid namespaceId; Oid namespaceId;
Oid toastspaceId;
Assert(!OidIsValid(myTempNamespace)); Assert(!OidIsValid(myTempNamespace));
...@@ -2054,12 +2099,31 @@ InitTempTableNamespace(void) ...@@ -2054,12 +2099,31 @@ InitTempTableNamespace(void)
RemoveTempRelations(namespaceId); RemoveTempRelations(namespaceId);
} }
/*
* If the corresponding temp-table namespace doesn't exist yet, create it.
* (We assume there is no need to clean it out if it does exist, since
* dropping a parent table should make its toast table go away.)
*/
snprintf(namespaceName, sizeof(namespaceName), "pg_toast_temp_%d",
MyBackendId);
toastspaceId = GetSysCacheOid(NAMESPACENAME,
CStringGetDatum(namespaceName),
0, 0, 0);
if (!OidIsValid(toastspaceId))
{
toastspaceId = NamespaceCreate(namespaceName, BOOTSTRAP_SUPERUSERID);
/* Advance command counter to make namespace visible */
CommandCounterIncrement();
}
/* /*
* Okay, we've prepared the temp namespace ... but it's not committed yet, * Okay, we've prepared the temp namespace ... but it's not committed yet,
* so all our work could be undone by transaction rollback. Set flag for * so all our work could be undone by transaction rollback. Set flag for
* AtEOXact_Namespace to know what to do. * AtEOXact_Namespace to know what to do.
*/ */
myTempNamespace = namespaceId; myTempNamespace = namespaceId;
myTempToastNamespace = toastspaceId;
/* It should not be done already. */ /* It should not be done already. */
AssertState(myTempNamespaceSubID == InvalidSubTransactionId); AssertState(myTempNamespaceSubID == InvalidSubTransactionId);
...@@ -2089,6 +2153,7 @@ AtEOXact_Namespace(bool isCommit) ...@@ -2089,6 +2153,7 @@ AtEOXact_Namespace(bool isCommit)
else else
{ {
myTempNamespace = InvalidOid; myTempNamespace = InvalidOid;
myTempToastNamespace = InvalidOid;
baseSearchPathValid = false; /* need to rebuild list */ baseSearchPathValid = false; /* need to rebuild list */
} }
myTempNamespaceSubID = InvalidSubTransactionId; myTempNamespaceSubID = InvalidSubTransactionId;
...@@ -2140,6 +2205,7 @@ AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid, ...@@ -2140,6 +2205,7 @@ AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
myTempNamespaceSubID = InvalidSubTransactionId; myTempNamespaceSubID = InvalidSubTransactionId;
/* TEMP namespace creation failed, so reset state */ /* TEMP namespace creation failed, so reset state */
myTempNamespace = InvalidOid; myTempNamespace = InvalidOid;
myTempToastNamespace = InvalidOid;
baseSearchPathValid = false; /* need to rebuild list */ baseSearchPathValid = false; /* need to rebuild list */
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 1996-2007, PostgreSQL Global Development Group * Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.38 2007/06/28 00:02:37 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.39 2007/07/25 22:16:18 tgl Exp $
*/ */
CREATE VIEW pg_roles AS CREATE VIEW pg_roles AS
...@@ -221,11 +221,13 @@ CREATE VIEW pg_stat_all_tables AS ...@@ -221,11 +221,13 @@ CREATE VIEW pg_stat_all_tables AS
CREATE VIEW pg_stat_sys_tables AS CREATE VIEW pg_stat_sys_tables AS
SELECT * FROM pg_stat_all_tables SELECT * FROM pg_stat_all_tables
WHERE schemaname IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname IN ('pg_catalog', 'information_schema') OR
schemaname ~ '^pg_toast';
CREATE VIEW pg_stat_user_tables AS CREATE VIEW pg_stat_user_tables AS
SELECT * FROM pg_stat_all_tables SELECT * FROM pg_stat_all_tables
WHERE schemaname NOT IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
CREATE VIEW pg_statio_all_tables AS CREATE VIEW pg_statio_all_tables AS
SELECT SELECT
...@@ -254,11 +256,13 @@ CREATE VIEW pg_statio_all_tables AS ...@@ -254,11 +256,13 @@ CREATE VIEW pg_statio_all_tables AS
CREATE VIEW pg_statio_sys_tables AS CREATE VIEW pg_statio_sys_tables AS
SELECT * FROM pg_statio_all_tables SELECT * FROM pg_statio_all_tables
WHERE schemaname IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname IN ('pg_catalog', 'information_schema') OR
schemaname ~ '^pg_toast';
CREATE VIEW pg_statio_user_tables AS CREATE VIEW pg_statio_user_tables AS
SELECT * FROM pg_statio_all_tables SELECT * FROM pg_statio_all_tables
WHERE schemaname NOT IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
CREATE VIEW pg_stat_all_indexes AS CREATE VIEW pg_stat_all_indexes AS
SELECT SELECT
...@@ -278,11 +282,13 @@ CREATE VIEW pg_stat_all_indexes AS ...@@ -278,11 +282,13 @@ CREATE VIEW pg_stat_all_indexes AS
CREATE VIEW pg_stat_sys_indexes AS CREATE VIEW pg_stat_sys_indexes AS
SELECT * FROM pg_stat_all_indexes SELECT * FROM pg_stat_all_indexes
WHERE schemaname IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname IN ('pg_catalog', 'information_schema') OR
schemaname ~ '^pg_toast';
CREATE VIEW pg_stat_user_indexes AS CREATE VIEW pg_stat_user_indexes AS
SELECT * FROM pg_stat_all_indexes SELECT * FROM pg_stat_all_indexes
WHERE schemaname NOT IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
CREATE VIEW pg_statio_all_indexes AS CREATE VIEW pg_statio_all_indexes AS
SELECT SELECT
...@@ -302,11 +308,13 @@ CREATE VIEW pg_statio_all_indexes AS ...@@ -302,11 +308,13 @@ CREATE VIEW pg_statio_all_indexes AS
CREATE VIEW pg_statio_sys_indexes AS CREATE VIEW pg_statio_sys_indexes AS
SELECT * FROM pg_statio_all_indexes SELECT * FROM pg_statio_all_indexes
WHERE schemaname IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname IN ('pg_catalog', 'information_schema') OR
schemaname ~ '^pg_toast';
CREATE VIEW pg_statio_user_indexes AS CREATE VIEW pg_statio_user_indexes AS
SELECT * FROM pg_statio_all_indexes SELECT * FROM pg_statio_all_indexes
WHERE schemaname NOT IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
CREATE VIEW pg_statio_all_sequences AS CREATE VIEW pg_statio_all_sequences AS
SELECT SELECT
...@@ -322,11 +330,13 @@ CREATE VIEW pg_statio_all_sequences AS ...@@ -322,11 +330,13 @@ CREATE VIEW pg_statio_all_sequences AS
CREATE VIEW pg_statio_sys_sequences AS CREATE VIEW pg_statio_sys_sequences AS
SELECT * FROM pg_statio_all_sequences SELECT * FROM pg_statio_all_sequences
WHERE schemaname IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname IN ('pg_catalog', 'information_schema') OR
schemaname ~ '^pg_toast';
CREATE VIEW pg_statio_user_sequences AS CREATE VIEW pg_statio_user_sequences AS
SELECT * FROM pg_statio_all_sequences SELECT * FROM pg_statio_all_sequences
WHERE schemaname NOT IN ('pg_catalog', 'pg_toast', 'information_schema'); WHERE schemaname NOT IN ('pg_catalog', 'information_schema') AND
schemaname !~ '^pg_toast';
CREATE VIEW pg_stat_activity AS CREATE VIEW pg_stat_activity AS
SELECT SELECT
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.6 2007/04/06 04:21:42 tgl Exp $ * $PostgreSQL: pgsql/src/backend/catalog/toasting.c,v 1.7 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "catalog/heap.h" #include "catalog/heap.h"
#include "catalog/index.h" #include "catalog/index.h"
#include "catalog/indexing.h" #include "catalog/indexing.h"
#include "catalog/namespace.h"
#include "catalog/pg_namespace.h" #include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h" #include "catalog/pg_opclass.h"
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
...@@ -108,6 +109,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid) ...@@ -108,6 +109,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid)
Relation class_rel; Relation class_rel;
Oid toast_relid; Oid toast_relid;
Oid toast_idxid; Oid toast_idxid;
Oid namespaceid;
char toast_relname[NAMEDATALEN]; char toast_relname[NAMEDATALEN];
char toast_idxname[NAMEDATALEN]; char toast_idxname[NAMEDATALEN];
IndexInfo *indexInfo; IndexInfo *indexInfo;
...@@ -173,16 +175,20 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid) ...@@ -173,16 +175,20 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid)
tupdesc->attrs[2]->attstorage = 'p'; tupdesc->attrs[2]->attstorage = 'p';
/* /*
* Note: the toast relation is placed in the regular pg_toast namespace * Toast tables for regular relations go in pg_toast; those for temp
* even if its master relation is a temp table. There cannot be any * relations go into the per-backend temp-toast-table namespace.
* naming collision, and the toast rel will be destroyed when its master */
* is, so there's no need to handle the toast rel as temp. if (rel->rd_istemp)
* namespaceid = GetTempToastNamespace();
else
namespaceid = PG_TOAST_NAMESPACE;
/*
* XXX would it make sense to apply the master's reloptions to the toast * XXX would it make sense to apply the master's reloptions to the toast
* table? * table? Or maybe some toast-specific reloptions?
*/ */
toast_relid = heap_create_with_catalog(toast_relname, toast_relid = heap_create_with_catalog(toast_relname,
PG_TOAST_NAMESPACE, namespaceid,
rel->rd_rel->reltablespace, rel->rd_rel->reltablespace,
toastOid, toastOid,
rel->rd_rel->relowner, rel->rd_rel->relowner,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.91 2007/06/19 20:13:21 tgl Exp $ * $PostgreSQL: pgsql/src/backend/storage/lmgr/lmgr.c,v 1.92 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -619,7 +619,7 @@ LockTagIsTemp(const LOCKTAG *tag) ...@@ -619,7 +619,7 @@ LockTagIsTemp(const LOCKTAG *tag)
/* field1 is dboid, field2 is reloid for all of these */ /* field1 is dboid, field2 is reloid for all of these */
if ((Oid) tag->locktag_field1 == InvalidOid) if ((Oid) tag->locktag_field1 == InvalidOid)
return false; /* shared, so not temp */ return false; /* shared, so not temp */
if (isTempNamespace(get_rel_namespace((Oid) tag->locktag_field2))) if (isTempOrToastNamespace(get_rel_namespace((Oid) tag->locktag_field2)))
return true; return true;
break; break;
case LOCKTAG_TRANSACTION: case LOCKTAG_TRANSACTION:
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.261 2007/05/27 03:50:39 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/cache/relcache.c,v 1.262 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -838,7 +838,7 @@ RelationBuildDesc(Oid targetRelId, Relation oldrelation) ...@@ -838,7 +838,7 @@ RelationBuildDesc(Oid targetRelId, Relation oldrelation)
relation->rd_isnailed = false; relation->rd_isnailed = false;
relation->rd_createSubid = InvalidSubTransactionId; relation->rd_createSubid = InvalidSubTransactionId;
relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
relation->rd_istemp = isTempNamespace(relation->rd_rel->relnamespace); relation->rd_istemp = isTempOrToastNamespace(relation->rd_rel->relnamespace);
/* /*
* initialize the tuple descriptor (relation->rd_att). * initialize the tuple descriptor (relation->rd_att).
...@@ -2315,7 +2315,7 @@ RelationBuildLocalRelation(const char *relname, ...@@ -2315,7 +2315,7 @@ RelationBuildLocalRelation(const char *relname,
need_eoxact_work = true; need_eoxact_work = true;
/* is it a temporary relation? */ /* is it a temporary relation? */
rel->rd_istemp = isTempNamespace(relnamespace); rel->rd_istemp = isTempOrToastNamespace(relnamespace);
/* /*
* create a new tuple descriptor from the one passed in. We do this * create a new tuple descriptor from the one passed in. We do this
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.156 2007/06/28 06:40:16 neilc Exp $ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.157 2007/07/25 22:16:18 tgl Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "describe.h" #include "describe.h"
...@@ -1688,9 +1688,12 @@ listTables(const char *tabtypes, const char *pattern, bool verbose) ...@@ -1688,9 +1688,12 @@ listTables(const char *tabtypes, const char *pattern, bool verbose)
* pg_catalog and pg_toast. (We don't want to hide temp tables though.) * pg_catalog and pg_toast. (We don't want to hide temp tables though.)
*/ */
if (showSystem) if (showSystem)
appendPQExpBuffer(&buf, " AND n.nspname = 'pg_catalog'\n"); appendPQExpBuffer(&buf,
" AND n.nspname = 'pg_catalog'\n");
else else
appendPQExpBuffer(&buf, " AND n.nspname NOT IN ('pg_catalog', 'pg_toast')\n"); appendPQExpBuffer(&buf,
" AND n.nspname <> 'pg_catalog'\n"
" AND n.nspname !~ '^pg_toast'\n");
processSQLNamePattern(pset.db, &buf, pattern, true, false, processSQLNamePattern(pset.db, &buf, pattern, true, false,
"n.nspname", "c.relname", NULL, "n.nspname", "c.relname", NULL,
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.414 2007/07/06 04:15:59 tgl Exp $ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.415 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -53,6 +53,6 @@ ...@@ -53,6 +53,6 @@
*/ */
/* yyyymmddN */ /* yyyymmddN */
#define CATALOG_VERSION_NO 200707051 #define CATALOG_VERSION_NO 200707251
#endif #endif
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.47 2007/04/12 22:34:45 neilc Exp $ * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.48 2007/07/25 22:16:18 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -79,8 +79,11 @@ extern char *NameListToString(List *names); ...@@ -79,8 +79,11 @@ extern char *NameListToString(List *names);
extern char *NameListToQuotedString(List *names); extern char *NameListToQuotedString(List *names);
extern bool isTempNamespace(Oid namespaceId); extern bool isTempNamespace(Oid namespaceId);
extern bool isTempToastNamespace(Oid namespaceId);
extern bool isTempOrToastNamespace(Oid namespaceId);
extern bool isAnyTempNamespace(Oid namespaceId); extern bool isAnyTempNamespace(Oid namespaceId);
extern bool isOtherTempNamespace(Oid namespaceId); extern bool isOtherTempNamespace(Oid namespaceId);
extern Oid GetTempToastNamespace(void);
extern void ResetTempTableNamespace(void); extern void ResetTempTableNamespace(void);
extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context); extern OverrideSearchPath *GetOverrideSearchPath(MemoryContext context);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment