Re: New 'pg' consolidated metacommand patch

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: New 'pg' consolidated metacommand patch
Date: 2020-05-27 08:50:48
Message-ID: CABUevEzneJB4=i_O9r83v8sswdwBY9kY393XPPOU=iOAKDenkA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 27, 2020 at 1:19 AM Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>
wrote:

> Hackers,
>
> Attached is a patch for a `pg' command that consolidates various
> PostgreSQL functionality into a single command, along the lines of how
> `git' commands are run from a single 'git' executable. In other words,
>
> `pg upgrade` # instead of `pg_upgrade`
> `pg resetwal` # instead of `pg_resetwal`
>
> This has been discussed before on the -hackers list, but I don't recall
> seeing a patch. I'm submitting this patch mostly as a way of moving the
> conversation along, fully expecting the community to want some (or all) of
> what I wrote to be changed.
>

As mentioned at least once before, the "pg" name is already taken in posix.
Granted it has been removed now, but it was removed from posix in 2018,
which I think is nowhere near soon enough to "steal. See for example
https://en.wikipedia.org/wiki/Pg_(Unix)

All other executables have been moved to LIBEXECDIR where they retain their
> old names and can still be run directly from the command line. If we
> committed this patch for v14, I think it makes sense that packagers could
> put the LIBEXECDIR in the PATH so that 3rd-party scripts which call pg_ctl,
> initdb, etc. continue to work.

I would definitely not expect a packager to change the PATH, as also
mentioned by others. More likely options would be to symlink the binaries
into the actual bindir, or just set both those directories to the same one
(in the path) for a number of releases as a transition.

But you should definitely poll the packagers separately to make sure
something is done that works well for them -- especially when it comes to
integrating with for example the debian/ubuntu wrapper system that already
supports multiple parallel installs. And mind that they don't typically
follow hackers actively (I think), so it would be worthwhile to bring their
attention specifically to the thread. In many ways I'd find them more
important to get input from than most "other hackers" :)

> For that reason, I did not change the names of the executables, merely
> their location. During conversations with Robert off-list, we discussed
> renaming the executables to things like 'pg-ctl' (hyphen rather than
> underscore), mostly because that's the more modern way of doing it and
> follows what 'git' does. To avoid breaking scripts that execute these
> commands by the old name, this patch doesn't go that far. It also leaves
> the usage() functions alone such that when they report their own progname
> in the usage text, they do so under the old name. This would need to
> change at some point, but I'm unclear on whether that would be for v14 or
> if it would be delayed.
>

Ugh, yeah, please don't do that. Renaming them just to make it "look more
modern" helps nobody, really. Especially if the suggestion is people should
be using the shared-launcher binary anyway.

usage() seems more reasonable to change as part of a patch like this.

The binaries 'createuser' and 'dropuser' might be better named 'createrole'
> and 'droprole'. I don't currently have aliases in this patch, but it might
> make sense to allow 'pg createrole' as a synonym for 'pg createuser' and
> 'pg droprole' as a synonym for 'pg dropuser'. I have not pursued that yet,
> largely because as soon as you go that route, it starts making sense to
> have things like 'pg drop user', 'pg cluster db' and so forth, with the
> extra spaces. How far would people want me to go in this direction?
>

I'd say a createrole would make sense, but certainly not a "create role".
You'd end up with unlimited number of commands. But in either of them, I'd
say keep aliases completely out of it for a first iteration.

Prior to this patch, postgres binaries that need to execute other postgres
> binaries determine the BINDIR using find_my_exec and trimming off their own
> executable name. They can then assume the other binary is in that same
> directory. After this patch, binaries need to find the common prefix
> ROOTDIR = commonprefix(BINDIR,LIBEXECDIR) and then assume the other binary
> is either in ROOTDIR/binsuffix or ROOTDIR/libexecsuffix. This may cause
> problems on windows if BINDIR and LIBEXECDIR are configured on different
> drives, as there won't be a common prefix of C:\my\pg\bin and
> D:\my\pg\libexec. I'm hoping somebody with more Windows savvy expresses an
> opinion about how to handle this.
>

Maybe the "pg" binary could just pass down it's own location as a parameter
to the binary it calls, thereby making sure that binary has direct access
to both?

--
Magnus Hagander
Me: https://www.hagander.net/ <http://www.hagander.net/>
Work: https://www.redpill-linpro.com/ <http://www.redpill-linpro.com/>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2020-05-27 09:07:04 Re: Trouble with hashagg spill I/O pattern and costing
Previous Message Jürgen Purtz 2020-05-27 08:29:03 Re: Change JOIN tutorial to focus more on explicit joins