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