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

Commit12f25e7

Browse files
committed
Fix two-argument form of ts_rewrite() so it actually works for cases where
a later rewrite rule should change a subtree modified by an earlier one.Per my gripe of a few days ago.
1 parentbb36c51 commit12f25e7

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

‎src/backend/utils/adt/tsquery_rewrite.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.4 2007/09/07 16:03:40 teodor Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_rewrite.c,v 1.5 2007/10/23 01:44:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -467,6 +467,13 @@ tsquery_rewrite(PG_FUNCTION_ARGS)
467467
QTNFree(qsubs);
468468
if (qtsubs!= (TSQuery)DatumGetPointer(sdata))
469469
pfree(qtsubs);
470+
471+
if (tree)
472+
{
473+
/* ready the tree for another pass */
474+
QTNClearFlags(tree,QTN_NOCHANGE);
475+
QTNSort(tree);
476+
}
470477
}
471478
}
472479

‎src/backend/utils/adt/tsquery_util.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.4 2007/09/07 16:03:40 teodor Exp $
10+
* $PostgreSQL: pgsql/src/backend/utils/adt/tsquery_util.c,v 1.5 2007/10/23 01:44:39 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -381,3 +381,20 @@ QTNCopy(QTNode *in)
381381

382382
returnout;
383383
}
384+
385+
void
386+
QTNClearFlags(QTNode*in,uint32flags)
387+
{
388+
/* since this function recurses, it could be driven to stack overflow. */
389+
check_stack_depth();
390+
391+
in->flags &= ~flags;
392+
393+
if (in->valnode->type!=QI_VAL)
394+
{
395+
inti;
396+
397+
for (i=0;i<in->nchild;i++)
398+
QTNClearFlags(in->child[i],flags);
399+
}
400+
}

‎src/include/tsearch/ts_utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1998-2007, PostgreSQL Global Development Group
77
*
8-
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.6 2007/10/21 22:29:56 tgl Exp $
8+
* $PostgreSQL: pgsql/src/include/tsearch/ts_utils.h,v 1.7 2007/10/23 01:44:39 tgl Exp $
99
*
1010
*-------------------------------------------------------------------------
1111
*/
@@ -172,6 +172,7 @@ typedef struct QTNode
172172
structQTNode**child;
173173
}QTNode;
174174

175+
/* bits in QTNode.flags */
175176
#defineQTN_NEEDFREE0x01
176177
#defineQTN_NOCHANGE0x02
177178
#defineQTN_WORDFREE0x04
@@ -189,6 +190,7 @@ extern void QTNTernary(QTNode * in);
189190
externvoidQTNBinary(QTNode*in);
190191
externintQTNodeCompare(QTNode*an,QTNode*bn);
191192
externQTNode*QTNCopy(QTNode*in);
193+
externvoidQTNClearFlags(QTNode*in,uint32flags);
192194
externboolQTNEq(QTNode*a,QTNode*b);
193195
externTSQuerySignmakeTSQuerySign(TSQuerya);
194196

‎src/test/regress/expected/tsearch.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ SELECT ts_rewrite('moscow', 'SELECT keyword, sample FROM test_tsquery'::text );
673673
SELECT ts_rewrite('moscow & hotel', 'SELECT keyword, sample FROM test_tsquery'::text );
674674
ts_rewrite
675675
-----------------------------------
676-
( 'moskva' | 'moscow' ) & 'hotel'
676+
'hotel' &( 'moskva' | 'moscow' )
677677
(1 row)
678678

679679
SELECT ts_rewrite('bar & new & qq & foo & york', 'SELECT keyword, sample FROM test_tsquery'::text );

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp