forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite81e574
committed
Fix full text search to handle NOT above a phrase search correctly.
Queries such as '!(foo<->bar)' failed to find matching rows whenimplemented as a GiST or GIN index search. That's because offailing to handle phrase searches as tri-valued when consideringa query without any position information for the target tsvector.We can only say that the phrase operator might match, not that itdoes match; and therefore its NOT also might match. The previouscoding incorrectly inverted the approximate phrase result todecide that there was certainly no match.To fix, we need to make TS_phrase_execute return a real ternary result,and then bubble that up accurately in TS_execute. As long as we haveto do that anyway, we can simplify the baroque things TS_phrase_executewas doing internally to manage tri-valued searching with only a boolas explicit result.For now, I left the externally-visible result of TS_execute as a plainbool. There do not appear to be any outside callers that need todistinguish a three-way result, given that they passed in a flagsaying what to do in the absence of position data. This might needto change someday, but we wouldn't want to back-patch such a change.Although tsginidx.c has its own TS_execute_ternary implementation foruse at upper index levels, that sadly managed to get this case wrongas well :-(. Fixing it is a lot easier fortunately.Per bug #16388 from Charles Offenbacher. Back-patch to 9.6 wherephrase search was introduced.Discussion:https://postgr.es/m/16388-98cffba38d0b7e6e@postgresql.org1 parent5ac2475 commite81e574
File tree
7 files changed
+734
-115
lines changed- src
- backend/utils/adt
- test/regress
- data
- expected
- sql
7 files changed
+734
-115
lines changedLines changed: 20 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
210 | 210 |
| |
211 | 211 |
| |
212 | 212 |
| |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
213 | 218 |
| |
214 | 219 |
| |
215 | 220 |
| |
| |||
230 | 235 |
| |
231 | 236 |
| |
232 | 237 |
| |
233 |
| - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
234 | 248 |
| |
235 | 249 |
| |
| 250 | + | |
236 | 251 |
| |
237 | 252 |
| |
238 | 253 |
| |
| |||
242 | 257 |
| |
243 | 258 |
| |
244 | 259 |
| |
245 |
| - | |
| 260 | + | |
| 261 | + | |
246 | 262 |
| |
247 | 263 |
| |
248 | 264 |
| |
| |||
258 | 274 |
| |
259 | 275 |
| |
260 | 276 |
| |
261 |
| - | |
| 277 | + | |
| 278 | + | |
262 | 279 |
| |
263 | 280 |
| |
264 | 281 |
| |
|
0 commit comments
Comments
(0)