pgsql: Fix pg_tablespace_location() with in-place tablespaces

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix pg_tablespace_location() with in-place tablespaces
Date: 2022-03-17 02:26:47
Message-ID: E1nUfqg-0003Q2-NH@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix pg_tablespace_location() with in-place tablespaces

Using this system function with an in-place tablespace (created when
allow_in_place_tablespaces is enabled by specifying an empty string as
location) caused a failure when using readlink(), as the tablespace is,
in this case, not a symbolic link in pg_tblspc/ but a directory.

Rather than getting a failure, the commit changes
pg_tablespace_location() so as a relative path to the data directory is
returned for in-place tablespaces, to make a difference between
tablespaces created when allow_in_place_tablespaces is enabled or not.
Getting a path rather than an empty string that would match the CREATE
TABLESPACE command in this case is more useful for tests that would like
to rely on this function.

While on it, a regression test is added for this case. This is simple
to add in the main regression test suite thanks to regexp_replace() to
mask the part of the tablespace location dependent on its OID.

Author: Michael Paquier
Reviewed-by: Kyotaro Horiguchi, Thomas Munro
Discussion: https://postgr.es/m/YiG1RleON1WBcLnX@paquier.xyz

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/f6f0db4d62400ff88f523dcc4d7e25f9506bc0d8

Modified Files
--------------
doc/src/sgml/func.sgml | 8 +++++++-
src/backend/utils/adt/misc.c | 29 +++++++++++++++++++++++++++++
src/test/regress/expected/tablespace.out | 9 +++++++++
src/test/regress/sql/tablespace.sql | 4 ++++
4 files changed, 49 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2022-03-17 10:22:32 pgsql: Add option to use ICU as global locale provider
Previous Message Michael Paquier 2022-03-17 01:56:02 Re: pgsql: Allow extensions to add new backup targets.