]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
oid2name: Add relation path to the information provided by -x/--extended
authorMichael Paquier <michael@paquier.xyz>
Thu, 5 Feb 2026 00:02:12 +0000 (09:02 +0900)
committerMichael Paquier <michael@paquier.xyz>
Thu, 5 Feb 2026 00:02:12 +0000 (09:02 +0900)
This affects two command patterns, showing information about relations:
* oid2name -x -d DBNAME, applying to all relations on a database.
* oid2name -x -d DBNAME -t TABNAME [-t ..], applying to a subset of
defined relations on a database.

The relative path of a relation is added to the information provided,
using pg_relation_filepath().

Author: David Bidoc <dcbidoc@gmail.com>
Reviewed-by: Laurenz Albe <laurenz.albe@cybertec.at>
Reviewed-by: Guillaume Lelarge <guillaume.lelarge@dalibo.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Reviewed-by: Mark Wong <markwkm@gmail.com>
Discussion: https://postgr.es/m/CABour1v2CU1wjjoM86wAFyezJQ3-+ncH43zY1f1uXeVojVN8Ow@mail.gmail.com

contrib/oid2name/oid2name.c
doc/src/sgml/oid2name.sgml

index 51802907138ed93409735dfef686db39cf4ce8b7..63e6ce2dae82c6f5cd880cb9c5214332e2fc5a09 100644 (file)
@@ -469,7 +469,7 @@ void
 sql_exec_dumpalltables(PGconn *conn, struct options *opts)
 {
        char            todo[1024];
-       char       *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
+       char       *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\", pg_relation_filepath(c.oid) as \"Path\" ";
 
        snprintf(todo, sizeof(todo),
                         "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s "
@@ -507,7 +507,7 @@ sql_exec_searchtables(PGconn *conn, struct options *opts)
                           *comma_filenumbers,
                           *comma_tables;
        bool            written = false;
-       char       *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\" ";
+       char       *addfields = ",c.oid AS \"Oid\", nspname AS \"Schema\", spcname as \"Tablespace\", pg_relation_filepath(c.oid) as \"Path\" ";
 
        /* get tables qualifiers, whether names, filenumbers, or OIDs */
        comma_oids = get_comma_elts(opts->oids);
index 54cc9be2b8278439d52a2927045927943e9b076a..9340d7376aae25148458c0166538f191cad67e77 100644 (file)
      <term><option>-x</option></term>
      <term><option>--extended</option></term>
      <listitem><para>display more information about each object shown: tablespace name,
-      schema name, and OID.
+      schema name, OID and path.
      </para></listitem>
     </varlistentry>
 
@@ -299,10 +299,10 @@ From database "alvherre":
 $ # you can mix the options, and get more details with -x
 $ oid2name -d alvherre -t accounts -f 1155291 -x
 From database "alvherre":
-  Filenode     Table Name      Oid  Schema  Tablespace
-------------------------------------------------------
-    155173       accounts   155173  public  pg_default
-   1155291  accounts_pkey  1155291  public  pg_default
+  Filenode     Table Name      Oid  Schema  Tablespace                Path
+--------------------------------------------------------------------------
+    155173       accounts   155173  public  pg_default   base/17228/155173
+   1155291  accounts_pkey  1155291  public  pg_default  base/17228/1155291
 
 $ # show disk space for every db object
 $ du [0-9]* |