Project

General

Profile

« Previous | Next » 

Revision 14465

bugfix: schemas/public_.sql: *_view_modify(): need to set the search_path so that tables are created in the same schema as the function, rather than whichever schema happens to be at the beginning of the search_path

View differences:

trunk/schemas/vegbien.my.sql
1360 1360

  
1361 1361

  
1362 1362
--
1363
-- Name: geoscrub_input_view_modify(int(1)); Type: FUNCTION; Schema: public; Owner: -
1363
-- Name: geoscrub_input_view_modify(int(1), anyelement); Type: FUNCTION; Schema: public; Owner: -
1364 1364
--
1365 1365

  
1366 1366

  
......
1402 1402

  
1403 1403

  
1404 1404
--
1405
-- Name: iucn_red_list_view_modify(int(1)); Type: FUNCTION; Schema: public; Owner: -
1405
-- Name: iucn_red_list_view_modify(int(1), anyelement); Type: FUNCTION; Schema: public; Owner: -
1406 1406
--
1407 1407

  
1408 1408

  
......
1632 1632

  
1633 1633

  
1634 1634
--
1635
-- Name: provider_count_view_modify(int(1)); Type: FUNCTION; Schema: public; Owner: -
1635
-- Name: provider_count_view_modify(int(1), anyelement); Type: FUNCTION; Schema: public; Owner: -
1636 1636
--
1637 1637

  
1638 1638

  
......
1723 1723

  
1724 1724

  
1725 1725
--
1726
-- Name: taxon_trait_view_modify(int(1)); Type: FUNCTION; Schema: public; Owner: -
1726
-- Name: taxon_trait_view_modify(int(1), anyelement); Type: FUNCTION; Schema: public; Owner: -
1727 1727
--
1728 1728

  
1729 1729

  
......
1888 1888

  
1889 1889

  
1890 1890
--
1891
-- Name: viewFullOccurrence_individual_view_modify(int(1)); Type: FUNCTION; Schema: public; Owner: -
1891
-- Name: viewFullOccurrence_individual_view_modify(int(1), anyelement); Type: FUNCTION; Schema: public; Owner: -
1892 1892
--
1893 1893

  
1894 1894

  
trunk/schemas/public_.sql
2175 2175

  
2176 2176

  
2177 2177
--
2178
-- Name: geoscrub_input_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
2178
-- Name: geoscrub_input_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
2179 2179
--
2180 2180

  
2181
CREATE FUNCTION geoscrub_input_view_modify(repopulate boolean DEFAULT true) RETURNS void
2182
    LANGUAGE sql
2181
CREATE FUNCTION geoscrub_input_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2182
    LANGUAGE plpgsql
2183 2183
    AS $_$
2184
SELECT util.rematerialize_view('geoscrub_input', 'geoscrub_input_view', $$
2184
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2185
changes of search_path (schema elements are bound at inline time rather than
2186
runtime) */
2187
/* function option search_path is needed to limit the effects of
2188
`SET LOCAL search_path` to the current function */
2189
BEGIN
2190
	PERFORM util.use_schema(schema_anchor);
2191
	
2192
	PERFORM util.rematerialize_view('geoscrub_input', 'geoscrub_input_view', $$
2185 2193
GRANT SELECT ON TABLE geoscrub_input TO bien_read;
2186 2194
GRANT SELECT ON TABLE geoscrub_input_view TO bien_read;
2187 2195
$$, repopulate);
2196
END;
2188 2197
$_$;
2189 2198

  
2190 2199

  
......
2259 2268

  
2260 2269

  
2261 2270
--
2262
-- Name: iucn_red_list_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
2271
-- Name: iucn_red_list_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
2263 2272
--
2264 2273

  
2265
CREATE FUNCTION iucn_red_list_view_modify(repopulate boolean DEFAULT true) RETURNS void
2266
    LANGUAGE sql
2274
CREATE FUNCTION iucn_red_list_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2275
    LANGUAGE plpgsql
2267 2276
    AS $_$
2268
SELECT util.rematerialize_view('iucn_red_list', 'iucn_red_list_view', $$
2277
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2278
changes of search_path (schema elements are bound at inline time rather than
2279
runtime) */
2280
/* function option search_path is needed to limit the effects of
2281
`SET LOCAL search_path` to the current function */
2282
BEGIN
2283
	PERFORM util.use_schema(schema_anchor);
2284
	
2285
	PERFORM util.rematerialize_view('iucn_red_list', 'iucn_red_list_view', $$
2269 2286
ALTER TABLE iucn_red_list ADD PRIMARY KEY(accepted_family, accepted_species_binomial);
2270 2287
$$, repopulate);
2288
END;
2271 2289
$_$;
2272 2290

  
2273 2291

  
......
2815 2833

  
2816 2834

  
2817 2835
--
2818
-- Name: provider_count_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
2836
-- Name: provider_count_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
2819 2837
--
2820 2838

  
2821
CREATE FUNCTION provider_count_view_modify(repopulate boolean DEFAULT true) RETURNS void
2822
    LANGUAGE sql
2839
CREATE FUNCTION provider_count_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2840
    LANGUAGE plpgsql
2823 2841
    AS $_$
2824
SELECT util.rematerialize_view('provider_count', 'provider_count_view', $$
2842
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2843
changes of search_path (schema elements are bound at inline time rather than
2844
runtime) */
2845
/* function option search_path is needed to limit the effects of
2846
`SET LOCAL search_path` to the current function */
2847
BEGIN
2848
	PERFORM util.use_schema(schema_anchor);
2849
	
2850
	PERFORM util.rematerialize_view('provider_count', 'provider_count_view', $$
2825 2851
GRANT SELECT ON TABLE provider_count TO bien_read;
2826 2852
GRANT SELECT ON TABLE provider_count TO public_;
2827 2853
GRANT SELECT ON TABLE provider_count_view TO bien_read;
......
2829 2855

  
2830 2856
ALTER TABLE provider_count ADD PRIMARY KEY (dataprovider, dataset);
2831 2857
$$, repopulate);
2858
END;
2832 2859
$_$;
2833 2860

  
2834 2861

  
......
3040 3067

  
3041 3068

  
3042 3069
--
3043
-- Name: taxon_trait_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
3070
-- Name: taxon_trait_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
3044 3071
--
3045 3072

  
3046
CREATE FUNCTION taxon_trait_view_modify(repopulate boolean DEFAULT true) RETURNS void
3047
    LANGUAGE sql
3073
CREATE FUNCTION taxon_trait_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
3074
    LANGUAGE plpgsql
3048 3075
    AS $_$
3049
SELECT util.rematerialize_view('taxon_trait', 'taxon_trait_view', $$
3076
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
3077
changes of search_path (schema elements are bound at inline time rather than
3078
runtime) */
3079
/* function option search_path is needed to limit the effects of
3080
`SET LOCAL search_path` to the current function */
3081
BEGIN
3082
	PERFORM util.use_schema(schema_anchor);
3083
	
3084
	PERFORM util.rematerialize_view('taxon_trait', 'taxon_trait_view', $$
3050 3085
GRANT SELECT ON TABLE taxon_trait TO bien_read;
3051 3086
GRANT SELECT ON TABLE taxon_trait_view TO bien_read;
3052 3087

  
......
3055 3090

  
3056 3091
CREATE INDEX ON taxon_trait ("scientificName", "measurementType" );
3057 3092
$$, repopulate);
3093
END;
3058 3094
$_$;
3059 3095

  
3060 3096

  
......
3430 3466

  
3431 3467

  
3432 3468
--
3433
-- Name: viewFullOccurrence_individual_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
3469
-- Name: viewFullOccurrence_individual_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
3434 3470
--
3435 3471

  
3436
CREATE FUNCTION "viewFullOccurrence_individual_view_modify"(repopulate boolean DEFAULT true) RETURNS void
3437
    LANGUAGE sql
3472
CREATE FUNCTION "viewFullOccurrence_individual_view_modify"(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
3473
    LANGUAGE plpgsql
3438 3474
    AS $_$
3439
SELECT util.rematerialize_view('"viewFullOccurrence_individual"', '"viewFullOccurrence_individual_view"', $$
3475
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
3476
changes of search_path (schema elements are bound at inline time rather than
3477
runtime) */
3478
/* function option search_path is needed to limit the effects of
3479
`SET LOCAL search_path` to the current function */
3480
BEGIN
3481
	PERFORM util.use_schema(schema_anchor);
3482
	
3483
	PERFORM util.rematerialize_view('"viewFullOccurrence_individual"', '"viewFullOccurrence_individual_view"', $$
3440 3484
ALTER TABLE "viewFullOccurrence_individual" ADD COLUMN "TAXONOBSERVATION_ID__@VegBank__.taxonObservation@vegpath.org" serial PRIMARY KEY;
3441 3485
COMMENT ON COLUMN "viewFullOccurrence_individual"."TAXONOBSERVATION_ID__@VegBank__.taxonObservation@vegpath.org" IS 'VegBIEN-autogenerated "identifier assigned to each unique observation of a taxon in a plot"';
3442 3486

  
......
3451 3495
CREATE INDEX ON "viewFullOccurrence_individual" ("datasource__@Brad__.identifier_examples@vegpath.org", "projectID__@VegX__.plotObservation@vegpath.org", "locationID__@DwC__@vegpath.org", "eventDate__@DwC__@vegpath.org");
3452 3496
CREATE INDEX ON "viewFullOccurrence_individual" ("speciesBinomialWithMorphospecies__@VegCore__@vegpath.org");
3453 3497
$$, repopulate);
3498
END;
3454 3499
$_$;
3455 3500

  
3456 3501

  
trunk/schemas/vegbien.sql
2175 2175

  
2176 2176

  
2177 2177
--
2178
-- Name: geoscrub_input_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
2178
-- Name: geoscrub_input_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
2179 2179
--
2180 2180

  
2181
CREATE FUNCTION geoscrub_input_view_modify(repopulate boolean DEFAULT true) RETURNS void
2182
    LANGUAGE sql
2181
CREATE FUNCTION geoscrub_input_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2182
    LANGUAGE plpgsql
2183 2183
    AS $_$
2184
SELECT util.rematerialize_view('geoscrub_input', 'geoscrub_input_view', $$
2184
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2185
changes of search_path (schema elements are bound at inline time rather than
2186
runtime) */
2187
/* function option search_path is needed to limit the effects of
2188
`SET LOCAL search_path` to the current function */
2189
BEGIN
2190
	PERFORM util.use_schema(schema_anchor);
2191
	
2192
	PERFORM util.rematerialize_view('geoscrub_input', 'geoscrub_input_view', $$
2185 2193
GRANT SELECT ON TABLE geoscrub_input TO bien_read;
2186 2194
GRANT SELECT ON TABLE geoscrub_input_view TO bien_read;
2187 2195
$$, repopulate);
2196
END;
2188 2197
$_$;
2189 2198

  
2190 2199

  
......
2259 2268

  
2260 2269

  
2261 2270
--
2262
-- Name: iucn_red_list_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
2271
-- Name: iucn_red_list_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
2263 2272
--
2264 2273

  
2265
CREATE FUNCTION iucn_red_list_view_modify(repopulate boolean DEFAULT true) RETURNS void
2266
    LANGUAGE sql
2274
CREATE FUNCTION iucn_red_list_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2275
    LANGUAGE plpgsql
2267 2276
    AS $_$
2268
SELECT util.rematerialize_view('iucn_red_list', 'iucn_red_list_view', $$
2277
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2278
changes of search_path (schema elements are bound at inline time rather than
2279
runtime) */
2280
/* function option search_path is needed to limit the effects of
2281
`SET LOCAL search_path` to the current function */
2282
BEGIN
2283
	PERFORM util.use_schema(schema_anchor);
2284
	
2285
	PERFORM util.rematerialize_view('iucn_red_list', 'iucn_red_list_view', $$
2269 2286
ALTER TABLE iucn_red_list ADD PRIMARY KEY(accepted_family, accepted_species_binomial);
2270 2287
$$, repopulate);
2288
END;
2271 2289
$_$;
2272 2290

  
2273 2291

  
......
2815 2833

  
2816 2834

  
2817 2835
--
2818
-- Name: provider_count_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
2836
-- Name: provider_count_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
2819 2837
--
2820 2838

  
2821
CREATE FUNCTION provider_count_view_modify(repopulate boolean DEFAULT true) RETURNS void
2822
    LANGUAGE sql
2839
CREATE FUNCTION provider_count_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
2840
    LANGUAGE plpgsql
2823 2841
    AS $_$
2824
SELECT util.rematerialize_view('provider_count', 'provider_count_view', $$
2842
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
2843
changes of search_path (schema elements are bound at inline time rather than
2844
runtime) */
2845
/* function option search_path is needed to limit the effects of
2846
`SET LOCAL search_path` to the current function */
2847
BEGIN
2848
	PERFORM util.use_schema(schema_anchor);
2849
	
2850
	PERFORM util.rematerialize_view('provider_count', 'provider_count_view', $$
2825 2851
GRANT SELECT ON TABLE provider_count TO bien_read;
2826 2852
GRANT SELECT ON TABLE provider_count TO public_;
2827 2853
GRANT SELECT ON TABLE provider_count_view TO bien_read;
......
2829 2855

  
2830 2856
ALTER TABLE provider_count ADD PRIMARY KEY (dataprovider, dataset);
2831 2857
$$, repopulate);
2858
END;
2832 2859
$_$;
2833 2860

  
2834 2861

  
......
3040 3067

  
3041 3068

  
3042 3069
--
3043
-- Name: taxon_trait_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
3070
-- Name: taxon_trait_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
3044 3071
--
3045 3072

  
3046
CREATE FUNCTION taxon_trait_view_modify(repopulate boolean DEFAULT true) RETURNS void
3047
    LANGUAGE sql
3073
CREATE FUNCTION taxon_trait_view_modify(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
3074
    LANGUAGE plpgsql
3048 3075
    AS $_$
3049
SELECT util.rematerialize_view('taxon_trait', 'taxon_trait_view', $$
3076
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
3077
changes of search_path (schema elements are bound at inline time rather than
3078
runtime) */
3079
/* function option search_path is needed to limit the effects of
3080
`SET LOCAL search_path` to the current function */
3081
BEGIN
3082
	PERFORM util.use_schema(schema_anchor);
3083
	
3084
	PERFORM util.rematerialize_view('taxon_trait', 'taxon_trait_view', $$
3050 3085
GRANT SELECT ON TABLE taxon_trait TO bien_read;
3051 3086
GRANT SELECT ON TABLE taxon_trait_view TO bien_read;
3052 3087

  
......
3055 3090

  
3056 3091
CREATE INDEX ON taxon_trait ("scientificName", "measurementType" );
3057 3092
$$, repopulate);
3093
END;
3058 3094
$_$;
3059 3095

  
3060 3096

  
......
3430 3466

  
3431 3467

  
3432 3468
--
3433
-- Name: viewFullOccurrence_individual_view_modify(boolean); Type: FUNCTION; Schema: public; Owner: -
3469
-- Name: viewFullOccurrence_individual_view_modify(boolean, anyelement); Type: FUNCTION; Schema: public; Owner: -
3434 3470
--
3435 3471

  
3436
CREATE FUNCTION "viewFullOccurrence_individual_view_modify"(repopulate boolean DEFAULT true) RETURNS void
3437
    LANGUAGE sql
3472
CREATE FUNCTION "viewFullOccurrence_individual_view_modify"(repopulate boolean DEFAULT true, schema_anchor anyelement DEFAULT NULL::schema_anchor) RETURNS void
3473
    LANGUAGE plpgsql
3438 3474
    AS $_$
3439
SELECT util.rematerialize_view('"viewFullOccurrence_individual"', '"viewFullOccurrence_individual_view"', $$
3475
/* must use LANGUAGE plpgsql because LANGUAGE sql does not support runtime
3476
changes of search_path (schema elements are bound at inline time rather than
3477
runtime) */
3478
/* function option search_path is needed to limit the effects of
3479
`SET LOCAL search_path` to the current function */
3480
BEGIN
3481
	PERFORM util.use_schema(schema_anchor);
3482
	
3483
	PERFORM util.rematerialize_view('"viewFullOccurrence_individual"', '"viewFullOccurrence_individual_view"', $$
3440 3484
ALTER TABLE "viewFullOccurrence_individual" ADD COLUMN "TAXONOBSERVATION_ID__@VegBank__.taxonObservation@vegpath.org" serial PRIMARY KEY;
3441 3485
COMMENT ON COLUMN "viewFullOccurrence_individual"."TAXONOBSERVATION_ID__@VegBank__.taxonObservation@vegpath.org" IS 'VegBIEN-autogenerated "identifier assigned to each unique observation of a taxon in a plot"';
3442 3486

  
......
3451 3495
CREATE INDEX ON "viewFullOccurrence_individual" ("datasource__@Brad__.identifier_examples@vegpath.org", "projectID__@VegX__.plotObservation@vegpath.org", "locationID__@DwC__@vegpath.org", "eventDate__@DwC__@vegpath.org");
3452 3496
CREATE INDEX ON "viewFullOccurrence_individual" ("speciesBinomialWithMorphospecies__@VegCore__@vegpath.org");
3453 3497
$$, repopulate);
3498
END;
3454 3499
$_$;
3455 3500

  
3456 3501

  

Also available in: Unified diff