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