The following bug has been logged online:
Bug reference: 4398
Logged by: Rainer
Email address: rainer@hamburg.ccc.de
PostgreSQL version: 8.3.3 /b1400
Operating system: Windows XP
Description: Backslashes get escaped despite of backslash_quote=off
Details:
Subject to: Backslashes get escaped in like operations despite of
backslash_quote=off
psql \version: PostgreSQL 8.3.3, compiled by Visual C++ build 1400
Goal to achieve: SQL compliant handling of escaping which means...
Expected result: ...backslashes are not to be escaped, single quotes are to
be escaped by itself
Current configuration is: backslash_quote=off and
standard_conforming_strings=on
Problem/Bug is: Operator "=" works fine, operator "like" does not (see test
case below)
Status is: I checked the three concerning manual chapters (4.1.2.1., 9.7.1.,
18.12.1.) which promise another result than actually received by the
following test case:
To see for yourself please feel free to use the following short script to
create a small test database with a table and a single test record:
-- --- BOF ---
create database dbs_test_escaping with encoding 'LATIN9';
\connect dbs_test_escaping
create table tbl_test_escaping
(
test_id int4 not null,
test_name varchar(100),
test_comment text,
constraint prk_test_id primary key (test_id)
);
-- this should make the comment actually to be like this: test "\te%s_t
<\'\>
insert into tbl_test_escaping
(test_id, test_name, test_comment)
values (1, 'Testname', 'test "\te%s_t <\''\>');
-- --- EOF ---
Now check the following statements whose results seem not to reflect the
above configuration:
1. Select the record by a single equal (works fine):
select * from tbl_test_escaping where test_comment = 'test "\te%s_t
<\''\>';
2. Select the record by a like-statement (won't return any result):
select * from tbl_test_escaping where test_comment like '%<\''\>%';
3. Select the record by a like-statement which is manually escaped and has
the escape flag reset (works fine):
select * from tbl_test_escaping where test_comment like '%<\''\>%' escape
'';
4. Select the record by a like-statement which is manually escaped (should
not match because of backslash_quote=off but it matches):
select * from tbl_test_escaping where test_comment like '%<\\''\\>%';
Two questions:
1. What I actually want: Shouldn't the second statement work by
documentation without the escape flag?
2. What I do not understand: Why does the fourth statement return a result
as backslash_quote is off?
Thanks sincerely,
Rainer
rainer@hamburg.ccc.de