Re: [HACKERS] psql \copy warning

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Jeremy Drake <pgsql(at)jdrake(dot)com>
Cc: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] psql \copy warning
Date: 2006-05-28 03:25:23
Message-ID: 200605280325.k4S3PNW06832@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Jeremy Drake wrote:
> I use the \copy command from psql to load data into postgres. I was
> fiddling with setting up a database on a HEAD build, and I got the
> following new warning
>
> testy=# \copy episodes from 'episodes.data' with delimiter as '\t'
> WARNING: nonstandard use of escape in a string literal
> LINE 1: COPY episodes FROM STDIN USING DELIMITERS '\t'
> ^
> HINT: Use the escape string syntax for escapes, e.g., E'\r\n'.
>
>
> I figured that this is the new standards conforming strings feature, and I
> guess I should get used to the new escape syntax. So I tried the hint
>
> testy=# \copy episodes FROM 'episodes.data' with delimiter as E'\t'
> \copy: parse error at "'\t'"
>
> So is it just me, or is this decidedly non-helpful? I assume someone
> missed this place for the new syntax tweaks?

Interesting bug report. The basic question is whether \copy should
follow the quoting rules of the SQL server, or of psql. Most psql
arguments have backslashes enabled, so I am thinking \copy should as
well, and not match COPY if standard_compliant_strings is on.

The attached patch fixes the warning you received by adding E'' strings
to the \copy arguments, and adds it for the other backslash commands
like \d.

I don't think we want a psql escape control setting, nor do we want to
remove backslash controls from psql commands (they are not SQL
standard).

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachment Content-Type Size
unknown_filename text/plain 5.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2006-05-28 03:32:53 Re: RELKIND_SPECIAL
Previous Message Bruce Momjian 2006-05-28 03:15:17 Re: Better to dump tabs as tabs, or \t?

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-05-28 05:00:18 Re: [HACKERS] psql \copy warning
Previous Message Andrew Dunstan 2006-05-28 01:17:29 Re: tg_table_name and tg_table_schema for plpgsql