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