Skip to content

Commit badea24

Browse files
committed
fix: schema (#338)
Signed-off-by: usamoi <usamoi@outlook.com>
1 parent fed818f commit badea24

2 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/index/functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl Drop for Index {
8888
}
8989

9090
#[pgrx::pg_extern(sql = "")]
91-
fn _vchordrq_sampled_vectors(indexrelid: Oid) -> SetOfIterator<'static, String> {
91+
fn _vchordrq_sampled_values(indexrelid: Oid) -> SetOfIterator<'static, String> {
9292
let pg_am = PgAm::search_amname(c"vchordrq").unwrap();
9393
let Some(pg_am) = pg_am.get() else {
9494
pgrx::error!("vchord is not installed");

src/sql/finalize.sql

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ IMMUTABLE STRICT PARALLEL SAFE LANGUAGE c AS 'MODULE_PATHNAME', '_vchord_vector_
142142
CREATE FUNCTION quantize_to_scalar8(halfvec) RETURNS scalar8
143143
IMMUTABLE STRICT PARALLEL SAFE LANGUAGE c AS 'MODULE_PATHNAME', '_vchord_halfvec_quantize_to_scalar8_wrapper';
144144

145-
CREATE FUNCTION vchordrq_sampled_vectors(regclass)
146-
RETURNS SETOF TEXT
147-
STRICT LANGUAGE c AS 'MODULE_PATHNAME', '_vchordrq_sampled_vectors_wrapper';
145+
CREATE FUNCTION vchordrq_sampled_values(regclass) RETURNS SETOF TEXT
146+
STRICT LANGUAGE c AS 'MODULE_PATHNAME', '_vchordrq_sampled_values_wrapper';
148147

149-
CREATE OR REPLACE FUNCTION vchordrq_sampled_queries(regclass)
148+
CREATE FUNCTION vchordrq_sampled_queries(regclass)
150149
RETURNS TABLE(
151150
schema_name NAME,
152151
index_name NAME,
@@ -155,8 +154,7 @@ RETURNS TABLE(
155154
operator NAME,
156155
value TEXT
157156
)
158-
LANGUAGE plpgsql
159-
STRICT AS $$
157+
STRICT LANGUAGE plpgsql AS $$
160158
DECLARE
161159
ext_schema TEXT;
162160
query_text TEXT;
@@ -214,7 +212,7 @@ BEGIN
214212
s.value
215213
FROM
216214
index_metadata im,
217-
LATERAL %2$I.vchordrq_sampled_vectors(%1$s) AS s(value);
215+
LATERAL %2$I.vchordrq_sampled_values(%1$s) AS s(value);
218216
$q$,
219217
$1::oid,
220218
ext_schema
@@ -223,25 +221,6 @@ BEGIN
223221
END;
224222
$$;
225223

226-
CREATE VIEW vchordrq_sampled_queries AS
227-
SELECT
228-
record.schema_name,
229-
record.index_name,
230-
record.table_name,
231-
record.column_name,
232-
record.operator,
233-
record.value
234-
FROM
235-
(
236-
SELECT i.oid
237-
FROM pg_catalog.pg_class AS i
238-
JOIN pg_catalog.pg_index AS ix ON i.oid = ix.indexrelid
239-
JOIN pg_catalog.pg_opclass AS opc ON ix.indclass[0] = opc.oid
240-
JOIN pg_catalog.pg_am AS am ON opc.opcmethod = am.oid
241-
WHERE am.amname = 'vchordrq'
242-
) AS index_oids
243-
CROSS JOIN LATERAL vchordrq_sampled_queries(index_oids.oid::regclass) AS record;
244-
245224
CREATE FUNCTION vchordrq_amhandler(internal) RETURNS index_am_handler
246225
IMMUTABLE STRICT PARALLEL SAFE LANGUAGE c AS 'MODULE_PATHNAME', '_vchordrq_amhandler_wrapper';
247226

@@ -432,3 +411,24 @@ CREATE OPERATOR CLASS halfvec_cosine_ops
432411
OPERATOR 1 <=> (halfvec, halfvec) FOR ORDER BY float_ops,
433412
OPERATOR 2 <<=>> (halfvec, sphere_halfvec) FOR SEARCH,
434413
FUNCTION 1 _vchordg_support_halfvec_cosine_ops();
414+
415+
-- List of views
416+
417+
CREATE VIEW vchordrq_sampled_queries AS
418+
SELECT
419+
record.schema_name,
420+
record.index_name,
421+
record.table_name,
422+
record.column_name,
423+
record.operator,
424+
record.value
425+
FROM
426+
(
427+
SELECT i.oid
428+
FROM pg_catalog.pg_class AS i
429+
JOIN pg_catalog.pg_index AS ix ON i.oid = ix.indexrelid
430+
JOIN pg_catalog.pg_opclass AS opc ON ix.indclass[0] = opc.oid
431+
JOIN pg_catalog.pg_am AS am ON opc.opcmethod = am.oid
432+
WHERE am.amname = 'vchordrq'
433+
) AS index_oids
434+
CROSS JOIN LATERAL vchordrq_sampled_queries(index_oids.oid::regclass) AS record;

0 commit comments

Comments
 (0)