Thread: Any way to disable backslash as a string literal escape character?

Any way to disable backslash as a string literal escape character?

From
"Grant Allen"
Date:
I know this has been asked before - I've trawled through the mail archives and FAQs looking for any info, and only
found"that's the way it works" answers. 

Basically, I want to turn off backslash ( \ ) as an escape character in string literals.  It makes porting apps to
PostgreSQLmuch more difficult, because no major rdbms behaves this way (at least, none of Oracle, SQL Server, DB2,
Sybase,Informix, SQL Anywhere or SQL Base ... the one's I've worked with).  I know PostgreSQL isn't designed to be a
cloneof any of these, and I should love it the way it is :-) :-) :-), but this one quirk is annoying the hell out of
me.

I'm guessing the answer will be no, because it would break things like null handling.

So, any postmaster switches, build/make options, etc.?  Or should I get hacking myself?

Ciao
Fuzzy
:-)

----------------------------------------------
The contents of this post are my opinions only
      If swallowed seek medical advice

Re: Any way to disable backslash as a string literal escape character?

From
Tom Lane
Date:
"Grant Allen" <Grant.Allen@towersoft.com.au> writes:
> Basically, I want to turn off backslash ( \ ) as an escape character
> in string literals.

No can do without hacking backend code.  But why are you more concerned
about backslash than, say, single-quote (')?  I cannot envision any way
of embedding arbitrary strings into SQL commands that doesn't have some
kind of escape-character rule.

I suspect what you really need is a way to supply strings as out-of-line
parameters to SQL commands.  This is available in PG as of 7.4, and I
think all the other major DBs had it long before.

            regards, tom lane

Re: Any way to disable backslash as a string literal escape character?

From
"Grant Allen"
Date:
Tom,

The big difference ... all DBs (at least, the ones I listed, including PostgreSQL) support the single quote as it's own
escapecharacter - so no difference when it comes to app porting (yes, PostgreSQL has the \' method as well, but ''
worksacross the board). 

The big P's atypical handing of backslashes is what causes the grief.

Thanks for the confirmation of the behaviour - I'm off to do some hacking (either of my code, or PostgreSQL's) :-)

Ciao
Fuzzy
:-)

----------------------------------------------
The contents of this post are my opinions only
      If swallowed seek medical advice

> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Tuesday, 30 December 2003 15:09
> To: Grant Allen
> Cc: pgsql-general@postgresql.org
> Subject: Re: [GENERAL] Any way to disable backslash as a
> string literal
> escape character?
>
>
> "Grant Allen" <Grant.Allen@towersoft.com.au> writes:
> > Basically, I want to turn off backslash ( \ ) as an escape character
> > in string literals.
>
> No can do without hacking backend code.  But why are you more
> concerned
> about backslash than, say, single-quote (')?  I cannot
> envision any way
> of embedding arbitrary strings into SQL commands that doesn't
> have some
> kind of escape-character rule.
>
> I suspect what you really need is a way to supply strings as
> out-of-line
> parameters to SQL commands.  This is available in PG as of 7.4, and I
> think all the other major DBs had it long before.
>
>             regards, tom lane
>