public inbox for [email protected]  
help / color / mirror / Atom feed
oid2name : add objects file path
8+ messages / 4 participants
[nested] [flat]

* oid2name : add objects file path
@ 2025-10-07 08:55 David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Bidoc @ 2025-10-07 08:55 UTC (permalink / raw)
  To: pgsql-hackers

--0000000000009a81bb06408dba67
Content-Type: multipart/alternative; boundary="0000000000009a81b906408dba65"

--0000000000009a81b906408dba65
Content-Type: text/plain; charset="UTF-8"

Hello,

This is my first patch to the project.

I noticed that the oid2name tool does not display the file path of objects.

I thought this could be interesting and that others might find it useful,
so I made a little patch to display the full path of objects retrieved by
the oid2name tool. These will be displayed using the -x --extended option.

$ oid2name -p 5435 -x
All databases:
    Oid  Database Name  Tablespace    Filepath
----------------------------------------------
  16392             b1  pg_default  base/16392
      5       postgres  pg_default      base/5
      4      template0  pg_default      base/4
      1      template1  pg_default      base/1

$ oid2name -p 5435 -d b1 -x


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
@ 2025-10-07 09:47 ` Euler Taveira <[email protected]>
  2025-10-08 12:44   ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Euler Taveira @ 2025-10-07 09:47 UTC (permalink / raw)
  To: David Bidoc <[email protected]>; pgsql-hackers

On Tue, Oct 7, 2025, at 5:55 AM, David Bidoc wrote:
> This is my first patch to the project.
>

Welcome to Postgres community.

> I noticed that the oid2name tool does not display the file path of objects.
>
> I thought this could be interesting and that others might find it 
> useful, so I made a little patch to display the full path of objects 
> retrieved by the oid2name tool. These will be displayed using the -x 
> --extended option.
>

I didn't review your patch in details but I noticed 2 things that should be
improved:

1. The database query is wrong because it is considering that all databases are
in the default tablespace. If you create a database in a different tablespace
you will notice the mistake.

2. I suggest that you change one of the examples (maybe the last one) to
illustrate this feature.

Since you are in this area, you could create a separate patch for show the
tablespace location (-s option). Use pg_tablespace_location function.

Register your patch for the next commitfest so we don't lose track of it. [1]
If you don't have an account, the 'Log In' link will redirect you to the page
to create a new one or even allow you to use a third party sign in.

[1] https://commitfest.postgresql.org/56/


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
@ 2025-10-08 12:44   ` David Bidoc <[email protected]>
  2025-11-26 20:02     ` Re: oid2name : add objects file path Guillaume Lelarge <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Bidoc @ 2025-10-08 12:44 UTC (permalink / raw)
  To: Euler Taveira <[email protected]>; +Cc: pgsql-hackers

--00000000000071b50c0640a50b04
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Tue, Oct 7, 2025 at 11:47=E2=80=AFAM Euler Taveira <[email protected]> w=
rote:

> 1. The database query is wrong because it is considering that all databas=
es are
> in the default tablespace. If you create a database in a different tables=
pace
> you will notice the mistake.

Thank you for your feedback.

Indeed, the path is wrong if the default tablespace is not used.
I did not find a simple way to retrieve the database path (to my
knowledge there is
no function like pg_database_location() or something similar), so I have re=
moved
this part from the patch for now.

>
> 2. I suggest that you change one of the examples (maybe the last one) to
> illustrate this feature.

Here is a new example by adding a table in a different tablespace :

$ oid2name -p 5435 -d b1 -t t2 -x


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  2025-10-08 12:44   ` Re: oid2name : add objects file path David Bidoc <[email protected]>
@ 2025-11-26 20:02     ` Guillaume Lelarge <[email protected]>
  2025-12-02 10:36       ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Guillaume Lelarge @ 2025-11-26 20:02 UTC (permalink / raw)
  To: [email protected]

Hi David,

I just looked at the commit fest entry and the bot says your patch needs 
a rebase. Can you do it? Thanks.

Regards.

On 08/10/2025 14:44, David Bidoc wrote:
> On Tue, Oct 7, 2025 at 11:47 AM Euler Taveira <[email protected]> wrote:
> 
>> 1. The database query is wrong because it is considering that all databases are
>> in the default tablespace. If you create a database in a different tablespace
>> you will notice the mistake.
> 
> Thank you for your feedback.
> 
> Indeed, the path is wrong if the default tablespace is not used.
> I did not find a simple way to retrieve the database path (to my
> knowledge there is
> no function like pg_database_location() or something similar), so I have removed
> this part from the patch for now.
> 
>>
>> 2. I suggest that you change one of the examples (maybe the last one) to
>> illustrate this feature.
> 
> Here is a new example by adding a table in a different tablespace :
> 
> $ oid2name -p 5435 -d b1 -t t2 -x
>  From database "b1":
>    Filenode  Table Name    Oid  Schema  Tablespace
>                 Filepath
> ----------------------------------------------------------------------------------------------
>       16403          t2  16403  public     tblspc1
> pg_tblspc/16393/PG_19_202510082/16384/16403
> 
> 
>> Since you are in this area, you could create a separate patch for show the
>> tablespace location (-s option). Use pg_tablespace_location function.
>>
> I attached a new patch to add a column Tablespace Location to the -s option.
> 
> $ oid2name -p 5435 -s
> All tablespaces:
>      Oid  Tablespace Name  Tablespace Location
> ---------------------------------------------
>     1663       pg_default
>     1664        pg_global
>    16393          tblspc1      /mnt/tblspc1/pg
> 
>> Register your patch for the next commitfest so we don't lose track of it. [1]
>> If you don't have an account, the 'Log In' link will redirect you to the page
>> to create a new one or even allow you to use a third party sign in.
>>
>> [1] https://commitfest.postgresql.org/56/
>>
> 
> Done.
> https://commitfest.postgresql.org/patch/6111/
> 
> Regards
> David Bidoc


-- 
Guillaume Lelarge
Consultant
https://dalibo.com





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  2025-10-08 12:44   ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  2025-11-26 20:02     ` Re: oid2name : add objects file path Guillaume Lelarge <[email protected]>
@ 2025-12-02 10:36       ` David Bidoc <[email protected]>
  2025-12-04 00:46         ` Re: oid2name : add objects file path Michael Paquier <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Bidoc @ 2025-12-02 10:36 UTC (permalink / raw)
  To: Guillaume Lelarge <[email protected]>; +Cc: [email protected]

> Hi David,

Hi Guillaume,

> I just looked at the commit fest entry and the bot says your patch needs
> a rebase. Can you do it? Thanks.

I attached the rebased patch.
Any feedback would be appreciated.

Regards.

On Wed, Nov 26, 2025 at 9:02 PM Guillaume Lelarge
<[email protected]> wrote:
>
> Hi David,
>
> I just looked at the commit fest entry and the bot says your patch needs
> a rebase. Can you do it? Thanks.
>
> Regards.
>
> On 08/10/2025 14:44, David Bidoc wrote:
> > On Tue, Oct 7, 2025 at 11:47 AM Euler Taveira <[email protected]> wrote:
> >
> >> 1. The database query is wrong because it is considering that all databases are
> >> in the default tablespace. If you create a database in a different tablespace
> >> you will notice the mistake.
> >
> > Thank you for your feedback.
> >
> > Indeed, the path is wrong if the default tablespace is not used.
> > I did not find a simple way to retrieve the database path (to my
> > knowledge there is
> > no function like pg_database_location() or something similar), so I have removed
> > this part from the patch for now.
> >
> >>
> >> 2. I suggest that you change one of the examples (maybe the last one) to
> >> illustrate this feature.
> >
> > Here is a new example by adding a table in a different tablespace :
> >
> > $ oid2name -p 5435 -d b1 -t t2 -x
> >  From database "b1":
> >    Filenode  Table Name    Oid  Schema  Tablespace
> >                 Filepath
> > ----------------------------------------------------------------------------------------------
> >       16403          t2  16403  public     tblspc1
> > pg_tblspc/16393/PG_19_202510082/16384/16403
> >
> >
> >> Since you are in this area, you could create a separate patch for show the
> >> tablespace location (-s option). Use pg_tablespace_location function.
> >>
> > I attached a new patch to add a column Tablespace Location to the -s option.
> >
> > $ oid2name -p 5435 -s
> > All tablespaces:
> >      Oid  Tablespace Name  Tablespace Location
> > ---------------------------------------------
> >     1663       pg_default
> >     1664        pg_global
> >    16393          tblspc1      /mnt/tblspc1/pg
> >
> >> Register your patch for the next commitfest so we don't lose track of it. [1]
> >> If you don't have an account, the 'Log In' link will redirect you to the page
> >> to create a new one or even allow you to use a third party sign in.
> >>
> >> [1] https://commitfest.postgresql.org/56/
> >>
> >
> > Done.
> > https://commitfest.postgresql.org/patch/6111/
> >
> > Regards
> > David Bidoc
>
>
> --
> Guillaume Lelarge
> Consultant
> https://dalibo.com
>
>


Attachments:

  [application/octet-stream] oid2name_filepathv3.patch (1.7K, ../../CABour1vvNTAA1S6zTVTiaz=PWcYFHar7Z6EEP0KRq7EaGAVAdg@mail.gmail.com/2-oid2name_filepathv3.patch)
  download | inline diff:
diff --git a/contrib/oid2name/oid2name.c b/contrib/oid2name/oid2name.c
index 51802907138..4a985d579b6 100644
--- a/contrib/oid2name/oid2name.c
+++ b/contrib/oid2name/oid2name.c
@@ -469,7 +472,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 \"Filepath\" ";
 
        snprintf(todo, sizeof(todo),
                         "SELECT pg_catalog.pg_relation_filenode(c.oid) as \"Filenode\", relname as \"Table Name\" %s "
@@ -507,7 +510,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 \"Filepath\"";
 
        /* get tables qualifiers, whether names, filenumbers, or OIDs */
        comma_oids = get_comma_elts(opts->oids);
diff --git a/doc/src/sgml/oid2name.sgml b/doc/src/sgml/oid2name.sgml
index 54cc9be2b82..411950ea0e5 100644
--- a/doc/src/sgml/oid2name.sgml
+++ b/doc/src/sgml/oid2name.sgml
@@ -118,7 +118,7 @@
      <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 file path.
      </para></listitem>
     </varlistentry>


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  2025-10-08 12:44   ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  2025-11-26 20:02     ` Re: oid2name : add objects file path Guillaume Lelarge <[email protected]>
  2025-12-02 10:36       ` Re: oid2name : add objects file path David Bidoc <[email protected]>
@ 2025-12-04 00:46         ` Michael Paquier <[email protected]>
  2025-12-15 14:30           ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: Michael Paquier @ 2025-12-04 00:46 UTC (permalink / raw)
  To: David Bidoc <[email protected]>; +Cc: Guillaume Lelarge <[email protected]>; [email protected]

On Tue, Dec 02, 2025 at 11:36:39AM +0100, David Bidoc wrote:
> I attached the rebased patch.
> Any feedback would be appreciated.

Your patch still fails to apply on HEAD for all the changes of
contrib/oid2name/oid2name.c.  Please see the following:
https://commitfest.postgresql.org/patch/6111/

It also seems like Euler's feedback has not been answered.  I am
pretty sure that he was referring about the addition of an example in
the documentation, or at least refreshing the areas of the docs that
are impacted with your change (no clear idea about all that without a
rebased patch).
--
Michael


Attachments:

  [application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
  download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  2025-10-08 12:44   ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  2025-11-26 20:02     ` Re: oid2name : add objects file path Guillaume Lelarge <[email protected]>
  2025-12-02 10:36       ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  2025-12-04 00:46         ` Re: oid2name : add objects file path Michael Paquier <[email protected]>
@ 2025-12-15 14:30           ` David Bidoc <[email protected]>
  2025-12-15 23:39             ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  0 siblings, 1 reply; 8+ messages in thread

From: David Bidoc @ 2025-12-15 14:30 UTC (permalink / raw)
  To: Michael Paquier <[email protected]>; +Cc: Guillaume Lelarge <[email protected]>; [email protected]

--0000000000001bfe2e0645fe766f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Michael

On Thu, Dec 4, 2025 at 1:46=E2=80=AFAM Michael Paquier <[email protected]=
> wrote:
>
> On Tue, Dec 02, 2025 at 11:36:39AM +0100, David Bidoc wrote:
> > I attached the rebased patch.
> > Any feedback would be appreciated.
>
> Your patch still fails to apply on HEAD for all the changes of
> contrib/oid2name/oid2name.c.  Please see the following:
> https://commitfest.postgresql.org/patch/6111/
>

Thank you for your feedback.
I attached the rebased and updated patch.

> It also seems like Euler's feedback has not been answered.  I am
> pretty sure that he was referring about the addition of an example in
> the documentation, or at least refreshing the areas of the docs that
> are impacted with your change (no clear idea about all that without a
> rebased patch).

I updated the documentation example about the -x option :

$ # you can mix the options, and get more details with -x
$ oid2name -d alvherre -t accounts -f 1155291 -x


^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: oid2name : add objects file path
  2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
  2025-10-07 09:47 ` Re: oid2name : add objects file path Euler Taveira <[email protected]>
  2025-10-08 12:44   ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  2025-11-26 20:02     ` Re: oid2name : add objects file path Guillaume Lelarge <[email protected]>
  2025-12-02 10:36       ` Re: oid2name : add objects file path David Bidoc <[email protected]>
  2025-12-04 00:46         ` Re: oid2name : add objects file path Michael Paquier <[email protected]>
  2025-12-15 14:30           ` Re: oid2name : add objects file path David Bidoc <[email protected]>
@ 2025-12-15 23:39             ` Euler Taveira <[email protected]>
  0 siblings, 0 replies; 8+ messages in thread

From: Euler Taveira @ 2025-12-15 23:39 UTC (permalink / raw)
  To: David Bidoc <[email protected]>; Michael Paquier <[email protected]>; +Cc: Guillaume Lelarge <[email protected]>; [email protected]

On Mon, Dec 15, 2025, at 11:30 AM, David Bidoc wrote:
>
> Thank you for your feedback.
> I attached the rebased and updated patch.
>

This patch was in the previous CF, I'm wondering that's why the "Emails" are
not reflecting the latest patches and the CF bot was not trying it. I moved
this patch to the next CF (PG19-4).  Hopefully, the CF entry will catch up in a
couple of hours.

https://commitfest.postgresql.org/patch/6111/


-- 
Euler Taveira
EDB   https://www.enterprisedb.com/





^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2025-12-15 23:39 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-10-07 08:55 oid2name : add objects file path David Bidoc <[email protected]>
2025-10-07 09:47 ` Euler Taveira <[email protected]>
2025-10-08 12:44   ` David Bidoc <[email protected]>
2025-11-26 20:02     ` Guillaume Lelarge <[email protected]>
2025-12-02 10:36       ` David Bidoc <[email protected]>
2025-12-04 00:46         ` Michael Paquier <[email protected]>
2025-12-15 14:30           ` David Bidoc <[email protected]>
2025-12-15 23:39             ` Euler Taveira <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox