Обсуждение: Command-line client sometimes misinterprets tabs for nulls

Поиск
Список
Период
Сортировка

Command-line client sometimes misinterprets tabs for nulls

От
Casey Allen Shobe
Дата:
Let's say I have typed a nice formatted SQL statement like so:

select        b1.blah,
        b1.blah2,
        b2.blah3
from        blah_table as b1
inner join only    blah_table2 as b2
on        b1.blah =3D b2.blah;

...using tabs as the indenting medium.  Now I copy that from my editor into=
=20
psql, and most of the tabs are converted to nulls, resulting in an error li=
ke=20
"Unknown value fromblah_table".  Tabs should paste; they're normal=20
characters.

--=20
Casey Allen Shobe / Network Security Analyst & PHP Developer
SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
cshobe@secureworks.net / http://www.secureworks.net
Content is my own and does not necessarily represent my company.

"Diagoras the Atheist once visited Samothrace and a friend there said to hi=
m,=20
'You think the gods have no care for humans?  Why, you can see from all the=
se=20
votive pictures here how many people have escaped the fury of storms at sea=
=20
by praying to the gods, who have brought them safe to harbour.'  'Yes,=20
indeed,' said Diagoras, 'but where are the pictures of all those who suffer=
ed=20
shipwreck and perished in the waves?'  On another occasion he was on a voya=
ge=20
and the crew became anxious about the bad weather and began to mutter that =
it=20
served them right for taking an atheist on board.  Diagoras just pointed ou=
t=20
to them a number of other ships on the same course which were in equal=20
difficulties and asked them whether they thought that there was a Diagoras =
on=20
the passenger-list of every one of them.  The fact is that a man's characte=
r=20
or way of life makes no difference at all to his good luck or bad."

- Cicero

Re: Command-line client sometimes misinterprets tabs for nulls

От
Tom Lane
Дата:
Casey Allen Shobe <cshobe@secureworks.net> writes:
> Tabs should paste; they're normal characters.

Turn off readline (psql -n).  For someone accustomed to tab completion,
the above is about as sensible as demanding we disable backspace.

It would be nice if we could distinguish pasted tabs from manually-typed
tabs, but I'm not aware of any way that psql could tell the difference.

            regards, tom lane

Re: Command-line client sometimes misinterprets tabs for nulls

От
Casey Allen Shobe
Дата:
On Tuesday 27 August 2002 01:48 am, Tom Lane wrote:
> Turn off readline (psql -n).  For someone accustomed to tab completion,
> the above is about as sensible as demanding we disable backspace.

Right, my original build of postgres did not have tab completion support as=
 I=20
did not have readline (a notice at the end of the configure script would ha=
ve=20
been nice, maybe a summary of what will and won't be supported?).  However,=
 I=20
love the command-line history, so readline was a must ;).

> It would be nice if we could distinguish pasted tabs from manually-typed
> tabs, but I'm not aware of any way that psql could tell the difference.

Can tab completion be disabled without disabling command line history?  I=
=20
noticed -n disables both.  I would gladly trade tab completion for tab=20
pastability, but I rely heavily on command line history.

Thanks,

--=20
Casey Allen Shobe / Network Security Analyst & PHP Developer
SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
cshobe@secureworks.net / http://www.secureworks.net
Content is my own and does not necessarily represent my company.

Re: Command-line client sometimes misinterprets tabs for nulls

От
Tom Lane
Дата:
Casey Allen Shobe <cshobe@secureworks.net> writes:
> Can tab completion be disabled without disabling command line history?

Get out the readline man page.  I believe you can configure it six
ways from Sunday, but I've never tried myself ...

            regards, tom lane

Re: Command-line client sometimes misinterprets tabs for

От
Rod Taylor
Дата:
The problem is that most items in postgresql are tab completed.

Cut and past your text into a bash or zsh prompt.  It injects a bunch of
filenames into your data, as per tab completion.

Annoying, but for the benefits it's livable.


Perhaps a toggle could be created to disable tab completion?

On Mon, 2002-08-26 at 23:36, Casey Allen Shobe wrote:
> Let's say I have typed a nice formatted SQL statement like so:
>
> select        b1.blah,
>         b1.blah2,
>         b2.blah3
> from        blah_table as b1
> inner join only    blah_table2 as b2
> on        b1.blah = b2.blah;
>
> ...using tabs as the indenting medium.  Now I copy that from my editor into
> psql, and most of the tabs are converted to nulls, resulting in an error like
> "Unknown value fromblah_table".  Tabs should paste; they're normal
> characters.
>
> --
> Casey Allen Shobe / Network Security Analyst & PHP Developer
> SecureWorks, Inc. / 404.327.6339 x169 / Fax: 404.728.0144
> cshobe@secureworks.net / http://www.secureworks.net
> Content is my own and does not necessarily represent my company.
>
> "Diagoras the Atheist once visited Samothrace and a friend there said to him,
> 'You think the gods have no care for humans?  Why, you can see from all these
> votive pictures here how many people have escaped the fury of storms at sea
> by praying to the gods, who have brought them safe to harbour.'  'Yes,
> indeed,' said Diagoras, 'but where are the pictures of all those who suffered
> shipwreck and perished in the waves?'  On another occasion he was on a voyage
> and the crew became anxious about the bad weather and began to mutter that it
> served them right for taking an atheist on board.  Diagoras just pointed out
> to them a number of other ships on the same course which were in equal
> difficulties and asked them whether they thought that there was a Diagoras on
> the passenger-list of every one of them.  The fact is that a man's character
> or way of life makes no difference at all to his good luck or bad."
>
> - Cicero
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>

Re: Command-line client sometimes misinterprets tabs for

От
Rod Taylor
Дата:
> Can tab completion be disabled without disabling command line history?  I
> noticed -n disables both.  I would gladly trade tab completion for tab
> pastability, but I rely heavily on command line history.

Perhaps annoying, but a simple work around is to use
<space><tab><space><tab>

Formats like tab in the code, but space/tab combinations don't complete
to anything, registering like a space in psql.

Re: Command-line client sometimes misinterprets tabs for

От
Peter Eisentraut
Дата:
Casey Allen Shobe writes:

> Can tab completion be disabled without disabling command line history?  I
> noticed -n disables both.  I would gladly trade tab completion for tab
> pastability, but I rely heavily on command line history.

man psql, search for "disable"

Also, you might find it easier to start an editor using \e and paste your
code there.

--
Peter Eisentraut   peter_e@gmx.net