--
-- 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: _alt(); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION _alt() RETURNS trigger
    LANGUAGE plpgsql IMMUTABLE
    AS $$
BEGIN
    new.result := coalesce(new."0", new."1", new."2", new."3", new."4", new."5",
        new."6", new."7", new."8", new."9");
    RETURN new;
END;
$$;


--
-- Name: boolean(text); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION "boolean"(value text) RETURNS boolean
    LANGUAGE plpgsql IMMUTABLE STRICT
    AS $$
BEGIN
    BEGIN
        RETURN value::boolean;
    EXCEPTION
        WHEN data_exception THEN
            RAISE WARNING '%', SQLERRM;
            RETURN NULL;
    END;
    RETURN new;
END;
$$;


--
-- Name: double precision(text); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION "double precision"(value text) RETURNS double precision
    LANGUAGE plpgsql IMMUTABLE STRICT
    AS $$
BEGIN
    BEGIN
        RETURN value::double precision;
    EXCEPTION
        WHEN data_exception THEN
            RAISE WARNING '%', SQLERRM;
            RETURN NULL;
    END;
    RETURN new;
END;
$$;


--
-- Name: ensure_not_null(text); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION ensure_not_null(value text) RETURNS text
    LANGUAGE sql IMMUTABLE
    AS $_$
SELECT COALESCE($1, E'\\N');
$_$;


--
-- Name: timestamp with time zone(text); Type: FUNCTION; Schema: functions; Owner: -
--

CREATE FUNCTION "timestamp with time zone"(value text) RETURNS timestamp with time zone
    LANGUAGE plpgsql IMMUTABLE STRICT
    AS $$
BEGIN
    BEGIN
        RETURN value::timestamp with time zone;
    EXCEPTION
        WHEN data_exception THEN
            RAISE WARNING '%', SQLERRM;
            RETURN NULL;
    END;
    RETURN new;
END;
$$;


SET default_tablespace = '';

SET default_with_oids = false;

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

CREATE TABLE _alt (
    result text,
    not_null_col boolean DEFAULT true NOT NULL,
    "0" text,
    "1" text,
    "2" text,
    "3" text,
    "4" text,
    "5" text,
    "6" text,
    "7" text,
    "8" text,
    "9" text
);


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

CREATE UNIQUE INDEX _alt_unique ON _alt USING btree (ensure_not_null("0"), ensure_not_null("1"), ensure_not_null("2"), ensure_not_null("3"), ensure_not_null("4"), ensure_not_null("5"), ensure_not_null("6"), ensure_not_null("7"), ensure_not_null("8"), ensure_not_null("9"));


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

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


--
-- PostgreSQL database dump complete
--

