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

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

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

    
534

    
535
--
536
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
537
--
538

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

    
542
derived column
543

    
544
to modify expr:
545
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$("*Genus_matched" || '' ''::text) || "*Specific_epithet_matched"$$)::util.derived_col_def);
546
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
547

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

    
554

    
555
--
556
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
557
--
558

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

    
562
derived column
563

    
564
to modify expr:
565
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Name_matched" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
566
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
567

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

    
574

    
575
--
576
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
577
--
578

    
579
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
580
= "*Accepted_name" IS NOT NULL
581

    
582
derived column
583

    
584
to modify expr:
585
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
586
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
587

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

    
594

    
595
--
596
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
597
--
598

    
599
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet}" IS '
600
= regexp_split_to_array("*Accepted_name_species", '' ''::text)
601

    
602
derived column
603

    
604
to modify expr:
605
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet}'')::util.col, $$regexp_split_to_array("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
606
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
607

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

    
614

    
615
--
616
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
617
--
618

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

    
622
derived column
623

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

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

    
634

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

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

    
642
derived column
643

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

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

    
654

    
655
--
656
-- Name: COLUMN taxon_match.__accepted_infraspecific_label; Type: COMMENT; Schema: TNRS; Owner: -
657
--
658

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

    
662
derived column
663

    
664
to modify expr:
665
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_label'')::util.col, $$ltrim(NULLIF(util.remove_prefix("*Accepted_name_species", "*Accepted_name", require := true), ''''::text), '' ''::text)$$)::util.derived_col_def);
666
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
667

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

    
674

    
675
--
676
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
677
--
678

    
679
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
680
= regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)
681

    
682
derived column
683

    
684
to modify expr:
685
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$regexp_split_to_array(__accepted_infraspecific_label, '' ''::text)$$)::util.derived_col_def);
686
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
687

    
688
to rename:
689
# rename column
690
# rename CHECK constraint
691
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
692
';
693

    
694

    
695
--
696
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
697
--
698

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

    
702
derived column
703

    
704
to modify expr:
705
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$"__accepted_infraspecific_{rank,epithet}"[1]$$)::util.derived_col_def);
706
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
707

    
708
to rename:
709
# rename column
710
# rename CHECK constraint
711
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
712
';
713

    
714

    
715
--
716
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
717
--
718

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

    
722
derived column
723

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

    
728
to rename:
729
# rename column
730
# rename CHECK constraint
731
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
732
';
733

    
734

    
735
--
736
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
737
--
738

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

    
742
derived column
743

    
744
to modify expr:
745
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"*Accepted_name" || COALESCE(('' ''::text || "*Accepted_name_author"), ''''::text)$$)::util.derived_col_def);
746
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
747

    
748
to rename:
749
# rename column
750
# rename CHECK constraint
751
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
752
';
753

    
754

    
755
--
756
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
757
--
758

    
759
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
760
= CASE
761
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
762
    ELSE "*Name_matched_rank"
763
END
764

    
765
derived column
766

    
767
to modify expr:
768
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
769
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
770
    ELSE "*Name_matched_rank"
771
END$$)::util.derived_col_def);
772
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
773

    
774
to rename:
775
# rename column
776
# rename CHECK constraint
777
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
778
';
779

    
780

    
781
--
782
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
783
--
784

    
785
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
786
= CASE
787
    WHEN matched_has_accepted THEN "*Accepted_name_family"
788
    ELSE "*Name_matched_accepted_family"
789
END
790

    
791
derived column
792

    
793
to modify expr:
794
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
795
    WHEN matched_has_accepted THEN "*Accepted_name_family"
796
    ELSE "*Name_matched_accepted_family"
797
END$$)::util.derived_col_def);
798
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
799

    
800
to rename:
801
# rename column
802
# rename CHECK constraint
803
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
804
';
805

    
806

    
807
--
808
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
809
--
810

    
811
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
812
= CASE
813
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
814
    ELSE "*Genus_matched"
815
END
816

    
817
derived column
818

    
819
to modify expr:
820
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
821
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
822
    ELSE "*Genus_matched"
823
END$$)::util.derived_col_def);
824
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
825

    
826
to rename:
827
# rename column
828
# rename CHECK constraint
829
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
830
';
831

    
832

    
833
--
834
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
835
--
836

    
837
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
838
= CASE
839
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
840
    ELSE "*Specific_epithet_matched"
841
END
842

    
843
derived column
844

    
845
to modify expr:
846
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
847
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
848
    ELSE "*Specific_epithet_matched"
849
END$$)::util.derived_col_def);
850
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
851

    
852
to rename:
853
# rename column
854
# rename CHECK constraint
855
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
856
';
857

    
858

    
859
--
860
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
861
--
862

    
863
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
864
= CASE
865
    WHEN matched_has_accepted THEN "*Accepted_name_species"
866
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
867
END
868

    
869
derived column
870

    
871
to modify expr:
872
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
873
    WHEN matched_has_accepted THEN "*Accepted_name_species"
874
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
875
END$$)::util.derived_col_def);
876
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
877

    
878
to rename:
879
# rename column
880
# rename CHECK constraint
881
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
882
';
883

    
884

    
885
--
886
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
887
--
888

    
889
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
890
= CASE
891
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
892
    ELSE "*Infraspecific_rank"
893
END
894

    
895
derived column
896

    
897
to modify expr:
898
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
899
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
900
    ELSE "*Infraspecific_rank"
901
END$$)::util.derived_col_def);
902
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
903

    
904
to rename:
905
# rename column
906
# rename CHECK constraint
907
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
908
';
909

    
910

    
911
--
912
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
913
--
914

    
915
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
916
= CASE
917
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
918
    ELSE "*Infraspecific_epithet_matched"
919
END
920

    
921
derived column
922

    
923
to modify expr:
924
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
925
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
926
    ELSE "*Infraspecific_epithet_matched"
927
END$$)::util.derived_col_def);
928
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
929

    
930
to rename:
931
# rename column
932
# rename CHECK constraint
933
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
934
';
935

    
936

    
937
--
938
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
939
--
940

    
941
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
942
= CASE
943
    WHEN matched_has_accepted THEN "*Accepted_name"
944
    ELSE "*Name_matched"
945
END
946

    
947
derived column
948

    
949
to modify expr:
950
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
951
    WHEN matched_has_accepted THEN "*Accepted_name"
952
    ELSE "*Name_matched"
953
END$$)::util.derived_col_def);
954
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
955

    
956
to rename:
957
# rename column
958
# rename CHECK constraint
959
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
960
';
961

    
962

    
963
--
964
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
965
--
966

    
967
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
968
= CASE
969
    WHEN matched_has_accepted THEN "*Accepted_name_author"
970
    ELSE "*Name_matched_author"
971
END
972

    
973
derived column
974

    
975
to modify expr:
976
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
977
    WHEN matched_has_accepted THEN "*Accepted_name_author"
978
    ELSE "*Name_matched_author"
979
END$$)::util.derived_col_def);
980
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
981

    
982
to rename:
983
# rename column
984
# rename CHECK constraint
985
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
986
';
987

    
988

    
989
--
990
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
991
--
992

    
993
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
994
= CASE
995
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
996
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
997
END
998

    
999
derived column
1000

    
1001
to modify expr:
1002
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1003
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1004
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1005
END$$)::util.derived_col_def);
1006
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1007

    
1008
to rename:
1009
# rename column
1010
# rename CHECK constraint
1011
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1012
';
1013

    
1014

    
1015
--
1016
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1017
--
1018

    
1019
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
1020
= "*Unmatched_terms"
1021

    
1022
derived column
1023

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

    
1028
to rename:
1029
# rename column
1030
# rename CHECK constraint
1031
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1032
';
1033

    
1034

    
1035
--
1036
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1037
--
1038

    
1039
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1040
= CASE
1041
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1042
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1043
    ELSE "*Accepted_name_species"
1044
END
1045

    
1046
derived column
1047

    
1048
to modify expr:
1049
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1050
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "*Accepted_name_family", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1051
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "*Accepted_name", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1052
    ELSE "*Accepted_name_species"
1053
END$$)::util.derived_col_def);
1054
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1055

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

    
1062

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

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

    
1132

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

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

    
1144

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

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

    
1219

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

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

    
1231

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

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

    
1303

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

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

    
1312

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

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

    
1324

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

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

    
1346

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

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

    
1355

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

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

    
1367

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

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

    
1376

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

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

    
1385

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

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

    
1394

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

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

    
1403

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

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

    
1447

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

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

    
1491

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

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

    
1509

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

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

    
1520
scrubbed_family: Name_matched_accepted_family was missing from the TNRS results at one point, so Family_matched is used as a workaround to populate this. the workaround is for *accepted names only*, as no opinion names do not have an Accepted_name_family to prepend to the scrubbed name to parse.
1521
';
1522

    
1523

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

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

    
1609

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

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

    
1621

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

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

    
1629

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

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

    
1637

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

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

    
1645

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

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

    
1653

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

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

    
1661
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1662

    
1663

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

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

    
1670

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

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

    
1677

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

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

    
1684

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

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

    
1691

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

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

    
1698

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

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

    
1705

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

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

    
1712

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

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

    
1719

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

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

    
1726

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

    
1731
CREATE TRIGGER taxon_match_input__copy_to__insert BEFORE INSERT ON taxon_match_input__copy_to FOR EACH ROW EXECUTE PROCEDURE taxon_match_input__copy_to__insert();
1732

    
1733

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

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

    
1741

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

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

    
1749

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

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

    
1757

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

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

    
1767

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

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

    
1777

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

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

    
1787

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

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

    
1797

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

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

    
1807

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

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

    
1817

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

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

    
1827

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

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

    
1837

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

    
(7-7/9)