--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = off;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET escape_string_warning = off;

--
-- Name: functions; Type: SCHEMA; Schema: -; Owner: -
--

CREATE SCHEMA functions;


SET search_path = functions, pg_catalog;

--
-- Name: _toBool(); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION "_toBool"() RETURNS trigger
    LANGUAGE plpgsql IMMUTABLE
    AS $$
BEGIN
    new.result := CAST(new.value AS boolean);
    RETURN new;
END;
$$;


--
-- Name: _toDouble(); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION "_toDouble"() RETURNS trigger
    LANGUAGE plpgsql IMMUTABLE
    AS $$
BEGIN
    new.result := CAST(new.value AS double precision);
    RETURN new;
END;
$$;


--
-- Name: _toTimestamp(); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION "_toTimestamp"() RETURNS trigger
    LANGUAGE plpgsql IMMUTABLE
    AS $$
BEGIN
    new.result := CAST(new.value AS timestamp with time zone);
    RETURN new;
END;
$$;


SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: _toBool; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
--

CREATE TABLE "_toBool" (
    result boolean,
    value text
);


--
-- Name: _toDouble; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
--

CREATE TABLE "_toDouble" (
    result double precision,
    value text
);


--
-- Name: _toTimestamp; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
--

CREATE TABLE "_toTimestamp" (
    result timestamp with time zone,
    value text
);


--
-- Name: _toBool_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX "_toBool_unique" ON "_toBool" USING btree ((COALESCE(value, '\\N'::text)));


--
-- Name: _toDouble_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX "_toDouble_unique" ON "_toDouble" USING btree ((COALESCE(value, '\\N'::text)));


--
-- Name: _toTimestamp_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
--

CREATE UNIQUE INDEX "_toTimestamp_unique" ON "_toTimestamp" USING btree ((COALESCE(value, '\\N'::text)));


--
-- Name: _toBool; Type: TRIGGER; Schema: functions; Owner: -
--

CREATE TRIGGER "_toBool" BEFORE INSERT OR UPDATE ON "_toBool" FOR EACH ROW EXECUTE PROCEDURE "_toBool"();


--
-- Name: _toDouble; Type: TRIGGER; Schema: functions; Owner: -
--

CREATE TRIGGER "_toDouble" BEFORE INSERT OR UPDATE ON "_toDouble" FOR EACH ROW EXECUTE PROCEDURE "_toDouble"();


--
-- Name: _toTimestamp; Type: TRIGGER; Schema: functions; Owner: -
--

CREATE TRIGGER "_toTimestamp" BEFORE INSERT OR UPDATE ON "_toTimestamp" FOR EACH ROW EXECUTE PROCEDURE "_toTimestamp"();


--
-- PostgreSQL database dump complete
--

