Re: logical decoding/replication: new functions pg_ls_logicaldir and pg_ls_replslotdir - Mailing list pgsql-hackers

From Bossart, Nathan
Subject Re: logical decoding/replication: new functions pg_ls_logicaldir and pg_ls_replslotdir
Date
Msg-id D3D7B42F-9675-4B30-BD10-F82D8AE9A02D@amazon.com
Whole thread Raw
In response to Re: logical decoding/replication: new functions pg_ls_logicaldir and pg_ls_replslotdir  (Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>)
Responses Re: logical decoding/replication: new functions pg_ls_logicaldir and pg_ls_replslotdir
List pgsql-hackers
On 10/30/21, 2:36 AM, "Bharath Rupireddy" <bharath.rupireddyforpostgres@gmail.com> wrote:
> I've added 3 functions pg_ls_logicalsnapdir, pg_ls_logicalmapdir,
> pg_ls_replslotdir, and attached the patch. The sample output looks
> like [1]. Please review it further.

I took a look at the patch.

+    char        path[MAXPGPATH + 11];

Why are you adding 11 to MAXPGPATH here?  I would think that MAXPGPATH
is sufficient.

+    filename = text_to_cstring(filename_t);
+    snprintf(path, sizeof(path), "%s/%s", "pg_replslot", filename);
+    return pg_ls_dir_files(fcinfo, path, false);

I think we need to do some additional input validation here.  It's
pretty easy to use this to see the contents of other directories.

        postgres=# SELECT * FROM pg_ls_replslotdir('../');
                 name         | size  |      modification
        ----------------------+-------+------------------------
         postgresql.conf      | 28995 | 2021-11-17 18:40:33+00
         pg_hba.conf          |  4789 | 2021-11-17 18:40:33+00
         postmaster.opts      |    39 | 2021-11-17 18:43:07+00
         postgresql.auto.conf |    88 | 2021-11-17 18:40:33+00
         pg_ident.conf        |  1636 | 2021-11-17 18:40:33+00
         postmaster.pid       |    95 | 2021-11-17 18:43:07+00
         PG_VERSION           |     3 | 2021-11-17 18:40:33+00
        (7 rows)

Nathan


pgsql-hackers by date:

Previous
From: Melanie Plageman
Date:
Subject: Re: Parallel Full Hash Join
Next
From: Tomas Vondra
Date:
Subject: Re: Propose a new hook for mutating the query bounds