Re: how to edit a function from psql?

From: Karim Nassar <Karim(dot)Nassar(at)NAU(dot)EDU>
To: "Thomas F(dot)O'Connell" <tfo(at)sitening(dot)com>
Cc: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, Patrick Hatcher <PHatcher(at)macys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: how to edit a function from psql?
Date: 2004-11-09 00:28:53
Message-ID: 1099960133.27046.94.camel@denali.cse.nau.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, 2004-11-07 at 20:36, Thomas F.O'Connell wrote:
> What version of postgres are you using? In postgresql-7.4.6, I get an
> empty query buffer when I try what you describe here.

7.4.5

I got it. Apparently the query buffer is the last run query (good or
bad). So, to get my function into the buffer, I would have to cut and
paste it (which I do often, and is what my last post showed). Backslash
functions are not included. I assume you ran no queries before \e, and
got an empty buffer.

Seems like \e is merely a convenient way to deal with long queries. I
always have my editor open, so this isn't much of a win for me.

Still, it might be nice to have a way to get the function into the
buffer without cutting and pasting from the (normally open) editor.

As a point of interest...

1) orfs=# select * from person
2) orfs-# ;
3) ERROR: relation "person" does not exist
4) orfs=# \e
5) orfs-# select
6) orfs-# *
7) orfs-# from
8) orfs-# person
9) orfs-# ;
10) ERROR: syntax error at or near "select" at character 23
11) orfs=# \e
12) orfs=# select * from person;
13) ERROR: relation "person" does not exist
14) orfs=# \e

At line 4, the query buffer has:
~~~~~~~~~~~~~~~~~~~~~
select * from person
~~~~~~~~~~~~~~~~~~~~~

Note that there is no semi-colon.

At line 11, the contents of the query buffer is:
~~~~~~~~~~~~~~~~~~~~~
select * from person

select
*
from
person
~~~~~~~~~~~~~~~~~~~~~~

And at line 14:
~~~~~~~~~~~~~~~~~~~~~~
select * from person;
~~~~~~~~~~~~~~~~~~~~~~

It seems that the query editor just dumps the contents to the command
line. Why the semi-colons from lines 2 and 9 aren't in the query buffers
is a mystery to me.

\<.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ed L. 2004-11-09 00:47:44 server auto-restarts and ipcs
Previous Message Ron St-Pierre 2004-11-09 00:15:34 INTERVAL in a function