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. ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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 |
| |||
| 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 |
| |||
| 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----- |
| |||
| 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 |
| ||||
| 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 |
| Thread Tools | |
| Display Modes | |
|
|