1 |
2094
|
aaronmk
|
--
|
2 |
|
|
-- PostgreSQL database dump
|
3 |
|
|
--
|
4 |
|
|
|
5 |
|
|
SET statement_timeout = 0;
|
6 |
|
|
SET client_encoding = 'UTF8';
|
7 |
|
|
SET standard_conforming_strings = off;
|
8 |
|
|
SET check_function_bodies = false;
|
9 |
|
|
SET client_min_messages = warning;
|
10 |
|
|
SET escape_string_warning = off;
|
11 |
|
|
|
12 |
|
|
--
|
13 |
|
|
-- Name: functions; Type: SCHEMA; Schema: -; Owner: -
|
14 |
|
|
--
|
15 |
|
|
|
16 |
|
|
CREATE SCHEMA functions;
|
17 |
|
|
|
18 |
|
|
|
19 |
2107
|
aaronmk
|
SET search_path = functions, pg_catalog;
|
20 |
|
|
|
21 |
2094
|
aaronmk
|
--
|
22 |
2138
|
aaronmk
|
-- Name: _toBool(); Type: FUNCTION; Schema: functions; Owner: -
|
23 |
|
|
--
|
24 |
|
|
|
25 |
|
|
CREATE FUNCTION "_toBool"() RETURNS trigger
|
26 |
|
|
LANGUAGE plpgsql IMMUTABLE
|
27 |
|
|
AS $$
|
28 |
|
|
BEGIN
|
29 |
2412
|
aaronmk
|
BEGIN
|
30 |
|
|
new.result := CAST(new.value AS boolean);
|
31 |
|
|
EXCEPTION
|
32 |
|
|
WHEN data_exception THEN
|
33 |
|
|
new.result := NULL;
|
34 |
|
|
RAISE WARNING '%', SQLERRM;
|
35 |
|
|
END;
|
36 |
2138
|
aaronmk
|
RETURN new;
|
37 |
|
|
END;
|
38 |
|
|
$$;
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
--
|
42 |
2107
|
aaronmk
|
-- Name: _toDouble(); Type: FUNCTION; Schema: functions; Owner: -
|
43 |
|
|
--
|
44 |
|
|
|
45 |
|
|
CREATE FUNCTION "_toDouble"() RETURNS trigger
|
46 |
2135
|
aaronmk
|
LANGUAGE plpgsql IMMUTABLE
|
47 |
2107
|
aaronmk
|
AS $$
|
48 |
|
|
BEGIN
|
49 |
2412
|
aaronmk
|
BEGIN
|
50 |
|
|
new.result := CAST(new.value AS double precision);
|
51 |
|
|
EXCEPTION
|
52 |
|
|
WHEN data_exception THEN
|
53 |
|
|
new.result := NULL;
|
54 |
|
|
RAISE WARNING '%', SQLERRM;
|
55 |
|
|
END;
|
56 |
2107
|
aaronmk
|
RETURN new;
|
57 |
|
|
END;
|
58 |
|
|
$$;
|
59 |
|
|
|
60 |
|
|
|
61 |
2249
|
aaronmk
|
--
|
62 |
|
|
-- Name: _toTimestamp(); Type: FUNCTION; Schema: functions; Owner: -
|
63 |
|
|
--
|
64 |
|
|
|
65 |
|
|
CREATE FUNCTION "_toTimestamp"() RETURNS trigger
|
66 |
|
|
LANGUAGE plpgsql IMMUTABLE
|
67 |
|
|
AS $$
|
68 |
|
|
BEGIN
|
69 |
2412
|
aaronmk
|
BEGIN
|
70 |
|
|
new.result := CAST(new.value AS timestamp with time zone);
|
71 |
|
|
EXCEPTION
|
72 |
|
|
WHEN data_exception THEN
|
73 |
|
|
new.result := NULL;
|
74 |
|
|
RAISE WARNING '%', SQLERRM;
|
75 |
|
|
END;
|
76 |
2249
|
aaronmk
|
RETURN new;
|
77 |
|
|
END;
|
78 |
|
|
$$;
|
79 |
|
|
|
80 |
|
|
|
81 |
2107
|
aaronmk
|
SET default_tablespace = '';
|
82 |
|
|
|
83 |
|
|
SET default_with_oids = false;
|
84 |
|
|
|
85 |
|
|
--
|
86 |
2138
|
aaronmk
|
-- Name: _toBool; Type: TABLE; Schema: functions; Owner: -; Tablespace:
|
87 |
2107
|
aaronmk
|
--
|
88 |
|
|
|
89 |
2138
|
aaronmk
|
CREATE TABLE "_toBool" (
|
90 |
|
|
result boolean,
|
91 |
2338
|
aaronmk
|
not_null boolean DEFAULT true NOT NULL,
|
92 |
2107
|
aaronmk
|
value text
|
93 |
|
|
);
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
--
|
97 |
2138
|
aaronmk
|
-- Name: _toDouble; Type: TABLE; Schema: functions; Owner: -; Tablespace:
|
98 |
2107
|
aaronmk
|
--
|
99 |
|
|
|
100 |
2138
|
aaronmk
|
CREATE TABLE "_toDouble" (
|
101 |
|
|
result double precision,
|
102 |
2338
|
aaronmk
|
not_null boolean DEFAULT true NOT NULL,
|
103 |
2138
|
aaronmk
|
value text
|
104 |
|
|
);
|
105 |
2107
|
aaronmk
|
|
106 |
|
|
|
107 |
|
|
--
|
108 |
2249
|
aaronmk
|
-- Name: _toTimestamp; Type: TABLE; Schema: functions; Owner: -; Tablespace:
|
109 |
|
|
--
|
110 |
|
|
|
111 |
|
|
CREATE TABLE "_toTimestamp" (
|
112 |
|
|
result timestamp with time zone,
|
113 |
2338
|
aaronmk
|
not_null boolean DEFAULT true NOT NULL,
|
114 |
2249
|
aaronmk
|
value text
|
115 |
|
|
);
|
116 |
|
|
|
117 |
|
|
|
118 |
|
|
--
|
119 |
2138
|
aaronmk
|
-- Name: _toBool_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace:
|
120 |
2107
|
aaronmk
|
--
|
121 |
|
|
|
122 |
2138
|
aaronmk
|
CREATE UNIQUE INDEX "_toBool_unique" ON "_toBool" USING btree ((COALESCE(value, '\\N'::text)));
|
123 |
2107
|
aaronmk
|
|
124 |
|
|
|
125 |
|
|
--
|
126 |
2138
|
aaronmk
|
-- Name: _toDouble_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace:
|
127 |
2094
|
aaronmk
|
--
|
128 |
|
|
|
129 |
2138
|
aaronmk
|
CREATE UNIQUE INDEX "_toDouble_unique" ON "_toDouble" USING btree ((COALESCE(value, '\\N'::text)));
|
130 |
2136
|
aaronmk
|
|
131 |
|
|
|
132 |
|
|
--
|
133 |
2249
|
aaronmk
|
-- Name: _toTimestamp_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace:
|
134 |
|
|
--
|
135 |
|
|
|
136 |
|
|
CREATE UNIQUE INDEX "_toTimestamp_unique" ON "_toTimestamp" USING btree ((COALESCE(value, '\\N'::text)));
|
137 |
|
|
|
138 |
|
|
|
139 |
|
|
--
|
140 |
2138
|
aaronmk
|
-- Name: _toBool; Type: TRIGGER; Schema: functions; Owner: -
|
141 |
2136
|
aaronmk
|
--
|
142 |
|
|
|
143 |
2138
|
aaronmk
|
CREATE TRIGGER "_toBool" BEFORE INSERT OR UPDATE ON "_toBool" FOR EACH ROW EXECUTE PROCEDURE "_toBool"();
|
144 |
2136
|
aaronmk
|
|
145 |
|
|
|
146 |
|
|
--
|
147 |
2138
|
aaronmk
|
-- Name: _toDouble; Type: TRIGGER; Schema: functions; Owner: -
|
148 |
2136
|
aaronmk
|
--
|
149 |
|
|
|
150 |
2138
|
aaronmk
|
CREATE TRIGGER "_toDouble" BEFORE INSERT OR UPDATE ON "_toDouble" FOR EACH ROW EXECUTE PROCEDURE "_toDouble"();
|
151 |
2136
|
aaronmk
|
|
152 |
|
|
|
153 |
|
|
--
|
154 |
2249
|
aaronmk
|
-- Name: _toTimestamp; Type: TRIGGER; Schema: functions; Owner: -
|
155 |
|
|
--
|
156 |
|
|
|
157 |
|
|
CREATE TRIGGER "_toTimestamp" BEFORE INSERT OR UPDATE ON "_toTimestamp" FOR EACH ROW EXECUTE PROCEDURE "_toTimestamp"();
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
--
|
161 |
2136
|
aaronmk
|
-- PostgreSQL database dump complete
|
162 |
|
|
--
|