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