diff options
Diffstat (limited to 'src/backend/catalog/namespace.c')
-rw-r--r-- | src/backend/catalog/namespace.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 5bacb412a97..dfaea41cfe4 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.106 2008/06/19 00:46:04 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.107 2008/07/01 02:09:34 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -2210,6 +2210,32 @@ isOtherTempNamespace(Oid namespaceId) } /* + * GetTempNamespaceBackendId - if the given namespace is a temporary-table + * namespace (either my own, or another backend's), return the BackendId + * that owns it. Temporary-toast-table namespaces are included, too. + * If it isn't a temp namespace, return -1. + */ +int +GetTempNamespaceBackendId(Oid namespaceId) +{ + int result; + char *nspname; + + /* See if the namespace name starts with "pg_temp_" or "pg_toast_temp_" */ + nspname = get_namespace_name(namespaceId); + if (!nspname) + return -1; /* no such namespace? */ + if (strncmp(nspname, "pg_temp_", 8) == 0) + result = atoi(nspname + 8); + else if (strncmp(nspname, "pg_toast_temp_", 14) == 0) + result = atoi(nspname + 14); + else + result = -1; + pfree(nspname); + return result; +} + +/* * 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) |