2015-07-20 23:18:48 +08:00
|
|
|
/* contrib/pg_trgm/pg_trgm--1.2.sql */
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-10-13 03:45:03 +08:00
|
|
|
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
|
|
|
|
\echo Use "CREATE EXTENSION pg_trgm" to load this file. \quit
|
|
|
|
|
2016-03-16 22:44:58 +08:00
|
|
|
-- Deprecated function
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION set_limit(float4)
|
2007-11-11 11:25:35 +08:00
|
|
|
RETURNS float4
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-12-09 10:22:46 +08:00
|
|
|
LANGUAGE C STRICT VOLATILE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2016-03-16 22:44:58 +08:00
|
|
|
-- Deprecated function
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION show_limit()
|
2007-11-11 11:25:35 +08:00
|
|
|
RETURNS float4
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-12-09 10:22:46 +08:00
|
|
|
LANGUAGE C STRICT STABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION show_trgm(text)
|
2007-11-11 11:25:35 +08:00
|
|
|
RETURNS _text
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION similarity(text,text)
|
2007-11-11 11:25:35 +08:00
|
|
|
RETURNS float4
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2007-09-30 23:52:06 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION similarity_op(text,text)
|
2007-11-11 11:25:35 +08:00
|
|
|
RETURNS bool
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2016-03-16 22:44:58 +08:00
|
|
|
LANGUAGE C STRICT STABLE; -- stable because depends on pg_trgm.similarity_threshold
|
2004-06-01 01:18:12 +08:00
|
|
|
|
|
|
|
CREATE OPERATOR % (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = similarity_op,
|
|
|
|
COMMUTATOR = '%',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2016-03-16 23:59:21 +08:00
|
|
|
CREATE FUNCTION word_similarity(text,text)
|
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
|
|
|
|
|
|
|
CREATE FUNCTION word_similarity_op(text,text)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C STRICT STABLE; -- stable because depends on pg_trgm.word_similarity_threshold
|
|
|
|
|
|
|
|
CREATE FUNCTION word_similarity_commutator_op(text,text)
|
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C STRICT STABLE; -- stable because depends on pg_trgm.word_similarity_threshold
|
|
|
|
|
|
|
|
CREATE OPERATOR <% (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = word_similarity_op,
|
|
|
|
COMMUTATOR = '%>',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR %> (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = word_similarity_commutator_op,
|
|
|
|
COMMUTATOR = '<%',
|
|
|
|
RESTRICT = contsel,
|
|
|
|
JOIN = contjoinsel
|
|
|
|
);
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION similarity_dist(text,text)
|
2010-12-04 13:16:21 +08:00
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
|
|
|
|
|
|
|
CREATE OPERATOR <-> (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = similarity_dist,
|
|
|
|
COMMUTATOR = '<->'
|
|
|
|
);
|
|
|
|
|
2016-03-16 23:59:21 +08:00
|
|
|
CREATE FUNCTION word_similarity_dist_op(text,text)
|
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
|
|
|
|
|
|
|
CREATE FUNCTION word_similarity_dist_commutator_op(text,text)
|
|
|
|
RETURNS float4
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
|
|
|
|
|
|
|
CREATE OPERATOR <<-> (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = word_similarity_dist_op,
|
|
|
|
COMMUTATOR = '<->>'
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE OPERATOR <->> (
|
|
|
|
LEFTARG = text,
|
|
|
|
RIGHTARG = text,
|
|
|
|
PROCEDURE = word_similarity_dist_commutator_op,
|
|
|
|
COMMUTATOR = '<<->'
|
|
|
|
);
|
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- gist key
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_in(cstring)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS gtrgm
|
|
|
|
AS 'MODULE_PATHNAME'
|
Fix volatility markings of some contrib I/O functions.
In general, datatype I/O functions are supposed to be immutable or at
worst stable. Some contrib I/O functions were, through oversight, not
marked with any volatility property at all, which made them VOLATILE.
Since (most of) these functions actually behave immutably, the erroneous
marking isn't terribly harmful; but it can be user-visible in certain
circumstances, as per a recent bug report from Joe Van Dyk in which a
cast to text was disallowed in an expression index definition.
To fix, just adjust the declarations in the extension SQL scripts. If we
were being very fussy about this, we'd bump the extension version numbers,
but that seems like more trouble (for both developers and users) than the
problem is worth.
A fly in the ointment is that chkpass_in actually is volatile, because
of its use of random() to generate a fresh salt when presented with a
not-yet-encrypted password. This is bad because of the general assumption
that I/O functions aren't volatile: the consequence is that records or
arrays containing chkpass elements may have input behavior a bit different
from a bare chkpass column. But there seems no way to fix this without
breaking existing usage patterns for chkpass, and the consequences of the
inconsistency don't seem bad enough to justify that. So for the moment,
just document it in a comment.
Since we're not bumping version numbers, there seems no harm in
back-patching these fixes; at least future installations will get the
functions marked correctly.
2014-11-06 00:34:11 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_out(gtrgm)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS cstring
|
|
|
|
AS 'MODULE_PATHNAME'
|
Fix volatility markings of some contrib I/O functions.
In general, datatype I/O functions are supposed to be immutable or at
worst stable. Some contrib I/O functions were, through oversight, not
marked with any volatility property at all, which made them VOLATILE.
Since (most of) these functions actually behave immutably, the erroneous
marking isn't terribly harmful; but it can be user-visible in certain
circumstances, as per a recent bug report from Joe Van Dyk in which a
cast to text was disallowed in an expression index definition.
To fix, just adjust the declarations in the extension SQL scripts. If we
were being very fussy about this, we'd bump the extension version numbers,
but that seems like more trouble (for both developers and users) than the
problem is worth.
A fly in the ointment is that chkpass_in actually is volatile, because
of its use of random() to generate a fresh salt when presented with a
not-yet-encrypted password. This is bad because of the general assumption
that I/O functions aren't volatile: the consequence is that records or
arrays containing chkpass elements may have input behavior a bit different
from a bare chkpass column. But there seems no way to fix this without
breaking existing usage patterns for chkpass, and the consequences of the
inconsistency don't seem bad enough to justify that. So for the moment,
just document it in a comment.
Since we're not bumping version numbers, there seems no harm in
back-patching these fixes; at least future installations will get the
functions marked correctly.
2014-11-06 00:34:11 +08:00
|
|
|
LANGUAGE C STRICT IMMUTABLE;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
|
|
|
CREATE TYPE gtrgm (
|
|
|
|
INTERNALLENGTH = -1,
|
|
|
|
INPUT = gtrgm_in,
|
|
|
|
OUTPUT = gtrgm_out
|
|
|
|
);
|
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- support functions for gist
|
Fix assorted inconsistencies in GiST opclass support function declarations.
The conventions specified by the GiST SGML documentation were widely
ignored. For example, the strategy-number argument for "consistent" and
"distance" functions is specified to be a smallint, but most of the
built-in support functions declared it as an integer, and for that matter
the core code passed it using Int32GetDatum not Int16GetDatum. None of
that makes any real difference at runtime, but it's quite confusing for
newcomers to the code, and it makes it very hard to write an amvalidate()
function that checks support function signatures. So let's try to instill
some consistency here.
Another similar issue is that the "query" argument is not of a single
well-defined type, but could have different types depending on the strategy
(corresponding to search operators with different righthand-side argument
types). Some of the functions threw up their hands and declared the query
argument as being of "internal" type, which surely isn't right ("any" would
have been more appropriate); but the majority position seemed to be to
declare it as being of the indexed data type, corresponding to a search
operator with both input types the same. So I've specified a convention
that that's what to do always.
Also, the result of the "union" support function actually must be of the
index's storage type, but the documentation suggested declaring it to
return "internal", and some of the functions followed that. Standardize
on telling the truth, instead.
Similarly, standardize on declaring the "same" function's inputs as
being of the storage type, not "internal".
Also, somebody had forgotten to add the "recheck" argument to both
the documentation of the "distance" support function and all of their
SQL declarations, even though the C code was happily using that argument.
Clean that up too.
Fix up some other omissions in the docs too, such as documenting that
union's second input argument is vestigial.
So far as the errors in core function declarations go, we can just fix
pg_proc.h and bump catversion. Adjusting the erroneous declarations in
contrib modules is more debatable: in principle any change in those
scripts should involve an extension version bump, which is a pain.
However, since these changes are purely cosmetic and make no functional
difference, I think we can get away without doing that.
2016-01-20 01:04:32 +08:00
|
|
|
CREATE FUNCTION gtrgm_consistent(internal,text,smallint,oid,internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS bool
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2010-11-24 04:27:50 +08:00
|
|
|
|
Fix assorted inconsistencies in GiST opclass support function declarations.
The conventions specified by the GiST SGML documentation were widely
ignored. For example, the strategy-number argument for "consistent" and
"distance" functions is specified to be a smallint, but most of the
built-in support functions declared it as an integer, and for that matter
the core code passed it using Int32GetDatum not Int16GetDatum. None of
that makes any real difference at runtime, but it's quite confusing for
newcomers to the code, and it makes it very hard to write an amvalidate()
function that checks support function signatures. So let's try to instill
some consistency here.
Another similar issue is that the "query" argument is not of a single
well-defined type, but could have different types depending on the strategy
(corresponding to search operators with different righthand-side argument
types). Some of the functions threw up their hands and declared the query
argument as being of "internal" type, which surely isn't right ("any" would
have been more appropriate); but the majority position seemed to be to
declare it as being of the indexed data type, corresponding to a search
operator with both input types the same. So I've specified a convention
that that's what to do always.
Also, the result of the "union" support function actually must be of the
index's storage type, but the documentation suggested declaring it to
return "internal", and some of the functions followed that. Standardize
on telling the truth, instead.
Similarly, standardize on declaring the "same" function's inputs as
being of the storage type, not "internal".
Also, somebody had forgotten to add the "recheck" argument to both
the documentation of the "distance" support function and all of their
SQL declarations, even though the C code was happily using that argument.
Clean that up too.
Fix up some other omissions in the docs too, such as documenting that
union's second input argument is vestigial.
So far as the errors in core function declarations go, we can just fix
pg_proc.h and bump catversion. Adjusting the erroneous declarations in
contrib modules is more debatable: in principle any change in those
scripts should involve an extension version bump, which is a pain.
However, since these changes are purely cosmetic and make no functional
difference, I think we can get away without doing that.
2016-01-20 01:04:32 +08:00
|
|
|
CREATE FUNCTION gtrgm_distance(internal,text,smallint,oid,internal)
|
2010-12-04 13:16:21 +08:00
|
|
|
RETURNS float8
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_compress(internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_decompress(internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_penalty(internal,internal,internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_picksplit(internal, internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
Fix assorted inconsistencies in GiST opclass support function declarations.
The conventions specified by the GiST SGML documentation were widely
ignored. For example, the strategy-number argument for "consistent" and
"distance" functions is specified to be a smallint, but most of the
built-in support functions declared it as an integer, and for that matter
the core code passed it using Int32GetDatum not Int16GetDatum. None of
that makes any real difference at runtime, but it's quite confusing for
newcomers to the code, and it makes it very hard to write an amvalidate()
function that checks support function signatures. So let's try to instill
some consistency here.
Another similar issue is that the "query" argument is not of a single
well-defined type, but could have different types depending on the strategy
(corresponding to search operators with different righthand-side argument
types). Some of the functions threw up their hands and declared the query
argument as being of "internal" type, which surely isn't right ("any" would
have been more appropriate); but the majority position seemed to be to
declare it as being of the indexed data type, corresponding to a search
operator with both input types the same. So I've specified a convention
that that's what to do always.
Also, the result of the "union" support function actually must be of the
index's storage type, but the documentation suggested declaring it to
return "internal", and some of the functions followed that. Standardize
on telling the truth, instead.
Similarly, standardize on declaring the "same" function's inputs as
being of the storage type, not "internal".
Also, somebody had forgotten to add the "recheck" argument to both
the documentation of the "distance" support function and all of their
SQL declarations, even though the C code was happily using that argument.
Clean that up too.
Fix up some other omissions in the docs too, such as documenting that
union's second input argument is vestigial.
So far as the errors in core function declarations go, we can just fix
pg_proc.h and bump catversion. Adjusting the erroneous declarations in
contrib modules is more debatable: in principle any change in those
scripts should involve an extension version bump, which is a pain.
However, since these changes are purely cosmetic and make no functional
difference, I think we can get away without doing that.
2016-01-20 01:04:32 +08:00
|
|
|
CREATE FUNCTION gtrgm_union(internal, internal)
|
|
|
|
RETURNS gtrgm
|
2004-06-01 01:18:12 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gtrgm_same(gtrgm, gtrgm, internal)
|
2004-06-01 01:18:12 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2004-06-01 01:18:12 +08:00
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- create the operator class for gist
|
2004-06-01 01:18:12 +08:00
|
|
|
CREATE OPERATOR CLASS gist_trgm_ops
|
|
|
|
FOR TYPE text USING gist
|
|
|
|
AS
|
|
|
|
OPERATOR 1 % (text, text),
|
Fix assorted inconsistencies in GiST opclass support function declarations.
The conventions specified by the GiST SGML documentation were widely
ignored. For example, the strategy-number argument for "consistent" and
"distance" functions is specified to be a smallint, but most of the
built-in support functions declared it as an integer, and for that matter
the core code passed it using Int32GetDatum not Int16GetDatum. None of
that makes any real difference at runtime, but it's quite confusing for
newcomers to the code, and it makes it very hard to write an amvalidate()
function that checks support function signatures. So let's try to instill
some consistency here.
Another similar issue is that the "query" argument is not of a single
well-defined type, but could have different types depending on the strategy
(corresponding to search operators with different righthand-side argument
types). Some of the functions threw up their hands and declared the query
argument as being of "internal" type, which surely isn't right ("any" would
have been more appropriate); but the majority position seemed to be to
declare it as being of the indexed data type, corresponding to a search
operator with both input types the same. So I've specified a convention
that that's what to do always.
Also, the result of the "union" support function actually must be of the
index's storage type, but the documentation suggested declaring it to
return "internal", and some of the functions followed that. Standardize
on telling the truth, instead.
Similarly, standardize on declaring the "same" function's inputs as
being of the storage type, not "internal".
Also, somebody had forgotten to add the "recheck" argument to both
the documentation of the "distance" support function and all of their
SQL declarations, even though the C code was happily using that argument.
Clean that up too.
Fix up some other omissions in the docs too, such as documenting that
union's second input argument is vestigial.
So far as the errors in core function declarations go, we can just fix
pg_proc.h and bump catversion. Adjusting the erroneous declarations in
contrib modules is more debatable: in principle any change in those
scripts should involve an extension version bump, which is a pain.
However, since these changes are purely cosmetic and make no functional
difference, I think we can get away without doing that.
2016-01-20 01:04:32 +08:00
|
|
|
FUNCTION 1 gtrgm_consistent (internal, text, smallint, oid, internal),
|
|
|
|
FUNCTION 2 gtrgm_union (internal, internal),
|
2004-06-01 01:18:12 +08:00
|
|
|
FUNCTION 3 gtrgm_compress (internal),
|
|
|
|
FUNCTION 4 gtrgm_decompress (internal),
|
|
|
|
FUNCTION 5 gtrgm_penalty (internal, internal, internal),
|
|
|
|
FUNCTION 6 gtrgm_picksplit (internal, internal),
|
|
|
|
FUNCTION 7 gtrgm_same (gtrgm, gtrgm, internal),
|
|
|
|
STORAGE gtrgm;
|
|
|
|
|
2011-02-18 04:03:30 +08:00
|
|
|
-- Add operators and support functions that are new in 9.1. We do it like
|
|
|
|
-- this, leaving them "loose" in the operator family rather than bound into
|
|
|
|
-- the gist_trgm_ops opclass, because that's the only state that can be
|
|
|
|
-- reproduced during an upgrade from 9.0 (see pg_trgm--unpackaged--1.0.sql).
|
|
|
|
|
|
|
|
ALTER OPERATOR FAMILY gist_trgm_ops USING gist ADD
|
|
|
|
OPERATOR 2 <-> (text, text) FOR ORDER BY pg_catalog.float_ops,
|
|
|
|
OPERATOR 3 pg_catalog.~~ (text, text),
|
|
|
|
OPERATOR 4 pg_catalog.~~* (text, text),
|
Fix assorted inconsistencies in GiST opclass support function declarations.
The conventions specified by the GiST SGML documentation were widely
ignored. For example, the strategy-number argument for "consistent" and
"distance" functions is specified to be a smallint, but most of the
built-in support functions declared it as an integer, and for that matter
the core code passed it using Int32GetDatum not Int16GetDatum. None of
that makes any real difference at runtime, but it's quite confusing for
newcomers to the code, and it makes it very hard to write an amvalidate()
function that checks support function signatures. So let's try to instill
some consistency here.
Another similar issue is that the "query" argument is not of a single
well-defined type, but could have different types depending on the strategy
(corresponding to search operators with different righthand-side argument
types). Some of the functions threw up their hands and declared the query
argument as being of "internal" type, which surely isn't right ("any" would
have been more appropriate); but the majority position seemed to be to
declare it as being of the indexed data type, corresponding to a search
operator with both input types the same. So I've specified a convention
that that's what to do always.
Also, the result of the "union" support function actually must be of the
index's storage type, but the documentation suggested declaring it to
return "internal", and some of the functions followed that. Standardize
on telling the truth, instead.
Similarly, standardize on declaring the "same" function's inputs as
being of the storage type, not "internal".
Also, somebody had forgotten to add the "recheck" argument to both
the documentation of the "distance" support function and all of their
SQL declarations, even though the C code was happily using that argument.
Clean that up too.
Fix up some other omissions in the docs too, such as documenting that
union's second input argument is vestigial.
So far as the errors in core function declarations go, we can just fix
pg_proc.h and bump catversion. Adjusting the erroneous declarations in
contrib modules is more debatable: in principle any change in those
scripts should involve an extension version bump, which is a pain.
However, since these changes are purely cosmetic and make no functional
difference, I think we can get away without doing that.
2016-01-20 01:04:32 +08:00
|
|
|
FUNCTION 8 (text, text) gtrgm_distance (internal, text, smallint, oid, internal);
|
2011-02-18 04:03:30 +08:00
|
|
|
|
2013-04-11 01:30:14 +08:00
|
|
|
-- Add operators that are new in 9.3.
|
|
|
|
|
|
|
|
ALTER OPERATOR FAMILY gist_trgm_ops USING gist ADD
|
|
|
|
OPERATOR 5 pg_catalog.~ (text, text),
|
|
|
|
OPERATOR 6 pg_catalog.~* (text, text);
|
|
|
|
|
2016-03-16 23:59:21 +08:00
|
|
|
-- Add operators that are new in 9.6 (pg_trgm 1.2).
|
|
|
|
|
|
|
|
ALTER OPERATOR FAMILY gist_trgm_ops USING gist ADD
|
|
|
|
OPERATOR 7 %> (text, text),
|
|
|
|
OPERATOR 8 <->> (text, text) FOR ORDER BY pg_catalog.float_ops;
|
|
|
|
|
2007-03-14 22:15:40 +08:00
|
|
|
-- support functions for gin
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gin_extract_value_trgm(text, internal)
|
2007-03-14 22:15:40 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2007-03-14 22:15:40 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gin_extract_query_trgm(text, internal, int2, internal, internal, internal, internal)
|
2007-03-14 22:15:40 +08:00
|
|
|
RETURNS internal
|
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2007-03-14 22:15:40 +08:00
|
|
|
|
2011-02-14 10:24:14 +08:00
|
|
|
CREATE FUNCTION gin_trgm_consistent(internal, int2, text, int4, internal, internal, internal, internal)
|
2009-03-26 06:19:02 +08:00
|
|
|
RETURNS bool
|
2007-03-14 22:15:40 +08:00
|
|
|
AS 'MODULE_PATHNAME'
|
2009-06-12 02:30:03 +08:00
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
2007-03-14 22:15:40 +08:00
|
|
|
|
|
|
|
-- create the operator class for gin
|
|
|
|
CREATE OPERATOR CLASS gin_trgm_ops
|
|
|
|
FOR TYPE text USING gin
|
|
|
|
AS
|
2008-04-15 01:05:34 +08:00
|
|
|
OPERATOR 1 % (text, text),
|
2007-03-14 22:15:40 +08:00
|
|
|
FUNCTION 1 btint4cmp (int4, int4),
|
2011-02-01 10:33:55 +08:00
|
|
|
FUNCTION 2 gin_extract_value_trgm (text, internal),
|
|
|
|
FUNCTION 3 gin_extract_query_trgm (text, internal, int2, internal, internal, internal, internal),
|
|
|
|
FUNCTION 4 gin_trgm_consistent (internal, int2, text, int4, internal, internal, internal, internal),
|
2007-03-14 22:15:40 +08:00
|
|
|
STORAGE int4;
|
2011-02-18 04:03:30 +08:00
|
|
|
|
|
|
|
-- Add operators that are new in 9.1.
|
|
|
|
|
|
|
|
ALTER OPERATOR FAMILY gin_trgm_ops USING gin ADD
|
|
|
|
OPERATOR 3 pg_catalog.~~ (text, text),
|
|
|
|
OPERATOR 4 pg_catalog.~~* (text, text);
|
2013-04-09 13:05:55 +08:00
|
|
|
|
|
|
|
-- Add operators that are new in 9.3.
|
|
|
|
|
|
|
|
ALTER OPERATOR FAMILY gin_trgm_ops USING gin ADD
|
|
|
|
OPERATOR 5 pg_catalog.~ (text, text),
|
|
|
|
OPERATOR 6 pg_catalog.~* (text, text);
|
2015-07-20 23:18:48 +08:00
|
|
|
|
|
|
|
-- Add functions that are new in 9.6 (pg_trgm 1.2).
|
|
|
|
|
|
|
|
CREATE FUNCTION gin_trgm_triconsistent(internal, int2, text, int4, internal, internal, internal)
|
|
|
|
RETURNS "char"
|
|
|
|
AS 'MODULE_PATHNAME'
|
|
|
|
LANGUAGE C IMMUTABLE STRICT;
|
|
|
|
|
|
|
|
ALTER OPERATOR FAMILY gin_trgm_ops USING gin ADD
|
2016-03-16 23:59:21 +08:00
|
|
|
OPERATOR 7 %> (text, text),
|
2015-07-20 23:18:48 +08:00
|
|
|
FUNCTION 6 (text,text) gin_trgm_triconsistent (internal, int2, text, int4, internal, internal, internal);
|