Unix Technical Forum

tabs in psql

This is a discussion on tabs in psql within the Pgsql General forums, part of the PostgreSQL category; --> Hi, I'm fairly new to postgresql, and I'm having some problems understanding the syntax of SQL statements in psql. ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:22 AM
Seb
 
Posts: n/a
Default tabs in psql

Hi,

I'm fairly new to postgresql, and I'm having some problems understanding
the syntax of SQL statements in psql. According to the documentation,
white space can be used freely. However, the following fails:

CREATE TABLE test
(
id Int8,
phenotype Varchar(510),
genotype Varchar(510)
);
testdb(> ERROR: syntax error at or near "Varchar"
LINE 4: phenotype Varchar(510),
^

where the field name and data type spec are separated by a tab
character. However, this works if the tab is separated by a single
space. Can someone please explain how this is controlled, and what the
proper syntax should be? Thanks in advance.

Cheers,

--
Seb


-
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:22 AM
Seb
 
Posts: n/a
Default Re: tabs in psql

On Sun, 23 Mar 2008 17:48:09 -0700,
"Joshua D. Drake" <jd@commandprompt.com> wrote:

[...]

> I can not duplicate your problem. However when I copy and paste
> directly from your email it does indeed fail watch:


[...]

> That is a direct copy and paste from your email. Notice that there is
> no space between id and Int8. Once I manually put the space in, it
> worked as expected.


Thanks Joshua, that is the problem I wanted to illustrate; i.e.
whenever a tab separates the field name from the data type spec, the tab
character gets swallowed and psql cannot parse correctly. So it seems
tabs are not interpreted as simple white space, and it should not be
used in this case, am I right?


--
Seb


-
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-10-2008, 12:22 AM
Joshua D. Drake
 
Posts: n/a
Default Re: tabs in psql

On Sun, 23 Mar 2008 20:01:28 -0500
Seb <spluque@gmail.com> wrote:

> Thanks Joshua, that is the problem I wanted to illustrate; i.e.
> whenever a tab separates the field name from the data type spec, the
> tab character gets swallowed and psql cannot parse correctly. So it
> seems tabs are not interpreted as simple white space, and it should
> not be used in this case, am I right?


Actually that would make sense as psql supports tab complete so if the
terminal interprets a tab, it isn't going to treat it as spaces. I
would suggest changing your editor to treat tabs as 4 spaces.

Sincerely,

Joshua D. Drake


--
The PostgreSQL Company since 1997: http://www.commandprompt.com/
PostgreSQL Community Conference: http://www.postgresqlconference.org/
Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate
PostgreSQL SPI Liaison | SPI Director | PostgreSQL political pundit


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH5wDNATb/zqfZUUQRAi8OAJ920n0JJP1eCeK5PX9GSAnGcrcaNACffcq0
POGMlYM12D+G+g9/uPXzVgg=
=oEE1
-----END PGP SIGNATURE-----

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008, 12:22 AM
Seb
 
Posts: n/a
Default Re: tabs in psql

On Sun, 23 Mar 2008 18:15:55 -0700,
"Joshua D. Drake" <jd@commandprompt.com> wrote:

[...]

> Actually that would make sense as psql supports tab complete so if the
> terminal interprets a tab, it isn't going to treat it as spaces. I
> would suggest changing your editor to treat tabs as 4 spaces.


But the problem still occurs with 'psql -f INPUTFILE', where tab
complete is irrelevant, so I'm confused.


--
Seb


-
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-10-2008, 12:22 AM
Tom Lane
 
Posts: n/a
Default Re: tabs in psql

Seb <spluque@gmail.com> writes:
> But the problem still occurs with 'psql -f INPUTFILE', where tab
> complete is irrelevant, so I'm confused.


You sure? I can't make the example fail that way. It does fail
when the example-with-tab is cut and pasted directly into a terminal
window, which is exactly as expected because that's exactly what
would happen if you interactively typed a TAB at that point. psql
doesn't see anything to complete with so it just beeps at you, without
adding anything to the input.

If you need to enter stuff like this interactively in psql, use -n
to disable readline.

You really shouldn't need -n to prevent tab completion in a -f file
though. If you can reproduce that then file a bug against whatever
version of readline you're using.

regards, tom lane

-
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:42 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com