Project

General

Profile

« Previous | Next » 

Revision 12262

schemas/vegbien.sql: materialize_query(): support schema-qualified tables. this requires escaping tables in calls to this function.

View differences:

trunk/schemas/util.sql
1617 1617
-- Name: materialize_query(text, text); Type: FUNCTION; Schema: util; Owner: -
1618 1618
--
1619 1619

  
1620
CREATE FUNCTION materialize_query(table_ text, sql text) RETURNS void
1620
CREATE FUNCTION materialize_query(table_esc text, sql text) RETURNS void
1621 1621
    LANGUAGE sql
1622 1622
    AS $_$
1623
SELECT util.create_if_not_exists($$CREATE TABLE $$||quote_ident($1)||$$ AS
1623
SELECT util.create_if_not_exists($$CREATE TABLE $$||$1||$$ AS
1624 1624
$$||$2)
1625 1625
$_$;
1626 1626

  
1627 1627

  
1628 1628
--
1629
-- Name: FUNCTION materialize_query(table_ text, sql text); Type: COMMENT; Schema: util; Owner: -
1629
-- Name: FUNCTION materialize_query(table_esc text, sql text); Type: COMMENT; Schema: util; Owner: -
1630 1630
--
1631 1631

  
1632
COMMENT ON FUNCTION materialize_query(table_ text, sql text) IS '
1632
COMMENT ON FUNCTION materialize_query(table_esc text, sql text) IS '
1633 1633
idempotent
1634 1634
';
1635 1635

  
......
1638 1638
-- Name: materialize_view(text, regclass); Type: FUNCTION; Schema: util; Owner: -
1639 1639
--
1640 1640

  
1641
CREATE FUNCTION materialize_view(table_ text, view_ regclass) RETURNS void
1641
CREATE FUNCTION materialize_view(table_esc text, view_ regclass) RETURNS void
1642 1642
    LANGUAGE sql
1643 1643
    AS $_$
1644 1644
SELECT util.materialize_query($1, $$SELECT * FROM $$||$2)
......
1646 1646

  
1647 1647

  
1648 1648
--
1649
-- Name: FUNCTION materialize_view(table_ text, view_ regclass); Type: COMMENT; Schema: util; Owner: -
1649
-- Name: FUNCTION materialize_view(table_esc text, view_ regclass); Type: COMMENT; Schema: util; Owner: -
1650 1650
--
1651 1651

  
1652
COMMENT ON FUNCTION materialize_view(table_ text, view_ regclass) IS '
1652
COMMENT ON FUNCTION materialize_view(table_esc text, view_ regclass) IS '
1653 1653
idempotent
1654 1654
';
1655 1655

  
......
2015 2015
-- Name: rematerialize_view(text, regclass); Type: FUNCTION; Schema: util; Owner: -
2016 2016
--
2017 2017

  
2018
CREATE FUNCTION rematerialize_view(table_ text, view_ regclass) RETURNS void
2018
CREATE FUNCTION rematerialize_view(table_esc text, view_ regclass) RETURNS void
2019 2019
    LANGUAGE sql
2020 2020
    AS $_$
2021 2021
SELECT util.drop_table($1);
......
2024 2024

  
2025 2025

  
2026 2026
--
2027
-- Name: FUNCTION rematerialize_view(table_ text, view_ regclass); Type: COMMENT; Schema: util; Owner: -
2027
-- Name: FUNCTION rematerialize_view(table_esc text, view_ regclass); Type: COMMENT; Schema: util; Owner: -
2028 2028
--
2029 2029

  
2030
COMMENT ON FUNCTION rematerialize_view(table_ text, view_ regclass) IS '
2030
COMMENT ON FUNCTION rematerialize_view(table_esc text, view_ regclass) IS '
2031 2031
idempotent, but repeats action each time
2032 2032
';
2033 2033

  
trunk/schemas/vegbien.sql
1940 1940
changes of search_path (schema elements are bound at inline time rather than
1941 1941
runtime) */
1942 1942
DECLARE
1943
	out_table text = '_out_'||util.name(out_view);
1943
	out_table text = quote_ident('_out_'||util.name(out_view));
1944 1944
BEGIN
1945 1945
	/* datasource_schema must be 1st in the search_path so that queries can use
1946 1946
	it in current_schema, and so that out_table is created in the datasource's

Also available in: Unified diff