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