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