-
Notifications
You must be signed in to change notification settings - Fork 12
/
unit--2--3.sql.in
66 lines (49 loc) · 1.45 KB
/
unit--2--3.sql.in
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
-- type definition
ALTER FUNCTION unit_in(cstring)
SET search_path = @extschema@;
-- prefix/unit definition tables
CREATE TABLE unit_prefixes (
prefix varchar(32) PRIMARY KEY,
factor double precision NOT NULL,
definition text, -- original definition, informational
dump boolean DEFAULT true
);
SELECT pg_catalog.pg_extension_config_dump('unit_prefixes', 'WHERE dump');
COPY unit_prefixes (prefix, factor, definition, dump) FROM '@MODULEDIR@/unit_prefixes.data';
CREATE TABLE unit_units (
name varchar(32) PRIMARY KEY,
unit unit NOT NULL,
shift double precision, -- NULL means 0.0 here
definition text, -- original definition, informational
dump boolean DEFAULT true
);
SELECT pg_catalog.pg_extension_config_dump('unit_units', 'WHERE dump');
COPY unit_units (name, unit, shift, definition, dump) FROM '@MODULEDIR@/unit_units.data';
-- operators
CREATE FUNCTION sqrt(unit)
RETURNS unit
AS '$libdir/unit', 'unit_sqrt'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR |/ (
rightarg = unit,
procedure = sqrt
);
CREATE FUNCTION cbrt(unit)
RETURNS unit
AS '$libdir/unit', 'unit_cbrt'
LANGUAGE C IMMUTABLE STRICT;
CREATE OPERATOR ||/ (
rightarg = unit,
procedure = cbrt
);
ALTER FUNCTION unit_at(unit, cstring)
SET search_path = @extschema@;
-- internal functions
CREATE FUNCTION unit_is_hashed(cstring)
RETURNS bool
AS '$libdir/unit'
LANGUAGE C VOLATILE STRICT;
CREATE FUNCTION unit_reset()
RETURNS void
AS '$libdir/unit'
LANGUAGE C VOLATILE STRICT;