Re: New 'pg' consolidated metacommand patch

Поиск
Список
Период
Сортировка
От Magnus Hagander
Тема Re: New 'pg' consolidated metacommand patch
Дата
Msg-id CABUevEzneJB4=i_O9r83v8sswdwBY9kY393XPPOU=iOAKDenkA@mail.gmail.com
обсуждение исходный текст
Ответ на New 'pg' consolidated metacommand patch  (Mark Dilger <mark.dilger@enterprisedb.com>)
Ответы Re: New 'pg' consolidated metacommand patch  (Mark Dilger <mark.dilger@enterprisedb.com>)
Re: New 'pg' consolidated metacommand patch  (Christoph Moench-Tegeder <cmt@burggraben.net>)
Re: New 'pg' consolidated metacommand patch  (Robert Haas <robertmhaas@gmail.com>)
Re: New 'pg' consolidated metacommand patch  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Wed, May 27, 2020 at 1:19 AM Mark Dilger <mark.dilger@enterprisedb.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? 


--

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Dave Page
Дата:
Сообщение: Re: New 'pg' consolidated metacommand patch
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: Trouble with hashagg spill I/O pattern and costing