Revision 2566
Added by Aaron Marcuse-Kubitza over 12 years ago
schemas/functions.sql | ||
---|---|---|
19 | 19 |
SET search_path = functions, pg_catalog; |
20 | 20 |
|
21 | 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 |
-- |
|
22 | 37 |
-- Name: boolean(text); Type: FUNCTION; Schema: functions; Owner: - |
23 | 38 |
-- |
24 | 39 |
|
... | ... | |
59 | 74 |
|
60 | 75 |
|
61 | 76 |
-- |
77 |
-- Name: ensure_not_null(text); Type: FUNCTION; Schema: functions; Owner: - |
|
78 |
-- |
|
79 |
|
|
80 |
CREATE FUNCTION ensure_not_null(value text) RETURNS text |
|
81 |
LANGUAGE sql IMMUTABLE |
|
82 |
AS $_$ |
|
83 |
SELECT COALESCE($1, E'\\N'); |
|
84 |
$_$; |
|
85 |
|
|
86 |
|
|
87 |
-- |
|
62 | 88 |
-- Name: timestamp with time zone(text); Type: FUNCTION; Schema: functions; Owner: - |
63 | 89 |
-- |
64 | 90 |
|
... | ... | |
78 | 104 |
$$; |
79 | 105 |
|
80 | 106 |
|
107 |
SET default_tablespace = ''; |
|
108 |
|
|
109 |
SET default_with_oids = false; |
|
110 |
|
|
81 | 111 |
-- |
112 |
-- Name: _alt; Type: TABLE; Schema: functions; Owner: -; Tablespace: |
|
113 |
-- |
|
114 |
|
|
115 |
CREATE TABLE _alt ( |
|
116 |
result text, |
|
117 |
not_null_col boolean DEFAULT true NOT NULL, |
|
118 |
"0" text, |
|
119 |
"1" text, |
|
120 |
"2" text, |
|
121 |
"3" text, |
|
122 |
"4" text, |
|
123 |
"5" text, |
|
124 |
"6" text, |
|
125 |
"7" text, |
|
126 |
"8" text, |
|
127 |
"9" text |
|
128 |
); |
|
129 |
|
|
130 |
|
|
131 |
-- |
|
132 |
-- Name: _alt_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: |
|
133 |
-- |
|
134 |
|
|
135 |
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")); |
|
136 |
|
|
137 |
|
|
138 |
-- |
|
139 |
-- Name: _alt; Type: TRIGGER; Schema: functions; Owner: - |
|
140 |
-- |
|
141 |
|
|
142 |
CREATE TRIGGER _alt BEFORE INSERT OR UPDATE ON _alt FOR EACH ROW EXECUTE PROCEDURE _alt(); |
|
143 |
|
|
144 |
|
|
145 |
-- |
|
82 | 146 |
-- PostgreSQL database dump complete |
83 | 147 |
-- |
84 | 148 |
|
Also available in: Unified diff
schemas/functions.sql: Added _alt relational function