\ef should probably append semicolons

Started by Joshua Tolleyover 17 years ago5 messageshackers
Jump to latest
#1Joshua Tolley
eggyknap@gmail.com

The new \ef psql command creates nicely usable "CREATE OR REPLACE
FUNCTION ..." text based on the function I tell it to edit, but the
text it creates *doesn't* include a final semicolon, so when I exit my
editor-of-choice after messing with my function, it doesn't run the
code I've given it until I type one of my own. This is annoying. See
attached for a patch to fix it.

- Josh / eggyknap

Attachments:

semicolon.patchtext/x-patch; name=semicolon.patchDownload+16-16
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Joshua Tolley (#1)
Re: \ef should probably append semicolons

"Joshua Tolley" <eggyknap@gmail.com> writes:

The new \ef psql command creates nicely usable "CREATE OR REPLACE
FUNCTION ..." text based on the function I tell it to edit, but the
text it creates *doesn't* include a final semicolon, so when I exit my
editor-of-choice after messing with my function, it doesn't run the
code I've given it until I type one of my own. This is annoying.

This is intentional.

If the semicolon is there, the command will be squirted to the backend
instantaneously upon your exiting the $EDITOR. The potential bad
consequences of that seem to me to outweigh the annoyance factor of
typing ; and return.

Now, if you want to fix psql so that even with a semicolon there it
will redisplay the command buffer and wait for a return, then I'd agree
that that's an improvement. I couldn't figure out how to get readline
to cooperate with that ... but I didn't spend a lot of time looking.

regards, tom lane

#3Joshua Tolley
eggyknap@gmail.com
In reply to: Tom Lane (#2)
Re: \ef should probably append semicolons

On Fri, Oct 10, 2008 at 7:10 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Joshua Tolley" <eggyknap@gmail.com> writes:

The new \ef psql command creates nicely usable "CREATE OR REPLACE
FUNCTION ..." text based on the function I tell it to edit, but the
text it creates *doesn't* include a final semicolon, so when I exit my
editor-of-choice after messing with my function, it doesn't run the
code I've given it until I type one of my own. This is annoying.

This is intentional.

If the semicolon is there, the command will be squirted to the backend
instantaneously upon your exiting the $EDITOR. The potential bad
consequences of that seem to me to outweigh the annoyance factor of
typing ; and return.

Something in the back of my mind told me this might have been on
purpose -- despite a number of us around a table at PG West agreeing
current behavior was a pain.

Now, if you want to fix psql so that even with a semicolon there it
will redisplay the command buffer and wait for a return, then I'd agree
that that's an improvement. I couldn't figure out how to get readline
to cooperate with that ... but I didn't spend a lot of time looking.

Mmm... but that's so much harder than a 2 line patch :) Thanks for
commenting. I may consider that in the (admittedly unlikely) event I
feel like getting personal with readline.

- Josh / eggyknap

#4David E. Wheeler
david@kineticode.com
In reply to: Joshua Tolley (#3)
Re: \ef should probably append semicolons

On Oct 10, 2008, at 20:27, Joshua Tolley wrote:

Now, if you want to fix psql so that even with a semicolon there it
will redisplay the command buffer and wait for a return, then I'd
agree
that that's an improvement. I couldn't figure out how to get
readline
to cooperate with that ... but I didn't spend a lot of time looking.

Mmm... but that's so much harder than a 2 line patch :) Thanks for
commenting. I may consider that in the (admittedly unlikely) event I
feel like getting personal with readline.

Not to mention libedit! :-)

Best,

David

#5David Fetter
david@fetter.org
In reply to: Tom Lane (#2)
Re: \ef should probably append semicolons

On Fri, Oct 10, 2008 at 09:10:50PM -0400, Tom Lane wrote:

"Joshua Tolley" <eggyknap@gmail.com> writes:

The new \ef psql command creates nicely usable "CREATE OR REPLACE
FUNCTION ..." text based on the function I tell it to edit, but the
text it creates *doesn't* include a final semicolon, so when I exit my
editor-of-choice after messing with my function, it doesn't run the
code I've given it until I type one of my own. This is annoying.

This is intentional.

If the semicolon is there, the command will be squirted to the backend
instantaneously upon your exiting the $EDITOR. The potential bad
consequences of that seem to me to outweigh the annoyance factor of
typing ; and return.

To mitigate this annoyance, we could have \ef prepend a
multi-line-style comment (proof against editor wrapping) that reads
something like:

/*
To make these changes take effect immediately, put a semicolon after
the $FUNCTION$ tag
*/

Speaking of the $FUNCTION$ tag, it appears to be being put in there
unconditionally, which will eventually break somebody's code. How
does pg_dump handle the dollar quoting situation, and could this
machinery be used here?

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david.fetter@gmail.com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate