Project

General

Profile

1
--
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
SET search_path = functions, pg_catalog;
20

    
21
--
22
-- Name: _alt(); Type: FUNCTION; Schema: functions; Owner: -
23
--
24

    
25
CREATE FUNCTION _alt() RETURNS trigger
26
    LANGUAGE plpgsql IMMUTABLE
27
    AS $$
28
BEGIN
29
    new.result := coalesce(new."0", new."1", new."2", new."3", new."4", new."5",
30
        new."6", new."7", new."8", new."9");
31
    RETURN new;
32
END;
33
$$;
34

    
35

    
36
--
37
-- Name: _merge(); Type: FUNCTION; Schema: functions; Owner: -
38
--
39

    
40
CREATE FUNCTION _merge() RETURNS trigger
41
    LANGUAGE plpgsql IMMUTABLE
42
    AS $$
43
BEGIN
44
    new.result := (
45
        SELECT DISTINCT functions.join_strs('; ', value)
46
        FROM
47
        (VALUES (new."0"), (new."1"), (new."2"), (new."3"), (new."4"),
48
            (new."5"), (new."6"), (new."7"), (new."8"), (new."9"))
49
        AS v (value)
50
    );
51
    RETURN new;
52
END;
53
$$;
54

    
55

    
56
--
57
-- Name: boolean(text); Type: FUNCTION; Schema: functions; Owner: -
58
--
59

    
60
CREATE FUNCTION "boolean"(value text) RETURNS boolean
61
    LANGUAGE plpgsql IMMUTABLE STRICT
62
    AS $$
63
BEGIN
64
    BEGIN
65
        RETURN value::boolean;
66
    EXCEPTION
67
        WHEN data_exception THEN
68
            RAISE WARNING '%', SQLERRM;
69
            RETURN NULL;
70
    END;
71
    RETURN new;
72
END;
73
$$;
74

    
75

    
76
--
77
-- Name: double precision(text); Type: FUNCTION; Schema: functions; Owner: -
78
--
79

    
80
CREATE FUNCTION "double precision"(value text) RETURNS double precision
81
    LANGUAGE plpgsql IMMUTABLE STRICT
82
    AS $$
83
BEGIN
84
    BEGIN
85
        RETURN value::double precision;
86
    EXCEPTION
87
        WHEN data_exception THEN
88
            RAISE WARNING '%', SQLERRM;
89
            RETURN NULL;
90
    END;
91
    RETURN new;
92
END;
93
$$;
94

    
95

    
96
--
97
-- Name: ensure_not_null(text); Type: FUNCTION; Schema: functions; Owner: -
98
--
99

    
100
CREATE FUNCTION ensure_not_null(value text) RETURNS text
101
    LANGUAGE sql IMMUTABLE
102
    AS $_$
103
SELECT COALESCE($1, E'\\N');
104
$_$;
105

    
106

    
107
--
108
-- Name: join_strs_(text, text, text); Type: FUNCTION; Schema: functions; Owner: -
109
--
110

    
111
CREATE FUNCTION join_strs_(state text, delim text, value text) RETURNS text
112
    LANGUAGE sql IMMUTABLE
113
    AS $_$
114
SELECT $1 || (CASE
115
WHEN $1 = '' OR $3 IS NULL OR $3 = ''
116
THEN ''
117
ELSE $2
118
END) || coalesce($3, '');
119
$_$;
120

    
121

    
122
--
123
-- Name: timestamp with time zone(text); Type: FUNCTION; Schema: functions; Owner: -
124
--
125

    
126
CREATE FUNCTION "timestamp with time zone"(value text) RETURNS timestamp with time zone
127
    LANGUAGE plpgsql IMMUTABLE STRICT
128
    AS $$
129
BEGIN
130
    BEGIN
131
        RETURN value::timestamp with time zone;
132
    EXCEPTION
133
        WHEN data_exception THEN
134
            RAISE WARNING '%', SQLERRM;
135
            RETURN NULL;
136
    END;
137
    RETURN new;
138
END;
139
$$;
140

    
141

    
142
--
143
-- Name: join_strs(text, text); Type: AGGREGATE; Schema: functions; Owner: -
144
--
145

    
146
CREATE AGGREGATE join_strs(text, text) (
147
    SFUNC = join_strs_,
148
    STYPE = text,
149
    INITCOND = ''
150
);
151

    
152

    
153
SET default_tablespace = '';
154

    
155
SET default_with_oids = false;
156

    
157
--
158
-- Name: _alt; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
159
--
160

    
161
CREATE TABLE _alt (
162
    result text,
163
    not_null_col boolean DEFAULT true NOT NULL,
164
    "0" text,
165
    "1" text,
166
    "2" text,
167
    "3" text,
168
    "4" text,
169
    "5" text,
170
    "6" text,
171
    "7" text,
172
    "8" text,
173
    "9" text
174
);
175

    
176

    
177
--
178
-- Name: _merge; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
179
--
180

    
181
CREATE TABLE _merge (
182
    result text,
183
    not_null_col boolean DEFAULT true NOT NULL,
184
    "0" text,
185
    "1" text,
186
    "2" text,
187
    "3" text,
188
    "4" text,
189
    "5" text,
190
    "6" text,
191
    "7" text,
192
    "8" text,
193
    "9" text
194
);
195

    
196

    
197
--
198
-- Name: _alt_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
199
--
200

    
201
CREATE UNIQUE INDEX _alt_unique ON _alt USING btree (ensure_not_null("0"), ensure_not_null("1"), ensure_not_null("2"), ensure_not_null("3"), ensure_not_null("4"), ensure_not_null("5"), ensure_not_null("6"), ensure_not_null("7"), ensure_not_null("8"), ensure_not_null("9"));
202

    
203

    
204
--
205
-- Name: _merge_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
206
--
207

    
208
CREATE UNIQUE INDEX _merge_unique ON _merge USING btree (ensure_not_null("0"), ensure_not_null("1"), ensure_not_null("2"), ensure_not_null("3"), ensure_not_null("4"), ensure_not_null("5"), ensure_not_null("6"), ensure_not_null("7"), ensure_not_null("8"), ensure_not_null("9"));
209

    
210

    
211
--
212
-- Name: _alt; Type: TRIGGER; Schema: functions; Owner: -
213
--
214

    
215
CREATE TRIGGER _alt BEFORE INSERT OR UPDATE ON _alt FOR EACH ROW EXECUTE PROCEDURE _alt();
216

    
217

    
218
--
219
-- Name: _merge; Type: TRIGGER; Schema: functions; Owner: -
220
--
221

    
222
CREATE TRIGGER _merge BEFORE INSERT OR UPDATE ON _merge FOR EACH ROW EXECUTE PROCEDURE _merge();
223

    
224

    
225
--
226
-- PostgreSQL database dump complete
227
--
228

    
(4-4/20)