Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c4f289

Browse files
committed
Use '' rather than \' for literal single quotes in strings in
/contrib/tsearch2.Teodor Sigaev
1 parent4b636e3 commit0c4f289

File tree

3 files changed

+43
-28
lines changed

3 files changed

+43
-28
lines changed

‎contrib/tsearch2/expected/tsearch2.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,25 +59,25 @@ SELECT '''1 2'''::tsvector;
5959
SELECT E'''1 \\''2'''::tsvector;
6060
tsvector
6161
----------
62-
'1\'2'
62+
'1''2'
6363
(1 row)
6464

6565
SELECT E'''1 \\''2''3'::tsvector;
6666
tsvector
6767
-------------
68-
'3' '1\'2'
68+
'3' '1''2'
6969
(1 row)
7070

7171
SELECT E'''1 \\''2'' 3'::tsvector;
7272
tsvector
7373
-------------
74-
'3' '1\'2'
74+
'3' '1''2'
7575
(1 row)
7676

7777
SELECT E'''1 \\''2'' '' 3'' 4 '::tsvector;
7878
tsvector
7979
------------------
80-
'4' ' 3' '1\'2'
80+
'4' ' 3' '1''2'
8181
(1 row)
8282

8383
select '''w'':4A,3B,2C,1D,5 a:8';
@@ -138,7 +138,7 @@ SELECT '''1 2'''::tsquery;
138138
SELECT E'''1 \\''2'''::tsquery;
139139
tsquery
140140
---------
141-
'1\'2'
141+
'1''2'
142142
(1 row)
143143

144144
SELECT '!1'::tsquery;
@@ -336,7 +336,7 @@ SELECT '1&(2&(4&(5|!6)))'::tsquery;
336336
SELECT E'1&(''2''&('' 4''&(\\|5 | ''6 \\'' !|&'')))'::tsquery;
337337
tsquery
338338
------------------------------------------
339-
'1' & '2' & ' 4' & ( '|5' | '6\' !|&' )
339+
'1' & '2' & ' 4' & ( '|5' | '6'' !|&' )
340340
(1 row)
341341

342342
SELECT '''the wether'':dc & '' sKies '':BC & a:d b:a';

‎contrib/tsearch2/query.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ findoprnd(ITEM * ptr, int4 *pos)
604604
* input
605605
*/
606606
staticQUERYTYPE*
607-
queryin(char*buf,void (*pushval) (QPRS_STATE*,int,char*,int,int2),intcfg_id,boolisplain)
607+
queryin(char*buf,void (*pushval) (QPRS_STATE*,int,char*,int,int2),intcfg_id,boolisplain)
608608
{
609609
QPRS_STATEstate;
610610
int4i;
@@ -748,7 +748,7 @@ infix(INFIX * in, bool first)
748748
{
749749
if (t_iseq(op,'\'') )
750750
{
751-
*(in->cur)='\\';
751+
*(in->cur)='\'';
752752
in->cur++;
753753
}
754754
COPYCHAR(in->cur,op);

‎contrib/tsearch2/tsvector.c

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,14 @@ uniqueentry(WordEntryIN * a, int4 l, char *buf, int4 *outbuflen)
164164
returnres+1-a;
165165
}
166166

167-
#defineWAITWORD1
168-
#defineWAITENDWORD 2
167+
#defineWAITWORD1
168+
#defineWAITENDWORD2
169169
#defineWAITNEXTCHAR3
170170
#defineWAITENDCMPLX4
171-
#defineWAITPOSINFO 5
172-
#defineINPOSINFO6
171+
#defineWAITPOSINFO5
172+
#defineINPOSINFO6
173173
#defineWAITPOSDELIM7
174+
#defineWAITCHARCMPLX8
174175

175176
#defineRESIZEPRSBUF \
176177
do { \
@@ -270,21 +271,8 @@ gettoken_tsvector(TI_IN_STATE * state)
270271
}
271272
elseif (state->state==WAITENDCMPLX)
272273
{
273-
if (t_iseq(state->prsbuf,'\'') )
274-
{
275-
RESIZEPRSBUF;
276-
*(state->curpos)='\0';
277-
if (state->curpos==state->word)
278-
ereport(ERROR,
279-
(errcode(ERRCODE_SYNTAX_ERROR),
280-
errmsg("syntax error")));
281-
if (state->oprisdelim)
282-
{
283-
state->prsbuf+=pg_mblen(state->prsbuf);
284-
return1;
285-
}
286-
else
287-
state->state=WAITPOSINFO;
274+
if (t_iseq(state->prsbuf,'\'') ) {
275+
state->state=WAITCHARCMPLX;
288276
}
289277
elseif (t_iseq(state->prsbuf,'\\') )
290278
{
@@ -302,6 +290,31 @@ gettoken_tsvector(TI_IN_STATE * state)
302290
state->curpos+=pg_mblen(state->prsbuf);
303291
}
304292
}
293+
elseif (state->state==WAITCHARCMPLX)
294+
{
295+
if (t_iseq(state->prsbuf,'\'') )
296+
{
297+
RESIZEPRSBUF;
298+
COPYCHAR(state->curpos,state->prsbuf);
299+
state->curpos+=pg_mblen(state->prsbuf);
300+
state->state=WAITENDCMPLX;
301+
}else {
302+
RESIZEPRSBUF;
303+
*(state->curpos)='\0';
304+
if (state->curpos==state->word)
305+
ereport(ERROR,
306+
(errcode(ERRCODE_SYNTAX_ERROR),
307+
errmsg("syntax error")));
308+
if (state->oprisdelim)
309+
{
310+
/* state->prsbuf+=pg_mblen(state->prsbuf); */
311+
return1;
312+
}
313+
else
314+
state->state=WAITPOSINFO;
315+
continue;/* recheck current character */
316+
}
317+
}
305318
elseif (state->state==WAITPOSINFO)
306319
{
307320
if (t_iseq(state->prsbuf,':') )
@@ -385,6 +398,8 @@ gettoken_tsvector(TI_IN_STATE * state)
385398
else
386399
/* internal error */
387400
elog(ERROR,"internal error");
401+
402+
/* get next char */
388403
state->prsbuf+=pg_mblen(state->prsbuf);
389404
}
390405

@@ -529,7 +544,7 @@ tsvector_out(PG_FUNCTION_ARGS)
529544

530545
outbuf= (char*)repalloc((void*)outbuf,++lenbuf);
531546
curout=outbuf+pos;
532-
*curout++='\\';
547+
*curout++='\'';
533548
}
534549
while(len--)
535550
*curout++=*curin++;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp