Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions pgvectorscale/sql/vectorscale--0.0.2--0.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,22 @@ BEGIN

IF c = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops;
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops;
Comment thread
mostafa marked this conversation as resolved.
Outdated
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
18 changes: 16 additions & 2 deletions pgvectorscale/sql/vectorscale--0.2.0--0.3.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,23 @@ BEGIN

IF c = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops;
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops;
Comment thread
mostafa marked this conversation as resolved.
Outdated
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;

Expand Down
18 changes: 16 additions & 2 deletions pgvectorscale/sql/vectorscale--0.3.0--0.4.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,23 @@ BEGIN

IF c = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops;
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops;
Comment thread
mostafa marked this conversation as resolved.
Outdated
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
26 changes: 20 additions & 6 deletions pgvectorscale/sql/vectorscale--0.4.0--0.5.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ BEGIN
IF have_cos_ops = 0 THEN
-- Fresh install from scratch
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
Comment thread
mostafa marked this conversation as resolved.
Outdated
FUNCTION 1 distance_type_cosine();

CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
ELSIF have_l2_ops = 0 THEN
-- Upgrade to add L2 distance support and update cosine opclass to
Expand All @@ -95,10 +95,24 @@ BEGIN
WHERE a.oid = c.opcmethod AND c.opcname = 'vector_cosine_ops' AND a.amname = 'diskann';

CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
26 changes: 20 additions & 6 deletions pgvectorscale/sql/vectorscale--0.5.0--0.5.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ BEGIN
IF have_cos_ops = 0 THEN
-- Fresh install from scratch
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
Comment thread
mostafa marked this conversation as resolved.
Outdated
FUNCTION 1 distance_type_cosine();

CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
ELSIF have_l2_ops = 0 THEN
-- Upgrade to add L2 distance support and update cosine opclass to
Expand All @@ -95,10 +95,24 @@ BEGIN
WHERE a.oid = c.opcmethod AND c.opcname = 'vector_cosine_ops' AND a.amname = 'diskann';

CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
26 changes: 20 additions & 6 deletions pgvectorscale/sql/vectorscale--0.5.1--0.6.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ BEGIN

IF have_cos_ops = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
Comment thread
mostafa marked this conversation as resolved.
Outdated
FUNCTION 1 distance_type_cosine();
ELSIF have_l2_ops = 0 THEN
-- Upgrade from 0.4.0 to 0.5.0. Update cosine opclass to include
Expand All @@ -110,17 +110,31 @@ BEGIN

IF have_l2_ops = 0 THEN
CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
END IF;

IF have_ip_ops = 0 THEN
CREATE OPERATOR CLASS vector_ip_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <#> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<#> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_inner_product();
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
26 changes: 20 additions & 6 deletions pgvectorscale/sql/vectorscale--0.6.0--0.7.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ BEGIN

IF have_cos_ops = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
Comment thread
mostafa marked this conversation as resolved.
Outdated
FUNCTION 1 distance_type_cosine();
ELSIF have_l2_ops = 0 THEN
-- Upgrade from 0.4.0 to 0.5.0. Update cosine opclass to include
Expand All @@ -132,15 +132,15 @@ BEGIN

IF have_l2_ops = 0 THEN
CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
END IF;

IF have_ip_ops = 0 THEN
CREATE OPERATOR CLASS vector_ip_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <#> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<#> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_inner_product();
END IF;

Expand Down Expand Up @@ -173,6 +173,20 @@ BEGIN
DEFAULT FOR TYPE smallint[] USING diskann AS
OPERATOR 1 &&;
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
26 changes: 20 additions & 6 deletions pgvectorscale/sql/vectorscale--0.7.0--0.7.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ BEGIN

IF have_cos_ops = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
Comment thread
mostafa marked this conversation as resolved.
Outdated
FUNCTION 1 distance_type_cosine();
ELSIF have_l2_ops = 0 THEN
-- Upgrade from 0.4.0 to 0.5.0. Update cosine opclass to include
Expand All @@ -132,15 +132,15 @@ BEGIN

IF have_l2_ops = 0 THEN
CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
END IF;

IF have_ip_ops = 0 THEN
CREATE OPERATOR CLASS vector_ip_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <#> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<#> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_inner_product();
END IF;

Expand Down Expand Up @@ -173,6 +173,20 @@ BEGIN
DEFAULT FOR TYPE smallint[] USING diskann AS
OPERATOR 1 &&;
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
26 changes: 20 additions & 6 deletions pgvectorscale/sql/vectorscale--0.7.1--0.8.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ BEGIN

IF have_cos_ops = 0 THEN
CREATE OPERATOR CLASS vector_cosine_ops DEFAULT
FOR TYPE vector USING diskann AS
OPERATOR 1 <=> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<=> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
Comment thread
mostafa marked this conversation as resolved.
Outdated
FUNCTION 1 distance_type_cosine();
ELSIF have_l2_ops = 0 THEN
-- Upgrade from 0.4.0 to 0.5.0. Update cosine opclass to include
Expand All @@ -132,15 +132,15 @@ BEGIN

IF have_l2_ops = 0 THEN
CREATE OPERATOR CLASS vector_l2_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <-> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<-> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_l2();
END IF;

IF have_ip_ops = 0 THEN
CREATE OPERATOR CLASS vector_ip_ops
FOR TYPE vector USING diskann AS
OPERATOR 1 <#> (vector, vector) FOR ORDER BY float_ops,
FOR TYPE @extschema:vector@.vector USING diskann AS
OPERATOR 1 @extschema:vector@.<#> (@extschema:vector@.vector, @extschema:vector@.vector) FOR ORDER BY pg_catalog.float_ops,
FUNCTION 1 distance_type_inner_product();
END IF;

Expand Down Expand Up @@ -173,6 +173,20 @@ BEGIN
DEFAULT FOR TYPE smallint[] USING diskann AS
OPERATOR 1 &&;
END IF;

-- Refuse wrongly bound DiskANN vector opclasses left behind by older installs.
IF EXISTS (
SELECT 1
FROM pg_catalog.pg_opclass c
JOIN pg_catalog.pg_am am ON am.oid = c.opcmethod
WHERE am.amname = 'diskann'
AND c.opcnamespace = (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = '@extschema@')
AND c.opcname IN ('vector_cosine_ops', 'vector_l2_ops', 'vector_ip_ops')
AND c.opcintype IS DISTINCT FROM '@extschema:vector@.vector'::pg_catalog.regtype
) THEN
RAISE EXCEPTION 'diskann: a vector operator class is not bound to pgvector''s vector type; drop the affected operator class and recreate the extension objects';
END IF;

END;
$$;
/* </end connected objects> */
Expand Down
Loading
Loading