From 75bf6b9c6f2a873e04c50aa55e6fd2cadffc82da Mon Sep 17 00:00:00 2001 From: usamoi Date: Sun, 17 Mar 2024 19:57:04 +0800 Subject: [PATCH] fix: revert set amoptionalkey to false Signed-off-by: usamoi --- src/index/am.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/index/am.rs b/src/index/am.rs index 13c519218..feb34274c 100644 --- a/src/index/am.rs +++ b/src/index/am.rs @@ -46,6 +46,15 @@ const AM_HANDLER: pgrx::pg_sys::IndexAmRoutine = { am_routine.amcanorderbyop = true; + // Index access methods that set `amoptionalkey` to `false` + // must index all tuples, even if the first column is `NULL`. + // However, PostgreSQL does not generate a path if there is no + // index clauses, even if there is a `ORDER BY` clause. + // So we have to set it to `true` and set costs of every path + // for vector index scans without `ORDER BY` clauses a large number + // and throw errors if someone really wants such a path. + am_routine.amoptionalkey = true; + am_routine.amvalidate = Some(amvalidate); am_routine.amoptions = Some(amoptions); am_routine.amcostestimate = Some(amcostestimate);