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: remove_prefix(text, text, boolean, boolean); Type: FUNCTION; Schema: TNRS; Owner: -
97
--
98

    
99
CREATE FUNCTION remove_prefix(prefix text, str text, require boolean DEFAULT true, case_sensitive boolean DEFAULT true) RETURNS text
100
    LANGUAGE sql IMMUTABLE
101
    AS $$
102
SELECT util.remove_prefix(prefix, str, require, case_sensitive)
103
$$;
104

    
105

    
106
--
107
-- Name: FUNCTION remove_prefix(prefix text, str text, require boolean, case_sensitive boolean); Type: COMMENT; Schema: TNRS; Owner: -
108
--
109

    
110
COMMENT ON FUNCTION remove_prefix(prefix text, str text, require boolean, case_sensitive boolean) IS '
111
wrapper that prevents views from getting dropped when the util schema is reinstalled
112
';
113

    
114

    
115
--
116
-- Name: taxon_match__batch_begin(); Type: FUNCTION; Schema: TNRS; Owner: -
117
--
118

    
119
CREATE FUNCTION taxon_match__batch_begin() RETURNS trigger
120
    LANGUAGE plpgsql
121
    AS $$
122
BEGIN
123
	PERFORM util.seq__reset('pg_temp.taxon_match__match_num__seq', 0);
124
	RETURN NULL;
125
END;
126
$$;
127

    
128

    
129
--
130
-- Name: taxon_match__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
131
--
132

    
133
CREATE FUNCTION taxon_match__fill() RETURNS trigger
134
    LANGUAGE plpgsql
135
    AS $$
136
BEGIN
137
	DECLARE
138
		"Specific_epithet_is_plant" boolean :=
139
			(CASE
140
			WHEN   new."*Infraspecific_epithet_matched"	 IS NOT NULL
141
				OR new."*Infraspecific_epithet_2_matched" IS NOT NULL
142
				OR new."*Specific_epithet_score" >= 0.9 -- fuzzy match
143
				THEN true
144
			ELSE NULL -- ambiguous
145
			END);
146
		never_homonym boolean = COALESCE(new."*Author_score" >= 0.6, false);
147
			-- author disambiguates
148
		family_is_homonym boolean = NOT never_homonym
149
			AND "TNRS".family_is_homonym(new."*Family_matched");
150
		genus_is_homonym  boolean = NOT never_homonym
151
			AND "TNRS".genus_is_homonym(new."*Genus_matched");
152
	BEGIN
153
		/* exclude homonyms because these are not valid matches (TNRS provides a
154
		name, but the name is not meaningful because it is not unambiguous) */
155
		new.is_valid_match = new."*Taxonomic_status" != 'Invalid'
156
			AND COALESCE(CASE
157
			WHEN new."*Family_score" = 1 AND NOT family_is_homonym -- exact match
158
				THEN true
159
			ELSE -- consider genus
160
				(CASE
161
				WHEN new."*Genus_score" =  1	   -- exact match
162
					THEN
163
					(CASE
164
					WHEN NOT genus_is_homonym THEN true
165
					ELSE "Specific_epithet_is_plant"
166
					END)
167
				WHEN new."*Genus_score" >= 0.85 -- fuzzy match
168
					THEN "Specific_epithet_is_plant"
169
				ELSE NULL -- ambiguous
170
				END)
171
			END, false);
172
	END;
173
	
174
	DECLARE
175
		matched_taxon_name_with_author text = NULLIF(concat_ws(' '
176
			, NULLIF(NULLIF(new."*Name_matched_accepted_family", 'Unknown'),
177
				new."*Name_matched")
178
			, NULLIF(new."*Name_matched", 'No suitable matches found.')
179
			, new."*Name_matched_author"
180
			), '');
181
		accepted_taxon_name_with_author text = NULLIF(concat_ws(' '
182
			, NULLIF(NULLIF(new."*Accepted_name_family", 'Unknown'),
183
				new."*Accepted_name")
184
			, new."*Accepted_name"
185
			, new."*Accepted_name_author"
186
			), '');
187
	BEGIN
188
		new.scrubbed_unique_taxon_name = COALESCE(
189
			accepted_taxon_name_with_author, matched_taxon_name_with_author);
190
	END;
191
	
192
	RETURN new;
193
END;
194
$$;
195

    
196

    
197
--
198
-- Name: FUNCTION taxon_match__fill(); Type: COMMENT; Schema: TNRS; Owner: -
199
--
200

    
201
COMMENT ON FUNCTION taxon_match__fill() IS '
202
IMPORTANT: when changing this function, you must regenerate the derived cols:
203
UPDATE "TNRS".taxon_match SET "Name_submitted" = "Name_submitted"
204
runtime: 30 min ("5564082 rows affected, 1918900 ms execution time")
205
VACUUM ANALYZE "TNRS".taxon_match -- to remove previous rows
206
runtime: 1.5 min ("92633 ms")
207
';
208

    
209

    
210
--
211
-- Name: taxon_match__fill_derived(); Type: FUNCTION; Schema: TNRS; Owner: -
212
--
213

    
214
CREATE FUNCTION taxon_match__fill_derived() RETURNS trigger
215
    LANGUAGE plpgsql
216
    AS $$
217
BEGIN
218
	-- clear derived cols so old values won't be used in calculations
219
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = NULL;
220
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
221
	new."matched~Name[_no_author]___@TNRS__@vegpath.org" = NULL;
222
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
223
	new.matched_has_accepted = NULL;
224
	new."Accepted_family__@TNRS__@vegpath.org" = NULL;
225
	new."Accepted_species[_binomial]__@TNRS__@vegpath.org" = NULL;
226
	new."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" = NULL;
227
	new."[accepted_]genus__@DwC__@vegpath.org" = NULL;
228
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = NULL;
229
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
230
	new.__accepted_infraspecific_label = NULL;
231
	new."__accepted_infraspecific_{rank,epithet}" = NULL;
232
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
233
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
234
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
235
	new."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" = NULL;
236
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = NULL;
237
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
238
	new."[scrubbed_]genus__@DwC__@vegpath.org" = NULL;
239
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = NULL;
240
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
241
	new."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = NULL;
242
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = NULL;
243
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = NULL;
244
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
245
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = NULL;
246
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = NULL;
247
	
248
	-- populate derived cols
249
	new."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" = (SELECT "*Unmatched_terms" FROM (SELECT new.*) new);
250
	new."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT ("*Genus_matched" || ' '::text) || "*Specific_epithet_matched" FROM (SELECT new.*) new);
251
	new."matched~Name[_no_author]___@TNRS__@vegpath.org" = (SELECT NULLIF("*Name_matched", 'No suitable matches found.'::text) FROM (SELECT new.*) new);
252
	new."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text) FROM (SELECT new.*) new);
253
	new.matched_has_accepted = (SELECT "*Accepted_name" IS NOT NULL FROM (SELECT new.*) new);
254
	new."Accepted_family__@TNRS__@vegpath.org" = (SELECT COALESCE("*Accepted_name_family",
255
CASE
256
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
257
    ELSE NULL::text
258
END) FROM (SELECT new.*) new);
259
	new."Accepted_species[_binomial]__@TNRS__@vegpath.org" = (SELECT rtrim("*Accepted_name_species", ' '::text) FROM (SELECT new.*) new);
260
	new."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" = (SELECT regexp_split_to_array("*Accepted_name", ' '::text) FROM (SELECT new.*) new);
261
	new."[accepted_]genus__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1] FROM (SELECT new.*) new);
262
	new."[accepted_]specificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2] FROM (SELECT new.*) new);
263
	new."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
264
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
265
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
266
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
267
END FROM (SELECT new.*) new);
268
	new.__accepted_infraspecific_label = (SELECT ltrim(NULLIF("TNRS".remove_prefix("Accepted_species[_binomial]__@TNRS__@vegpath.org", "*Accepted_name", require := true, case_sensitive := false), ''::text), ' '::text) FROM (SELECT new.*) new);
269
	new."__accepted_infraspecific_{rank,epithet}" = (SELECT NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], '{}'::text[]) FROM (SELECT new.*) new);
270
	new."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[1] FROM (SELECT new.*) new);
271
	new."[accepted_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT "__accepted_infraspecific_{rank,epithet}"[2] FROM (SELECT new.*) new);
272
	new."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT "*Accepted_name" || COALESCE((' '::text || "*Accepted_name_author"), ''::text) FROM (SELECT new.*) new);
273
	new."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" = (SELECT "TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name") FROM (SELECT new.*) new);
274
	new."[scrubbed_]taxonRank__@DwC__@vegpath.org" = (SELECT CASE
275
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
276
    ELSE "*Name_matched_rank"
277
END FROM (SELECT new.*) new);
278
	new."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
279
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
280
    ELSE "*Name_matched_accepted_family"
281
END FROM (SELECT new.*) new);
282
	new."[scrubbed_]genus__@DwC__@vegpath.org" = (SELECT CASE
283
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
284
    ELSE "*Genus_matched"
285
END FROM (SELECT new.*) new);
286
	new."[scrubbed_]specificEpithet__@DwC__@vegpath.org" = (SELECT CASE
287
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
288
    ELSE "*Specific_epithet_matched"
289
END FROM (SELECT new.*) new);
290
	new."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
291
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
292
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
293
END FROM (SELECT new.*) new);
294
	new."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" = (SELECT CASE
295
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'family'::text) THEN concat_ws(' '::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
296
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'genus'::text) THEN concat_ws(' '::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
297
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
298
END FROM (SELECT new.*) new);
299
	new."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" = (SELECT CASE
300
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
301
    ELSE "*Infraspecific_rank"
302
END FROM (SELECT new.*) new);
303
	new."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" = (SELECT CASE
304
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
305
    ELSE "*Infraspecific_epithet_matched"
306
END FROM (SELECT new.*) new);
307
	new."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
308
    WHEN matched_has_accepted THEN "*Accepted_name"
309
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
310
END FROM (SELECT new.*) new);
311
	new."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" = (SELECT CASE
312
    WHEN matched_has_accepted THEN "*Accepted_name_author"
313
    ELSE "*Name_matched_author"
314
END FROM (SELECT new.*) new);
315
	new."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" = (SELECT CASE
316
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
317
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
318
END FROM (SELECT new.*) new);
319
	
320
	RETURN new;
321
END;
322
$$;
323

    
324

    
325
--
326
-- Name: FUNCTION taxon_match__fill_derived(); Type: COMMENT; Schema: TNRS; Owner: -
327
--
328

    
329
COMMENT ON FUNCTION taxon_match__fill_derived() IS '
330
autogenerated, do not edit
331

    
332
to regenerate:
333
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
334
';
335

    
336

    
337
--
338
-- Name: taxon_match__match_num__fill(); Type: FUNCTION; Schema: TNRS; Owner: -
339
--
340

    
341
CREATE FUNCTION taxon_match__match_num__fill() RETURNS trigger
342
    LANGUAGE plpgsql
343
    AS $$
344
BEGIN
345
	IF new.match_num IS NULL THEN
346
		new.match_num = "TNRS".taxon_match__match_num__next();
347
	END IF;
348
	RETURN new;
349
END;
350
$$;
351

    
352

    
353
--
354
-- Name: taxon_match__match_num__next(); Type: FUNCTION; Schema: TNRS; Owner: -
355
--
356

    
357
CREATE FUNCTION taxon_match__match_num__next() RETURNS bigint
358
    LANGUAGE sql
359
    AS $$
360
SELECT nextval('pg_temp.taxon_match__match_num__seq');
361
$$;
362

    
363

    
364
--
365
-- Name: taxon_match_input__copy_to__insert(); Type: FUNCTION; Schema: TNRS; Owner: -
366
--
367

    
368
CREATE FUNCTION taxon_match_input__copy_to__insert() RETURNS trigger
369
    LANGUAGE plpgsql
370
    AS $$
371
BEGIN
372
	INSERT INTO "TNRS".taxon_match_input SELECT new.*;
373
	RETURN NULL;
374
END;
375
$$;
376

    
377

    
378
--
379
-- Name: taxon_name_is_safe(text); Type: FUNCTION; Schema: TNRS; Owner: -
380
--
381

    
382
CREATE FUNCTION taxon_name_is_safe(taxon_name text) RETURNS boolean
383
    LANGUAGE sql IMMUTABLE
384
    AS $_$
385
SELECT NOT ($1 = ANY("TNRS".unsafe_taxon_names()))
386
$_$;
387

    
388

    
389
--
390
-- Name: unsafe_taxon_names(); Type: FUNCTION; Schema: TNRS; Owner: -
391
--
392

    
393
CREATE FUNCTION unsafe_taxon_names() RETURNS text[]
394
    LANGUAGE sql IMMUTABLE
395
    AS $$
396
SELECT ARRAY[
397
]::text[]
398
$$;
399

    
400

    
401
SET default_tablespace = '';
402

    
403
SET default_with_oids = false;
404

    
405
--
406
-- Name: taxon_match; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
407
--
408

    
409
CREATE TABLE taxon_match (
410
    batch text DEFAULT now() NOT NULL,
411
    match_num integer NOT NULL,
412
    "*Name_number" integer NOT NULL,
413
    "*Name_submitted" text NOT NULL,
414
    "*Overall_score" double precision,
415
    "*Name_matched" text,
416
    "*Name_matched_rank" text,
417
    "*Name_score" double precision,
418
    "*Name_matched_author" text,
419
    "*Name_matched_url" text,
420
    "*Author_matched" text,
421
    "*Author_score" double precision,
422
    "*Family_matched" text,
423
    "*Family_score" double precision,
424
    "*Name_matched_accepted_family" text,
425
    "*Genus_matched" text,
426
    "*Genus_score" double precision,
427
    "*Specific_epithet_matched" text,
428
    "*Specific_epithet_score" double precision,
429
    "*Infraspecific_rank" text,
430
    "*Infraspecific_epithet_matched" text,
431
    "*Infraspecific_epithet_score" double precision,
432
    "*Infraspecific_rank_2" text,
433
    "*Infraspecific_epithet_2_matched" text,
434
    "*Infraspecific_epithet_2_score" double precision,
435
    "*Annotations" text,
436
    "*Unmatched_terms" text,
437
    "*Taxonomic_status" text,
438
    "*Accepted_name" text,
439
    "*Accepted_name_author" text,
440
    "*Accepted_name_rank" text,
441
    "*Accepted_name_url" text,
442
    "*Accepted_name_species" text,
443
    "*Accepted_name_family" text,
444
    "*Selected" text,
445
    "*Source" text,
446
    "*Warnings" text,
447
    "*Accepted_name_lsid" text,
448
    is_valid_match boolean NOT NULL,
449
    scrubbed_unique_taxon_name text,
450
    "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" text,
451
    "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org" text,
452
    "matched~Name[_no_author]___@TNRS__@vegpath.org" text,
453
    "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" text,
454
    matched_has_accepted boolean,
455
    "Accepted_family__@TNRS__@vegpath.org" text,
456
    "Accepted_species[_binomial]__@TNRS__@vegpath.org" text,
457
    "__accepted_{genus,specific_epithet,infra_{rank,epithet}}" text[],
458
    "[accepted_]genus__@DwC__@vegpath.org" text,
459
    "[accepted_]specificEpithet__@DwC__@vegpath.org" text,
460
    "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
461
    "__accepted_infraspecific_{rank,epithet}" text[],
462
    "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
463
    "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" text,
464
    "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org" text,
465
    "[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" text,
466
    "[scrubbed_]taxonRank__@DwC__@vegpath.org" text,
467
    "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" text,
468
    "[scrubbed_]genus__@DwC__@vegpath.org" text,
469
    "[scrubbed_]specificEpithet__@DwC__@vegpath.org" text,
470
    "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" text,
471
    "[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" text,
472
    "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" text,
473
    "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" text,
474
    "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" text,
475
    "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" text,
476
    "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" text,
477
    CONSTRAINT "Accepted_family__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_family__@TNRS__@vegpath.org" IS DISTINCT FROM COALESCE("*Accepted_name_family",
478
CASE
479
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN "*Accepted_name"
480
    ELSE NULL::text
481
END)))),
482
    CONSTRAINT "Accepted_species[_binomial]__@TNRS__@vegpath.org" CHECK ((NOT ("Accepted_species[_binomial]__@TNRS__@vegpath.org" IS DISTINCT FROM rtrim("*Accepted_name_species", ' '::text)))),
483
    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]))),
484
    CONSTRAINT "[accepted_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]genus__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]))),
485
    CONSTRAINT "[accepted_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_infraspecific_{rank,epithet}"[2]))),
486
    CONSTRAINT "[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
487
CASE
488
    WHEN ("*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
489
    WHEN ("*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
490
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
491
END))),
492
    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))))),
493
    CONSTRAINT "[accepted_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[accepted_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]))),
494
    CONSTRAINT "[matched_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM ("matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE((' '::text || "*Name_matched_author"), ''::text))))),
495
    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")))),
496
    CONSTRAINT "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" CHECK ((NOT ("[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS DISTINCT FROM "*Unmatched_terms"))),
497
    CONSTRAINT "[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS DISTINCT FROM
498
CASE
499
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
500
    ELSE "*Infraspecific_rank"
501
END))),
502
    CONSTRAINT "[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
503
CASE
504
    WHEN matched_has_accepted THEN "*Accepted_name_author"
505
    ELSE "*Name_matched_author"
506
END))),
507
    CONSTRAINT "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
508
CASE
509
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
510
    ELSE "*Name_matched_accepted_family"
511
END))),
512
    CONSTRAINT "[scrubbed_]genus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]genus__@DwC__@vegpath.org" IS DISTINCT FROM
513
CASE
514
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
515
    ELSE "*Genus_matched"
516
END))),
517
    CONSTRAINT "[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
518
CASE
519
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
520
    ELSE "*Infraspecific_epithet_matched"
521
END))),
522
    CONSTRAINT "[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" CHECK ((NOT ("[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS DISTINCT FROM
523
CASE
524
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'family'::text) THEN concat_ws(' '::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
525
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = 'genus'::text) THEN concat_ws(' '::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
526
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
527
END))),
528
    CONSTRAINT "[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
529
CASE
530
    WHEN matched_has_accepted THEN "*Accepted_name"
531
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
532
END))),
533
    CONSTRAINT "[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS DISTINCT FROM
534
CASE
535
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
536
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
537
END))),
538
    CONSTRAINT "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" CHECK ((NOT ("[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS DISTINCT FROM
539
CASE
540
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
541
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
542
END))),
543
    CONSTRAINT "[scrubbed_]specificEpithet__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS DISTINCT FROM
544
CASE
545
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
546
    ELSE "*Specific_epithet_matched"
547
END))),
548
    CONSTRAINT "[scrubbed_]taxonRank__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonRank__@DwC__@vegpath.org" IS DISTINCT FROM
549
CASE
550
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
551
    ELSE "*Name_matched_rank"
552
END))),
553
    CONSTRAINT "[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" CHECK ((NOT ("[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" IS DISTINCT FROM map_taxonomic_status("*Taxonomic_status", "*Accepted_name")))),
554
    CONSTRAINT "__accepted_infraspecific_{rank,epithet}" CHECK ((NOT ("__accepted_infraspecific_{rank,epithet}" IS DISTINCT FROM NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], '{}'::text[])))),
555
    CONSTRAINT "__accepted_{genus,specific_epithet,infra_{rank,epithet}}" CHECK ((NOT ("__accepted_{genus,specific_epithet,infra_{rank,epithet}}" IS DISTINCT FROM regexp_split_to_array("*Accepted_name", ' '::text)))),
556
    CONSTRAINT matched_has_accepted CHECK ((NOT (matched_has_accepted IS DISTINCT FROM ("*Accepted_name" IS NOT NULL)))),
557
    CONSTRAINT "matched~Name[_no_author]___@TNRS__@vegpath.org" CHECK ((NOT ("matched~Name[_no_author]___@TNRS__@vegpath.org" IS DISTINCT FROM NULLIF("*Name_matched", 'No suitable matches found.'::text))))
558
);
559

    
560

    
561
--
562
-- Name: TABLE taxon_match; Type: COMMENT; Schema: TNRS; Owner: -
563
--
564

    
565
COMMENT ON TABLE taxon_match IS '
566
whenever columns are renamed:
567
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
568

    
569
to port derived column changes to vegbiendev:
570
SELECT util.derived_cols_export(''"TNRS".taxon_match'');
571
# run the returned SQL on vegbiendev
572
	-- runtime: 30 min ("5564201 rows affected, 1624829 ms execution time")
573
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
574

    
575
to add a new derived column:
576
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''col''), $$
577
expr
578
$$));
579
SELECT util.derived_cols_populate(''"TNRS".taxon_match'');
580
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
581
$ make schemas/remake
582

    
583
to remove a derived column:
584
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''col''));
585
$ make schemas/remake
586

    
587
to remove a non-derived column:
588
SELECT util.drop_column((''"TNRS".taxon_match'', ''col''));
589
$ make schemas/remake
590

    
591
to move a derived column to the middle or to add a non-derived column:
592
make the changes in inputs/.TNRS/schema.sql
593
$ inputs/.TNRS/data.sql.run refresh # re-run TNRS; runtime: 1 min ("1m2.629s")
594
SELECT util.derived_cols_update(''"TNRS".taxon_match'');
595
SELECT util.derived_cols_repopulate(''"TNRS".taxon_match'');
596
SELECT util.recreate_view(''"TNRS".taxon_best_match'');
597
$ make schemas/remake
598

    
599
to add a constraint: runtime: 3 min ("173620 ms")
600
';
601

    
602

    
603
--
604
-- Name: COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
605
--
606

    
607
COMMENT ON COLUMN taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org" IS '
608
= "*Unmatched_terms"
609

    
610
derived column
611

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

    
616
to rename:
617
# rename column
618
# rename CHECK constraint
619
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
620

    
621
to drop:
622
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org'')::util.col);
623
	-- DROP __ CASCADE doesn''t work when there are dependent views
624
';
625

    
626

    
627
--
628
-- Name: COLUMN taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
629
--
630

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

    
634
derived column
635

    
636
to modify expr:
637
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);
638
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
639

    
640
to rename:
641
# rename column
642
# rename CHECK constraint
643
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
644

    
645
to drop:
646
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
647
	-- DROP __ CASCADE doesn''t work when there are dependent views
648
';
649

    
650

    
651
--
652
-- Name: COLUMN taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
653
--
654

    
655
COMMENT ON COLUMN taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org" IS '
656
= NULLIF("*Name_matched", ''No suitable matches found.''::text)
657

    
658
derived column
659

    
660
to modify expr:
661
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched~Name[_no_author]___@TNRS__@vegpath.org'')::util.col, $$NULLIF("*Name_matched", ''No suitable matches found.''::text)$$)::util.derived_col_def);
662
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
663

    
664
to rename:
665
# rename column
666
# rename CHECK constraint
667
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
668

    
669
to drop:
670
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''matched~Name[_no_author]___@TNRS__@vegpath.org'')::util.col);
671
	-- DROP __ CASCADE doesn''t work when there are dependent views
672
';
673

    
674

    
675
--
676
-- Name: COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
677
--
678

    
679
COMMENT ON COLUMN taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
680
= "matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)
681

    
682
derived column
683

    
684
to modify expr:
685
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$"matched~Name[_no_author]___@TNRS__@vegpath.org" || COALESCE(('' ''::text || "*Name_matched_author"), ''''::text)$$)::util.derived_col_def);
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
to drop:
694
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[matched_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
695
	-- DROP __ CASCADE doesn''t work when there are dependent views
696
';
697

    
698

    
699
--
700
-- Name: COLUMN taxon_match.matched_has_accepted; Type: COMMENT; Schema: TNRS; Owner: -
701
--
702

    
703
COMMENT ON COLUMN taxon_match.matched_has_accepted IS '
704
= "*Accepted_name" IS NOT NULL
705

    
706
derived column
707

    
708
to modify expr:
709
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col, $$"*Accepted_name" IS NOT NULL$$)::util.derived_col_def);
710
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
711

    
712
to rename:
713
# rename column
714
# rename CHECK constraint
715
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
716

    
717
to drop:
718
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''matched_has_accepted'')::util.col);
719
	-- DROP __ CASCADE doesn''t work when there are dependent views
720
';
721

    
722

    
723
--
724
-- Name: COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
725
--
726

    
727
COMMENT ON COLUMN taxon_match."Accepted_family__@TNRS__@vegpath.org" IS '
728
= COALESCE("*Accepted_name_family",
729
CASE
730
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
731
    ELSE NULL::text
732
END)
733

    
734
derived column
735

    
736
to modify expr:
737
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_family__@TNRS__@vegpath.org'')::util.col, $$COALESCE("*Accepted_name_family",
738
CASE
739
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN "*Accepted_name"
740
    ELSE NULL::text
741
END)$$)::util.derived_col_def);
742
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
743

    
744
to rename:
745
# rename column
746
# rename CHECK constraint
747
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
748

    
749
to drop:
750
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''Accepted_family__@TNRS__@vegpath.org'')::util.col);
751
	-- DROP __ CASCADE doesn''t work when there are dependent views
752
';
753

    
754

    
755
--
756
-- Name: COLUMN taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
757
--
758

    
759
COMMENT ON COLUMN taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org" IS '
760
= rtrim("*Accepted_name_species", '' ''::text)
761

    
762
derived column
763

    
764
to modify expr:
765
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''Accepted_species[_binomial]__@TNRS__@vegpath.org'')::util.col, $$rtrim("*Accepted_name_species", '' ''::text)$$)::util.derived_col_def);
766
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
767

    
768
to rename:
769
# rename column
770
# rename CHECK constraint
771
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
772

    
773
to drop:
774
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''Accepted_species[_binomial]__@TNRS__@vegpath.org'')::util.col);
775
	-- DROP __ CASCADE doesn''t work when there are dependent views
776
';
777

    
778

    
779
--
780
-- Name: COLUMN taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}"; Type: COMMENT; Schema: TNRS; Owner: -
781
--
782

    
783
COMMENT ON COLUMN taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}" IS '
784
= regexp_split_to_array("*Accepted_name", '' ''::text)
785

    
786
derived column
787

    
788
to modify expr:
789
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet,infra_{rank,epithet}}'')::util.col, $$regexp_split_to_array("*Accepted_name", '' ''::text)$$)::util.derived_col_def);
790
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
791

    
792
to rename:
793
# rename column
794
# rename CHECK constraint
795
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
796

    
797
to drop:
798
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''__accepted_{genus,specific_epithet,infra_{rank,epithet}}'')::util.col);
799
	-- DROP __ CASCADE doesn''t work when there are dependent views
800
';
801

    
802

    
803
--
804
-- Name: COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
805
--
806

    
807
COMMENT ON COLUMN taxon_match."[accepted_]genus__@DwC__@vegpath.org" IS '
808
= "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]
809

    
810
derived column
811

    
812
to modify expr:
813
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[1]$$)::util.derived_col_def);
814
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
815

    
816
to rename:
817
# rename column
818
# rename CHECK constraint
819
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
820

    
821
to drop:
822
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]genus__@DwC__@vegpath.org'')::util.col);
823
	-- DROP __ CASCADE doesn''t work when there are dependent views
824
';
825

    
826

    
827
--
828
-- Name: COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
829
--
830

    
831
COMMENT ON COLUMN taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org" IS '
832
= "__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]
833

    
834
derived column
835

    
836
to modify expr:
837
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$"__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[2]$$)::util.derived_col_def);
838
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
839

    
840
to rename:
841
# rename column
842
# rename CHECK constraint
843
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
844

    
845
to drop:
846
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]specificEpithet__@DwC__@vegpath.org'')::util.col);
847
	-- DROP __ CASCADE doesn''t work when there are dependent views
848
';
849

    
850

    
851
--
852
-- Name: COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
853
--
854

    
855
COMMENT ON COLUMN taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
856
= CASE
857
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
858
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
859
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
860
END
861

    
862
derived column
863

    
864
to modify expr:
865
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
866
    WHEN ("*Accepted_name_rank" = ''family''::text) THEN concat_ws('' ''::text, "Accepted_family__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
867
    WHEN ("*Accepted_name_rank" = ''genus''::text) THEN concat_ws('' ''::text, "[accepted_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
868
    ELSE "Accepted_species[_binomial]__@TNRS__@vegpath.org"
869
END$$)::util.derived_col_def);
870
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
871

    
872
to rename:
873
# rename column
874
# rename CHECK constraint
875
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
876

    
877
to drop:
878
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col);
879
	-- DROP __ CASCADE doesn''t work when there are dependent views
880
';
881

    
882

    
883
--
884
-- Name: COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}"; Type: COMMENT; Schema: TNRS; Owner: -
885
--
886

    
887
COMMENT ON COLUMN taxon_match."__accepted_infraspecific_{rank,epithet}" IS '
888
= NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], ''{}''::text[])
889

    
890
derived column
891

    
892
to modify expr:
893
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col, $$NULLIF("__accepted_{genus,specific_epithet,infra_{rank,epithet}}"[3:4], ''{}''::text[])$$)::util.derived_col_def);
894
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
895

    
896
to rename:
897
# rename column
898
# rename CHECK constraint
899
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
900

    
901
to drop:
902
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''__accepted_infraspecific_{rank,epithet}'')::util.col);
903
	-- DROP __ CASCADE doesn''t work when there are dependent views
904
';
905

    
906

    
907
--
908
-- Name: COLUMN taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
909
--
910

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

    
914
derived column
915

    
916
to modify expr:
917
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);
918
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
919

    
920
to rename:
921
# rename column
922
# rename CHECK constraint
923
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
924

    
925
to drop:
926
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col);
927
	-- DROP __ CASCADE doesn''t work when there are dependent views
928
';
929

    
930

    
931
--
932
-- Name: COLUMN taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
933
--
934

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

    
938
derived column
939

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

    
944
to rename:
945
# rename column
946
# rename CHECK constraint
947
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
948

    
949
to drop:
950
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col);
951
	-- DROP __ CASCADE doesn''t work when there are dependent views
952
';
953

    
954

    
955
--
956
-- Name: COLUMN taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
957
--
958

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

    
962
derived column
963

    
964
to modify expr:
965
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);
966
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
967

    
968
to rename:
969
# rename column
970
# rename CHECK constraint
971
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
972

    
973
to drop:
974
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[accepted_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
975
	-- DROP __ CASCADE doesn''t work when there are dependent views
976
';
977

    
978

    
979
--
980
-- Name: COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
981
--
982

    
983
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org" IS '
984
= "TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name")
985

    
986
derived column
987

    
988
to modify expr:
989
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonomicStatus__@DwC__@vegpath.org'')::util.col, $$"TNRS".map_taxonomic_status("*Taxonomic_status", "*Accepted_name")$$)::util.derived_col_def);
990
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
991

    
992
to rename:
993
# rename column
994
# rename CHECK constraint
995
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
996

    
997
to drop:
998
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]taxonomicStatus__@DwC__@vegpath.org'')::util.col);
999
	-- DROP __ CASCADE doesn''t work when there are dependent views
1000
';
1001

    
1002

    
1003
--
1004
-- Name: COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1005
--
1006

    
1007
COMMENT ON COLUMN taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org" IS '
1008
= CASE
1009
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
1010
    ELSE "*Name_matched_rank"
1011
END
1012

    
1013
derived column
1014

    
1015
to modify expr:
1016
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col, $$CASE
1017
    WHEN matched_has_accepted THEN "*Accepted_name_rank"
1018
    ELSE "*Name_matched_rank"
1019
END$$)::util.derived_col_def);
1020
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1021

    
1022
to rename:
1023
# rename column
1024
# rename CHECK constraint
1025
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1026

    
1027
to drop:
1028
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]taxonRank__@DwC__@vegpath.org'')::util.col);
1029
	-- DROP __ CASCADE doesn''t work when there are dependent views
1030
';
1031

    
1032

    
1033
--
1034
-- Name: COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1035
--
1036

    
1037
COMMENT ON COLUMN taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1038
= CASE
1039
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
1040
    ELSE "*Name_matched_accepted_family"
1041
END
1042

    
1043
derived column
1044

    
1045
to modify expr:
1046
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1047
    WHEN matched_has_accepted THEN "Accepted_family__@TNRS__@vegpath.org"
1048
    ELSE "*Name_matched_accepted_family"
1049
END$$)::util.derived_col_def);
1050
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1051

    
1052
to rename:
1053
# rename column
1054
# rename CHECK constraint
1055
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1056

    
1057
to drop:
1058
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1059
	-- DROP __ CASCADE doesn''t work when there are dependent views
1060
';
1061

    
1062

    
1063
--
1064
-- Name: COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1065
--
1066

    
1067
COMMENT ON COLUMN taxon_match."[scrubbed_]genus__@DwC__@vegpath.org" IS '
1068
= CASE
1069
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1070
    ELSE "*Genus_matched"
1071
END
1072

    
1073
derived column
1074

    
1075
to modify expr:
1076
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col, $$CASE
1077
    WHEN matched_has_accepted THEN "[accepted_]genus__@DwC__@vegpath.org"
1078
    ELSE "*Genus_matched"
1079
END$$)::util.derived_col_def);
1080
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1081

    
1082
to rename:
1083
# rename column
1084
# rename CHECK constraint
1085
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1086

    
1087
to drop:
1088
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]genus__@DwC__@vegpath.org'')::util.col);
1089
	-- DROP __ CASCADE doesn''t work when there are dependent views
1090
';
1091

    
1092

    
1093
--
1094
-- Name: COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1095
--
1096

    
1097
COMMENT ON COLUMN taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org" IS '
1098
= CASE
1099
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1100
    ELSE "*Specific_epithet_matched"
1101
END
1102

    
1103
derived column
1104

    
1105
to modify expr:
1106
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1107
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1108
    ELSE "*Specific_epithet_matched"
1109
END$$)::util.derived_col_def);
1110
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1111

    
1112
to rename:
1113
# rename column
1114
# rename CHECK constraint
1115
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1116

    
1117
to drop:
1118
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]specificEpithet__@DwC__@vegpath.org'')::util.col);
1119
	-- DROP __ CASCADE doesn''t work when there are dependent views
1120
';
1121

    
1122

    
1123
--
1124
-- Name: COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1125
--
1126

    
1127
COMMENT ON COLUMN taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1128
= CASE
1129
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1130
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1131
END
1132

    
1133
derived column
1134

    
1135
to modify expr:
1136
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1137
    WHEN matched_has_accepted THEN "Accepted_species[_binomial]__@TNRS__@vegpath.org"
1138
    ELSE "[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org"
1139
END$$)::util.derived_col_def);
1140
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1141

    
1142
to rename:
1143
# rename column
1144
# rename CHECK constraint
1145
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1146

    
1147
to drop:
1148
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1149
	-- DROP __ CASCADE doesn''t work when there are dependent views
1150
';
1151

    
1152

    
1153
--
1154
-- Name: COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1155
--
1156

    
1157
COMMENT ON COLUMN taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org" IS '
1158
= CASE
1159
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1160
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1161
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1162
END
1163

    
1164
derived column
1165

    
1166
to modify expr:
1167
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col, $$CASE
1168
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''family''::text) THEN concat_ws('' ''::text, "[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1169
    WHEN ("[scrubbed_]taxonRank__@DwC__@vegpath.org" = ''genus''::text) THEN concat_ws('' ''::text, "[scrubbed_]genus__@DwC__@vegpath.org", "[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org")
1170
    ELSE "[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org"
1171
END$$)::util.derived_col_def);
1172
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1173

    
1174
to rename:
1175
# rename column
1176
# rename CHECK constraint
1177
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1178

    
1179
to drop:
1180
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org'')::util.col);
1181
	-- DROP __ CASCADE doesn''t work when there are dependent views
1182
';
1183

    
1184

    
1185
--
1186
-- Name: COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1187
--
1188

    
1189
COMMENT ON COLUMN taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org" IS '
1190
= CASE
1191
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1192
    ELSE "*Infraspecific_rank"
1193
END
1194

    
1195
derived column
1196

    
1197
to modify expr:
1198
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col, $$CASE
1199
    WHEN matched_has_accepted THEN "[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org"
1200
    ELSE "*Infraspecific_rank"
1201
END$$)::util.derived_col_def);
1202
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1203

    
1204
to rename:
1205
# rename column
1206
# rename CHECK constraint
1207
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1208

    
1209
to drop:
1210
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org'')::util.col);
1211
	-- DROP __ CASCADE doesn''t work when there are dependent views
1212
';
1213

    
1214

    
1215
--
1216
-- Name: COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1217
--
1218

    
1219
COMMENT ON COLUMN taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org" IS '
1220
= CASE
1221
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1222
    ELSE "*Infraspecific_epithet_matched"
1223
END
1224

    
1225
derived column
1226

    
1227
to modify expr:
1228
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col, $$CASE
1229
    WHEN matched_has_accepted THEN "[accepted_]specificEpithet__@DwC__@vegpath.org"
1230
    ELSE "*Infraspecific_epithet_matched"
1231
END$$)::util.derived_col_def);
1232
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1233

    
1234
to rename:
1235
# rename column
1236
# rename CHECK constraint
1237
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1238

    
1239
to drop:
1240
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org'')::util.col);
1241
	-- DROP __ CASCADE doesn''t work when there are dependent views
1242
';
1243

    
1244

    
1245
--
1246
-- Name: COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1247
--
1248

    
1249
COMMENT ON COLUMN taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1250
= CASE
1251
    WHEN matched_has_accepted THEN "*Accepted_name"
1252
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1253
END
1254

    
1255
derived column
1256

    
1257
to modify expr:
1258
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1259
    WHEN matched_has_accepted THEN "*Accepted_name"
1260
    ELSE "matched~Name[_no_author]___@TNRS__@vegpath.org"
1261
END$$)::util.derived_col_def);
1262
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1263

    
1264
to rename:
1265
# rename column
1266
# rename CHECK constraint
1267
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1268

    
1269
to drop:
1270
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1271
	-- DROP __ CASCADE doesn''t work when there are dependent views
1272
';
1273

    
1274

    
1275
--
1276
-- Name: COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1277
--
1278

    
1279
COMMENT ON COLUMN taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org" IS '
1280
= CASE
1281
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1282
    ELSE "*Name_matched_author"
1283
END
1284

    
1285
derived column
1286

    
1287
to modify expr:
1288
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col, $$CASE
1289
    WHEN matched_has_accepted THEN "*Accepted_name_author"
1290
    ELSE "*Name_matched_author"
1291
END$$)::util.derived_col_def);
1292
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1293

    
1294
to rename:
1295
# rename column
1296
# rename CHECK constraint
1297
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1298

    
1299
to drop:
1300
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org'')::util.col);
1301
	-- DROP __ CASCADE doesn''t work when there are dependent views
1302
';
1303

    
1304

    
1305
--
1306
-- Name: COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"; Type: COMMENT; Schema: TNRS; Owner: -
1307
--
1308

    
1309
COMMENT ON COLUMN taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org" IS '
1310
= CASE
1311
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1312
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1313
END
1314

    
1315
derived column
1316

    
1317
to modify expr:
1318
SELECT util.derived_col_update(((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col, $$CASE
1319
    WHEN matched_has_accepted THEN "[accepted_]scientificName[_with_author]__@DwC__@vegpath.org"
1320
    ELSE "[matched_]scientificName[_with_author]__@DwC__@vegpath.org"
1321
END$$)::util.derived_col_def);
1322
SELECT util.derived_cols_populate(''"TNRS".taxon_match''::regclass);
1323

    
1324
to rename:
1325
# rename column
1326
# rename CHECK constraint
1327
SELECT util.derived_cols_update(''"TNRS".taxon_match''::regclass);
1328

    
1329
to drop:
1330
SELECT util.drop_derived_col((''"TNRS".taxon_match'', ''[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org'')::util.col);
1331
	-- DROP __ CASCADE doesn''t work when there are dependent views
1332
';
1333

    
1334

    
1335
--
1336
-- Name: taxon_best_match; Type: VIEW; Schema: TNRS; Owner: -
1337
--
1338

    
1339
CREATE VIEW taxon_best_match AS
1340
 SELECT taxon_match.batch,
1341
    taxon_match.match_num,
1342
    taxon_match."*Name_number",
1343
    taxon_match."*Name_submitted",
1344
    taxon_match."*Overall_score",
1345
    taxon_match."*Name_matched",
1346
    taxon_match."*Name_matched_rank",
1347
    taxon_match."*Name_score",
1348
    taxon_match."*Name_matched_author",
1349
    taxon_match."*Name_matched_url",
1350
    taxon_match."*Author_matched",
1351
    taxon_match."*Author_score",
1352
    taxon_match."*Family_matched",
1353
    taxon_match."*Family_score",
1354
    taxon_match."*Name_matched_accepted_family",
1355
    taxon_match."*Genus_matched",
1356
    taxon_match."*Genus_score",
1357
    taxon_match."*Specific_epithet_matched",
1358
    taxon_match."*Specific_epithet_score",
1359
    taxon_match."*Infraspecific_rank",
1360
    taxon_match."*Infraspecific_epithet_matched",
1361
    taxon_match."*Infraspecific_epithet_score",
1362
    taxon_match."*Infraspecific_rank_2",
1363
    taxon_match."*Infraspecific_epithet_2_matched",
1364
    taxon_match."*Infraspecific_epithet_2_score",
1365
    taxon_match."*Annotations",
1366
    taxon_match."*Unmatched_terms",
1367
    taxon_match."*Taxonomic_status",
1368
    taxon_match."*Accepted_name",
1369
    taxon_match."*Accepted_name_author",
1370
    taxon_match."*Accepted_name_rank",
1371
    taxon_match."*Accepted_name_url",
1372
    taxon_match."*Accepted_name_species",
1373
    taxon_match."*Accepted_name_family",
1374
    taxon_match."*Selected",
1375
    taxon_match."*Source",
1376
    taxon_match."*Warnings",
1377
    taxon_match."*Accepted_name_lsid",
1378
    taxon_match.is_valid_match,
1379
    taxon_match.scrubbed_unique_taxon_name,
1380
    taxon_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1381
    taxon_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1382
    taxon_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1383
    taxon_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1384
    taxon_match.matched_has_accepted,
1385
    taxon_match."Accepted_family__@TNRS__@vegpath.org",
1386
    taxon_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1387
    taxon_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1388
    taxon_match."[accepted_]genus__@DwC__@vegpath.org",
1389
    taxon_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1390
    taxon_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1391
    taxon_match."__accepted_infraspecific_{rank,epithet}",
1392
    taxon_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1393
    taxon_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1394
    taxon_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1395
    taxon_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1396
    taxon_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1397
    taxon_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1398
    taxon_match."[scrubbed_]genus__@DwC__@vegpath.org",
1399
    taxon_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1400
    taxon_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1401
    taxon_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1402
    taxon_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1403
    taxon_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1404
    taxon_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1405
    taxon_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1406
    taxon_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org"
1407
   FROM taxon_match
1408
  WHERE (taxon_match."*Selected" = 'true'::text);
1409

    
1410

    
1411
--
1412
-- Name: VIEW taxon_best_match; Type: COMMENT; Schema: TNRS; Owner: -
1413
--
1414

    
1415
COMMENT ON VIEW taxon_best_match IS '
1416
to modify:
1417
SELECT util.recreate_view(''"TNRS"."taxon_best_match"'', $$
1418
SELECT __
1419
$$);
1420
';
1421

    
1422

    
1423
--
1424
-- Name: MatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1425
--
1426

    
1427
CREATE VIEW "MatchedTaxon" AS
1428
 SELECT taxon_best_match.batch,
1429
    taxon_best_match.match_num,
1430
    taxon_best_match."*Name_number",
1431
    taxon_best_match."*Name_submitted",
1432
    taxon_best_match."*Overall_score",
1433
    taxon_best_match."*Name_matched",
1434
    taxon_best_match."*Name_matched_rank",
1435
    taxon_best_match."*Name_score",
1436
    taxon_best_match."*Name_matched_author",
1437
    taxon_best_match."*Name_matched_url",
1438
    taxon_best_match."*Author_matched",
1439
    taxon_best_match."*Author_score",
1440
    taxon_best_match."*Family_matched",
1441
    taxon_best_match."*Family_score",
1442
    taxon_best_match."*Name_matched_accepted_family",
1443
    taxon_best_match."*Genus_matched",
1444
    taxon_best_match."*Genus_score",
1445
    taxon_best_match."*Specific_epithet_matched",
1446
    taxon_best_match."*Specific_epithet_score",
1447
    taxon_best_match."*Infraspecific_rank",
1448
    taxon_best_match."*Infraspecific_epithet_matched",
1449
    taxon_best_match."*Infraspecific_epithet_score",
1450
    taxon_best_match."*Infraspecific_rank_2",
1451
    taxon_best_match."*Infraspecific_epithet_2_matched",
1452
    taxon_best_match."*Infraspecific_epithet_2_score",
1453
    taxon_best_match."*Annotations",
1454
    taxon_best_match."*Unmatched_terms",
1455
    taxon_best_match."*Taxonomic_status",
1456
    taxon_best_match."*Accepted_name",
1457
    taxon_best_match."*Accepted_name_author",
1458
    taxon_best_match."*Accepted_name_rank",
1459
    taxon_best_match."*Accepted_name_url",
1460
    taxon_best_match."*Accepted_name_species",
1461
    taxon_best_match."*Accepted_name_family",
1462
    taxon_best_match."*Selected",
1463
    taxon_best_match."*Source",
1464
    taxon_best_match."*Warnings",
1465
    taxon_best_match."*Accepted_name_lsid",
1466
    taxon_best_match.is_valid_match,
1467
    taxon_best_match.scrubbed_unique_taxon_name,
1468
    taxon_best_match."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1469
    taxon_best_match."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1470
    taxon_best_match."matched~Name[_no_author]___@TNRS__@vegpath.org",
1471
    taxon_best_match."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1472
    taxon_best_match.matched_has_accepted,
1473
    taxon_best_match."Accepted_family__@TNRS__@vegpath.org",
1474
    taxon_best_match."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1475
    taxon_best_match."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1476
    taxon_best_match."[accepted_]genus__@DwC__@vegpath.org",
1477
    taxon_best_match."[accepted_]specificEpithet__@DwC__@vegpath.org",
1478
    taxon_best_match."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1479
    taxon_best_match."__accepted_infraspecific_{rank,epithet}",
1480
    taxon_best_match."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1481
    taxon_best_match."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1482
    taxon_best_match."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1483
    taxon_best_match."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1484
    taxon_best_match."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1485
    taxon_best_match."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1486
    taxon_best_match."[scrubbed_]genus__@DwC__@vegpath.org",
1487
    taxon_best_match."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1488
    taxon_best_match."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1489
    taxon_best_match."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1490
    taxon_best_match."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1491
    taxon_best_match."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1492
    taxon_best_match."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1493
    taxon_best_match."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1494
    taxon_best_match."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1495
    map_taxonomic_status(taxon_best_match."*Taxonomic_status", taxon_best_match."*Accepted_name") AS "taxonomicStatus",
1496
        CASE
1497
            WHEN (taxon_best_match."*Accepted_name_rank" = 'family'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name_family", taxon_best_match."*Unmatched_terms")
1498
            WHEN (taxon_best_match."*Accepted_name_rank" = 'genus'::text) THEN concat_ws(' '::text, taxon_best_match."*Accepted_name", taxon_best_match."*Unmatched_terms")
1499
            ELSE taxon_best_match."*Accepted_name_species"
1500
        END AS accepted_morphospecies_binomial
1501
   FROM taxon_best_match;
1502

    
1503

    
1504
--
1505
-- Name: VIEW "MatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1506
--
1507

    
1508
COMMENT ON VIEW "MatchedTaxon" IS '
1509
to modify:
1510
SELECT util.recreate_view(''"TNRS"."MatchedTaxon"'', $$
1511
SELECT __
1512
$$);
1513
';
1514

    
1515

    
1516
--
1517
-- Name: ValidMatchedTaxon; Type: VIEW; Schema: TNRS; Owner: -
1518
--
1519

    
1520
CREATE VIEW "ValidMatchedTaxon" AS
1521
 SELECT "MatchedTaxon".batch,
1522
    "MatchedTaxon".match_num,
1523
    "MatchedTaxon"."*Name_number",
1524
    "MatchedTaxon"."*Name_submitted",
1525
    "MatchedTaxon"."*Overall_score",
1526
    "MatchedTaxon"."*Name_matched",
1527
    "MatchedTaxon"."*Name_matched_rank",
1528
    "MatchedTaxon"."*Name_score",
1529
    "MatchedTaxon"."*Name_matched_author",
1530
    "MatchedTaxon"."*Name_matched_url",
1531
    "MatchedTaxon"."*Author_matched",
1532
    "MatchedTaxon"."*Author_score",
1533
    "MatchedTaxon"."*Family_matched",
1534
    "MatchedTaxon"."*Family_score",
1535
    "MatchedTaxon"."*Name_matched_accepted_family",
1536
    "MatchedTaxon"."*Genus_matched",
1537
    "MatchedTaxon"."*Genus_score",
1538
    "MatchedTaxon"."*Specific_epithet_matched",
1539
    "MatchedTaxon"."*Specific_epithet_score",
1540
    "MatchedTaxon"."*Infraspecific_rank",
1541
    "MatchedTaxon"."*Infraspecific_epithet_matched",
1542
    "MatchedTaxon"."*Infraspecific_epithet_score",
1543
    "MatchedTaxon"."*Infraspecific_rank_2",
1544
    "MatchedTaxon"."*Infraspecific_epithet_2_matched",
1545
    "MatchedTaxon"."*Infraspecific_epithet_2_score",
1546
    "MatchedTaxon"."*Annotations",
1547
    "MatchedTaxon"."*Unmatched_terms",
1548
    "MatchedTaxon"."*Taxonomic_status",
1549
    "MatchedTaxon"."*Accepted_name",
1550
    "MatchedTaxon"."*Accepted_name_author",
1551
    "MatchedTaxon"."*Accepted_name_rank",
1552
    "MatchedTaxon"."*Accepted_name_url",
1553
    "MatchedTaxon"."*Accepted_name_species",
1554
    "MatchedTaxon"."*Accepted_name_family",
1555
    "MatchedTaxon"."*Selected",
1556
    "MatchedTaxon"."*Source",
1557
    "MatchedTaxon"."*Warnings",
1558
    "MatchedTaxon"."*Accepted_name_lsid",
1559
    "MatchedTaxon".is_valid_match,
1560
    "MatchedTaxon".scrubbed_unique_taxon_name,
1561
    "MatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1562
    "MatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1563
    "MatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1564
    "MatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1565
    "MatchedTaxon".matched_has_accepted,
1566
    "MatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1567
    "MatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1568
    "MatchedTaxon"."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1569
    "MatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1570
    "MatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1571
    "MatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1572
    "MatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1573
    "MatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1574
    "MatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1575
    "MatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1576
    "MatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1577
    "MatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1578
    "MatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1579
    "MatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1580
    "MatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1581
    "MatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1582
    "MatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1583
    "MatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1584
    "MatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1585
    "MatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1586
    "MatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1587
    "MatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1588
    "MatchedTaxon"."taxonomicStatus",
1589
    "MatchedTaxon".accepted_morphospecies_binomial
1590
   FROM "MatchedTaxon"
1591
  WHERE "MatchedTaxon".is_valid_match;
1592

    
1593

    
1594
--
1595
-- Name: VIEW "ValidMatchedTaxon"; Type: COMMENT; Schema: TNRS; Owner: -
1596
--
1597

    
1598
COMMENT ON VIEW "ValidMatchedTaxon" IS '
1599
to update, use * as the column list
1600
';
1601

    
1602

    
1603
--
1604
-- Name: batch; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1605
--
1606

    
1607
CREATE TABLE batch (
1608
    id text NOT NULL,
1609
    id_by_time text,
1610
    time_submitted timestamp with time zone DEFAULT now(),
1611
    client_version text
1612
);
1613

    
1614

    
1615
--
1616
-- Name: batch_download_settings; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1617
--
1618

    
1619
CREATE TABLE batch_download_settings (
1620
    id text NOT NULL,
1621
    "E-mail" text,
1622
    "Id" text,
1623
    "Job type" text,
1624
    "Contains Id" boolean,
1625
    "Start time" text,
1626
    "Finish time" text,
1627
    "TNRS version" text,
1628
    "Sources selected" text,
1629
    "Match threshold" double precision,
1630
    "Classification" text,
1631
    "Allow partial matches?" boolean,
1632
    "Sort by source" boolean,
1633
    "Constrain by higher taxonomy" boolean
1634
);
1635

    
1636

    
1637
--
1638
-- Name: TABLE batch_download_settings; Type: COMMENT; Schema: TNRS; Owner: -
1639
--
1640

    
1641
COMMENT ON TABLE batch_download_settings IS '
1642
stores data from http://tnrs.iplantcollaborative.org/TNRSapp.html > Submit List > results section > Download settings > settings.txt
1643
';
1644

    
1645

    
1646
--
1647
-- Name: client_version; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1648
--
1649

    
1650
CREATE TABLE client_version (
1651
    id text NOT NULL,
1652
    global_rev integer NOT NULL,
1653
    "/lib/tnrs.py rev" integer,
1654
    "/bin/tnrs_db rev" integer
1655
);
1656

    
1657

    
1658
--
1659
-- Name: TABLE client_version; Type: COMMENT; Schema: TNRS; Owner: -
1660
--
1661

    
1662
COMMENT ON TABLE client_version IS '
1663
contains svn revisions
1664
';
1665

    
1666

    
1667
--
1668
-- Name: COLUMN client_version.global_rev; Type: COMMENT; Schema: TNRS; Owner: -
1669
--
1670

    
1671
COMMENT ON COLUMN client_version.global_rev IS '
1672
from `svn info .` > Last Changed Rev
1673
';
1674

    
1675

    
1676
--
1677
-- Name: COLUMN client_version."/lib/tnrs.py rev"; Type: COMMENT; Schema: TNRS; Owner: -
1678
--
1679

    
1680
COMMENT ON COLUMN client_version."/lib/tnrs.py rev" IS '
1681
from `svn info lib/tnrs.py` > Last Changed Rev
1682
';
1683

    
1684

    
1685
--
1686
-- Name: COLUMN client_version."/bin/tnrs_db rev"; Type: COMMENT; Schema: TNRS; Owner: -
1687
--
1688

    
1689
COMMENT ON COLUMN client_version."/bin/tnrs_db rev" IS '
1690
from `svn info bin/tnrs_db` > Last Changed Rev
1691
';
1692

    
1693

    
1694
--
1695
-- Name: taxon_match_input; Type: VIEW; Schema: TNRS; Owner: -
1696
--
1697

    
1698
CREATE VIEW taxon_match_input AS
1699
 SELECT taxon_match."*Name_number" AS "Name_number",
1700
    taxon_match."*Name_submitted" AS "Name_submitted",
1701
    taxon_match."*Overall_score" AS "Overall_score",
1702
    taxon_match."*Name_matched" AS "Name_matched",
1703
    taxon_match."*Name_matched_rank" AS "Name_matched_rank",
1704
    taxon_match."*Name_score" AS "Name_score",
1705
    taxon_match."*Name_matched_author" AS "Name_matched_author",
1706
    taxon_match."*Name_matched_url" AS "Name_matched_url",
1707
    taxon_match."*Author_matched" AS "Author_matched",
1708
    taxon_match."*Author_score" AS "Author_score",
1709
    taxon_match."*Family_matched" AS "Family_matched",
1710
    taxon_match."*Family_score" AS "Family_score",
1711
    taxon_match."*Name_matched_accepted_family" AS "Name_matched_accepted_family",
1712
    taxon_match."*Genus_matched" AS "Genus_matched",
1713
    taxon_match."*Genus_score" AS "Genus_score",
1714
    taxon_match."*Specific_epithet_matched" AS "Specific_epithet_matched",
1715
    taxon_match."*Specific_epithet_score" AS "Specific_epithet_score",
1716
    taxon_match."*Infraspecific_rank" AS "Infraspecific_rank",
1717
    taxon_match."*Infraspecific_epithet_matched" AS "Infraspecific_epithet_matched",
1718
    taxon_match."*Infraspecific_epithet_score" AS "Infraspecific_epithet_score",
1719
    taxon_match."*Infraspecific_rank_2" AS "Infraspecific_rank_2",
1720
    taxon_match."*Infraspecific_epithet_2_matched" AS "Infraspecific_epithet_2_matched",
1721
    taxon_match."*Infraspecific_epithet_2_score" AS "Infraspecific_epithet_2_score",
1722
    taxon_match."*Annotations" AS "Annotations",
1723
    taxon_match."*Unmatched_terms" AS "Unmatched_terms",
1724
    taxon_match."*Taxonomic_status" AS "Taxonomic_status",
1725
    taxon_match."*Accepted_name" AS "Accepted_name",
1726
    taxon_match."*Accepted_name_author" AS "Accepted_name_author",
1727
    taxon_match."*Accepted_name_rank" AS "Accepted_name_rank",
1728
    taxon_match."*Accepted_name_url" AS "Accepted_name_url",
1729
    taxon_match."*Accepted_name_species" AS "Accepted_name_species",
1730
    taxon_match."*Accepted_name_family" AS "Accepted_name_family",
1731
    taxon_match."*Selected" AS "Selected",
1732
    taxon_match."*Source" AS "Source",
1733
    taxon_match."*Warnings" AS "Warnings",
1734
    taxon_match."*Accepted_name_lsid" AS "Accepted_name_lsid"
1735
   FROM taxon_match;
1736

    
1737

    
1738
--
1739
-- Name: taxon_match_input__copy_to; Type: TABLE; Schema: TNRS; Owner: -; Tablespace: 
1740
--
1741

    
1742
CREATE TABLE taxon_match_input__copy_to (
1743
    "Name_number" integer,
1744
    "Name_submitted" text,
1745
    "Overall_score" double precision,
1746
    "Name_matched" text,
1747
    "Name_matched_rank" text,
1748
    "Name_score" double precision,
1749
    "Name_matched_author" text,
1750
    "Name_matched_url" text,
1751
    "Author_matched" text,
1752
    "Author_score" double precision,
1753
    "Family_matched" text,
1754
    "Family_score" double precision,
1755
    "Name_matched_accepted_family" text,
1756
    "Genus_matched" text,
1757
    "Genus_score" double precision,
1758
    "Specific_epithet_matched" text,
1759
    "Specific_epithet_score" double precision,
1760
    "Infraspecific_rank" text,
1761
    "Infraspecific_epithet_matched" text,
1762
    "Infraspecific_epithet_score" double precision,
1763
    "Infraspecific_rank_2" text,
1764
    "Infraspecific_epithet_2_matched" text,
1765
    "Infraspecific_epithet_2_score" double precision,
1766
    "Annotations" text,
1767
    "Unmatched_terms" text,
1768
    "Taxonomic_status" text,
1769
    "Accepted_name" text,
1770
    "Accepted_name_author" text,
1771
    "Accepted_name_rank" text,
1772
    "Accepted_name_url" text,
1773
    "Accepted_name_species" text,
1774
    "Accepted_name_family" text,
1775
    "Selected" text,
1776
    "Source" text,
1777
    "Warnings" text,
1778
    "Accepted_name_lsid" text
1779
);
1780

    
1781

    
1782
--
1783
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: VIEW; Schema: TNRS; Owner: -
1784
--
1785

    
1786
CREATE VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" AS
1787
 SELECT taxon_match."*Name_submitted" AS scrubbed_unique_taxon_name,
1788
    taxon_match."*Name_matched_rank" AS scrubbed_taxon_rank,
1789
    COALESCE(taxon_match."*Name_matched_accepted_family", taxon_match."*Family_matched") AS scrubbed_family,
1790
    taxon_match."*Genus_matched" AS scrubbed_genus,
1791
    taxon_match."*Specific_epithet_matched" AS scrubbed_specific_epithet,
1792
    taxon_match."*Infraspecific_rank" AS scrubbed_infraspecific_rank,
1793
    taxon_match."*Infraspecific_epithet_matched" AS scrubbed_infraspecific_epithet,
1794
    taxon_match."*Name_matched_author" AS scrubbed_author,
1795
    taxon_match."*Name_matched" AS scrubbed_taxon_name_no_author,
1796
    (taxon_match."*Name_matched" || COALESCE((' '::text || taxon_match."*Name_matched_author"), ''::text)) AS scrubbed_taxon_name_with_author
1797
   FROM taxon_match;
1798

    
1799

    
1800
--
1801
-- Name: VIEW "taxon_scrub.scrubbed_unique_taxon_name.*"; Type: COMMENT; Schema: TNRS; Owner: -
1802
--
1803

    
1804
COMMENT ON VIEW "taxon_scrub.scrubbed_unique_taxon_name.*" IS '
1805
to modify:
1806
SELECT util.recreate_view(''"TNRS"."taxon_scrub.scrubbed_unique_taxon_name.*"'', $$
1807
SELECT __
1808
$$);
1809

    
1810
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.
1811
';
1812

    
1813

    
1814
--
1815
-- Name: taxon_scrub; Type: VIEW; Schema: TNRS; Owner: -
1816
--
1817

    
1818
CREATE VIEW taxon_scrub AS
1819
 SELECT "ValidMatchedTaxon".scrubbed_unique_taxon_name,
1820
    "ValidMatchedTaxon".batch,
1821
    "ValidMatchedTaxon".match_num,
1822
    "ValidMatchedTaxon"."*Name_number",
1823
    "ValidMatchedTaxon"."*Name_submitted",
1824
    "ValidMatchedTaxon"."*Overall_score",
1825
    "ValidMatchedTaxon"."*Name_matched",
1826
    "ValidMatchedTaxon"."*Name_matched_rank",
1827
    "ValidMatchedTaxon"."*Name_score",
1828
    "ValidMatchedTaxon"."*Name_matched_author",
1829
    "ValidMatchedTaxon"."*Name_matched_url",
1830
    "ValidMatchedTaxon"."*Author_matched",
1831
    "ValidMatchedTaxon"."*Author_score",
1832
    "ValidMatchedTaxon"."*Family_matched",
1833
    "ValidMatchedTaxon"."*Family_score",
1834
    "ValidMatchedTaxon"."*Name_matched_accepted_family",
1835
    "ValidMatchedTaxon"."*Genus_matched",
1836
    "ValidMatchedTaxon"."*Genus_score",
1837
    "ValidMatchedTaxon"."*Specific_epithet_matched",
1838
    "ValidMatchedTaxon"."*Specific_epithet_score",
1839
    "ValidMatchedTaxon"."*Infraspecific_rank",
1840
    "ValidMatchedTaxon"."*Infraspecific_epithet_matched",
1841
    "ValidMatchedTaxon"."*Infraspecific_epithet_score",
1842
    "ValidMatchedTaxon"."*Infraspecific_rank_2",
1843
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_matched",
1844
    "ValidMatchedTaxon"."*Infraspecific_epithet_2_score",
1845
    "ValidMatchedTaxon"."*Annotations",
1846
    "ValidMatchedTaxon"."*Unmatched_terms",
1847
    "ValidMatchedTaxon"."*Taxonomic_status",
1848
    "ValidMatchedTaxon"."*Accepted_name",
1849
    "ValidMatchedTaxon"."*Accepted_name_author",
1850
    "ValidMatchedTaxon"."*Accepted_name_rank",
1851
    "ValidMatchedTaxon"."*Accepted_name_url",
1852
    "ValidMatchedTaxon"."*Accepted_name_species",
1853
    "ValidMatchedTaxon"."*Accepted_name_family",
1854
    "ValidMatchedTaxon"."*Selected",
1855
    "ValidMatchedTaxon"."*Source",
1856
    "ValidMatchedTaxon"."*Warnings",
1857
    "ValidMatchedTaxon"."*Accepted_name_lsid",
1858
    "ValidMatchedTaxon".is_valid_match,
1859
    "ValidMatchedTaxon"."[parsed_]morphospecies[_suffix]__@Brad__.morphosp@vegpath.org",
1860
    "ValidMatchedTaxon"."[matched_]species[_binomial]~(-Accepted_-)__@TNRS__@vegpath.org",
1861
    "ValidMatchedTaxon"."matched~Name[_no_author]___@TNRS__@vegpath.org",
1862
    "ValidMatchedTaxon"."[matched_]scientificName[_with_author]__@DwC__@vegpath.org",
1863
    "ValidMatchedTaxon".matched_has_accepted,
1864
    "ValidMatchedTaxon"."Accepted_family__@TNRS__@vegpath.org",
1865
    "ValidMatchedTaxon"."Accepted_species[_binomial]__@TNRS__@vegpath.org",
1866
    "ValidMatchedTaxon"."__accepted_{genus,specific_epithet,infra_{rank,epithet}}",
1867
    "ValidMatchedTaxon"."[accepted_]genus__@DwC__@vegpath.org",
1868
    "ValidMatchedTaxon"."[accepted_]specificEpithet__@DwC__@vegpath.org",
1869
    "ValidMatchedTaxon"."[accepted_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1870
    "ValidMatchedTaxon"."__accepted_infraspecific_{rank,epithet}",
1871
    "ValidMatchedTaxon"."[accepted_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1872
    "ValidMatchedTaxon"."[accepted_]infraspecificEpithet__@DwC__@vegpath.org",
1873
    "ValidMatchedTaxon"."[accepted_]scientificName[_with_author]__@DwC__@vegpath.org",
1874
    "ValidMatchedTaxon"."[scrubbed_]taxonomicStatus__@DwC__@vegpath.org",
1875
    "ValidMatchedTaxon"."[scrubbed_]taxonRank__@DwC__@vegpath.org",
1876
    "ValidMatchedTaxon"."[scrubbed_]family~(-Accepted_-)__@TNRS__@vegpath.org",
1877
    "ValidMatchedTaxon"."[scrubbed_]genus__@DwC__@vegpath.org",
1878
    "ValidMatchedTaxon"."[scrubbed_]specificEpithet__@DwC__@vegpath.org",
1879
    "ValidMatchedTaxon"."[scrubbed_]species[_binom]~(-Accepted_-)__@TNRS__@vegpath.org",
1880
    "ValidMatchedTaxon"."[scrubbed_]morphospecies[_binomial]__@Brad__.TNRS@vegpath.org",
1881
    "ValidMatchedTaxon"."[scrubbed_]Infraspecific_rank[_abbr]__@TNRS__@vegpath.org",
1882
    "ValidMatchedTaxon"."[scrubbed_]infraspecificEpithet__@DwC__@vegpath.org",
1883
    "ValidMatchedTaxon"."[scrubbed_]name[_no_author]~(-Accepted_-)__@TNRS__@vegpath.org",
1884
    "ValidMatchedTaxon"."[scrubbed_]author~(-Accepted_-)__@TNRS__@vegpath.org",
1885
    "ValidMatchedTaxon"."[scrubbed_]scientificName[_with_author]__@DwC__@vegpath.org",
1886
    "ValidMatchedTaxon"."taxonomicStatus",
1887
    "ValidMatchedTaxon".accepted_morphospecies_binomial,
1888
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_rank,
1889
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_family,
1890
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus,
1891
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet,
1892
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_rank,
1893
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_infraspecific_epithet,
1894
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_author,
1895
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_no_author,
1896
    "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_taxon_name_with_author,
1897
        CASE
1898
            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")
1899
            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")
1900
            ELSE (("taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_genus || ' '::text) || "taxon_scrub.scrubbed_unique_taxon_name.*".scrubbed_specific_epithet)
1901
        END AS scrubbed_morphospecies_binomial
1902
   FROM ("ValidMatchedTaxon"
1903
   LEFT JOIN "taxon_scrub.scrubbed_unique_taxon_name.*" USING (scrubbed_unique_taxon_name));
1904

    
1905

    
1906
--
1907
-- Name: VIEW taxon_scrub; Type: COMMENT; Schema: TNRS; Owner: -
1908
--
1909

    
1910
COMMENT ON VIEW taxon_scrub IS '
1911
to modify:
1912
SELECT util.recreate_view(''"TNRS".taxon_scrub'', $$
1913
SELECT __
1914
$$);
1915
';
1916

    
1917

    
1918
--
1919
-- Name: batch_download_settings_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1920
--
1921

    
1922
ALTER TABLE ONLY batch_download_settings
1923
    ADD CONSTRAINT batch_download_settings_pkey PRIMARY KEY (id);
1924

    
1925

    
1926
--
1927
-- Name: batch_id_by_time_key; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1928
--
1929

    
1930
ALTER TABLE ONLY batch
1931
    ADD CONSTRAINT batch_id_by_time_key UNIQUE (id_by_time);
1932

    
1933

    
1934
--
1935
-- Name: batch_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1936
--
1937

    
1938
ALTER TABLE ONLY batch
1939
    ADD CONSTRAINT batch_pkey PRIMARY KEY (id);
1940

    
1941

    
1942
--
1943
-- Name: client_version_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1944
--
1945

    
1946
ALTER TABLE ONLY client_version
1947
    ADD CONSTRAINT client_version_pkey PRIMARY KEY (id);
1948

    
1949

    
1950
--
1951
-- Name: taxon_match_pkey; Type: CONSTRAINT; Schema: TNRS; Owner: -; Tablespace: 
1952
--
1953

    
1954
ALTER TABLE ONLY taxon_match
1955
    ADD CONSTRAINT taxon_match_pkey PRIMARY KEY (batch, match_num);
1956

    
1957
ALTER TABLE taxon_match CLUSTER ON taxon_match_pkey;
1958

    
1959

    
1960
--
1961
-- Name: batch_client_version_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1962
--
1963

    
1964
CREATE INDEX batch_client_version_idx ON batch USING btree (client_version);
1965

    
1966

    
1967
--
1968
-- Name: taxon_best_match__valid_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1969
--
1970

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

    
1973

    
1974
--
1975
-- Name: taxon_match_Name_submitted_idx; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1976
--
1977

    
1978
CREATE INDEX "taxon_match_Name_submitted_idx" ON taxon_match USING btree ("*Name_submitted");
1979

    
1980

    
1981
--
1982
-- Name: taxon_match__one_selected_match; Type: INDEX; Schema: TNRS; Owner: -; Tablespace: 
1983
--
1984

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

    
1987

    
1988
--
1989
-- Name: batch__fill; Type: TRIGGER; Schema: TNRS; Owner: -
1990
--
1991

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

    
1994

    
1995
--
1996
-- Name: taxon_match__batch_begin; Type: TRIGGER; Schema: TNRS; Owner: -
1997
--
1998

    
1999
CREATE TRIGGER taxon_match__batch_begin BEFORE INSERT ON taxon_match_input__copy_to FOR EACH STATEMENT EXECUTE PROCEDURE taxon_match__batch_begin();
2000

    
2001

    
2002
--
2003
-- Name: taxon_match__fill; Type: TRIGGER; Schema: TNRS; Owner: -
2004
--
2005

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

    
2008

    
2009
--
2010
-- Name: taxon_match__fill_derived; Type: TRIGGER; Schema: TNRS; Owner: -
2011
--
2012

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

    
2015

    
2016
--
2017
-- Name: taxon_match__match_num__fill; Type: TRIGGER; Schema: TNRS; Owner: -
2018
--
2019

    
2020
CREATE TRIGGER taxon_match__match_num__fill BEFORE INSERT ON taxon_match FOR EACH ROW EXECUTE PROCEDURE taxon_match__match_num__fill();
2021

    
2022

    
2023
--
2024
-- Name: taxon_match_input__copy_to__insert; Type: TRIGGER; Schema: TNRS; Owner: -
2025
--
2026

    
2027
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();
2028

    
2029

    
2030
--
2031
-- Name: batch_client_version_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2032
--
2033

    
2034
ALTER TABLE ONLY batch
2035
    ADD CONSTRAINT batch_client_version_fkey FOREIGN KEY (client_version) REFERENCES client_version(id) ON UPDATE CASCADE ON DELETE CASCADE;
2036

    
2037

    
2038
--
2039
-- Name: batch_download_settings_id_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2040
--
2041

    
2042
ALTER TABLE ONLY batch_download_settings
2043
    ADD CONSTRAINT batch_download_settings_id_fkey FOREIGN KEY (id) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
2044

    
2045

    
2046
--
2047
-- Name: taxon_match_batch_fkey; Type: FK CONSTRAINT; Schema: TNRS; Owner: -
2048
--
2049

    
2050
ALTER TABLE ONLY taxon_match
2051
    ADD CONSTRAINT taxon_match_batch_fkey FOREIGN KEY (batch) REFERENCES batch(id) ON UPDATE CASCADE ON DELETE CASCADE;
2052

    
2053

    
2054
--
2055
-- Name: TNRS; Type: ACL; Schema: -; Owner: -
2056
--
2057

    
2058
REVOKE ALL ON SCHEMA "TNRS" FROM PUBLIC;
2059
REVOKE ALL ON SCHEMA "TNRS" FROM bien;
2060
GRANT ALL ON SCHEMA "TNRS" TO bien;
2061
GRANT USAGE ON SCHEMA "TNRS" TO bien_read;
2062

    
2063

    
2064
--
2065
-- Name: taxon_match; Type: ACL; Schema: TNRS; Owner: -
2066
--
2067

    
2068
REVOKE ALL ON TABLE taxon_match FROM PUBLIC;
2069
REVOKE ALL ON TABLE taxon_match FROM bien;
2070
GRANT ALL ON TABLE taxon_match TO bien;
2071
GRANT SELECT ON TABLE taxon_match TO bien_read;
2072

    
2073

    
2074
--
2075
-- Name: taxon_best_match; Type: ACL; Schema: TNRS; Owner: -
2076
--
2077

    
2078
REVOKE ALL ON TABLE taxon_best_match FROM PUBLIC;
2079
REVOKE ALL ON TABLE taxon_best_match FROM bien;
2080
GRANT ALL ON TABLE taxon_best_match TO bien;
2081
GRANT SELECT ON TABLE taxon_best_match TO bien_read;
2082

    
2083

    
2084
--
2085
-- Name: MatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2086
--
2087

    
2088
REVOKE ALL ON TABLE "MatchedTaxon" FROM PUBLIC;
2089
REVOKE ALL ON TABLE "MatchedTaxon" FROM bien;
2090
GRANT ALL ON TABLE "MatchedTaxon" TO bien;
2091
GRANT SELECT ON TABLE "MatchedTaxon" TO bien_read;
2092

    
2093

    
2094
--
2095
-- Name: ValidMatchedTaxon; Type: ACL; Schema: TNRS; Owner: -
2096
--
2097

    
2098
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM PUBLIC;
2099
REVOKE ALL ON TABLE "ValidMatchedTaxon" FROM bien;
2100
GRANT ALL ON TABLE "ValidMatchedTaxon" TO bien;
2101
GRANT SELECT ON TABLE "ValidMatchedTaxon" TO bien_read;
2102

    
2103

    
2104
--
2105
-- Name: taxon_match_input; Type: ACL; Schema: TNRS; Owner: -
2106
--
2107

    
2108
REVOKE ALL ON TABLE taxon_match_input FROM PUBLIC;
2109
REVOKE ALL ON TABLE taxon_match_input FROM bien;
2110
GRANT ALL ON TABLE taxon_match_input TO bien;
2111
GRANT SELECT ON TABLE taxon_match_input TO bien_read;
2112

    
2113

    
2114
--
2115
-- Name: taxon_scrub.scrubbed_unique_taxon_name.*; Type: ACL; Schema: TNRS; Owner: -
2116
--
2117

    
2118
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM PUBLIC;
2119
REVOKE ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" FROM bien;
2120
GRANT ALL ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien;
2121
GRANT SELECT ON TABLE "taxon_scrub.scrubbed_unique_taxon_name.*" TO bien_read;
2122

    
2123

    
2124
--
2125
-- Name: taxon_scrub; Type: ACL; Schema: TNRS; Owner: -
2126
--
2127

    
2128
REVOKE ALL ON TABLE taxon_scrub FROM PUBLIC;
2129
REVOKE ALL ON TABLE taxon_scrub FROM bien;
2130
GRANT ALL ON TABLE taxon_scrub TO bien;
2131
GRANT SELECT ON TABLE taxon_scrub TO bien_read;
2132

    
2133

    
2134
--
2135
-- PostgreSQL database dump complete
2136
--
2137

    
(7-7/9)