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