aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--contrib/tsearch2/expected/tsearch2.out6
-rw-r--r--contrib/tsearch2/query.c5
-rw-r--r--contrib/tsearch2/sql/tsearch2.sql2
-rw-r--r--contrib/tsearch2/tsvector.c8
4 files changed, 21 insertions, 0 deletions
diff --git a/contrib/tsearch2/expected/tsearch2.out b/contrib/tsearch2/expected/tsearch2.out
index 926bc3ad1af..f069fec5121 100644
--- a/contrib/tsearch2/expected/tsearch2.out
+++ b/contrib/tsearch2/expected/tsearch2.out
@@ -331,6 +331,12 @@ SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';
'the wether':dc & ' sKies ':BC & a:d b:a
(1 row)
+SELECT tsvector_in(tsvector_out($$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector)), tsquery_in(tsquery_out($$'\\as'$$::tsquery));
+ tsvector_in | tsquery_in
+----------------------------------------+------------
+ '\\as' 'abc' 'AB\\c' 'ab\\c' 'ab\\\\c' | '\\as'
+(1 row)
+
select 'a' < 'b & c'::tsquery;
?column?
----------
diff --git a/contrib/tsearch2/query.c b/contrib/tsearch2/query.c
index 37f60caf1ad..c86169874cb 100644
--- a/contrib/tsearch2/query.c
+++ b/contrib/tsearch2/query.c
@@ -765,6 +765,11 @@ infix(INFIX * in, bool first)
*(in->cur) = '\'';
in->cur++;
}
+ else if (t_iseq(op, '\\'))
+ {
+ *(in->cur) = '\\';
+ in->cur++;
+ }
COPYCHAR(in->cur, op);
clen = pg_mblen(op);
diff --git a/contrib/tsearch2/sql/tsearch2.sql b/contrib/tsearch2/sql/tsearch2.sql
index c6ed880b473..27b29661d27 100644
--- a/contrib/tsearch2/sql/tsearch2.sql
+++ b/contrib/tsearch2/sql/tsearch2.sql
@@ -67,6 +67,8 @@ SELECT '1&(2&(4&(5|!6)))'::tsquery;
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';
+SELECT tsvector_in(tsvector_out($$'\\as' ab\c ab\\c AB\\\c ab\\\\c$$::tsvector)), tsquery_in(tsquery_out($$'\\as'$$::tsquery));
+
select 'a' < 'b & c'::tsquery;
select 'a' > 'b & c'::tsquery;
select 'a | f' < 'b & c'::tsquery;
diff --git a/contrib/tsearch2/tsvector.c b/contrib/tsearch2/tsvector.c
index 059a247f186..ac8923d8dac 100644
--- a/contrib/tsearch2/tsvector.c
+++ b/contrib/tsearch2/tsvector.c
@@ -550,6 +550,14 @@ tsvector_out(PG_FUNCTION_ARGS)
curout = outbuf + pos;
*curout++ = '\'';
}
+ else if (t_iseq(curin, '\\'))
+ {
+ int4 pos = curout - outbuf;
+
+ outbuf = (char *) repalloc((void *) outbuf, ++lenbuf);
+ curout = outbuf + pos;
+ *curout++ = '\\';
+ }
while (len--)
*curout++ = *curin++;
}