Select with backslash '\' character

Started by Andy Hallamover 24 years ago4 messagesbugs
Jump to latest
#1Andy Hallam
ahm@exel.co.uk

PostgreSQL - 7.1.3 (installed on Linux 2.4.2-2)
PSQLODBC.DLL - 07.01.0007
Visual C++ - 6.0

SELECT a FROM b WHERE c = 'WORKGROUP\me'

Does not return any rows.

SELECT a FROM b WHERE c = 'WORKGROUP\\me'

Returns required rows.

Result = PostgreSQL ODBC driver cannot handle backslash character - have to
escape it myself.

Can someone confirm this to be a bug please.

Thanks.

Andy
ahm@exel.co.uk

#2Andy Hallam
ahm@exel.co.uk
In reply to: Andy Hallam (#1)
Re: Select with backslash '\' character

Just to clarify.

---
The below SELECT SQL was ran from the command line:

mydb=# SELECT a FROM b WHERE c = 'WORKGROUP\me'
Result = Zero rows returned.

mydb=# SELECT a FROM b WHERE c = 'WORKGROUP\\me'
Result = One row returned.

---
And from my C app.

strcpy(strID, "WORKGROUP\\me");
Result = Zero rows returned.

strcpy(strID, "WORKGROUP\\\\me");
Result = One row returned.

"Andy Hallam" <ahm@exel.co.uk> wrote in message
news:9rc03b$16df$1@news.tht.net...

PostgreSQL - 7.1.3 (installed on Linux 2.4.2-2)
PSQLODBC.DLL - 07.01.0007
Visual C++ - 6.0

SELECT a FROM b WHERE c = 'WORKGROUP\me'

Does not return any rows.

SELECT a FROM b WHERE c = 'WORKGROUP\\me'

Returns required rows.

Result = PostgreSQL ODBC driver cannot handle backslash character - have

to

Show quoted text

escape it myself.

Can someone confirm this to be a bug please.

Thanks.

Andy
ahm@exel.co.uk

#3Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Andy Hallam (#1)
Re: Select with backslash '\' character

On Fri, 26 Oct 2001, Andy Hallam wrote:

PostgreSQL - 7.1.3 (installed on Linux 2.4.2-2)
PSQLODBC.DLL - 07.01.0007
Visual C++ - 6.0

SELECT a FROM b WHERE c = 'WORKGROUP\me'

Does not return any rows.

SELECT a FROM b WHERE c = 'WORKGROUP\\me'

Returns required rows.

Result = PostgreSQL ODBC driver cannot handle backslash character - have to
escape it myself.

Actually, it's probably the backend since I'm pretty sure you get the
same thing in psql. IIRC, the \ is treated as an escape character to
escape what follows (like a ' or for providing octal values).

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Andy Hallam (#1)
Re: Select with backslash '\' character

"Andy Hallam" <ahm@exel.co.uk> writes:

SELECT a FROM b WHERE c = 'WORKGROUP\me'
Does not return any rows.
SELECT a FROM b WHERE c = 'WORKGROUP\\me'
Returns required rows.

Can someone confirm this to be a bug please.

This is not a bug. Backslash is an escape character in Postgres'
string literals, therefore you gotta double it to get a single
backslash into the actual data.

regards, tom lane