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

Commit62e0ade

Browse files
committed
Fix lossy KNN GiST when ordering operator returns non-float8 value.
KNN GiST with recheck flag should return to executor the same type as orderingoperator, GiST detects this type by looking to return type of function whichimplements ordering operator. But occasionally detecting code works afterreplacing ordering operator function to distance support function.Distance support function always returns float8, so, detecting code get float8instead of actual return type of ordering operator.Built-in opclasses don't have ordering operator which doesn't returnnon-float8 value, so, tests are impossible here, at least now.Backpatch to 9.5 where lozzy KNN was introduced.Author: Alexander KorotkovReport by: Artur Zakirov
1 parent829757c commit62e0ade

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎src/backend/access/gist/gistscan.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ gistrescan(PG_FUNCTION_ARGS)
230230
{
231231
ScanKeyskey=scan->keyData+i;
232232

233+
/*
234+
* Copy consistent support function to ScanKey structure
235+
* instead of function implementing filtering operator.
236+
*/
233237
fmgr_info_copy(&(skey->sk_func),
234238
&(so->giststate->consistentFn[skey->sk_attno-1]),
235239
so->giststate->scanCxt);
@@ -285,8 +289,6 @@ gistrescan(PG_FUNCTION_ARGS)
285289
GIST_DISTANCE_PROC,skey->sk_attno,
286290
RelationGetRelationName(scan->indexRelation));
287291

288-
fmgr_info_copy(&(skey->sk_func),finfo,so->giststate->scanCxt);
289-
290292
/*
291293
* Look up the datatype returned by the original ordering
292294
* operator. GiST always uses a float8 for the distance function,
@@ -301,6 +303,12 @@ gistrescan(PG_FUNCTION_ARGS)
301303
*/
302304
so->orderByTypes[i]=get_func_rettype(skey->sk_func.fn_oid);
303305

306+
/*
307+
* Copy distance support function to ScanKey structure
308+
* instead of function implementing ordering operator.
309+
*/
310+
fmgr_info_copy(&(skey->sk_func),finfo,so->giststate->scanCxt);
311+
304312
/* Restore prior fn_extra pointers, if not first time */
305313
if (!first_time)
306314
skey->sk_func.fn_extra=fn_extras[i];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp