Re: Unwanted nested dollar-quoted constants

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: bhv(at)quebecemail(dot)com
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Unwanted nested dollar-quoted constants
Date: 2005-08-27 14:56:47
Message-ID: 1353.1125154607@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Bernard Henry Voynet <bhv(at)quebecemail(dot)com> writes:
> All the text fields are specified using the dollar-quoted string constant form that.

This is your mistake to start with. You can not simply stick a couple
of dollar signs around a random string and expect to have a valid
literal, any more than you can stick a couple of quote marks around it
and expect to have a valid literal. Dollar-quoting is not a magic
bullet that will let you forget about escaping data.

I would recommend going back to regular quoted literals and making sure
you double any quotes or backslashes in the data. It's possible to
develop appropriate code for dollar-quoting random text, but it's a lot
harder than it is to escape the data in the old style.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Shavonne Marietta Wijesinghe 2005-08-29 10:27:41 PostgreSQL help
Previous Message Bruno Wolff III 2005-08-27 13:56:29 Re: nullif('','') on insert