BUG #4927: psql does "spoil" the query before sending it to server

Started by Filip Rembiałkowskiover 16 years ago4 messagesbugs
Jump to latest
#1Filip Rembiałkowski
filip.rembialkowski@gmail.com

The following bug has been logged online:

Bug reference: 4927
Logged by: handling numeric literals with dots in psql \copy
command
Email address: filip.rembialkowski@gmail.com
PostgreSQL version: 8.4.0
Operating system: Linux
Description: psql does "spoil" the query before sending it to server
Details:

8.4.0:

filip@filip=# \copy ( select 1.23::numeric as num ) to 'out.csv' with csv
header
ERROR: syntax error at or near "."
LINE 1: COPY ( select 1 . 23::numeric as num ) TO STDOUT CSV HEADER
^
\copy: ERROR: syntax error at or near "."
LINE 1: COPY ( select 1 . 23::numeric as num ) TO STDOUT CSV HEADER
^

query inside parentheses is OK.

same bug reproduced in 8.3.7

In reply to: Filip Rembiałkowski (#1)
Re: BUG #4927: psql does "spoil" the query before sending it to server

handling numeric literals with dots in psql copy command escreveu:

filip@filip=# \copy ( select 1.23::numeric as num ) to 'out.csv' with csv
header
ERROR: syntax error at or near "."
LINE 1: COPY ( select 1 . 23::numeric as num ) TO STDOUT CSV HEADER
^
\copy: ERROR: syntax error at or near "."
LINE 1: COPY ( select 1 . 23::numeric as num ) TO STDOUT CSV HEADER
^

query inside parentheses is OK.

same bug reproduced in 8.3.7

Thanks for your report.

Why are we analysing the query there? One possible fix is to remove the '.' as
delimiter in strtokx(). The trivial patch is attached.

--
Euler Taveira de Oliveira
http://www.timbira.com/

Attachments:

psqltext/plain; name=psqlDownload+2-2
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Euler Taveira de Oliveira (#2)
Re: BUG #4927: psql does "spoil" the query before sending it to server

Euler Taveira de Oliveira <euler@timbira.com> writes:

Why are we analysing the query there? One possible fix is to remove the '.' as
delimiter in strtokx(). The trivial patch is attached.

Surely that would break a lot of other cases.

regards, tom lane

In reply to: Tom Lane (#3)
Re: BUG #4927: psql does "spoil" the query before sending it to server

Tom Lane escreveu:

Euler Taveira de Oliveira <euler@timbira.com> writes:

Why are we analysing the query there? One possible fix is to remove the '.' as
delimiter in strtokx(). The trivial patch is attached.

Surely that would break a lot of other cases.

Why? Even if it can't catch all cases when we remove the '.', the query will
be parsed (again) by PostgreSQL.

--
Euler Taveira de Oliveira
http://www.timbira.com/