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