Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] psql \copy warning

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jeremy Drake <pgsql(at)jdrake(dot)com>
Subject: Re: [HACKERS] psql \copy warning
Date: 2006-05-29 21:42:47
Message-ID: 200605292142.k4TLglg10722@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
I have developed an updated patch that:

	o  turns off escape_string_warning in pg_dumpall.c
	o  optionally use E'' for \password (undocumented option?)
	o  honor standard_conforming-strings for \copy (but not
	   support literal E'' strings)
	o  optionally use E'' for \d commands
	o  turn off escape_string_warning for createdb, createuser,
	   droplang

I agree someday we might want to turn off escape_string_warning, but I
think we should leave it on as long as possible as it is still pointing
out escape problem areas in the code.

---------------------------------------------------------------------------

Bruce Momjian wrote:
> Tom Lane wrote:
> > Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > > Right.  I think the question is whether we want all psql strings to
> > > accept backslashes, and hence not support E'' at all for psql commands.
> > > I figured that made the most sense.
> > 
> > I'm not convinced.  Wouldn't it be better if psql commands track the
> > backend syntax?  With standard_conforming_strings on, there will be two
> > ways to tell COPY you want a tab as a delimiter:
> > 	DELIMITER '<actual tab char>'
> > 	DELIMITER E'\t'
> > and in particular this will NOT do that:
> > 	DELIMITER '\t'
> 
> Well, I think it a little more confusing that just \copy.  What about \d
> and \set uses of backslashes.  Do they honor standard_conforming_strings
> too?  I assume you are saying they should.
> 
> > If we keep '\t' as meaning tab in the \copy syntax then I think we're
> > going to cause confusion in the long run.  I think we should fix \copy
> > and related psql backslash commands to accept E'\t', and make sure that
> > the behavior is the same as the connected backend depending on what its 
> > standard_conforming_strings setting is.
> 
> OK, though this is going to mean that examples in the psql manual page
> are going to be different for different standard_conforming_strings
> settings:
> 
>        testdb=> \set content '\'' `cat my_file.txt` '\''
>        testdb=> INSERT INTO my_table VALUES (:content);
> 
> psql doesn't know '''' is about doubling single quotes in a string,
> though \copy does.  The major problem, I think, is that psql often
> follows the shell rules, rather than the SQL rules for most things.
> 
> > There is a secondary, largely cosmetic question of whether psql should
> > attempt to prevent you from seeing escape_string_warning messages.
> > I personally have come to the conclusion that escape_string_warning is
> > probably not going to be on by default anyway ;-), and hence it's not
> > worth going to great extremes to prevent this, particularly if it breaks
> > the ability to use psql against pre-8.1 servers.
> 
> It does break backward compatibility.
> 
> -- 
>   Bruce Momjian   http://candle.pha.pa.us
>   EnterpriseDB    http://www.enterprisedb.com
> 
>   + If your life is a hard drive, Christ can be your backup. +
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
> 
>                http://archives.postgresql.org
> 

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

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

In response to

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2006-05-29 21:47:00
Subject: psql strings and ''
Previous:From: RĂ©mi ZaraDate: 2006-05-29 21:21:32
Subject: Re: osprey buildfarm member has been failing for a long while

pgsql-patches by date

Next:From: Bruce MomjianDate: 2006-05-29 21:47:00
Subject: psql strings and ''
Previous:From: Tom LaneDate: 2006-05-29 14:47:38
Subject: Re: non-transactional pg_class

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group