Use of backslash in tsearch2 - Mailing list pgsql-patches
| From | Bruce Momjian |
|---|---|
| Subject | Use of backslash in tsearch2 |
| Date | |
| Msg-id | 200608220004.k7M041804370@momjian.us Whole thread Raw |
| Responses |
Re: Use of backslash in tsearch2
Re: Use of backslash in tsearch2 |
| List | pgsql-patches |
Bruce Momjian wrote:
>
> I backed out the patch, attached, and it has fixed the regression
> problem. What has me confused is that is looks like it is checking for
> ', then putting \, which doesn't make a lot of sense, but the regression
> output is corrected, so I just don't get it. Here is an example:
>
> test=> SELECT E'''1 \\''2''';
> ?column?
> ----------
> '1 \'2'
>
> My only guess is that the output is somehow a single-quoted string
> itself, and in fact \' should become ''. Is that right? Basically they
> are doing \' in their output, and it should be doing '', but then the
> query above would be wrong and shouldn't be using \'.
As part of the move to support standard-conforming strings and treat
backslash literally, I reviewed the tsearch2 code and found two place
that seemed to use \' rather than '', and generated the attached patch.
('' is standards conforming.) However, when I fixed the code, the
regression tests failed.
Teodor, are the new attached regression results correct? If so, I will
apply the patch and update the expected file.
--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com
+ If your life is a hard drive, Christ can be your backup. +
Index: contrib/tsearch2/query.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/tsearch2/query.c,v
retrieving revision 1.25
diff -c -c -r1.25 query.c
*** contrib/tsearch2/query.c 19 May 2006 02:38:47 -0000 1.25
--- contrib/tsearch2/query.c 19 May 2006 04:37:35 -0000
***************
*** 748,754 ****
{
if ( t_iseq(op, '\'') )
{
! *(in->cur) = '\'';
in->cur++;
}
COPYCHAR(in->cur,op);
--- 748,754 ----
{
if ( t_iseq(op, '\'') )
{
! *(in->cur) = '\\';
in->cur++;
}
COPYCHAR(in->cur,op);
Index: contrib/tsearch2/tsvector.c
===================================================================
RCS file: /cvsroot/pgsql/contrib/tsearch2/tsvector.c,v
retrieving revision 1.18
diff -c -c -r1.18 tsvector.c
*** contrib/tsearch2/tsvector.c 19 May 2006 02:38:47 -0000 1.18
--- contrib/tsearch2/tsvector.c 19 May 2006 04:37:39 -0000
***************
*** 529,535 ****
outbuf = (char *) repalloc((void *) outbuf, ++lenbuf);
curout = outbuf + pos;
! *curout++ = '\'';
}
while(len--)
*curout++ = *curin++;
--- 529,535 ----
outbuf = (char *) repalloc((void *) outbuf, ++lenbuf);
curout = outbuf + pos;
! *curout++ = '\\';
}
while(len--)
*curout++ = *curin++;
*** ./expected/tsearch2.out Wed May 31 10:05:31 2006
--- ./results/tsearch2.out Mon Aug 21 20:01:12 2006
***************
*** 59,83 ****
SELECT E'''1 \\''2'''::tsvector;
tsvector
----------
! '1 \'2'
(1 row)
SELECT E'''1 \\''2''3'::tsvector;
tsvector
-------------
! '3' '1 \'2'
(1 row)
SELECT E'''1 \\''2'' 3'::tsvector;
tsvector
-------------
! '3' '1 \'2'
(1 row)
SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector;
tsvector
------------------
! '4' ' 3' '1 \'2'
(1 row)
select '''w'':4A,3B,2C,1D,5 a:8';
--- 59,83 ----
SELECT E'''1 \\''2'''::tsvector;
tsvector
----------
! '1 ''2'
(1 row)
SELECT E'''1 \\''2''3'::tsvector;
tsvector
-------------
! '3' '1 ''2'
(1 row)
SELECT E'''1 \\''2'' 3'::tsvector;
tsvector
-------------
! '3' '1 ''2'
(1 row)
SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector;
tsvector
------------------
! '4' ' 3' '1 ''2'
(1 row)
select '''w'':4A,3B,2C,1D,5 a:8';
***************
*** 138,144 ****
SELECT E'''1 \\''2'''::tsquery;
tsquery
---------
! '1 \'2'
(1 row)
SELECT '!1'::tsquery;
--- 138,144 ----
SELECT E'''1 \\''2'''::tsquery;
tsquery
---------
! '1 ''2'
(1 row)
SELECT '!1'::tsquery;
***************
*** 336,342 ****
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
tsquery
------------------------------------------
! '1' & '2' & ' 4' & ( '|5' | '6 \' !|&' )
(1 row)
SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';
--- 336,342 ----
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
tsquery
------------------------------------------
! '1' & '2' & ' 4' & ( '|5' | '6 '' !|&' )
(1 row)
SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';
======================================================================
pgsql-patches by date: