dbTalk Databases Forums  

[BUGS] BUG #2729: Backslash escaping not working as expected

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2729: Backslash escaping not working as expected in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael van Rooyen
 
Posts: n/a

Default [BUGS] BUG #2729: Backslash escaping not working as expected - 11-02-2006 , 10:13 AM







The following bug has been logged online:

Bug reference: 2729
Logged by: Michael van Rooyen
Email address: mvanr (AT) bigfoot (DOT) com
PostgreSQL version: 8.1.4
Operating system: Linux
Description: Backslash escaping not working as expected
Details:

The following query from psql:

select * from product where name like '%\\%';

Yields products whose names end with a %. I would have expected it to yeild
products whose names contained a backslash.

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2729: Backslash escaping not working as expected - 11-02-2006 , 10:59 AM






"Michael van Rooyen" <mvanr (AT) bigfoot (DOT) com> writes:
Quote:
The following query from psql:
select * from product where name like '%\\%';
Yields products whose names end with a %. I would have expected it to yeild
products whose names contained a backslash.
Postgres defaults to assuming \ as the LIKE escape character, that is,
what you typed is equivalent to

select * from product where name like '%\\%' escape '\\';

You can get the behavior you're expecting by not having any escape character:

select * from product where name like '%\\%' escape '';

This is as explained in TFM:
http://www.postgresql.org/docs/8.1/s...FUNCTIONS-LIKE
although I notice that SQL92 says that there is no escape character by
default. We can't change our historical documented behavior on the
point unless we were willing to provide a configuration variable to
adjust it, and I'm not sure it's worth that.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.