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

Lists: pgsql-bugs
From: "handling numeric literals with dots in psql \copy command" <filip(dot)rembialkowski(at)gmail(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #4927: psql does "spoil" the query before sending it to server
Date: 2009-07-17 10:31:52
Message-ID: 200907171031.n6HAVqw3084583@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 4927
Logged by: handling numeric literals with dots in psql \copy
command
Email address: filip(dot)rembialkowski(at)gmail(dot)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(at)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


From: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
To: handling numeric literals with dots in psql copy command <filip(dot)rembialkowski(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4927: psql does "spoil" the query before sending it to server
Date: 2009-07-17 19:50:02
Message-ID: 4A60D5EA.5060308@timbira.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

handling numeric literals with dots in psql copy command escreveu:
> filip(at)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/

Attachment Content-Type Size
psql text/plain 672 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
Cc: handling numeric literals with dots in psql copy command <filip(dot)rembialkowski(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4927: psql does "spoil" the query before sending it to server
Date: 2009-07-17 21:26:04
Message-ID: 8574.1247865964@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Euler Taveira de Oliveira <euler(at)timbira(dot)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


From: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: handling numeric literals with dots in psql copy command <filip(dot)rembialkowski(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4927: psql does "spoil" the query before sending it to server
Date: 2009-07-18 02:09:54
Message-ID: 4A612EF2.3020801@timbira.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

Tom Lane escreveu:
> Euler Taveira de Oliveira <euler(at)timbira(dot)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/