Project

General

Profile

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