Project

General

Profile

1 10778 aaronmk
--
2
-- PostgreSQL database dump
3
--
4 10737 aaronmk
5 10778 aaronmk
SET statement_timeout = 0;
6 11708 aaronmk
SET lock_timeout = 0;
7 10778 aaronmk
SET client_encoding = 'UTF8';
8
SET standard_conforming_strings = on;
9
SET check_function_bodies = false;
10
SET client_min_messages = warning;
11
12 10737 aaronmk
--
13 10778 aaronmk
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: -
14
--
15 10737 aaronmk
16 10778 aaronmk
--CREATE SCHEMA "TNRS";
17 10725 aaronmk
18
19 11614 aaronmk
--
20
-- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: -
21
--
22
23 13575 aaronmk
COMMENT ON SCHEMA "TNRS" IS '
24
IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
25 11617 aaronmk
on vegbiendev:
26
# back up existing TNRS schema (in case of an accidental incorrect change):
27 11614 aaronmk
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
28 11616 aaronmk
$ svn up
29
$ svn di
30
# make the changes shown in the diff
31
## to change column types:
32 13861 aaronmk
SELECT util.set_col_types(''"TNRS".taxon_match'', ARRAY[
33 11614 aaronmk
  (''col'', ''new_type'')
34 11616 aaronmk
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
35 11617 aaronmk
$ rm=1 inputs/.TNRS/schema.sql.run
36
# repeat until `svn di` shows no diff
37
# back up new TNRS schema:
38 13575 aaronmk
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
39
';
40 11614 aaronmk
41
42 10778 aaronmk
SET search_path = "TNRS", pg_catalog;
43
44
--
45
-- Name: batch__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
46
--
47
48
CREATE FUNCTION batch__fill() RETURNS trigger
49
    LANGUAGE plpgsql
50
    AS $$
51 10728 aaronmk
BEGIN
52
	new.id_by_time = new.time_submitted;
53
	new.id = COALESCE(new.id, new.id_by_time);
54
	RETURN new;
55
END;
56 10778 aaronmk
$$;
57 10728 aaronmk
58
59
--
60 10778 aaronmk
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
61
--
62 10728 aaronmk
63 10778 aaronmk
CREATE FUNCTION family_is_homonym(family text) RETURNS boolean
64
    LANGUAGE sql STABLE STRICT
65
    AS $_$
66
SELECT EXISTS(SELECT * FROM "IRMNG".family_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
67
$_$;
68 10736 aaronmk
69 10778 aaronmk
70 10736 aaronmk
--
71 10778 aaronmk
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
72
--
73 10736 aaronmk
74 10778 aaronmk
CREATE FUNCTION genus_is_homonym(genus text) RETURNS boolean
75
    LANGUAGE sql STABLE STRICT
76
    AS $_$
77
SELECT EXISTS(SELECT * FROM "IRMNG".genus_homonym_epithet WHERE "taxonNameOrEpithet" = $1)
78
$_$;
79 7844 aaronmk
80 9985 aaronmk
81 10778 aaronmk
--
82 11709 aaronmk
-- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: -
83
--
84
85 13503 aaronmk
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text
86 11709 aaronmk
    LANGUAGE sql IMMUTABLE
87
    AS $_$
88 13503 aaronmk
/* from http://wiki.vegpath.org/2013-11-14_conference_call#taxonomic-fields:
89
"taxonomic_status should be accepted instead of synonym when an accepted name is
90
available (this is not always the case when a name is marked as a synonym)" */
91 11709 aaronmk
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
92
$_$;
93
94
95
--
96 14356 aaronmk
-- Name: remove_prefix(text, text, boolean, boolean); Type: FUNCTION; Schema: TNRS; Owner: -
97 14347 aaronmk
--
98
99 14356 aaronmk
CREATE FUNCTION remove_prefix(prefix text, str text, require boolean DEFAULT true, case_sensitive boolean DEFAULT true) RETURNS text
100 14347 aaronmk
    LANGUAGE sql IMMUTABLE
101
    AS $$
102 14358 aaronmk
SELECT util.remove_prefix(prefix, str, require, case_sensitive)
103 14347 aaronmk
$$;
104
105
106
--
107 14356 aaronmk
-- Name: FUNCTION remove_prefix(prefix text, str text, require boolean, case_sensitive boolean); Type: COMMENT; Schema: TNRS; Owner: -
108 14347 aaronmk
--
109
110 14356 aaronmk
COMMENT ON FUNCTION remove_prefix(prefix text, str text, require boolean, case_sensitive boolean) IS '
111 14347 aaronmk
wrapper that prevents views from getting dropped when the util schema is reinstalled
112
';
113
114
115
--
116 13868 aaronmk
-- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
117 13866 aaronmk
--
118
119 13868 aaronmk
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
120 13866 aaronmk
    LANGUAGE plpgsql
121
    AS $$
122
BEGIN
123 13869 aaronmk
	PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
124 13567 aaronmk
	RETURN NULL;
125
END;
126
$$;
127
128
129
--
130 13868 aaronmk
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
131 13578 aaronmk
--
132
133 13868 aaronmk
CREATE FUNCTION taxon_match__fill() RETURNS trigger
134 13578 aaronmk
    LANGUAGE plpgsql
135
    AS $$
136 11643 aaronmk
BEGIN
137 13871 aaronmk
	DECLARE
138
		"Specific_epithet_is_plant" boolean :=
139 11628 aaronmk
			(CASE
140 14111 aaronmk
			WHEN   new."*Infraspecific_epithet_matched"	 IS NOT NULL
141
				OR new."*Infraspecific_epithet_2_matched" IS NOT NULL
142
				OR new."*Specific_epithet_score" >= 0.9 -- fuzzy match
143 13871 aaronmk
				THEN true
144
			ELSE NULL -- ambiguous
145
			END);
146 14111 aaronmk
		never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
147 13871 aaronmk
			-- author disambiguates
148
		family_is_homonym boolean = NOT never_homonym
149 14111 aaronmk
			AND "TNRS".family_is_homonym(new."*Family_matched");
150 13871 aaronmk
		genus_is_homonym  boolean = NOT never_homonym
151 14111 aaronmk
			AND "TNRS".genus_is_homonym(new."*Genus_matched");
152 13871 aaronmk
	BEGIN
153
		/* exclude homonyms because these are not valid matches (TNRS provides a
154
		name, but the name is not meaningful because it is not unambiguous) */
155 14111 aaronmk
		new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
156 13871 aaronmk
			AND COALESCE(CASE
157 14111 aaronmk
			WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
158 13871 aaronmk
				THEN true
159
			ELSE -- consider genus
160 11628 aaronmk
				(CASE
161 14111 aaronmk
				WHEN new."*Genus_score" =  1	   -- exact match
162 13871 aaronmk
					THEN
163
					(CASE
164
					WHEN NOT genus_is_homonym THEN true
165
					ELSE "Specific_epithet_is_plant"
166
					END)
167 14111 aaronmk
				WHEN new."*Genus_score" >= 0.85 -- fuzzy match
168 13871 aaronmk
					THEN "Specific_epithet_is_plant"
169
				ELSE NULL -- ambiguous
170 11628 aaronmk
				END)
171 13871 aaronmk
			END, false);
172
	END;
173 11628 aaronmk
174 13871 aaronmk
	DECLARE
175
		matched_taxon_name_with_author text = NULLIF(concat_ws(' '
176 14111 aaronmk
			, NULLIF(NULLIF(new."*Name_matched_accepted_family", 'Unknown'),
177
				new."*Name_matched")
178
			, NULLIF(new."*Name_matched", 'No suitable matches found.')
179
			, new."*Name_matched_author"
180 13871 aaronmk
			), '');
181
		accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
182 14111 aaronmk
			, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
183
				new."*Accepted_name")
184
			, new."*Accepted_name"
185
			, new."*Accepted_name_author"
186 13871 aaronmk
			), '');
187
	BEGIN
188
		new.scrubbed_unique_taxon_name = COALESCE(
189
			accepted_taxon_name_with_author, matched_taxon_name_with_author);
190
	END;
191
192 11628 aaronmk
	RETURN new;
193 7134 aaronmk
END;
194 10778 aaronmk
$$;
195
196
197
--
198 13868 aaronmk
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
199 10778 aaronmk
--
200
201 13868 aaronmk
COMMENT ON FUNCTION taxon_match__fill() IS '
202 13575 aaronmk
IMPORTANT: when changing this function, you must regenerate the derived cols:
203 13861 aaronmk
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
204 11715 aaronmk
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
205 13861 aaronmk
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
206 13575 aaronmk
runtime: 1.5 min ("92633 ms")
207
';
208 7134 aaronmk
209 7251 aaronmk
210 13631 aaronmk
--
211 14122 aaronmk
-- Name: taxon_match__fill_derived(); Type: FUNCTION; Schema: TNRS; Owner: -
212
--
213
214
CREATE FUNCTION taxon_match__fill_derived() RETURNS trigger
215
    LANGUAGE plpgsql
216
    AS $$
217
BEGIN
218 14309 aaronmk
	-- clear derived cols so old values won't be used in calculations
219 14311 aaronmk
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = NULL;
220 14309 aaronmk
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
221 14330 aaronmk
	new."matched~Name[_no_author]___@TNRS__@vegpath.org" = NULL;
222 14309 aaronmk
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
223
	new.matched_has_accepted = NULL;
224 14318 aaronmk
	new."Accepted_family__@TNRS__@vegpath.org" = NULL;
225 14366 aaronmk
	new."Accepted_species[_binomial]__@TNRS__@vegpath.org" = NULL;
226 14376 aaronmk
	new."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" = NULL;
227 14309 aaronmk
	new."[accepted_]genus__@DwC__@vegpath.org" = NULL;
228
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = NULL;
229 14311 aaronmk
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
230 14309 aaronmk
	new.__accepted_infraspecific_label = NULL;
231
	new."__accepted_infraspecific_{rank,epithet}" = NULL;
232
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
233
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
234
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
235 14328 aaronmk
	new."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" = NULL;
236 14309 aaronmk
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = NULL;
237
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
238
	new."[scrubbed_]genus__@DwC__@vegpath.org" = NULL;
239
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = NULL;
240
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
241 14328 aaronmk
	new."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
242 14309 aaronmk
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
243
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
244
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
245
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
246
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
247
248
	-- populate derived cols
249 14311 aaronmk
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT "*Unmatched_terms" FROM (SELECT new.*) new);
250 14308 aaronmk
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT ("*Genus_matched" || ' '::text) || "*Specific_epithet_matched" FROM (SELECT new.*) new);
251 14330 aaronmk
	new."matched~Name[_no_author]___@TNRS__@vegpath.org" = (SELECT NULLIF("*Name_matched", 'No suitable matches found.'::text) FROM (SELECT new.*) new);
252
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new);
253 14308 aaronmk
	new.matched_has_accepted = (SELECT "*Accepted_name" IS NOT NULL FROM (SELECT new.*) new);
254 14318 aaronmk
	new."Accepted_family__@TNRS__@vegpath.org" = (SELECT COALESCE("*Accepted_name_family",
255
CASE
256
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
257
    ELSE NULL::text
258
END) FROM (SELECT new.*) new);
259 14366 aaronmk
	new."Accepted_species[_binomial]__@TNRS__@vegpath.org" = (SELECT rtrim("*Accepted_name_species", ' '::text) FROM (SELECT new.*) new);
260 14376 aaronmk
	new."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" = (SELECT regexp_split_to_array("*Accepted_name", ' '::text) FROM (SELECT new.*) new);
261 14377 aaronmk
	new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1] FROM (SELECT new.*) new);
262 14376 aaronmk
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2] FROM (SELECT new.*) new);
263 14311 aaronmk
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
264 14323 aaronmk
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
265 14327 aaronmk
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
266 14367 aaronmk
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
267 14311 aaronmk
END FROM (SELECT new.*) new);
268 14367 aaronmk
	new.__accepted_infraspecific_label = (SELECT ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''::text), ' '::text) FROM (SELECT new.*) new);
269 14308 aaronmk
	new."__accepted_infraspecific_{rank,epithet}" = (SELECT regexp_split_to_array(__accepted_infraspecific_label, ' '::text) FROM (SELECT new.*) new);
270
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[1] FROM (SELECT new.*) new);
271
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[2] FROM (SELECT new.*) new);
272
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text) FROM (SELECT new.*) new);
273 14328 aaronmk
	new."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" = (SELECT "TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name") FROM (SELECT new.*) new);
274 14308 aaronmk
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = (SELECT CASE
275 14282 aaronmk
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
276
    ELSE "*Name_matched_rank"
277 14308 aaronmk
END FROM (SELECT new.*) new);
278
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
279 14323 aaronmk
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
280 14282 aaronmk
    ELSE "*Name_matched_accepted_family"
281 14308 aaronmk
END FROM (SELECT new.*) new);
282
	new."[scrubbed_]genus__@DwC__@vegpath.org" = (SELECT CASE
283 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
284
    ELSE "*Genus_matched"
285 14308 aaronmk
END FROM (SELECT new.*) new);
286
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = (SELECT CASE
287 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
288
    ELSE "*Specific_epithet_matched"
289 14308 aaronmk
END FROM (SELECT new.*) new);
290
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
291 14367 aaronmk
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
292 14282 aaronmk
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
293 14308 aaronmk
END FROM (SELECT new.*) new);
294 14328 aaronmk
	new."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
295
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'family'::text) THEN concat_ws(' '::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
296
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'genus'::text) THEN concat_ws(' '::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
297
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
298
END FROM (SELECT new.*) new);
299 14308 aaronmk
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT CASE
300 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
301
    ELSE "*Infraspecific_rank"
302 14308 aaronmk
END FROM (SELECT new.*) new);
303
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT CASE
304 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
305
    ELSE "*Infraspecific_epithet_matched"
306 14308 aaronmk
END FROM (SELECT new.*) new);
307
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
308 14282 aaronmk
    WHEN matched_has_accepted THEN "*Accepted_name"
309 14330 aaronmk
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
310 14308 aaronmk
END FROM (SELECT new.*) new);
311
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
312 14282 aaronmk
    WHEN matched_has_accepted THEN "*Accepted_name_author"
313
    ELSE "*Name_matched_author"
314 14308 aaronmk
END FROM (SELECT new.*) new);
315
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT CASE
316 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
317
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
318 14308 aaronmk
END FROM (SELECT new.*) new);
319 14304 aaronmk
320 14122 aaronmk
	RETURN new;
321
END;
322
$$;
323
324
325
--
326 14254 aaronmk
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
327
--
328
329
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
330
autogenerated, do not edit
331
332
to regenerate:
333
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
334
';
335
336
337
--
338 13868 aaronmk
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
339
--
340
341
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
342
    LANGUAGE plpgsql
343
    AS $$
344
BEGIN
345
	IF new.match_num IS NULL THEN
346 13869 aaronmk
		new.match_num = "TNRS".taxon_match__match_num__next();
347 13868 aaronmk
	END IF;
348
	RETURN new;
349
END;
350
$$;
351
352
353
--
354 13869 aaronmk
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
355
--
356
357
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
358
    LANGUAGE sql
359
    AS $$
360
SELECT nextval('pg_temp.taxon_match__match_num__seq');
361
$$;
362
363
364
--
365 13868 aaronmk
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
366
--
367
368
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
369
    LANGUAGE plpgsql
370
    AS $$
371
BEGIN
372
	INSERT INTO "TNRS".taxon_match_input SELECT new.*;
373
	RETURN NULL;
374
END;
375
$$;
376
377
378
--
379
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
380
--
381
382
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
383
    LANGUAGE sql IMMUTABLE
384
    AS $_$
385
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
386
$_$;
387
388
389
--
390 13631 aaronmk
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
391
--
392
393
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
394
    LANGUAGE sql IMMUTABLE
395
    AS $$
396
SELECT ARRAY[
397 13686 aaronmk
]::text[]
398 13631 aaronmk
$$;
399
400
401 10778 aaronmk
SET default_tablespace = '';
402
403
SET default_with_oids = false;
404
405 10728 aaronmk
--
406 13861 aaronmk
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
407 10778 aaronmk
--
408 7251 aaronmk
409 13861 aaronmk
CREATE TABLE taxon_match (
410 10778 aaronmk
    batch text DEFAULT now() NOT NULL,
411 13580 aaronmk
    match_num integer NOT NULL,
412 14111 aaronmk
    "*Name_number" integer NOT NULL,
413
    "*Name_submitted" text NOT NULL,
414
    "*Overall_score" double precision,
415
    "*Name_matched" text,
416
    "*Name_matched_rank" text,
417
    "*Name_score" double precision,
418
    "*Name_matched_author" text,
419
    "*Name_matched_url" text,
420
    "*Author_matched" text,
421
    "*Author_score" double precision,
422
    "*Family_matched" text,
423
    "*Family_score" double precision,
424
    "*Name_matched_accepted_family" text,
425
    "*Genus_matched" text,
426
    "*Genus_score" double precision,
427
    "*Specific_epithet_matched" text,
428
    "*Specific_epithet_score" double precision,
429
    "*Infraspecific_rank" text,
430
    "*Infraspecific_epithet_matched" text,
431
    "*Infraspecific_epithet_score" double precision,
432
    "*Infraspecific_rank_2" text,
433
    "*Infraspecific_epithet_2_matched" text,
434
    "*Infraspecific_epithet_2_score" double precision,
435
    "*Annotations" text,
436
    "*Unmatched_terms" text,
437
    "*Taxonomic_status" text,
438
    "*Accepted_name" text,
439
    "*Accepted_name_author" text,
440
    "*Accepted_name_rank" text,
441
    "*Accepted_name_url" text,
442
    "*Accepted_name_species" text,
443
    "*Accepted_name_family" text,
444
    "*Selected" text,
445
    "*Source" text,
446
    "*Warnings" text,
447
    "*Accepted_name_lsid" text,
448 11628 aaronmk
    is_valid_match boolean NOT NULL,
449 14122 aaronmk
    scrubbed_unique_taxon_name text,
450 14310 aaronmk
    "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" text,
451 14279 aaronmk
    "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" text,
452 14329 aaronmk
    "matched~Name[_no_author]___@TNRS__@vegpath.org" text,
453 14279 aaronmk
    "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" text,
454
    matched_has_accepted boolean,
455 14318 aaronmk
    "Accepted_family__@TNRS__@vegpath.org" text,
456 14366 aaronmk
    "Accepted_species[_binomial]__@TNRS__@vegpath.org" text,
457 14376 aaronmk
    "__accepted_{genus,specific_epithet,infra_{rank,epithet}}" text[],
458 14257 aaronmk
    "[accepted_]genus__@DwC__@vegpath.org" text,
459
    "[accepted_]specificEpithet__@DwC__@vegpath.org" text,
460 14310 aaronmk
    "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
461 14264 aaronmk
    __accepted_infraspecific_label text,
462 14265 aaronmk
    "__accepted_infraspecific_{rank,epithet}" text[],
463 14266 aaronmk
    "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
464
    "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
465 14267 aaronmk
    "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" text,
466 14328 aaronmk
    "[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" text,
467 14281 aaronmk
    "[scrubbed_]taxonRank__@DwC__@vegpath.org" text,
468
    "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" text,
469
    "[scrubbed_]genus__@DwC__@vegpath.org" text,
470
    "[scrubbed_]specificEpithet__@DwC__@vegpath.org" text,
471
    "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" text,
472 14328 aaronmk
    "[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
473 14281 aaronmk
    "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
474
    "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" text,
475
    "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" text,
476
    "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" text,
477
    "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" text,
478 14318 aaronmk
    CONSTRAINT "Accepted_family__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_family__@TNRS__@vegpath.org" IS DISTINCT FROM COALESCE("*Accepted_name_family",
479
CASE
480
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
481
    ELSE NULL::text
482
END)))),
483 14366 aaronmk
    CONSTRAINT "Accepted_species[_binomial]__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_species[_binomial]__@TNRS__@vegpath.org" IS DISTINCT FROM rtrim("*Accepted_name_species", ' '::text)))),
484 14266 aaronmk
    CONSTRAINT "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[1]))),
485 14377 aaronmk
    CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]))),
486 14266 aaronmk
    CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
487 14304 aaronmk
    CONSTRAINT "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
488
CASE
489 14323 aaronmk
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
490 14327 aaronmk
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
491 14367 aaronmk
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
492 14304 aaronmk
END))),
493 14267 aaronmk
    CONSTRAINT "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text))))),
494 14376 aaronmk
    CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]))),
495 14330 aaronmk
    CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
496 14278 aaronmk
    CONSTRAINT "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM (("*Genus_matched" || ' '::text) || "*Specific_epithet_matched")))),
497 14303 aaronmk
    CONSTRAINT "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" CHECK ((NOT ("[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS DISTINCT FROM "*Unmatched_terms"))),
498 14281 aaronmk
    CONSTRAINT "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM
499
CASE
500
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
501
    ELSE "*Infraspecific_rank"
502
END))),
503
    CONSTRAINT "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
504
CASE
505
    WHEN matched_has_accepted THEN "*Accepted_name_author"
506
    ELSE "*Name_matched_author"
507
END))),
508
    CONSTRAINT "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
509
CASE
510 14323 aaronmk
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
511 14281 aaronmk
    ELSE "*Name_matched_accepted_family"
512
END))),
513
    CONSTRAINT "[scrubbed_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]genus__@DwC__@vegpath.org" IS DISTINCT FROM
514
CASE
515
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
516
    ELSE "*Genus_matched"
517
END))),
518
    CONSTRAINT "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
519
CASE
520
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
521
    ELSE "*Infraspecific_epithet_matched"
522
END))),
523 14326 aaronmk
    CONSTRAINT "[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
524
CASE
525
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'family'::text) THEN concat_ws(' '::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
526
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'genus'::text) THEN concat_ws(' '::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
527
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
528
END))),
529 14281 aaronmk
    CONSTRAINT "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
530
CASE
531
    WHEN matched_has_accepted THEN "*Accepted_name"
532 14330 aaronmk
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
533 14281 aaronmk
END))),
534
    CONSTRAINT "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM
535
CASE
536
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
537
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
538
END))),
539
    CONSTRAINT "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
540
CASE
541 14367 aaronmk
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
542 14281 aaronmk
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
543
END))),
544
    CONSTRAINT "[scrubbed_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
545
CASE
546
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
547
    ELSE "*Specific_epithet_matched"
548
END))),
549
    CONSTRAINT "[scrubbed_]taxonRank__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonRank__@DwC__@vegpath.org" IS DISTINCT FROM
550
CASE
551
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
552
    ELSE "*Name_matched_rank"
553
END))),
554 14324 aaronmk
    CONSTRAINT "[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" IS DISTINCT FROM map_taxonomic_status("*Taxonomic_status", "*Accepted_name")))),
555 14367 aaronmk
    CONSTRAINT __accepted_infraspecific_label CHECK ((NOT (__accepted_infraspecific_label IS DISTINCT FROM ltrim(NULLIF(remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''::text), ' '::text)))),
556 14265 aaronmk
    CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM regexp_split_to_array(__accepted_infraspecific_label, ' '::text)))),
557 14376 aaronmk
    CONSTRAINT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}" CHECK ((NOT ("__accepted_{genus,specific_epithet,infra_{rank,epithet}}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name", ' '::text)))),
558 14329 aaronmk
    CONSTRAINT matched_has_accepted CHECK ((NOT (matched_has_accepted IS DISTINCT FROM ("*Accepted_name" IS NOT NULL)))),
559
    CONSTRAINT "matched~Name[_no_author]___@TNRS__@vegpath.org" CHECK ((NOT ("matched~Name[_no_author]___@TNRS__@vegpath.org" IS DISTINCT FROM NULLIF("*Name_matched", 'No suitable matches found.'::text))))
560 10778 aaronmk
);
561 7823 aaronmk
562 9759 aaronmk
563 10778 aaronmk
--
564 13861 aaronmk
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
565 10778 aaronmk
--
566 7823 aaronmk
567 13861 aaronmk
COMMENT ON TABLE taxon_match IS '
568 14161 aaronmk
whenever columns are renamed:
569 14312 aaronmk
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
570 14161 aaronmk
571 14332 aaronmk
to port derived column changes to vegbiendev:
572
SELECT util.derived_cols_export(''"TNRS".taxon_match'');
573
# run the returned SQL on vegbiendev
574 14364 aaronmk
	-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
575 14361 aaronmk
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
576 14332 aaronmk
577 14364 aaronmk
to add a new derived column:
578
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''col''), $$
579
expr
580
$$));
581
SELECT util.derived_cols_populate(''"TNRS".taxon_match'');
582 14361 aaronmk
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
583 13577 aaronmk
$ make schemas/remake
584
585 14365 aaronmk
to remove a column:
586
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
587
$ make schemas/remake
588
589
to move a derived column to the middle or to add a non-derived column:
590 13577 aaronmk
make the changes in inputs/.TNRS/schema.sql
591 14368 aaronmk
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS; runtime: 1 min ("1m2.629s")
592 14313 aaronmk
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
593 14317 aaronmk
SELECT util.derived_cols_repopulate(''"TNRS".taxon_match'');
594 14361 aaronmk
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
595 13577 aaronmk
$ make schemas/remake
596 13582 aaronmk
597 13584 aaronmk
to add a constraint: runtime: 3 min ("173620 ms")
598 13575 aaronmk
';
599 10778 aaronmk
600
601
--
602 14311 aaronmk
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
603
--
604
605
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
606
= "*Unmatched_terms"
607
608
derived column
609
610
to modify expr:
611
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org'')::util.col, $$"*Unmatched_terms"$$)::util.derived_col_def);
612
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
613
614
to rename:
615
# rename column
616
# rename CHECK constraint
617
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
618
';
619
620
621
--
622 14279 aaronmk
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
623 14254 aaronmk
--
624
625 14279 aaronmk
COMMENT ON COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
626 14283 aaronmk
= ("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"
627 14254 aaronmk
628 14283 aaronmk
derived column
629
630 14275 aaronmk
to modify expr:
631 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"$$)::util.derived_col_def);
632 14258 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
633 14275 aaronmk
634
to rename:
635
# rename column
636
# rename CHECK constraint
637
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
638 14254 aaronmk
';
639
640
641
--
642 14329 aaronmk
-- Name: COLUMN taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
643
--
644
645
COMMENT ON COLUMN taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org" IS '
646
= NULLIF("*Name_matched", ''No suitable matches found.''::text)
647
648
derived column
649
650
to modify expr:
651
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched~Name[_no_author]___@TNRS__@vegpath.org'')::util.col, $$NULLIF("*Name_matched", ''No suitable matches found.''::text)$$)::util.derived_col_def);
652
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
653
654
to rename:
655
# rename column
656
# rename CHECK constraint
657
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
658
';
659
660
661
--
662 14279 aaronmk
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
663 14257 aaronmk
--
664
665 14279 aaronmk
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
666 14330 aaronmk
= "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
667 14257 aaronmk
668 14283 aaronmk
derived column
669
670 14275 aaronmk
to modify expr:
671 14330 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
672 14258 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
673 14275 aaronmk
674
to rename:
675
# rename column
676
# rename CHECK constraint
677
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
678 14257 aaronmk
';
679
680
681
--
682 14279 aaronmk
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
683 14257 aaronmk
--
684
685 14279 aaronmk
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
686 14283 aaronmk
= "*Accepted_name" IS NOT NULL
687 14257 aaronmk
688 14283 aaronmk
derived column
689
690 14275 aaronmk
to modify expr:
691 14279 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
692 14258 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
693 14275 aaronmk
694
to rename:
695
# rename column
696
# rename CHECK constraint
697
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
698 14257 aaronmk
';
699
700
701
--
702 14318 aaronmk
-- Name: COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
703
--
704
705
COMMENT ON COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org" IS '
706
= COALESCE("*Accepted_name_family",
707
CASE
708
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
709
    ELSE NULL::text
710
END)
711
712
derived column
713
714
to modify expr:
715
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_family__@TNRS__@vegpath.org'')::util.col, $$COALESCE("*Accepted_name_family",
716
CASE
717
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
718
    ELSE NULL::text
719
END)$$)::util.derived_col_def);
720
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
721
722
to rename:
723
# rename column
724
# rename CHECK constraint
725
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
726
';
727
728
729
--
730 14366 aaronmk
-- Name: COLUMN taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
731
--
732
733
COMMENT ON COLUMN taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org" IS '
734
= rtrim("*Accepted_name_species", '' ''::text)
735
736
derived column
737
738
to modify expr:
739
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_species[_binomial]__@TNRS__@vegpath.org'')::util.col, $$rtrim("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
740
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
741
742
to rename:
743
# rename column
744
# rename CHECK constraint
745
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
746
';
747
748
749
--
750 14376 aaronmk
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}"; Type: COMMENT; Schema: TNRS; Owner: -
751 14264 aaronmk
--
752
753 14376 aaronmk
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" IS '
754 14375 aaronmk
= regexp_split_to_array("*Accepted_name", '' ''::text)
755 14264 aaronmk
756 14283 aaronmk
derived column
757
758 14275 aaronmk
to modify expr:
759 14376 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet,infra_{rank,epithet}}'')::util.col, $$regexp_split_to_array("*Accepted_name", '' ''::text)$$)::util.derived_col_def);
760 14264 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
761 14275 aaronmk
762
to rename:
763
# rename column
764
# rename CHECK constraint
765
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
766 14264 aaronmk
';
767
768
769
--
770 14279 aaronmk
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
771 14265 aaronmk
--
772
773 14279 aaronmk
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
774 14377 aaronmk
= "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]
775 14265 aaronmk
776 14283 aaronmk
derived column
777
778 14275 aaronmk
to modify expr:
779 14377 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]$$)::util.derived_col_def);
780 14265 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
781 14275 aaronmk
782
to rename:
783
# rename column
784
# rename CHECK constraint
785
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
786 14265 aaronmk
';
787
788
789
--
790 14279 aaronmk
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
791 14266 aaronmk
--
792
793 14279 aaronmk
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
794 14376 aaronmk
= "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]
795 14266 aaronmk
796 14283 aaronmk
derived column
797
798 14275 aaronmk
to modify expr:
799 14376 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]$$)::util.derived_col_def);
800 14266 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
801 14275 aaronmk
802
to rename:
803
# rename column
804
# rename CHECK constraint
805
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
806 14266 aaronmk
';
807
808
809
--
810 14311 aaronmk
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
811
--
812
813
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
814
= CASE
815 14323 aaronmk
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
816 14327 aaronmk
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
817 14367 aaronmk
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
818 14311 aaronmk
END
819
820
derived column
821
822
to modify expr:
823
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
824 14323 aaronmk
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
825 14327 aaronmk
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
826 14367 aaronmk
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
827 14311 aaronmk
END$$)::util.derived_col_def);
828
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
829
830
to rename:
831
# rename column
832
# rename CHECK constraint
833
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
834
';
835
836
837
--
838 14279 aaronmk
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
839 14266 aaronmk
--
840
841 14279 aaronmk
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
842 14367 aaronmk
= ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''''::text), '' ''::text)
843 14266 aaronmk
844 14283 aaronmk
derived column
845
846 14275 aaronmk
to modify expr:
847 14367 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col, $$ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''''::text), '' ''::text)$$)::util.derived_col_def);
848 14266 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
849 14275 aaronmk
850
to rename:
851
# rename column
852
# rename CHECK constraint
853
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
854 14266 aaronmk
';
855
856
857
--
858 14279 aaronmk
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
859 14267 aaronmk
--
860
861 14279 aaronmk
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
862 14283 aaronmk
= regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)
863 14267 aaronmk
864 14283 aaronmk
derived column
865
866 14275 aaronmk
to modify expr:
867 14279 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)$$)::util.derived_col_def);
868 14267 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
869 14275 aaronmk
870
to rename:
871
# rename column
872
# rename CHECK constraint
873
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
874 14267 aaronmk
';
875
876
877
--
878 14279 aaronmk
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
879 14267 aaronmk
--
880
881 14279 aaronmk
COMMENT ON COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
882 14283 aaronmk
= "__accepted_infraspecific_{rank,epithet}"[1]
883 14267 aaronmk
884 14283 aaronmk
derived column
885
886 14275 aaronmk
to modify expr:
887 14279 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[1]$$)::util.derived_col_def);
888 14267 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
889 14275 aaronmk
890
to rename:
891
# rename column
892
# rename CHECK constraint
893
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
894 14267 aaronmk
';
895
896
897
--
898 14279 aaronmk
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
899 14269 aaronmk
--
900
901 14279 aaronmk
COMMENT ON COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS '
902 14283 aaronmk
= "__accepted_infraspecific_{rank,epithet}"[2]
903 14269 aaronmk
904 14283 aaronmk
derived column
905
906 14275 aaronmk
to modify expr:
907 14279 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[2]$$)::util.derived_col_def);
908 14269 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
909 14275 aaronmk
910
to rename:
911
# rename column
912
# rename CHECK constraint
913
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
914 14269 aaronmk
';
915
916
917
--
918 14279 aaronmk
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
919 14278 aaronmk
--
920
921 14279 aaronmk
COMMENT ON COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
922 14283 aaronmk
= "*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)
923 14278 aaronmk
924 14283 aaronmk
derived column
925
926 14278 aaronmk
to modify expr:
927 14279 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)$$)::util.derived_col_def);
928 14278 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
929
930
to rename:
931
# rename column
932
# rename CHECK constraint
933
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
934
';
935
936
937
--
938 14328 aaronmk
-- Name: COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
939
--
940
941
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" IS '
942
= "TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name")
943
944
derived column
945
946
to modify expr:
947
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonomicStatus__@DwC__@vegpath.org'')::util.col, $$"TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name")$$)::util.derived_col_def);
948
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
949
950
to rename:
951
# rename column
952
# rename CHECK constraint
953
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
954
';
955
956
957
--
958 14281 aaronmk
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
959
--
960
961
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
962 14283 aaronmk
= CASE
963 14282 aaronmk
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
964
    ELSE "*Name_matched_rank"
965
END
966 14281 aaronmk
967 14283 aaronmk
derived column
968
969 14281 aaronmk
to modify expr:
970 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
971
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
972
    ELSE "*Name_matched_rank"
973
END$$)::util.derived_col_def);
974 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
975
976
to rename:
977
# rename column
978
# rename CHECK constraint
979
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
980
';
981
982
983
--
984
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
985
--
986
987
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
988 14283 aaronmk
= CASE
989 14323 aaronmk
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
990 14282 aaronmk
    ELSE "*Name_matched_accepted_family"
991
END
992 14281 aaronmk
993 14283 aaronmk
derived column
994
995 14281 aaronmk
to modify expr:
996 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
997 14323 aaronmk
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
998 14282 aaronmk
    ELSE "*Name_matched_accepted_family"
999
END$$)::util.derived_col_def);
1000 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1001
1002
to rename:
1003
# rename column
1004
# rename CHECK constraint
1005
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1006
';
1007
1008
1009
--
1010
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1011
--
1012
1013
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
1014 14283 aaronmk
= CASE
1015 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1016
    ELSE "*Genus_matched"
1017
END
1018 14281 aaronmk
1019 14283 aaronmk
derived column
1020
1021 14281 aaronmk
to modify expr:
1022 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
1023
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1024
    ELSE "*Genus_matched"
1025
END$$)::util.derived_col_def);
1026 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1027
1028
to rename:
1029
# rename column
1030
# rename CHECK constraint
1031
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1032
';
1033
1034
1035
--
1036
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1037
--
1038
1039
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
1040 14283 aaronmk
= CASE
1041 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1042
    ELSE "*Specific_epithet_matched"
1043
END
1044 14281 aaronmk
1045 14283 aaronmk
derived column
1046
1047 14281 aaronmk
to modify expr:
1048 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1049
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1050
    ELSE "*Specific_epithet_matched"
1051
END$$)::util.derived_col_def);
1052 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1053
1054
to rename:
1055
# rename column
1056
# rename CHECK constraint
1057
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1058
';
1059
1060
1061
--
1062
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1063
--
1064
1065
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1066 14283 aaronmk
= CASE
1067 14367 aaronmk
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1068 14282 aaronmk
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1069
END
1070 14281 aaronmk
1071 14283 aaronmk
derived column
1072
1073 14281 aaronmk
to modify expr:
1074 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1075 14367 aaronmk
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1076 14282 aaronmk
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1077
END$$)::util.derived_col_def);
1078 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1079
1080
to rename:
1081
# rename column
1082
# rename CHECK constraint
1083
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1084
';
1085
1086
1087
--
1088 14328 aaronmk
-- Name: COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1089
--
1090
1091
COMMENT ON COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1092
= CASE
1093
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1094
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1095
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1096
END
1097
1098
derived column
1099
1100
to modify expr:
1101
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1102
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1103
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1104
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1105
END$$)::util.derived_col_def);
1106
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1107
1108
to rename:
1109
# rename column
1110
# rename CHECK constraint
1111
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1112
';
1113
1114
1115
--
1116 14281 aaronmk
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1117
--
1118
1119
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
1120 14283 aaronmk
= CASE
1121 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1122
    ELSE "*Infraspecific_rank"
1123
END
1124 14281 aaronmk
1125 14283 aaronmk
derived column
1126
1127 14281 aaronmk
to modify expr:
1128 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
1129
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1130
    ELSE "*Infraspecific_rank"
1131
END$$)::util.derived_col_def);
1132 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1133
1134
to rename:
1135
# rename column
1136
# rename CHECK constraint
1137
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1138
';
1139
1140
1141
--
1142
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1143
--
1144
1145
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
1146 14283 aaronmk
= CASE
1147 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1148
    ELSE "*Infraspecific_epithet_matched"
1149
END
1150 14281 aaronmk
1151 14283 aaronmk
derived column
1152
1153 14281 aaronmk
to modify expr:
1154 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1155
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1156
    ELSE "*Infraspecific_epithet_matched"
1157
END$$)::util.derived_col_def);
1158 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1159
1160
to rename:
1161
# rename column
1162
# rename CHECK constraint
1163
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1164
';
1165
1166
1167
--
1168
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1169
--
1170
1171
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1172 14283 aaronmk
= CASE
1173 14282 aaronmk
    WHEN matched_has_accepted THEN "*Accepted_name"
1174 14330 aaronmk
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1175 14282 aaronmk
END
1176 14281 aaronmk
1177 14283 aaronmk
derived column
1178
1179 14281 aaronmk
to modify expr:
1180 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1181
    WHEN matched_has_accepted THEN "*Accepted_name"
1182 14330 aaronmk
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1183 14282 aaronmk
END$$)::util.derived_col_def);
1184 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1185
1186
to rename:
1187
# rename column
1188
# rename CHECK constraint
1189
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1190
';
1191
1192
1193
--
1194
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1195
--
1196
1197
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1198 14283 aaronmk
= CASE
1199 14282 aaronmk
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1200
    ELSE "*Name_matched_author"
1201
END
1202 14281 aaronmk
1203 14283 aaronmk
derived column
1204
1205 14281 aaronmk
to modify expr:
1206 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1207
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1208
    ELSE "*Name_matched_author"
1209
END$$)::util.derived_col_def);
1210 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1211
1212
to rename:
1213
# rename column
1214
# rename CHECK constraint
1215
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1216
';
1217
1218
1219
--
1220
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1221
--
1222
1223
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1224 14283 aaronmk
= CASE
1225 14282 aaronmk
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1226
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1227
END
1228 14281 aaronmk
1229 14283 aaronmk
derived column
1230
1231 14281 aaronmk
to modify expr:
1232 14282 aaronmk
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1233
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1234
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1235
END$$)::util.derived_col_def);
1236 14281 aaronmk
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1237
1238
to rename:
1239
# rename column
1240
# rename CHECK constraint
1241
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1242
';
1243
1244
1245
--
1246 13878 aaronmk
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1247
--
1248
1249
CREATE VIEW taxon_best_match AS
1250
 SELECT taxon_match.batch,
1251
    taxon_match.match_num,
1252 14111 aaronmk
    taxon_match."*Name_number",
1253
    taxon_match."*Name_submitted",
1254
    taxon_match."*Overall_score",
1255
    taxon_match."*Name_matched",
1256
    taxon_match."*Name_matched_rank",
1257
    taxon_match."*Name_score",
1258
    taxon_match."*Name_matched_author",
1259
    taxon_match."*Name_matched_url",
1260
    taxon_match."*Author_matched",
1261
    taxon_match."*Author_score",
1262
    taxon_match."*Family_matched",
1263
    taxon_match."*Family_score",
1264
    taxon_match."*Name_matched_accepted_family",
1265
    taxon_match."*Genus_matched",
1266
    taxon_match."*Genus_score",
1267
    taxon_match."*Specific_epithet_matched",
1268
    taxon_match."*Specific_epithet_score",
1269
    taxon_match."*Infraspecific_rank",
1270
    taxon_match."*Infraspecific_epithet_matched",
1271
    taxon_match."*Infraspecific_epithet_score",
1272
    taxon_match."*Infraspecific_rank_2",
1273
    taxon_match."*Infraspecific_epithet_2_matched",
1274
    taxon_match."*Infraspecific_epithet_2_score",
1275
    taxon_match."*Annotations",
1276
    taxon_match."*Unmatched_terms",
1277
    taxon_match."*Taxonomic_status",
1278
    taxon_match."*Accepted_name",
1279
    taxon_match."*Accepted_name_author",
1280
    taxon_match."*Accepted_name_rank",
1281
    taxon_match."*Accepted_name_url",
1282
    taxon_match."*Accepted_name_species",
1283
    taxon_match."*Accepted_name_family",
1284
    taxon_match."*Selected",
1285
    taxon_match."*Source",
1286
    taxon_match."*Warnings",
1287
    taxon_match."*Accepted_name_lsid",
1288 13878 aaronmk
    taxon_match.is_valid_match,
1289 14268 aaronmk
    taxon_match.scrubbed_unique_taxon_name,
1290 14359 aaronmk
    taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1291 14284 aaronmk
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1292 14359 aaronmk
    taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1293 14284 aaronmk
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1294
    taxon_match.matched_has_accepted,
1295 14359 aaronmk
    taxon_match."Accepted_family__@TNRS__@vegpath.org",
1296 14366 aaronmk
    taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1297 14376 aaronmk
    taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" AS "__accepted_{genus,specific_epithet}",
1298 14268 aaronmk
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1299
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1300 14359 aaronmk
    taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1301 14268 aaronmk
    taxon_match.__accepted_infraspecific_label,
1302
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1303
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1304
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1305 14284 aaronmk
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1306 14359 aaronmk
    taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1307 14284 aaronmk
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1308
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1309
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1310
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1311
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1312 14359 aaronmk
    taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1313 14284 aaronmk
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1314
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1315
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1316
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1317
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1318 13878 aaronmk
   FROM taxon_match
1319 14111 aaronmk
  WHERE (taxon_match."*Selected" = 'true'::text);
1320 13878 aaronmk
1321
1322
--
1323
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1324
--
1325
1326
COMMENT ON VIEW taxon_best_match IS '
1327
to modify:
1328
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1329
SELECT __
1330
$$);
1331
';
1332
1333
1334
--
1335 10778 aaronmk
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1336
--
1337
1338
CREATE VIEW "MatchedTaxon" AS
1339 14110 aaronmk
 SELECT taxon_best_match.batch,
1340
    taxon_best_match.match_num,
1341 14111 aaronmk
    taxon_best_match."*Name_number",
1342
    taxon_best_match."*Name_submitted",
1343
    taxon_best_match."*Overall_score",
1344
    taxon_best_match."*Name_matched",
1345
    taxon_best_match."*Name_matched_rank",
1346
    taxon_best_match."*Name_score",
1347
    taxon_best_match."*Name_matched_author",
1348
    taxon_best_match."*Name_matched_url",
1349
    taxon_best_match."*Author_matched",
1350
    taxon_best_match."*Author_score",
1351
    taxon_best_match."*Family_matched",
1352
    taxon_best_match."*Family_score",
1353
    taxon_best_match."*Name_matched_accepted_family",
1354
    taxon_best_match."*Genus_matched",
1355
    taxon_best_match."*Genus_score",
1356
    taxon_best_match."*Specific_epithet_matched",
1357
    taxon_best_match."*Specific_epithet_score",
1358
    taxon_best_match."*Infraspecific_rank",
1359
    taxon_best_match."*Infraspecific_epithet_matched",
1360
    taxon_best_match."*Infraspecific_epithet_score",
1361
    taxon_best_match."*Infraspecific_rank_2",
1362
    taxon_best_match."*Infraspecific_epithet_2_matched",
1363
    taxon_best_match."*Infraspecific_epithet_2_score",
1364
    taxon_best_match."*Annotations",
1365
    taxon_best_match."*Unmatched_terms",
1366
    taxon_best_match."*Taxonomic_status",
1367
    taxon_best_match."*Accepted_name",
1368
    taxon_best_match."*Accepted_name_author",
1369
    taxon_best_match."*Accepted_name_rank",
1370
    taxon_best_match."*Accepted_name_url",
1371
    taxon_best_match."*Accepted_name_species",
1372
    taxon_best_match."*Accepted_name_family",
1373
    taxon_best_match."*Selected",
1374
    taxon_best_match."*Source",
1375
    taxon_best_match."*Warnings",
1376
    taxon_best_match."*Accepted_name_lsid",
1377 14110 aaronmk
    taxon_best_match.is_valid_match,
1378
    taxon_best_match.scrubbed_unique_taxon_name,
1379 14359 aaronmk
    taxon_best_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1380 14284 aaronmk
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1381 14359 aaronmk
    taxon_best_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1382 14284 aaronmk
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1383
    taxon_best_match.matched_has_accepted,
1384 14359 aaronmk
    taxon_best_match."Accepted_family__@TNRS__@vegpath.org",
1385 14366 aaronmk
    taxon_best_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1386 14268 aaronmk
    taxon_best_match."__accepted_{genus,specific_epithet}",
1387
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1388
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1389 14359 aaronmk
    taxon_best_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1390 14268 aaronmk
    taxon_best_match.__accepted_infraspecific_label,
1391
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1392
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1393
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1394
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1395 14359 aaronmk
    taxon_best_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1396 14284 aaronmk
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1397
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1398
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1399
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1400
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1401 14359 aaronmk
    taxon_best_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1402 14284 aaronmk
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1403
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1404
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1405
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1406
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1407 14111 aaronmk
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1408 13498 aaronmk
        CASE
1409 14111 aaronmk
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1410
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1411
            ELSE taxon_best_match."*Accepted_name_species"
1412 13498 aaronmk
        END AS accepted_morphospecies_binomial
1413 14110 aaronmk
   FROM taxon_best_match;
1414 10778 aaronmk
1415
1416
--
1417 13498 aaronmk
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1418
--
1419
1420
COMMENT ON VIEW "MatchedTaxon" IS '
1421 13501 aaronmk
to modify:
1422 13845 aaronmk
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1423 13647 aaronmk
SELECT __
1424 13501 aaronmk
$$);
1425 13498 aaronmk
';
1426
1427
1428
--
1429 10778 aaronmk
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1430
--
1431
1432
CREATE VIEW "ValidMatchedTaxon" AS
1433 14108 aaronmk
 SELECT "MatchedTaxon".batch,
1434 14105 aaronmk
    "MatchedTaxon".match_num,
1435 14111 aaronmk
    "MatchedTaxon"."*Name_number",
1436
    "MatchedTaxon"."*Name_submitted",
1437
    "MatchedTaxon"."*Overall_score",
1438
    "MatchedTaxon"."*Name_matched",
1439
    "MatchedTaxon"."*Name_matched_rank",
1440
    "MatchedTaxon"."*Name_score",
1441
    "MatchedTaxon"."*Name_matched_author",
1442
    "MatchedTaxon"."*Name_matched_url",
1443
    "MatchedTaxon"."*Author_matched",
1444
    "MatchedTaxon"."*Author_score",
1445
    "MatchedTaxon"."*Family_matched",
1446
    "MatchedTaxon"."*Family_score",
1447
    "MatchedTaxon"."*Name_matched_accepted_family",
1448
    "MatchedTaxon"."*Genus_matched",
1449
    "MatchedTaxon"."*Genus_score",
1450
    "MatchedTaxon"."*Specific_epithet_matched",
1451
    "MatchedTaxon"."*Specific_epithet_score",
1452
    "MatchedTaxon"."*Infraspecific_rank",
1453
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1454
    "MatchedTaxon"."*Infraspecific_epithet_score",
1455
    "MatchedTaxon"."*Infraspecific_rank_2",
1456
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1457
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1458
    "MatchedTaxon"."*Annotations",
1459
    "MatchedTaxon"."*Unmatched_terms",
1460
    "MatchedTaxon"."*Taxonomic_status",
1461
    "MatchedTaxon"."*Accepted_name",
1462
    "MatchedTaxon"."*Accepted_name_author",
1463
    "MatchedTaxon"."*Accepted_name_rank",
1464
    "MatchedTaxon"."*Accepted_name_url",
1465
    "MatchedTaxon"."*Accepted_name_species",
1466
    "MatchedTaxon"."*Accepted_name_family",
1467
    "MatchedTaxon"."*Selected",
1468
    "MatchedTaxon"."*Source",
1469
    "MatchedTaxon"."*Warnings",
1470
    "MatchedTaxon"."*Accepted_name_lsid",
1471 14108 aaronmk
    "MatchedTaxon".is_valid_match,
1472 13800 aaronmk
    "MatchedTaxon".scrubbed_unique_taxon_name,
1473 14359 aaronmk
    "MatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1474 14284 aaronmk
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1475 14359 aaronmk
    "MatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1476 14284 aaronmk
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1477
    "MatchedTaxon".matched_has_accepted,
1478 14359 aaronmk
    "MatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1479 14366 aaronmk
    "MatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1480 14268 aaronmk
    "MatchedTaxon"."__accepted_{genus,specific_epithet}",
1481
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1482
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1483 14359 aaronmk
    "MatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1484 14268 aaronmk
    "MatchedTaxon".__accepted_infraspecific_label,
1485
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1486
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1487
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1488
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1489 14359 aaronmk
    "MatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1490 14284 aaronmk
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1491
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1492
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1493
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1494
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1495 14359 aaronmk
    "MatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1496 14284 aaronmk
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1497
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1498
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1499
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1500
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1501 14103 aaronmk
    "MatchedTaxon"."taxonomicStatus",
1502 13498 aaronmk
    "MatchedTaxon".accepted_morphospecies_binomial
1503 11708 aaronmk
   FROM "MatchedTaxon"
1504 14108 aaronmk
  WHERE "MatchedTaxon".is_valid_match;
1505 10778 aaronmk
1506
1507
--
1508
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1509
--
1510
1511 13443 aaronmk
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1512
to update, use * as the column list
1513
';
1514 10778 aaronmk
1515
1516
--
1517
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
1518
--
1519
1520
CREATE TABLE batch (
1521
    id text NOT NULL,
1522
    id_by_time text,
1523
    time_submitted timestamp with time zone DEFAULT now(),
1524
    client_version text
1525
);
1526
1527
1528
--
1529
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
1530
--
1531
1532
CREATE TABLE batch_download_settings (
1533
    id text NOT NULL,
1534
    "E-mail" text,
1535
    "Id" text,
1536
    "Job type" text,
1537
    "Contains Id" boolean,
1538
    "Start time" text,
1539
    "Finish time" text,
1540
    "TNRS version" text,
1541
    "Sources selected" text,
1542
    "Match threshold" double precision,
1543
    "Classification" text,
1544
    "Allow partial matches?" boolean,
1545
    "Sort by source" boolean,
1546
    "Constrain by higher taxonomy" boolean
1547
);
1548
1549
1550
--
1551
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1552
--
1553
1554 13575 aaronmk
COMMENT ON TABLE batch_download_settings IS '
1555
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1556
';
1557 10778 aaronmk
1558
1559
--
1560
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
1561
--
1562
1563
CREATE TABLE client_version (
1564
    id text NOT NULL,
1565
    global_rev integer NOT NULL,
1566
    "/lib/tnrs.py rev" integer,
1567
    "/bin/tnrs_db rev" integer
1568
);
1569
1570
1571
--
1572
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1573
--
1574
1575 13575 aaronmk
COMMENT ON TABLE client_version IS '
1576
contains svn revisions
1577
';
1578 10778 aaronmk
1579
1580
--
1581
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1582
--
1583
1584 13575 aaronmk
COMMENT ON COLUMN client_version.global_rev IS '
1585
from `svn info .` > Last Changed Rev
1586
';
1587 10778 aaronmk
1588
1589
--
1590
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1591
--
1592
1593 13575 aaronmk
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1594
from `svn info lib/tnrs.py` > Last Changed Rev
1595
';
1596 10778 aaronmk
1597
1598
--
1599
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1600
--
1601
1602 13575 aaronmk
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1603
from `svn info bin/tnrs_db` > Last Changed Rev
1604
';
1605 10778 aaronmk
1606
1607
--
1608 13866 aaronmk
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1609
--
1610
1611
CREATE VIEW taxon_match_input AS
1612 14111 aaronmk
 SELECT taxon_match."*Name_number" AS "Name_number",
1613
    taxon_match."*Name_submitted" AS "Name_submitted",
1614
    taxon_match."*Overall_score" AS "Overall_score",
1615
    taxon_match."*Name_matched" AS "Name_matched",
1616
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1617
    taxon_match."*Name_score" AS "Name_score",
1618
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1619
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1620
    taxon_match."*Author_matched" AS "Author_matched",
1621
    taxon_match."*Author_score" AS "Author_score",
1622
    taxon_match."*Family_matched" AS "Family_matched",
1623
    taxon_match."*Family_score" AS "Family_score",
1624
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1625
    taxon_match."*Genus_matched" AS "Genus_matched",
1626
    taxon_match."*Genus_score" AS "Genus_score",
1627
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1628
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1629
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1630
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1631
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1632
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1633
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1634
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1635
    taxon_match."*Annotations" AS "Annotations",
1636
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1637
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1638
    taxon_match."*Accepted_name" AS "Accepted_name",
1639
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1640
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1641
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1642
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1643
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1644
    taxon_match."*Selected" AS "Selected",
1645
    taxon_match."*Source" AS "Source",
1646
    taxon_match."*Warnings" AS "Warnings",
1647
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1648 13866 aaronmk
   FROM taxon_match;
1649
1650
1651
--
1652
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace:
1653
--
1654
1655
CREATE TABLE taxon_match_input__copy_to (
1656
    "Name_number" integer,
1657
    "Name_submitted" text,
1658
    "Overall_score" double precision,
1659
    "Name_matched" text,
1660
    "Name_matched_rank" text,
1661
    "Name_score" double precision,
1662
    "Name_matched_author" text,
1663
    "Name_matched_url" text,
1664
    "Author_matched" text,
1665
    "Author_score" double precision,
1666
    "Family_matched" text,
1667
    "Family_score" double precision,
1668
    "Name_matched_accepted_family" text,
1669
    "Genus_matched" text,
1670
    "Genus_score" double precision,
1671
    "Specific_epithet_matched" text,
1672
    "Specific_epithet_score" double precision,
1673
    "Infraspecific_rank" text,
1674
    "Infraspecific_epithet_matched" text,
1675
    "Infraspecific_epithet_score" double precision,
1676
    "Infraspecific_rank_2" text,
1677
    "Infraspecific_epithet_2_matched" text,
1678
    "Infraspecific_epithet_2_score" double precision,
1679
    "Annotations" text,
1680
    "Unmatched_terms" text,
1681
    "Taxonomic_status" text,
1682
    "Accepted_name" text,
1683
    "Accepted_name_author" text,
1684
    "Accepted_name_rank" text,
1685
    "Accepted_name_url" text,
1686
    "Accepted_name_species" text,
1687
    "Accepted_name_family" text,
1688
    "Selected" text,
1689
    "Source" text,
1690
    "Warnings" text,
1691
    "Accepted_name_lsid" text
1692
);
1693
1694
1695
--
1696 11964 aaronmk
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1697
--
1698
1699
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1700 14111 aaronmk
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1701
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1702
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1703
    taxon_match."*Genus_matched" AS scrubbed_genus,
1704
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1705
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1706
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1707
    taxon_match."*Name_matched_author" AS scrubbed_author,
1708
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1709
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1710 13861 aaronmk
   FROM taxon_match;
1711 11964 aaronmk
1712
1713
--
1714 11965 aaronmk
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1715
--
1716
1717 13575 aaronmk
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1718 13846 aaronmk
to modify:
1719
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1720
SELECT __
1721
$$);
1722
1723 13575 aaronmk
scrubbed_family: Name_matched_accepted_family was missing from the TNRS results at one point, so Family_matched is used as a workaround to populate this. the workaround is for *accepted names only*, as no opinion names do not have an Accepted_name_family to prepend to the scrubbed name to parse.
1724
';
1725 11965 aaronmk
1726
1727
--
1728 11964 aaronmk
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1729
--
1730
1731
CREATE VIEW taxon_scrub AS
1732 13800 aaronmk
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1733 14108 aaronmk
    "ValidMatchedTaxon".batch,
1734 14105 aaronmk
    "ValidMatchedTaxon".match_num,
1735 14111 aaronmk
    "ValidMatchedTaxon"."*Name_number",
1736
    "ValidMatchedTaxon"."*Name_submitted",
1737
    "ValidMatchedTaxon"."*Overall_score",
1738
    "ValidMatchedTaxon"."*Name_matched",
1739
    "ValidMatchedTaxon"."*Name_matched_rank",
1740
    "ValidMatchedTaxon"."*Name_score",
1741
    "ValidMatchedTaxon"."*Name_matched_author",
1742
    "ValidMatchedTaxon"."*Name_matched_url",
1743
    "ValidMatchedTaxon"."*Author_matched",
1744
    "ValidMatchedTaxon"."*Author_score",
1745
    "ValidMatchedTaxon"."*Family_matched",
1746
    "ValidMatchedTaxon"."*Family_score",
1747
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1748
    "ValidMatchedTaxon"."*Genus_matched",
1749
    "ValidMatchedTaxon"."*Genus_score",
1750
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1751
    "ValidMatchedTaxon"."*Specific_epithet_score",
1752
    "ValidMatchedTaxon"."*Infraspecific_rank",
1753
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1754
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1755
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1756
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1757
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1758
    "ValidMatchedTaxon"."*Annotations",
1759
    "ValidMatchedTaxon"."*Unmatched_terms",
1760
    "ValidMatchedTaxon"."*Taxonomic_status",
1761
    "ValidMatchedTaxon"."*Accepted_name",
1762
    "ValidMatchedTaxon"."*Accepted_name_author",
1763
    "ValidMatchedTaxon"."*Accepted_name_rank",
1764
    "ValidMatchedTaxon"."*Accepted_name_url",
1765
    "ValidMatchedTaxon"."*Accepted_name_species",
1766
    "ValidMatchedTaxon"."*Accepted_name_family",
1767
    "ValidMatchedTaxon"."*Selected",
1768
    "ValidMatchedTaxon"."*Source",
1769
    "ValidMatchedTaxon"."*Warnings",
1770
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1771 14108 aaronmk
    "ValidMatchedTaxon".is_valid_match,
1772 14359 aaronmk
    "ValidMatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1773 14284 aaronmk
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1774 14359 aaronmk
    "ValidMatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1775 14284 aaronmk
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1776
    "ValidMatchedTaxon".matched_has_accepted,
1777 14359 aaronmk
    "ValidMatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1778 14366 aaronmk
    "ValidMatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1779 14268 aaronmk
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet}",
1780
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1781
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1782 14359 aaronmk
    "ValidMatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1783 14268 aaronmk
    "ValidMatchedTaxon".__accepted_infraspecific_label,
1784
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1785
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1786
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1787
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1788 14359 aaronmk
    "ValidMatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1789 14284 aaronmk
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1790
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1791
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1792
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1793
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1794 14359 aaronmk
    "ValidMatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1795 14284 aaronmk
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1796
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1797
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1798
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1799
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1800 14103 aaronmk
    "ValidMatchedTaxon"."taxonomicStatus",
1801 13800 aaronmk
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1802
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1803
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1804
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1805
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1806
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1807
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1808
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1809
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1810
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1811 13532 aaronmk
        CASE
1812 14111 aaronmk
            WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'family'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family, "ValidMatchedTaxon"."*Unmatched_terms")
1813
            WHEN ("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank = 'genus'::text) THEN concat_ws(' '::text, "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author, "ValidMatchedTaxon"."*Unmatched_terms")
1814 13532 aaronmk
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1815
        END AS scrubbed_morphospecies_binomial
1816 11964 aaronmk
   FROM ("ValidMatchedTaxon"
1817
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1818
1819
1820
--
1821
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1822
--
1823
1824 13443 aaronmk
COMMENT ON VIEW taxon_scrub IS '
1825 13531 aaronmk
to modify:
1826 13845 aaronmk
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1827 13647 aaronmk
SELECT __
1828 13531 aaronmk
$$);
1829 13443 aaronmk
';
1830 11964 aaronmk
1831
1832
--
1833 10778 aaronmk
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
1834
--
1835
1836
ALTER TABLE ONLY batch_download_settings
1837
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1838
1839
1840
--
1841
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
1842
--
1843
1844
ALTER TABLE ONLY batch
1845
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1846
1847
1848
--
1849
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
1850
--
1851
1852
ALTER TABLE ONLY batch
1853
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1854
1855
1856
--
1857
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
1858
--
1859
1860
ALTER TABLE ONLY client_version
1861
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1862
1863
1864
--
1865 13868 aaronmk
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace:
1866 10778 aaronmk
--
1867
1868 13861 aaronmk
ALTER TABLE ONLY taxon_match
1869 13868 aaronmk
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1870 10778 aaronmk
1871 14125 aaronmk
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1872 10778 aaronmk
1873 14125 aaronmk
1874 10778 aaronmk
--
1875 10793 aaronmk
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
1876
--
1877
1878
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1879
1880
1881
--
1882 13879 aaronmk
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
1883 13589 aaronmk
--
1884
1885 14111 aaronmk
CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("*Name_submitted") WHERE (("*Selected" = 'true'::text) AND is_valid_match);
1886 13589 aaronmk
1887
1888
--
1889 13879 aaronmk
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
1890 13874 aaronmk
--
1891
1892 14111 aaronmk
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
1893 13874 aaronmk
1894
1895
--
1896 13879 aaronmk
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace:
1897 11607 aaronmk
--
1898
1899 14111 aaronmk
CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "*Name_number") WHERE ("*Selected" = 'true'::text);
1900 11607 aaronmk
1901
1902
--
1903 10778 aaronmk
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1904
--
1905
1906
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
1907
1908
1909
--
1910 13868 aaronmk
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
1911 13866 aaronmk
--
1912
1913 13868 aaronmk
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
1914 13866 aaronmk
1915
1916
--
1917 13868 aaronmk
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1918 13567 aaronmk
--
1919
1920 13868 aaronmk
CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill();
1921 13567 aaronmk
1922
1923
--
1924 14122 aaronmk
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
1925
--
1926
1927
CREATE TRIGGER taxon_match__fill_derived BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill_derived();
1928
1929
1930
--
1931 13868 aaronmk
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1932 13578 aaronmk
--
1933
1934 13868 aaronmk
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
1935 13578 aaronmk
1936
1937
--
1938 13868 aaronmk
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
1939 10778 aaronmk
--
1940
1941 13868 aaronmk
CREATE TRIGGER taxon_match_input__copy_to__insert BEFORE INSERT ON taxon_match_input__copy_to FOR EACH ROW EXECUTE PROCEDURE taxon_match_input__copy_to__insert();
1942 10778 aaronmk
1943
1944
--
1945
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1946
--
1947
1948
ALTER TABLE ONLY batch
1949
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
1950
1951
1952
--
1953
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1954
--
1955
1956
ALTER TABLE ONLY batch_download_settings
1957
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1958
1959
1960
--
1961 13868 aaronmk
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1962 10778 aaronmk
--
1963
1964 13861 aaronmk
ALTER TABLE ONLY taxon_match
1965 13868 aaronmk
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1966 10778 aaronmk
1967
1968
--
1969
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
1970
--
1971
1972
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
1973
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
1974
GRANT ALL ON SCHEMA "TNRS" TO bien;
1975
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
1976
1977
1978
--
1979 13861 aaronmk
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
1980 10778 aaronmk
--
1981
1982 13861 aaronmk
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
1983
REVOKE ALL ON TABLE taxon_match FROM bien;
1984
GRANT ALL ON TABLE taxon_match TO bien;
1985
GRANT SELECT ON TABLE taxon_match TO bien_read;
1986 10778 aaronmk
1987
1988
--
1989 13878 aaronmk
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
1990
--
1991
1992
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
1993
REVOKE ALL ON TABLE taxon_best_match FROM bien;
1994
GRANT ALL ON TABLE taxon_best_match TO bien;
1995
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
1996
1997
1998
--
1999 11912 aaronmk
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2000
--
2001
2002
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
2003
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
2004
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
2005
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
2006
2007
2008
--
2009
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2010
--
2011
2012
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
2013
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
2014
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
2015
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
2016
2017
2018
--
2019 13866 aaronmk
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
2020
--
2021
2022
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
2023
REVOKE ALL ON TABLE taxon_match_input FROM bien;
2024
GRANT ALL ON TABLE taxon_match_input TO bien;
2025
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
2026
2027
2028
--
2029 11912 aaronmk
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
2030
--
2031
2032
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
2033
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
2034
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
2035
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
2036
2037
2038
--
2039
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
2040
--
2041
2042
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
2043
REVOKE ALL ON TABLE taxon_scrub FROM bien;
2044
GRANT ALL ON TABLE taxon_scrub TO bien;
2045
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
2046
2047
2048
--
2049 10778 aaronmk
-- PostgreSQL database dump complete
2050
--