From 0554055dd482ec3c78efafa67a3da036b06a795a Mon Sep 17 00:00:00 2001 From: cutecutecat Date: Fri, 12 Sep 2025 17:43:20 +0800 Subject: [PATCH] fix: permission and sql for query sample Signed-off-by: cutecutecat --- src/index/gucs.rs | 6 +++--- src/sql/finalize.sql | 16 ++++++++-------- tests/vchordrq/recall.slt | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/index/gucs.rs b/src/index/gucs.rs index ed501a52..5b74bc2b 100644 --- a/src/index/gucs.rs +++ b/src/index/gucs.rs @@ -169,7 +169,7 @@ pub fn init() { c"`query_sampling_enable` argument of vchordrq.", c"`query_sampling_enable` argument of vchordrq.", &VCHORDRQ_QUERY_SAMPLING_ENABLE, - GucContext::Userset, + GucContext::Suset, GucFlags::default(), ); GucRegistry::define_int_guc( @@ -179,7 +179,7 @@ pub fn init() { &VCHORDRQ_QUERY_SAMPLING_MAX_RECORDS, 0, 10000, - GucContext::Userset, + GucContext::Suset, GucFlags::default(), ); GucRegistry::define_float_guc( @@ -189,7 +189,7 @@ pub fn init() { &VCHORDRQ_QUERY_SAMPLING_RATE, 0.0, 1.0, - GucContext::Userset, + GucContext::Suset, GucFlags::default(), ); unsafe { diff --git a/src/sql/finalize.sql b/src/sql/finalize.sql index c5844c44..7396fb74 100644 --- a/src/sql/finalize.sql +++ b/src/sql/finalize.sql @@ -152,7 +152,7 @@ RETURNS TABLE( index_name NAME, table_name NAME, column_name NAME, - operator TEXT, + operator NAME, value TEXT ) LANGUAGE plpgsql @@ -179,12 +179,7 @@ BEGIN I.relname AS index_name, C.relname AS table_name, PA.attname AS column_name, - CASE - WHEN OP.opcname LIKE '%%l2%%' THEN '<->' - WHEN OP.opcname LIKE '%%ip%%' THEN '<#>' - WHEN OP.opcname LIKE '%%cosine%%' THEN '<=>' - ELSE '' - END AS operator + OP.oprname AS operator FROM pg_catalog.pg_index X JOIN @@ -196,11 +191,16 @@ BEGIN JOIN pg_catalog.pg_am A ON A.oid = I.relam LEFT JOIN - pg_catalog.pg_opclass AS OP ON OP.oid = X.indclass[0] + pg_catalog.pg_opclass AS OPC ON OPC.oid = X.indclass[0] + LEFT JOIN + pg_catalog.pg_amop AO ON OPC.opcfamily = AO.amopfamily + LEFT JOIN + pg_catalog.pg_operator OP ON OP.oid = AO.amopopr LEFT JOIN pg_catalog.pg_attribute PA ON PA.attrelid = X.indrelid AND PA.attnum = X.indkey[0] WHERE A.amname = 'vchordrq' + AND AO.amopstrategy = 1 AND C.relkind = 'r' AND X.indnatts = 1 AND X.indexrelid = %1$s diff --git a/tests/vchordrq/recall.slt b/tests/vchordrq/recall.slt index d75068cc..475046fa 100644 --- a/tests/vchordrq/recall.slt +++ b/tests/vchordrq/recall.slt @@ -114,7 +114,7 @@ FROM ( SELECT vchordrq_evaluate_query_recall( query => format( - 'SELECT ctid FROM %I.%I ORDER BY %I %s ''%s'' LIMIT 10', + 'SELECT ctid FROM %I.%I ORDER BY %I OPERATOR(%s) %L LIMIT 10', lq.schema_name, lq.table_name, lq.column_name,