Re: Annoying messages when copy sql code to psql terminal

Lists: pgsql-general
From: "A B" <gentosaker(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Annoying messages when copy sql code to psql terminal
Date: 2008-05-27 13:24:38
Message-ID: dbbf25900805270624j6e7075cv69ef5dd253de39e8@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Whenever I use copy-paste to run code in a terminal window that is
running psql, and the code contains a row like

IF FOUND THEN

then I get the words

ABORT CHECKPOINT COMMIT DECLARE EXECUTE
INSERT MOVE REINDEX ROLLBACK SHOW
UPDATE
ALTER CLOSE COPY DELETE FROM EXPLAIN
LISTEN NOTIFY RELEASE SAVEPOINT START
VACUUM
ANALYZE CLUSTER CREATE DROP FETCH LOAD
PREPARE RESET SELECT TRUNCATE
BEGIN COMMENT DEALLOCATE END GRANT LOCK
REASSIGN REVOKE SET UNLISTEN

That must be some kind of display of possible stuff to write after
"THEN" but it is very annoying. How to turn it of?


From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-05-27 14:06:53
Message-ID: 20080527140653.GJ27988@frubble.xen.chris-lamb.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Tue, May 27, 2008 at 03:24:38PM +0200, A B wrote:
> Whenever I use copy-paste to run code in a terminal window that is
> running psql, and the code contains a row like
>
> IF FOUND THEN
>
> then I get the words

[...]

> That must be some kind of display of possible stuff to write after
> "THEN" but it is very annoying. How to turn it of?

I'd guess the next line of code starts with a tab character and hence
psql is just tab completing the (empty) line. If you don't want this to
happen, you can disable table completion. From the man page:

If
for some reason you do not like the tab completion, you can turn it off
by putting this in a file named .inputrc in your home directory:

$if psql
set disable-completion on
$endif

As an aside, there isn't an "if" statement in SQL.

Sam


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "A B" <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-05-27 14:29:26
Message-ID: 27369.1211898566@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

"A B" <gentosaker(at)gmail(dot)com> writes:
> Whenever I use copy-paste to run code in a terminal window that is
> running psql, and the code contains a row like

> IF FOUND THEN

> then I get the words

> ABORT CHECKPOINT COMMIT DECLARE EXECUTE
> ...

Either avoid copying/pasting tabs, or turn off readline
(-n option to psql, I think, but check the manual).

There's probably a way to turn off tab-completion without
disabling readline altogether, but I don't know how offhand.

regards, tom lane


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: A B <gentosaker(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-06-05 21:50:57
Message-ID: 20080605215057.GS16502@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Tom Lane escribió:
> "A B" <gentosaker(at)gmail(dot)com> writes:
> > Whenever I use copy-paste to run code in a terminal window that is
> > running psql, and the code contains a row like
> > [...]

> Either avoid copying/pasting tabs, or turn off readline
> (-n option to psql, I think, but check the manual).
>
> There's probably a way to turn off tab-completion without
> disabling readline altogether, but I don't know how offhand.

This can be done by adding

$if psql
set disable-completion on
$endif

to .inputrc.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "A B" <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-06-06 02:28:42
Message-ID: b42b73150806051928y6b12d775xe2d4de138d1a5fd3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Tue, May 27, 2008 at 9:24 AM, A B <gentosaker(at)gmail(dot)com> wrote:
> Whenever I use copy-paste to run code in a terminal window that is
> running psql, and the code contains a row like
>
> IF FOUND THEN
>
> then I get the words
>
> ABORT CHECKPOINT COMMIT DECLARE EXECUTE

[...]

As others have noted, you have tabs in your sql source. I'd advise if
possible, not to use the tab character in sql, for this and other
reasons.

merlin


From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: "A B" <gentosaker(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-06-06 04:39:25
Message-ID: 65937bea0806052139i1f6b9613qd07166bfe30c031d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Jun 6, 2008 at 7:58 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:

> On Tue, May 27, 2008 at 9:24 AM, A B <gentosaker(at)gmail(dot)com> wrote:
> > Whenever I use copy-paste to run code in a terminal window that is
> > running psql, and the code contains a row like
> >
> > IF FOUND THEN
> >
> > then I get the words
> >
> > ABORT CHECKPOINT COMMIT DECLARE EXECUTE
>
> [...]
>
> As others have noted, you have tabs in your sql source. I'd advise if
> possible, not to use the tab character in sql, for this and other
> reasons.

Can you please elaborate on other reasons? I have never encountered any
_other_ reason!!

And 'using psql' is not reason enough to not indent your SQL code.

Best regards,
--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | indiatimes | yahoo }.com

EnterpriseDB http://www.enterprisedb.com

Mail sent from my BlackLaptop device


From: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
To: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
Cc: "A B" <gentosaker(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-06-06 12:12:18
Message-ID: b42b73150806060512k707d11f5hfa07fce5014e773d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Jun 6, 2008 at 12:39 AM, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:
> On Fri, Jun 6, 2008 at 7:58 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>> As others have noted, you have tabs in your sql source. I'd advise if
>> possible, not to use the tab character in sql, for this and other
>> reasons.
>
> Can you please elaborate on other reasons? I have never encountered any
> _other_ reason!!
>
> And 'using psql' is not reason enough to not indent your SQL code.

For example, another reason tabs are annoying are how your function
sources show up in '\df+' (escaped). iirc you can get around this
with '\x', but why bother with that? Also, I am not suggesting not to
indent your sql, just not to use the tab character.

merlin


From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: "Merlin Moncure" <mmoncure(at)gmail(dot)com>
Cc: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>, "A B" <gentosaker(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-06-06 17:05:42
Message-ID: dcc563d10806061005r72c424d8xa375350e8345a450@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Fri, Jun 6, 2008 at 6:12 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Fri, Jun 6, 2008 at 12:39 AM, Gurjeet Singh <singh(dot)gurjeet(at)gmail(dot)com> wrote:
>> On Fri, Jun 6, 2008 at 7:58 AM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
>>> As others have noted, you have tabs in your sql source. I'd advise if
>>> possible, not to use the tab character in sql, for this and other
>>> reasons.
>>
>> Can you please elaborate on other reasons? I have never encountered any
>> _other_ reason!!
>>
>> And 'using psql' is not reason enough to not indent your SQL code.
>
> For example, another reason tabs are annoying are how your function
> sources show up in '\df+' (escaped). iirc you can get around this
> with '\x', but why bother with that? Also, I am not suggesting not to
> indent your sql, just not to use the tab character.

Almost every decent text editor has the option to use spaces in place
of tabs. Even Nano can do it.


From: Reece Hart <reece(at)harts(dot)net>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: A B <gentosaker(at)gmail(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Annoying messages when copy sql code to psql terminal
Date: 2008-06-06 17:13:53
Message-ID: 1212772433.7018.12.camel@snafu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

On Thu, 2008-06-05 at 22:28 -0400, Merlin Moncure wrote:

> As others have noted, you have tabs in your sql source. I'd advise if
> possible, not to use the tab character in sql, for this and other
> reasons.

Tabs in SQL are a problem only if you copy-paste. If your editor and
psql can see the same files (i.e., are running on the same machine or
you're saving to a network fs), it's more reliable to save the file and
read it in psql with \i or with psql -f. (\i and -f won't try to do tab
completion, of course.)

-Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0