Project

General

Profile

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