-
Notifications
You must be signed in to change notification settings - Fork 1
/
vgram--1.0.sql
executable file
·83 lines (68 loc) · 2.17 KB
/
vgram--1.0.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION vgram" to load this file. \quit
CREATE TABLE qgram_stat
(
qgram text,
frequency float4
);
CREATE FUNCTION print_qgrams(text)
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION get_vgrams(text)
RETURNS text[]
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION print_qgram_stat()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE FUNCTION qgram_stat_reset_cache()
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C;
CREATE OR REPLACE FUNCTION qgram_stat_transfn(internal, text)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE;
CREATE OR REPLACE FUNCTION qgram_stat_finalfn(internal)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE;
CREATE AGGREGATE qgram_stat(text) (
SFUNC = qgram_stat_transfn,
STYPE = internal,
FINALFUNC = qgram_stat_finalfn
);
-- support functions for gin
CREATE FUNCTION vgram_cmp(text, text)
RETURNS int4
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION vgram_gin_extract_value(text, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION vgram_gin_extract_query(text, internal, int2, internal, internal, internal, internal)
RETURNS internal
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION vgram_gin_consistent(internal, int2, text, int4, internal, internal, internal, internal)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE FUNCTION vgram_gin_triconsistent(internal, int2, text, int4, internal, internal, internal)
RETURNS "char"
AS 'MODULE_PATHNAME'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR CLASS vgram_gin_ops
FOR TYPE text USING gin
AS
OPERATOR 3 pg_catalog.~~ (text, text),
OPERATOR 4 pg_catalog.~~* (text, text),
FUNCTION 1 vgram_cmp (text, text),
FUNCTION 2 vgram_gin_extract_value (text, internal),
FUNCTION 3 vgram_gin_extract_query (text, internal, int2, internal, internal, internal, internal),
FUNCTION 4 vgram_gin_consistent (internal, int2, text, int4, internal, internal, internal, internal),
FUNCTION 6 vgram_gin_triconsistent (internal, int2, text, int4, internal, internal, internal),
STORAGE text;