Project

General

Profile

1
--
2
-- PostgreSQL database dump
3
--
4

    
5
SET statement_timeout = 0;
6
SET lock_timeout = 0;
7
SET client_encoding = 'UTF8';
8
SET standard_conforming_strings = on;
9
SET check_function_bodies = false;
10
SET client_min_messages = warning;
11

    
12
--
13
-- Name: TNRS; Type: SCHEMA; Schema: -; Owner: -
14
--
15

    
16
--CREATE SCHEMA "TNRS";
17

    
18

    
19
--
20
-- Name: SCHEMA "TNRS"; Type: COMMENT; Schema: -; Owner: -
21
--
22

    
23
COMMENT ON SCHEMA "TNRS" IS '
24
IMPORTANT: when changing this schema, you must also make the same changes on vegbiendev:
25
on vegbiendev:
26
# back up existing TNRS schema (in case of an accidental incorrect change):
27
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
28
$ svn up
29
$ svn di
30
# make the changes shown in the diff
31
## to change column types:
32
SELECT util.set_col_types(''"TNRS".taxon_match'', ARRAY[
33
  (''col'', ''new_type'')
34
]::util.col_cast[]); -- runtime: 9 min ("531282 ms")
35
$ rm=1 inputs/.TNRS/schema.sql.run
36
# repeat until `svn di` shows no diff
37
# back up new TNRS schema:
38
$ make backups/TNRS.backup-remake # runtime: 3 min ("real 2m44.277s")
39
';
40

    
41

    
42
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
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
$$;
57

    
58

    
59
--
60
-- Name: family_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
61
--
62

    
63
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

    
69

    
70
--
71
-- Name: genus_is_homonym(text); Type: FUNCTION; Schema: TNRS; Owner: -
72
--
73

    
74
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

    
80

    
81
--
82
-- Name: map_taxonomic_status(text, text); Type: FUNCTION; Schema: TNRS; Owner: -
83
--
84

    
85
CREATE FUNCTION map_taxonomic_status(taxonomic_status_verbatim text, accepted_taxon_name_no_author text) RETURNS text
86
    LANGUAGE sql IMMUTABLE
87
    AS $_$
88
/* 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
SELECT CASE WHEN $2 IS NOT NULL THEN 'accepted' ELSE lower($1) END
92
$_$;
93

    
94

    
95
--
96
-- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
97
--
98

    
99
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
100
    LANGUAGE plpgsql
101
    AS $$
102
BEGIN
103
	PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
104
	RETURN NULL;
105
END;
106
$$;
107

    
108

    
109
--
110
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
111
--
112

    
113
CREATE FUNCTION taxon_match__fill() RETURNS trigger
114
    LANGUAGE plpgsql
115
    AS $$
116
BEGIN
117
	DECLARE
118
		"Specific_epithet_is_plant" boolean :=
119
			(CASE
120
			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
				THEN true
124
			ELSE NULL -- ambiguous
125
			END);
126
		never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
127
			-- author disambiguates
128
		family_is_homonym boolean = NOT never_homonym
129
			AND "TNRS".family_is_homonym(new."*Family_matched");
130
		genus_is_homonym  boolean = NOT never_homonym
131
			AND "TNRS".genus_is_homonym(new."*Genus_matched");
132
	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
		new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
136
			AND COALESCE(CASE
137
			WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
138
				THEN true
139
			ELSE -- consider genus
140
				(CASE
141
				WHEN new."*Genus_score" =  1	   -- exact match
142
					THEN
143
					(CASE
144
					WHEN NOT genus_is_homonym THEN true
145
					ELSE "Specific_epithet_is_plant"
146
					END)
147
				WHEN new."*Genus_score" >= 0.85 -- fuzzy match
148
					THEN "Specific_epithet_is_plant"
149
				ELSE NULL -- ambiguous
150
				END)
151
			END, false);
152
	END;
153
	
154
	DECLARE
155
		matched_taxon_name_with_author text = NULLIF(concat_ws(' '
156
			, 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
			), '');
161
		accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
162
			, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
163
				new."*Accepted_name")
164
			, new."*Accepted_name"
165
			, new."*Accepted_name_author"
166
			), '');
167
	BEGIN
168
		new.scrubbed_unique_taxon_name = COALESCE(
169
			accepted_taxon_name_with_author, matched_taxon_name_with_author);
170
	END;
171
	
172
	RETURN new;
173
END;
174
$$;
175

    
176

    
177
--
178
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
179
--
180

    
181
COMMENT ON FUNCTION taxon_match__fill() IS '
182
IMPORTANT: when changing this function, you must regenerate the derived cols:
183
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
184
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
185
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
186
runtime: 1.5 min ("92633 ms")
187
';
188

    
189

    
190
--
191
-- 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
	-- clear derived cols so old values won't be used in calculations
199
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = NULL;
200
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
201
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
202
	new.matched_has_accepted = NULL;
203
	new."__accepted_{genus,specific_epithet}" = NULL;
204
	new."[accepted_]genus__@DwC__@vegpath.org" = NULL;
205
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = NULL;
206
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
207
	new.__accepted_infraspecific_label = NULL;
208
	new."__accepted_infraspecific_{rank,epithet}" = NULL;
209
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
210
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
211
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
212
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = NULL;
213
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
214
	new."[scrubbed_]genus__@DwC__@vegpath.org" = NULL;
215
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = NULL;
216
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
217
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
218
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
219
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
220
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
221
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
222
	
223
	-- populate derived cols
224
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT "*Unmatched_terms" FROM (SELECT new.*) new);
225
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT ("*Genus_matched" || ' '::text) || "*Specific_epithet_matched" FROM (SELECT new.*) new);
226
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new);
227
	new.matched_has_accepted = (SELECT "*Accepted_name" IS NOT NULL FROM (SELECT new.*) new);
228
	new."__accepted_{genus,specific_epithet}" = (SELECT regexp_split_to_array("*Accepted_name_species", ' '::text) FROM (SELECT new.*) new);
229
	new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet}"[1] FROM (SELECT new.*) new);
230
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet}"[2] FROM (SELECT new.*) new);
231
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
232
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
233
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
234
    ELSE "*Accepted_name_species"
235
END FROM (SELECT new.*) new);
236
	new.__accepted_infraspecific_label = (SELECT ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text) FROM (SELECT new.*) new);
237
	new."__accepted_infraspecific_{rank,epithet}" = (SELECT regexp_split_to_array(__accepted_infraspecific_label, ' '::text) FROM (SELECT new.*) new);
238
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[1] FROM (SELECT new.*) new);
239
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[2] FROM (SELECT new.*) new);
240
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text) FROM (SELECT new.*) new);
241
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = (SELECT CASE
242
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
243
    ELSE "*Name_matched_rank"
244
END FROM (SELECT new.*) new);
245
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
246
    WHEN matched_has_accepted THEN "*Accepted_name_family"
247
    ELSE "*Name_matched_accepted_family"
248
END FROM (SELECT new.*) new);
249
	new."[scrubbed_]genus__@DwC__@vegpath.org" = (SELECT CASE
250
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
251
    ELSE "*Genus_matched"
252
END FROM (SELECT new.*) new);
253
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = (SELECT CASE
254
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
255
    ELSE "*Specific_epithet_matched"
256
END FROM (SELECT new.*) new);
257
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
258
    WHEN matched_has_accepted THEN "*Accepted_name_species"
259
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
260
END FROM (SELECT new.*) new);
261
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT CASE
262
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
263
    ELSE "*Infraspecific_rank"
264
END FROM (SELECT new.*) new);
265
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT CASE
266
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
267
    ELSE "*Infraspecific_epithet_matched"
268
END FROM (SELECT new.*) new);
269
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
270
    WHEN matched_has_accepted THEN "*Accepted_name"
271
    ELSE "*Name_matched"
272
END FROM (SELECT new.*) new);
273
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
274
    WHEN matched_has_accepted THEN "*Accepted_name_author"
275
    ELSE "*Name_matched_author"
276
END FROM (SELECT new.*) new);
277
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT CASE
278
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
279
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
280
END FROM (SELECT new.*) new);
281
	
282
	RETURN new;
283
END;
284
$$;
285

    
286

    
287
--
288
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
289
--
290

    
291
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
292
autogenerated, do not edit
293

    
294
to regenerate:
295
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
296
';
297

    
298

    
299
--
300
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
301
--
302

    
303
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
304
    LANGUAGE plpgsql
305
    AS $$
306
BEGIN
307
	IF new.match_num IS NULL THEN
308
		new.match_num = "TNRS".taxon_match__match_num__next();
309
	END IF;
310
	RETURN new;
311
END;
312
$$;
313

    
314

    
315
--
316
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
317
--
318

    
319
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
320
    LANGUAGE sql
321
    AS $$
322
SELECT nextval('pg_temp.taxon_match__match_num__seq');
323
$$;
324

    
325

    
326
--
327
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
328
--
329

    
330
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
331
    LANGUAGE plpgsql
332
    AS $$
333
BEGIN
334
	INSERT INTO "TNRS".taxon_match_input SELECT new.*;
335
	RETURN NULL;
336
END;
337
$$;
338

    
339

    
340
--
341
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
342
--
343

    
344
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
345
    LANGUAGE sql IMMUTABLE
346
    AS $_$
347
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
348
$_$;
349

    
350

    
351
--
352
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
353
--
354

    
355
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
356
    LANGUAGE sql IMMUTABLE
357
    AS $$
358
SELECT ARRAY[
359
]::text[]
360
$$;
361

    
362

    
363
SET default_tablespace = '';
364

    
365
SET default_with_oids = false;
366

    
367
--
368
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
369
--
370

    
371
CREATE TABLE taxon_match (
372
    batch text DEFAULT now() NOT NULL,
373
    match_num integer NOT NULL,
374
    "*Name_number" integer NOT NULL,
375
    "*Name_submitted" text NOT NULL,
376
    "*Overall_score" double precision,
377
    "*Name_matched" text,
378
    "*Name_matched_rank" text,
379
    "*Name_score" double precision,
380
    "*Name_matched_author" text,
381
    "*Name_matched_url" text,
382
    "*Author_matched" text,
383
    "*Author_score" double precision,
384
    "*Family_matched" text,
385
    "*Family_score" double precision,
386
    "*Name_matched_accepted_family" text,
387
    "*Genus_matched" text,
388
    "*Genus_score" double precision,
389
    "*Specific_epithet_matched" text,
390
    "*Specific_epithet_score" double precision,
391
    "*Infraspecific_rank" text,
392
    "*Infraspecific_epithet_matched" text,
393
    "*Infraspecific_epithet_score" double precision,
394
    "*Infraspecific_rank_2" text,
395
    "*Infraspecific_epithet_2_matched" text,
396
    "*Infraspecific_epithet_2_score" double precision,
397
    "*Annotations" text,
398
    "*Unmatched_terms" text,
399
    "*Taxonomic_status" text,
400
    "*Accepted_name" text,
401
    "*Accepted_name_author" text,
402
    "*Accepted_name_rank" text,
403
    "*Accepted_name_url" text,
404
    "*Accepted_name_species" text,
405
    "*Accepted_name_family" text,
406
    "*Selected" text,
407
    "*Source" text,
408
    "*Warnings" text,
409
    "*Accepted_name_lsid" text,
410
    is_valid_match boolean NOT NULL,
411
    scrubbed_unique_taxon_name text,
412
    "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" text,
413
    "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" text,
414
    "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" text,
415
    matched_has_accepted boolean,
416
    "__accepted_{genus,specific_epithet}" text[],
417
    "[accepted_]genus__@DwC__@vegpath.org" text,
418
    "[accepted_]specificEpithet__@DwC__@vegpath.org" text,
419
    "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
420
    __accepted_infraspecific_label text,
421
    "__accepted_infraspecific_{rank,epithet}" text[],
422
    "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
423
    "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
424
    "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" text,
425
    "[scrubbed_]taxonRank__@DwC__@vegpath.org" text,
426
    "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" text,
427
    "[scrubbed_]genus__@DwC__@vegpath.org" text,
428
    "[scrubbed_]specificEpithet__@DwC__@vegpath.org" text,
429
    "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" text,
430
    "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
431
    "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" text,
432
    "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" text,
433
    "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" text,
434
    "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" text,
435
    CONSTRAINT "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[1]))),
436
    CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[1]))),
437
    CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
438
    CONSTRAINT "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
439
CASE
440
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
441
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
442
    ELSE "*Accepted_name_species"
443
END))),
444
    CONSTRAINT "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text))))),
445
    CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet}"[2]))),
446
    CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("*Name_matched" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
447
    CONSTRAINT "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM (("*Genus_matched" || ' '::text) || "*Specific_epithet_matched")))),
448
    CONSTRAINT "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" CHECK ((NOT ("[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS DISTINCT FROM "*Unmatched_terms"))),
449
    CONSTRAINT "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM
450
CASE
451
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
452
    ELSE "*Infraspecific_rank"
453
END))),
454
    CONSTRAINT "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
455
CASE
456
    WHEN matched_has_accepted THEN "*Accepted_name_author"
457
    ELSE "*Name_matched_author"
458
END))),
459
    CONSTRAINT "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
460
CASE
461
    WHEN matched_has_accepted THEN "*Accepted_name_family"
462
    ELSE "*Name_matched_accepted_family"
463
END))),
464
    CONSTRAINT "[scrubbed_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]genus__@DwC__@vegpath.org" IS DISTINCT FROM
465
CASE
466
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
467
    ELSE "*Genus_matched"
468
END))),
469
    CONSTRAINT "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
470
CASE
471
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
472
    ELSE "*Infraspecific_epithet_matched"
473
END))),
474
    CONSTRAINT "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
475
CASE
476
    WHEN matched_has_accepted THEN "*Accepted_name"
477
    ELSE "*Name_matched"
478
END))),
479
    CONSTRAINT "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM
480
CASE
481
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
482
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
483
END))),
484
    CONSTRAINT "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
485
CASE
486
    WHEN matched_has_accepted THEN "*Accepted_name_species"
487
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
488
END))),
489
    CONSTRAINT "[scrubbed_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
490
CASE
491
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
492
    ELSE "*Specific_epithet_matched"
493
END))),
494
    CONSTRAINT "[scrubbed_]taxonRank__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonRank__@DwC__@vegpath.org" IS DISTINCT FROM
495
CASE
496
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
497
    ELSE "*Name_matched_rank"
498
END))),
499
    CONSTRAINT __accepted_infraspecific_label CHECK ((NOT (__accepted_infraspecific_label IS DISTINCT FROM ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''::text), ' '::text)))),
500
    CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM regexp_split_to_array(__accepted_infraspecific_label, ' '::text)))),
501
    CONSTRAINT "__accepted_{genus,specific_epithet}" CHECK ((NOT ("__accepted_{genus,specific_epithet}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name_species", ' '::text)))),
502
    CONSTRAINT matched_has_accepted CHECK ((NOT (matched_has_accepted IS DISTINCT FROM ("*Accepted_name" IS NOT NULL))))
503
);
504

    
505

    
506
--
507
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
508
--
509

    
510
COMMENT ON TABLE taxon_match IS '
511
whenever columns are renamed:
512
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
513

    
514
to remove columns or add columns at the end:
515
$ rm=1 inputs/.TNRS/data.sql.run
516
$ make schemas/remake
517

    
518
to add columns in the middle:
519
make the changes in inputs/.TNRS/schema.sql
520
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS
521
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
522
$ make schemas/remake
523

    
524
to populate a new column:
525
ALTER TABLE "TNRS".taxon_match DISABLE TRIGGER taxon_match__fill; --speeds up update
526
UPDATE "TNRS".taxon_match SET "col" = value;
527
	-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
528
CLUSTER "TNRS".taxon_match; -- ensure rows are exported in sorted order
529
ALTER TABLE "TNRS".taxon_match ENABLE TRIGGER taxon_match__fill;
530
VACUUM ANALYZE "TNRS".taxon_match --remove previous rows; runtime: 1.5 min ("92633 ms")
531

    
532
to add a constraint: runtime: 3 min ("173620 ms")
533
';
534

    
535

    
536
--
537
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
538
--
539

    
540
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
541
= "*Unmatched_terms"
542

    
543
derived column
544

    
545
to modify expr:
546
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org'')::util.col, $$"*Unmatched_terms"$$)::util.derived_col_def);
547
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
548

    
549
to rename:
550
# rename column
551
# rename CHECK constraint
552
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
553
';
554

    
555

    
556
--
557
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
558
--
559

    
560
COMMENT ON COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
561
= ("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"
562

    
563
derived column
564

    
565
to modify expr:
566
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);
567
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
568

    
569
to rename:
570
# rename column
571
# rename CHECK constraint
572
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
573
';
574

    
575

    
576
--
577
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
578
--
579

    
580
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
581
= "*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
582

    
583
derived column
584

    
585
to modify expr:
586
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);
587
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
588

    
589
to rename:
590
# rename column
591
# rename CHECK constraint
592
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
593
';
594

    
595

    
596
--
597
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
598
--
599

    
600
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
601
= "*Accepted_name" IS NOT NULL
602

    
603
derived column
604

    
605
to modify expr:
606
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
607
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
608

    
609
to rename:
610
# rename column
611
# rename CHECK constraint
612
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
613
';
614

    
615

    
616
--
617
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
618
--
619

    
620
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
621
= regexp_split_to_array("*Accepted_name_species", '' ''::text)
622

    
623
derived column
624

    
625
to modify expr:
626
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);
627
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
628

    
629
to rename:
630
# rename column
631
# rename CHECK constraint
632
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
633
';
634

    
635

    
636
--
637
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
638
--
639

    
640
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
641
= "__accepted_{genus,specific_epithet}"[1]
642

    
643
derived column
644

    
645
to modify expr:
646
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[1]$$)::util.derived_col_def);
647
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
648

    
649
to rename:
650
# rename column
651
# rename CHECK constraint
652
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
653
';
654

    
655

    
656
--
657
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
658
--
659

    
660
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
661
= "__accepted_{genus,specific_epithet}"[2]
662

    
663
derived column
664

    
665
to modify expr:
666
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet}"[2]$$)::util.derived_col_def);
667
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
668

    
669
to rename:
670
# rename column
671
# rename CHECK constraint
672
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
673
';
674

    
675

    
676
--
677
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
678
--
679

    
680
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
681
= CASE
682
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
683
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
684
    ELSE "*Accepted_name_species"
685
END
686

    
687
derived column
688

    
689
to modify expr:
690
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
691
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
692
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
693
    ELSE "*Accepted_name_species"
694
END$$)::util.derived_col_def);
695
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
696

    
697
to rename:
698
# rename column
699
# rename CHECK constraint
700
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
701
';
702

    
703

    
704
--
705
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
706
--
707

    
708
COMMENT ON COLUMN taxon_match.__accepted_infraspecific_label IS '
709
= ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''::text), '' ''::text)
710

    
711
derived column
712

    
713
to modify expr:
714
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);
715
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
716

    
717
to rename:
718
# rename column
719
# rename CHECK constraint
720
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
721
';
722

    
723

    
724
--
725
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
726
--
727

    
728
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
729
= regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)
730

    
731
derived column
732

    
733
to modify expr:
734
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);
735
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
736

    
737
to rename:
738
# rename column
739
# rename CHECK constraint
740
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
741
';
742

    
743

    
744
--
745
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
746
--
747

    
748
COMMENT ON COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
749
= "__accepted_infraspecific_{rank,epithet}"[1]
750

    
751
derived column
752

    
753
to modify expr:
754
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);
755
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
756

    
757
to rename:
758
# rename column
759
# rename CHECK constraint
760
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
761
';
762

    
763

    
764
--
765
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
766
--
767

    
768
COMMENT ON COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS '
769
= "__accepted_infraspecific_{rank,epithet}"[2]
770

    
771
derived column
772

    
773
to modify expr:
774
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[2]$$)::util.derived_col_def);
775
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
776

    
777
to rename:
778
# rename column
779
# rename CHECK constraint
780
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
781
';
782

    
783

    
784
--
785
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
786
--
787

    
788
COMMENT ON COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
789
= "*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)
790

    
791
derived column
792

    
793
to modify expr:
794
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);
795
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
796

    
797
to rename:
798
# rename column
799
# rename CHECK constraint
800
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
801
';
802

    
803

    
804
--
805
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
806
--
807

    
808
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
809
= CASE
810
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
811
    ELSE "*Name_matched_rank"
812
END
813

    
814
derived column
815

    
816
to modify expr:
817
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
818
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
819
    ELSE "*Name_matched_rank"
820
END$$)::util.derived_col_def);
821
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
822

    
823
to rename:
824
# rename column
825
# rename CHECK constraint
826
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
827
';
828

    
829

    
830
--
831
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
832
--
833

    
834
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
835
= CASE
836
    WHEN matched_has_accepted THEN "*Accepted_name_family"
837
    ELSE "*Name_matched_accepted_family"
838
END
839

    
840
derived column
841

    
842
to modify expr:
843
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
844
    WHEN matched_has_accepted THEN "*Accepted_name_family"
845
    ELSE "*Name_matched_accepted_family"
846
END$$)::util.derived_col_def);
847
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
848

    
849
to rename:
850
# rename column
851
# rename CHECK constraint
852
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
853
';
854

    
855

    
856
--
857
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
858
--
859

    
860
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
861
= CASE
862
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
863
    ELSE "*Genus_matched"
864
END
865

    
866
derived column
867

    
868
to modify expr:
869
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
870
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
871
    ELSE "*Genus_matched"
872
END$$)::util.derived_col_def);
873
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
874

    
875
to rename:
876
# rename column
877
# rename CHECK constraint
878
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
879
';
880

    
881

    
882
--
883
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
884
--
885

    
886
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
887
= CASE
888
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
889
    ELSE "*Specific_epithet_matched"
890
END
891

    
892
derived column
893

    
894
to modify expr:
895
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
896
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
897
    ELSE "*Specific_epithet_matched"
898
END$$)::util.derived_col_def);
899
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
900

    
901
to rename:
902
# rename column
903
# rename CHECK constraint
904
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
905
';
906

    
907

    
908
--
909
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
910
--
911

    
912
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
913
= CASE
914
    WHEN matched_has_accepted THEN "*Accepted_name_species"
915
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
916
END
917

    
918
derived column
919

    
920
to modify expr:
921
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
922
    WHEN matched_has_accepted THEN "*Accepted_name_species"
923
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
924
END$$)::util.derived_col_def);
925
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
926

    
927
to rename:
928
# rename column
929
# rename CHECK constraint
930
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
931
';
932

    
933

    
934
--
935
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
936
--
937

    
938
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
939
= CASE
940
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
941
    ELSE "*Infraspecific_rank"
942
END
943

    
944
derived column
945

    
946
to modify expr:
947
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
948
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
949
    ELSE "*Infraspecific_rank"
950
END$$)::util.derived_col_def);
951
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
952

    
953
to rename:
954
# rename column
955
# rename CHECK constraint
956
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
957
';
958

    
959

    
960
--
961
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
962
--
963

    
964
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
965
= CASE
966
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
967
    ELSE "*Infraspecific_epithet_matched"
968
END
969

    
970
derived column
971

    
972
to modify expr:
973
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
974
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
975
    ELSE "*Infraspecific_epithet_matched"
976
END$$)::util.derived_col_def);
977
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
978

    
979
to rename:
980
# rename column
981
# rename CHECK constraint
982
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
983
';
984

    
985

    
986
--
987
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
988
--
989

    
990
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
991
= CASE
992
    WHEN matched_has_accepted THEN "*Accepted_name"
993
    ELSE "*Name_matched"
994
END
995

    
996
derived column
997

    
998
to modify expr:
999
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1000
    WHEN matched_has_accepted THEN "*Accepted_name"
1001
    ELSE "*Name_matched"
1002
END$$)::util.derived_col_def);
1003
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1004

    
1005
to rename:
1006
# rename column
1007
# rename CHECK constraint
1008
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1009
';
1010

    
1011

    
1012
--
1013
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1014
--
1015

    
1016
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1017
= CASE
1018
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1019
    ELSE "*Name_matched_author"
1020
END
1021

    
1022
derived column
1023

    
1024
to modify expr:
1025
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1026
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1027
    ELSE "*Name_matched_author"
1028
END$$)::util.derived_col_def);
1029
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1030

    
1031
to rename:
1032
# rename column
1033
# rename CHECK constraint
1034
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1035
';
1036

    
1037

    
1038
--
1039
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1040
--
1041

    
1042
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1043
= CASE
1044
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1045
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1046
END
1047

    
1048
derived column
1049

    
1050
to modify expr:
1051
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1052
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1053
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1054
END$$)::util.derived_col_def);
1055
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1056

    
1057
to rename:
1058
# rename column
1059
# rename CHECK constraint
1060
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1061
';
1062

    
1063

    
1064
--
1065
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1066
--
1067

    
1068
CREATE VIEW taxon_best_match AS
1069
 SELECT taxon_match.batch,
1070
    taxon_match.match_num,
1071
    taxon_match."*Name_number",
1072
    taxon_match."*Name_submitted",
1073
    taxon_match."*Overall_score",
1074
    taxon_match."*Name_matched",
1075
    taxon_match."*Name_matched_rank",
1076
    taxon_match."*Name_score",
1077
    taxon_match."*Name_matched_author",
1078
    taxon_match."*Name_matched_url",
1079
    taxon_match."*Author_matched",
1080
    taxon_match."*Author_score",
1081
    taxon_match."*Family_matched",
1082
    taxon_match."*Family_score",
1083
    taxon_match."*Name_matched_accepted_family",
1084
    taxon_match."*Genus_matched",
1085
    taxon_match."*Genus_score",
1086
    taxon_match."*Specific_epithet_matched",
1087
    taxon_match."*Specific_epithet_score",
1088
    taxon_match."*Infraspecific_rank",
1089
    taxon_match."*Infraspecific_epithet_matched",
1090
    taxon_match."*Infraspecific_epithet_score",
1091
    taxon_match."*Infraspecific_rank_2",
1092
    taxon_match."*Infraspecific_epithet_2_matched",
1093
    taxon_match."*Infraspecific_epithet_2_score",
1094
    taxon_match."*Annotations",
1095
    taxon_match."*Unmatched_terms",
1096
    taxon_match."*Taxonomic_status",
1097
    taxon_match."*Accepted_name",
1098
    taxon_match."*Accepted_name_author",
1099
    taxon_match."*Accepted_name_rank",
1100
    taxon_match."*Accepted_name_url",
1101
    taxon_match."*Accepted_name_species",
1102
    taxon_match."*Accepted_name_family",
1103
    taxon_match."*Selected",
1104
    taxon_match."*Source",
1105
    taxon_match."*Warnings",
1106
    taxon_match."*Accepted_name_lsid",
1107
    taxon_match.is_valid_match,
1108
    taxon_match.scrubbed_unique_taxon_name,
1109
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1110
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1111
    taxon_match.matched_has_accepted,
1112
    taxon_match."__accepted_{genus,specific_epithet}",
1113
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1114
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1115
    taxon_match.__accepted_infraspecific_label,
1116
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1117
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1118
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1119
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1120
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1121
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1122
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1123
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1124
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1125
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1126
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1127
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1128
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1129
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1130
   FROM taxon_match
1131
  WHERE (taxon_match."*Selected" = 'true'::text);
1132

    
1133

    
1134
--
1135
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1136
--
1137

    
1138
COMMENT ON VIEW taxon_best_match IS '
1139
to modify:
1140
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1141
SELECT __
1142
$$);
1143
';
1144

    
1145

    
1146
--
1147
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1148
--
1149

    
1150
CREATE VIEW "MatchedTaxon" AS
1151
 SELECT taxon_best_match.batch,
1152
    taxon_best_match.match_num,
1153
    taxon_best_match."*Name_number",
1154
    taxon_best_match."*Name_submitted",
1155
    taxon_best_match."*Overall_score",
1156
    taxon_best_match."*Name_matched",
1157
    taxon_best_match."*Name_matched_rank",
1158
    taxon_best_match."*Name_score",
1159
    taxon_best_match."*Name_matched_author",
1160
    taxon_best_match."*Name_matched_url",
1161
    taxon_best_match."*Author_matched",
1162
    taxon_best_match."*Author_score",
1163
    taxon_best_match."*Family_matched",
1164
    taxon_best_match."*Family_score",
1165
    taxon_best_match."*Name_matched_accepted_family",
1166
    taxon_best_match."*Genus_matched",
1167
    taxon_best_match."*Genus_score",
1168
    taxon_best_match."*Specific_epithet_matched",
1169
    taxon_best_match."*Specific_epithet_score",
1170
    taxon_best_match."*Infraspecific_rank",
1171
    taxon_best_match."*Infraspecific_epithet_matched",
1172
    taxon_best_match."*Infraspecific_epithet_score",
1173
    taxon_best_match."*Infraspecific_rank_2",
1174
    taxon_best_match."*Infraspecific_epithet_2_matched",
1175
    taxon_best_match."*Infraspecific_epithet_2_score",
1176
    taxon_best_match."*Annotations",
1177
    taxon_best_match."*Unmatched_terms",
1178
    taxon_best_match."*Taxonomic_status",
1179
    taxon_best_match."*Accepted_name",
1180
    taxon_best_match."*Accepted_name_author",
1181
    taxon_best_match."*Accepted_name_rank",
1182
    taxon_best_match."*Accepted_name_url",
1183
    taxon_best_match."*Accepted_name_species",
1184
    taxon_best_match."*Accepted_name_family",
1185
    taxon_best_match."*Selected",
1186
    taxon_best_match."*Source",
1187
    taxon_best_match."*Warnings",
1188
    taxon_best_match."*Accepted_name_lsid",
1189
    taxon_best_match.is_valid_match,
1190
    taxon_best_match.scrubbed_unique_taxon_name,
1191
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1192
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1193
    taxon_best_match.matched_has_accepted,
1194
    taxon_best_match."__accepted_{genus,specific_epithet}",
1195
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1196
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1197
    taxon_best_match.__accepted_infraspecific_label,
1198
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1199
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1200
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1201
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1202
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1203
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1204
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1205
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1206
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1207
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1208
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1209
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1210
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1211
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1212
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1213
        CASE
1214
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1215
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1216
            ELSE taxon_best_match."*Accepted_name_species"
1217
        END AS accepted_morphospecies_binomial
1218
   FROM taxon_best_match;
1219

    
1220

    
1221
--
1222
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1223
--
1224

    
1225
COMMENT ON VIEW "MatchedTaxon" IS '
1226
to modify:
1227
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1228
SELECT __
1229
$$);
1230
';
1231

    
1232

    
1233
--
1234
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1235
--
1236

    
1237
CREATE VIEW "ValidMatchedTaxon" AS
1238
 SELECT "MatchedTaxon".batch,
1239
    "MatchedTaxon".match_num,
1240
    "MatchedTaxon"."*Name_number",
1241
    "MatchedTaxon"."*Name_submitted",
1242
    "MatchedTaxon"."*Overall_score",
1243
    "MatchedTaxon"."*Name_matched",
1244
    "MatchedTaxon"."*Name_matched_rank",
1245
    "MatchedTaxon"."*Name_score",
1246
    "MatchedTaxon"."*Name_matched_author",
1247
    "MatchedTaxon"."*Name_matched_url",
1248
    "MatchedTaxon"."*Author_matched",
1249
    "MatchedTaxon"."*Author_score",
1250
    "MatchedTaxon"."*Family_matched",
1251
    "MatchedTaxon"."*Family_score",
1252
    "MatchedTaxon"."*Name_matched_accepted_family",
1253
    "MatchedTaxon"."*Genus_matched",
1254
    "MatchedTaxon"."*Genus_score",
1255
    "MatchedTaxon"."*Specific_epithet_matched",
1256
    "MatchedTaxon"."*Specific_epithet_score",
1257
    "MatchedTaxon"."*Infraspecific_rank",
1258
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1259
    "MatchedTaxon"."*Infraspecific_epithet_score",
1260
    "MatchedTaxon"."*Infraspecific_rank_2",
1261
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1262
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1263
    "MatchedTaxon"."*Annotations",
1264
    "MatchedTaxon"."*Unmatched_terms",
1265
    "MatchedTaxon"."*Taxonomic_status",
1266
    "MatchedTaxon"."*Accepted_name",
1267
    "MatchedTaxon"."*Accepted_name_author",
1268
    "MatchedTaxon"."*Accepted_name_rank",
1269
    "MatchedTaxon"."*Accepted_name_url",
1270
    "MatchedTaxon"."*Accepted_name_species",
1271
    "MatchedTaxon"."*Accepted_name_family",
1272
    "MatchedTaxon"."*Selected",
1273
    "MatchedTaxon"."*Source",
1274
    "MatchedTaxon"."*Warnings",
1275
    "MatchedTaxon"."*Accepted_name_lsid",
1276
    "MatchedTaxon".is_valid_match,
1277
    "MatchedTaxon".scrubbed_unique_taxon_name,
1278
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1279
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1280
    "MatchedTaxon".matched_has_accepted,
1281
    "MatchedTaxon"."__accepted_{genus,specific_epithet}",
1282
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1283
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1284
    "MatchedTaxon".__accepted_infraspecific_label,
1285
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1286
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1287
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1288
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1289
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1290
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1291
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1292
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1293
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1294
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1295
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1296
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1297
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1298
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1299
    "MatchedTaxon"."taxonomicStatus",
1300
    "MatchedTaxon".accepted_morphospecies_binomial
1301
   FROM "MatchedTaxon"
1302
  WHERE "MatchedTaxon".is_valid_match;
1303

    
1304

    
1305
--
1306
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1307
--
1308

    
1309
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1310
to update, use * as the column list
1311
';
1312

    
1313

    
1314
--
1315
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1316
--
1317

    
1318
CREATE TABLE batch (
1319
    id text NOT NULL,
1320
    id_by_time text,
1321
    time_submitted timestamp with time zone DEFAULT now(),
1322
    client_version text
1323
);
1324

    
1325

    
1326
--
1327
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1328
--
1329

    
1330
CREATE TABLE batch_download_settings (
1331
    id text NOT NULL,
1332
    "E-mail" text,
1333
    "Id" text,
1334
    "Job type" text,
1335
    "Contains Id" boolean,
1336
    "Start time" text,
1337
    "Finish time" text,
1338
    "TNRS version" text,
1339
    "Sources selected" text,
1340
    "Match threshold" double precision,
1341
    "Classification" text,
1342
    "Allow partial matches?" boolean,
1343
    "Sort by source" boolean,
1344
    "Constrain by higher taxonomy" boolean
1345
);
1346

    
1347

    
1348
--
1349
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1350
--
1351

    
1352
COMMENT ON TABLE batch_download_settings IS '
1353
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1354
';
1355

    
1356

    
1357
--
1358
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1359
--
1360

    
1361
CREATE TABLE client_version (
1362
    id text NOT NULL,
1363
    global_rev integer NOT NULL,
1364
    "/lib/tnrs.py rev" integer,
1365
    "/bin/tnrs_db rev" integer
1366
);
1367

    
1368

    
1369
--
1370
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1371
--
1372

    
1373
COMMENT ON TABLE client_version IS '
1374
contains svn revisions
1375
';
1376

    
1377

    
1378
--
1379
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1380
--
1381

    
1382
COMMENT ON COLUMN client_version.global_rev IS '
1383
from `svn info .` > Last Changed Rev
1384
';
1385

    
1386

    
1387
--
1388
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1389
--
1390

    
1391
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1392
from `svn info lib/tnrs.py` > Last Changed Rev
1393
';
1394

    
1395

    
1396
--
1397
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1398
--
1399

    
1400
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1401
from `svn info bin/tnrs_db` > Last Changed Rev
1402
';
1403

    
1404

    
1405
--
1406
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1407
--
1408

    
1409
CREATE VIEW taxon_match_input AS
1410
 SELECT taxon_match."*Name_number" AS "Name_number",
1411
    taxon_match."*Name_submitted" AS "Name_submitted",
1412
    taxon_match."*Overall_score" AS "Overall_score",
1413
    taxon_match."*Name_matched" AS "Name_matched",
1414
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1415
    taxon_match."*Name_score" AS "Name_score",
1416
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1417
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1418
    taxon_match."*Author_matched" AS "Author_matched",
1419
    taxon_match."*Author_score" AS "Author_score",
1420
    taxon_match."*Family_matched" AS "Family_matched",
1421
    taxon_match."*Family_score" AS "Family_score",
1422
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1423
    taxon_match."*Genus_matched" AS "Genus_matched",
1424
    taxon_match."*Genus_score" AS "Genus_score",
1425
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1426
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1427
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1428
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1429
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1430
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1431
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1432
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1433
    taxon_match."*Annotations" AS "Annotations",
1434
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1435
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1436
    taxon_match."*Accepted_name" AS "Accepted_name",
1437
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1438
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1439
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1440
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1441
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1442
    taxon_match."*Selected" AS "Selected",
1443
    taxon_match."*Source" AS "Source",
1444
    taxon_match."*Warnings" AS "Warnings",
1445
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1446
   FROM taxon_match;
1447

    
1448

    
1449
--
1450
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1451
--
1452

    
1453
CREATE TABLE taxon_match_input__copy_to (
1454
    "Name_number" integer,
1455
    "Name_submitted" text,
1456
    "Overall_score" double precision,
1457
    "Name_matched" text,
1458
    "Name_matched_rank" text,
1459
    "Name_score" double precision,
1460
    "Name_matched_author" text,
1461
    "Name_matched_url" text,
1462
    "Author_matched" text,
1463
    "Author_score" double precision,
1464
    "Family_matched" text,
1465
    "Family_score" double precision,
1466
    "Name_matched_accepted_family" text,
1467
    "Genus_matched" text,
1468
    "Genus_score" double precision,
1469
    "Specific_epithet_matched" text,
1470
    "Specific_epithet_score" double precision,
1471
    "Infraspecific_rank" text,
1472
    "Infraspecific_epithet_matched" text,
1473
    "Infraspecific_epithet_score" double precision,
1474
    "Infraspecific_rank_2" text,
1475
    "Infraspecific_epithet_2_matched" text,
1476
    "Infraspecific_epithet_2_score" double precision,
1477
    "Annotations" text,
1478
    "Unmatched_terms" text,
1479
    "Taxonomic_status" text,
1480
    "Accepted_name" text,
1481
    "Accepted_name_author" text,
1482
    "Accepted_name_rank" text,
1483
    "Accepted_name_url" text,
1484
    "Accepted_name_species" text,
1485
    "Accepted_name_family" text,
1486
    "Selected" text,
1487
    "Source" text,
1488
    "Warnings" text,
1489
    "Accepted_name_lsid" text
1490
);
1491

    
1492

    
1493
--
1494
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1495
--
1496

    
1497
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1498
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1499
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1500
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1501
    taxon_match."*Genus_matched" AS scrubbed_genus,
1502
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1503
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1504
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1505
    taxon_match."*Name_matched_author" AS scrubbed_author,
1506
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1507
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1508
   FROM taxon_match;
1509

    
1510

    
1511
--
1512
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1513
--
1514

    
1515
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1516
to modify:
1517
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1518
SELECT __
1519
$$);
1520

    
1521
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.
1522
';
1523

    
1524

    
1525
--
1526
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1527
--
1528

    
1529
CREATE VIEW taxon_scrub AS
1530
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1531
    "ValidMatchedTaxon".batch,
1532
    "ValidMatchedTaxon".match_num,
1533
    "ValidMatchedTaxon"."*Name_number",
1534
    "ValidMatchedTaxon"."*Name_submitted",
1535
    "ValidMatchedTaxon"."*Overall_score",
1536
    "ValidMatchedTaxon"."*Name_matched",
1537
    "ValidMatchedTaxon"."*Name_matched_rank",
1538
    "ValidMatchedTaxon"."*Name_score",
1539
    "ValidMatchedTaxon"."*Name_matched_author",
1540
    "ValidMatchedTaxon"."*Name_matched_url",
1541
    "ValidMatchedTaxon"."*Author_matched",
1542
    "ValidMatchedTaxon"."*Author_score",
1543
    "ValidMatchedTaxon"."*Family_matched",
1544
    "ValidMatchedTaxon"."*Family_score",
1545
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1546
    "ValidMatchedTaxon"."*Genus_matched",
1547
    "ValidMatchedTaxon"."*Genus_score",
1548
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1549
    "ValidMatchedTaxon"."*Specific_epithet_score",
1550
    "ValidMatchedTaxon"."*Infraspecific_rank",
1551
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1552
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1553
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1554
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1555
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1556
    "ValidMatchedTaxon"."*Annotations",
1557
    "ValidMatchedTaxon"."*Unmatched_terms",
1558
    "ValidMatchedTaxon"."*Taxonomic_status",
1559
    "ValidMatchedTaxon"."*Accepted_name",
1560
    "ValidMatchedTaxon"."*Accepted_name_author",
1561
    "ValidMatchedTaxon"."*Accepted_name_rank",
1562
    "ValidMatchedTaxon"."*Accepted_name_url",
1563
    "ValidMatchedTaxon"."*Accepted_name_species",
1564
    "ValidMatchedTaxon"."*Accepted_name_family",
1565
    "ValidMatchedTaxon"."*Selected",
1566
    "ValidMatchedTaxon"."*Source",
1567
    "ValidMatchedTaxon"."*Warnings",
1568
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1569
    "ValidMatchedTaxon".is_valid_match,
1570
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1571
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1572
    "ValidMatchedTaxon".matched_has_accepted,
1573
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet}",
1574
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1575
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1576
    "ValidMatchedTaxon".__accepted_infraspecific_label,
1577
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1578
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1579
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1580
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1581
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1582
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1583
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1584
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1585
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1586
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1587
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1588
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1589
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1590
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1591
    "ValidMatchedTaxon"."taxonomicStatus",
1592
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1593
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1594
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1595
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1596
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1597
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1598
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1599
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1600
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1601
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1602
        CASE
1603
            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")
1604
            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")
1605
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1606
        END AS scrubbed_morphospecies_binomial
1607
   FROM ("ValidMatchedTaxon"
1608
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1609

    
1610

    
1611
--
1612
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1613
--
1614

    
1615
COMMENT ON VIEW taxon_scrub IS '
1616
to modify:
1617
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1618
SELECT __
1619
$$);
1620
';
1621

    
1622

    
1623
--
1624
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1625
--
1626

    
1627
ALTER TABLE ONLY batch_download_settings
1628
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1629

    
1630

    
1631
--
1632
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1633
--
1634

    
1635
ALTER TABLE ONLY batch
1636
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1637

    
1638

    
1639
--
1640
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1641
--
1642

    
1643
ALTER TABLE ONLY batch
1644
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1645

    
1646

    
1647
--
1648
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1649
--
1650

    
1651
ALTER TABLE ONLY client_version
1652
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1653

    
1654

    
1655
--
1656
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1657
--
1658

    
1659
ALTER TABLE ONLY taxon_match
1660
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1661

    
1662
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1663

    
1664

    
1665
--
1666
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1667
--
1668

    
1669
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1670

    
1671

    
1672
--
1673
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1674
--
1675

    
1676
CREATE INDEX taxon_best_match__valid_match ON taxon_match USING btree ("*Name_submitted") WHERE (("*Selected" = 'true'::text) AND is_valid_match);
1677

    
1678

    
1679
--
1680
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1681
--
1682

    
1683
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
1684

    
1685

    
1686
--
1687
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1688
--
1689

    
1690
CREATE UNIQUE INDEX taxon_match__one_selected_match ON taxon_match USING btree (batch, "*Name_number") WHERE ("*Selected" = 'true'::text);
1691

    
1692

    
1693
--
1694
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1695
--
1696

    
1697
CREATE TRIGGER batch__fill BEFORE INSERT OR UPDATE ON batch FOR EACH ROW EXECUTE PROCEDURE batch__fill();
1698

    
1699

    
1700
--
1701
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
1702
--
1703

    
1704
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
1705

    
1706

    
1707
--
1708
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1709
--
1710

    
1711
CREATE TRIGGER taxon_match__fill BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill();
1712

    
1713

    
1714
--
1715
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
1716
--
1717

    
1718
CREATE TRIGGER taxon_match__fill_derived BEFORE INSERT OR UPDATE ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__fill_derived();
1719

    
1720

    
1721
--
1722
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1723
--
1724

    
1725
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
1726

    
1727

    
1728
--
1729
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
1730
--
1731

    
1732
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();
1733

    
1734

    
1735
--
1736
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1737
--
1738

    
1739
ALTER TABLE ONLY batch
1740
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
1741

    
1742

    
1743
--
1744
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1745
--
1746

    
1747
ALTER TABLE ONLY batch_download_settings
1748
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1749

    
1750

    
1751
--
1752
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
1753
--
1754

    
1755
ALTER TABLE ONLY taxon_match
1756
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
1757

    
1758

    
1759
--
1760
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
1761
--
1762

    
1763
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
1764
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
1765
GRANT ALL ON SCHEMA "TNRS" TO bien;
1766
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
1767

    
1768

    
1769
--
1770
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
1771
--
1772

    
1773
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
1774
REVOKE ALL ON TABLE taxon_match FROM bien;
1775
GRANT ALL ON TABLE taxon_match TO bien;
1776
GRANT SELECT ON TABLE taxon_match TO bien_read;
1777

    
1778

    
1779
--
1780
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
1781
--
1782

    
1783
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
1784
REVOKE ALL ON TABLE taxon_best_match FROM bien;
1785
GRANT ALL ON TABLE taxon_best_match TO bien;
1786
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
1787

    
1788

    
1789
--
1790
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
1791
--
1792

    
1793
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
1794
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
1795
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
1796
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
1797

    
1798

    
1799
--
1800
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
1801
--
1802

    
1803
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
1804
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
1805
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
1806
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
1807

    
1808

    
1809
--
1810
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
1811
--
1812

    
1813
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
1814
REVOKE ALL ON TABLE taxon_match_input FROM bien;
1815
GRANT ALL ON TABLE taxon_match_input TO bien;
1816
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
1817

    
1818

    
1819
--
1820
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
1821
--
1822

    
1823
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
1824
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
1825
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
1826
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
1827

    
1828

    
1829
--
1830
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
1831
--
1832

    
1833
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
1834
REVOKE ALL ON TABLE taxon_scrub FROM bien;
1835
GRANT ALL ON TABLE taxon_scrub TO bien;
1836
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
1837

    
1838

    
1839
--
1840
-- PostgreSQL database dump complete
1841
--
1842

    
(7-7/9)