Skip to content

Commit 3769fa5

Browse files
committed
Make pg_tablespace_location(0) return the database's default tablespace.
This definition is convenient when applying the function to the reltablespace column of pg_class, since that's what zero means there; and it doesn't interfere with any other plausible use of the function. Per gripe from Bruce Momjian.
1 parent 38458e4 commit 3769fa5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/backend/utils/adt/misc.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,15 @@ pg_tablespace_location(PG_FUNCTION_ARGS)
335335
int rllen;
336336

337337
/*
338-
* Return empty string for our default tablespaces
338+
* It's useful to apply this function to pg_class.reltablespace, wherein
339+
* zero means "the database's default tablespace". So, rather than
340+
* throwing an error for zero, we choose to assume that's what is meant.
341+
*/
342+
if (tablespaceOid == InvalidOid)
343+
tablespaceOid = MyDatabaseTableSpace;
344+
345+
/*
346+
* Return empty string for the cluster's default tablespaces
339347
*/
340348
if (tablespaceOid == DEFAULTTABLESPACE_OID ||
341349
tablespaceOid == GLOBALTABLESPACE_OID)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy