--
--

SET escape_string_warning = off;

--
-- Name: decimail; Type: DATABASE; Schema: -; Owner: decimail
--

CREATE DATABASE decimail WITH TEMPLATE = template0 ENCODING = 'UTF8';


ALTER DATABASE decimail OWNER TO decimail;

\connect decimail

SET escape_string_warning = off;

--
-- Name: decimail; Type: COMMENT; Schema: -; Owner: decimail
--

COMMENT ON DATABASE decimail IS 'Email database for Decimail';


--
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres
--

COMMENT ON SCHEMA public IS 'Standard public schema';


--
-- Name: plpgsql; Type: PROCEDURAL LANGUAGE; Schema: -; Owner: postgres
--

CREATE PROCEDURAL LANGUAGE plpgsql;



--
-- Name: gtsq; Type: SHELL TYPE; Schema: public; Owner: postgres
--

CREATE TYPE gtsq;


--
-- Name: gtsq_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_in(cstring) RETURNS gtsq
    AS '$libdir/tsearch2', 'gtsq_in'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gtsq_in(cstring) OWNER TO postgres;

--
-- Name: gtsq_out(gtsq); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_out(gtsq) RETURNS cstring
    AS '$libdir/tsearch2', 'gtsq_out'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gtsq_out(gtsq) OWNER TO postgres;

--
-- Name: gtsq; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE gtsq (
    INTERNALLENGTH = 8,
    INPUT = gtsq_in,
    OUTPUT = gtsq_out,
    ALIGNMENT = int4,
    STORAGE = plain
);


ALTER TYPE public.gtsq OWNER TO postgres;

--
-- Name: gtsvector; Type: SHELL TYPE; Schema: public; Owner: postgres
--

CREATE TYPE gtsvector;


--
-- Name: gtsvector_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_in(cstring) RETURNS gtsvector
    AS '$libdir/tsearch2', 'gtsvector_in'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gtsvector_in(cstring) OWNER TO postgres;

--
-- Name: gtsvector_out(gtsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_out(gtsvector) RETURNS cstring
    AS '$libdir/tsearch2', 'gtsvector_out'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gtsvector_out(gtsvector) OWNER TO postgres;

--
-- Name: gtsvector; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE gtsvector (
    INTERNALLENGTH = variable,
    INPUT = gtsvector_in,
    OUTPUT = gtsvector_out,
    ALIGNMENT = int4,
    STORAGE = plain
);


ALTER TYPE public.gtsvector OWNER TO postgres;

--
-- Name: tsquery; Type: SHELL TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tsquery;


--
-- Name: tsquery_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_in(cstring) RETURNS tsquery
    AS '$libdir/tsearch2', 'tsquery_in'
    LANGUAGE c STRICT;


ALTER FUNCTION public.tsquery_in(cstring) OWNER TO postgres;

--
-- Name: tsquery_out(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_out(tsquery) RETURNS cstring
    AS '$libdir/tsearch2', 'tsquery_out'
    LANGUAGE c STRICT;


ALTER FUNCTION public.tsquery_out(tsquery) OWNER TO postgres;

--
-- Name: tsquery; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tsquery (
    INTERNALLENGTH = variable,
    INPUT = tsquery_in,
    OUTPUT = tsquery_out,
    ALIGNMENT = int4,
    STORAGE = plain
);


ALTER TYPE public.tsquery OWNER TO postgres;

--
-- Name: tsvector; Type: SHELL TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tsvector;


--
-- Name: tsvector_in(cstring); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_in(cstring) RETURNS tsvector
    AS '$libdir/tsearch2', 'tsvector_in'
    LANGUAGE c STRICT;


ALTER FUNCTION public.tsvector_in(cstring) OWNER TO postgres;

--
-- Name: tsvector_out(tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_out(tsvector) RETURNS cstring
    AS '$libdir/tsearch2', 'tsvector_out'
    LANGUAGE c STRICT;


ALTER FUNCTION public.tsvector_out(tsvector) OWNER TO postgres;

--
-- Name: tsvector; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tsvector (
    INTERNALLENGTH = variable,
    INPUT = tsvector_in,
    OUTPUT = tsvector_out,
    ALIGNMENT = int4,
    STORAGE = extended
);


ALTER TYPE public.tsvector OWNER TO postgres;

--
-- Name: statinfo; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE statinfo AS (
	word text,
	ndoc integer,
	nentry integer
);


ALTER TYPE public.statinfo OWNER TO postgres;

--
-- Name: tokenout; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tokenout AS (
	tokid integer,
	token text
);


ALTER TYPE public.tokenout OWNER TO postgres;

--
-- Name: tokentype; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tokentype AS (
	tokid integer,
	alias text,
	descr text
);


ALTER TYPE public.tokentype OWNER TO postgres;

--
-- Name: tsdebug; Type: TYPE; Schema: public; Owner: postgres
--

CREATE TYPE tsdebug AS (
	ts_name text,
	tok_type text,
	description text,
	token text,
	dict_name text[],
	tsvector tsvector
);


ALTER TYPE public.tsdebug OWNER TO postgres;

--
-- Name: _get_parser_from_curcfg(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION _get_parser_from_curcfg() RETURNS text
    AS $$ select prs_name from pg_ts_cfg where oid = show_curcfg() $$
    LANGUAGE sql IMMUTABLE STRICT;


ALTER FUNCTION public._get_parser_from_curcfg() OWNER TO postgres;

--
-- Name: concat(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION concat(tsvector, tsvector) RETURNS tsvector
    AS '$libdir/tsearch2', 'concat'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.concat(tsvector, tsvector) OWNER TO postgres;

--
-- Name: dex_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION dex_init(internal) RETURNS internal
    AS '$libdir/tsearch2', 'dex_init'
    LANGUAGE c;


ALTER FUNCTION public.dex_init(internal) OWNER TO postgres;

--
-- Name: dex_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION dex_lexize(internal, internal, integer) RETURNS internal
    AS '$libdir/tsearch2', 'dex_lexize'
    LANGUAGE c STRICT;


ALTER FUNCTION public.dex_lexize(internal, internal, integer) OWNER TO postgres;

--
-- Name: exectsq(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION exectsq(tsvector, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'exectsq'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.exectsq(tsvector, tsquery) OWNER TO postgres;

--
-- Name: FUNCTION exectsq(tsvector, tsquery); Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON FUNCTION exectsq(tsvector, tsquery) IS 'boolean operation with text index';


--
-- Name: get_covers(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION get_covers(tsvector, tsquery) RETURNS text
    AS '$libdir/tsearch2', 'get_covers'
    LANGUAGE c STRICT;


ALTER FUNCTION public.get_covers(tsvector, tsquery) OWNER TO postgres;

--
-- Name: gin_extract_tsquery(tsquery, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gin_extract_tsquery(tsquery, internal, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gin_extract_tsquery'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gin_extract_tsquery(tsquery, internal, internal) OWNER TO postgres;

--
-- Name: gin_extract_tsvector(tsvector, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gin_extract_tsvector(tsvector, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gin_extract_tsvector'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gin_extract_tsvector(tsvector, internal) OWNER TO postgres;

--
-- Name: gin_ts_consistent(internal, internal, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gin_ts_consistent(internal, internal, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'gin_ts_consistent'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gin_ts_consistent(internal, internal, tsquery) OWNER TO postgres;

--
-- Name: gtsq_compress(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_compress(internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsq_compress'
    LANGUAGE c;


ALTER FUNCTION public.gtsq_compress(internal) OWNER TO postgres;

--
-- Name: gtsq_consistent(gtsq, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_consistent(gtsq, internal, integer) RETURNS boolean
    AS '$libdir/tsearch2', 'gtsq_consistent'
    LANGUAGE c;


ALTER FUNCTION public.gtsq_consistent(gtsq, internal, integer) OWNER TO postgres;

--
-- Name: gtsq_decompress(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_decompress(internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsq_decompress'
    LANGUAGE c;


ALTER FUNCTION public.gtsq_decompress(internal) OWNER TO postgres;

--
-- Name: gtsq_penalty(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_penalty(internal, internal, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsq_penalty'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gtsq_penalty(internal, internal, internal) OWNER TO postgres;

--
-- Name: gtsq_picksplit(internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_picksplit(internal, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsq_picksplit'
    LANGUAGE c;


ALTER FUNCTION public.gtsq_picksplit(internal, internal) OWNER TO postgres;

--
-- Name: gtsq_same(gtsq, gtsq, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_same(gtsq, gtsq, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsq_same'
    LANGUAGE c;


ALTER FUNCTION public.gtsq_same(gtsq, gtsq, internal) OWNER TO postgres;

--
-- Name: gtsq_union(bytea, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsq_union(bytea, internal) RETURNS integer[]
    AS '$libdir/tsearch2', 'gtsq_union'
    LANGUAGE c;


ALTER FUNCTION public.gtsq_union(bytea, internal) OWNER TO postgres;

--
-- Name: gtsvector_compress(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_compress(internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsvector_compress'
    LANGUAGE c;


ALTER FUNCTION public.gtsvector_compress(internal) OWNER TO postgres;

--
-- Name: gtsvector_consistent(gtsvector, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_consistent(gtsvector, internal, integer) RETURNS boolean
    AS '$libdir/tsearch2', 'gtsvector_consistent'
    LANGUAGE c;


ALTER FUNCTION public.gtsvector_consistent(gtsvector, internal, integer) OWNER TO postgres;

--
-- Name: gtsvector_decompress(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_decompress(internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsvector_decompress'
    LANGUAGE c;


ALTER FUNCTION public.gtsvector_decompress(internal) OWNER TO postgres;

--
-- Name: gtsvector_penalty(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_penalty(internal, internal, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsvector_penalty'
    LANGUAGE c STRICT;


ALTER FUNCTION public.gtsvector_penalty(internal, internal, internal) OWNER TO postgres;

--
-- Name: gtsvector_picksplit(internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_picksplit(internal, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsvector_picksplit'
    LANGUAGE c;


ALTER FUNCTION public.gtsvector_picksplit(internal, internal) OWNER TO postgres;

--
-- Name: gtsvector_same(gtsvector, gtsvector, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_same(gtsvector, gtsvector, internal) RETURNS internal
    AS '$libdir/tsearch2', 'gtsvector_same'
    LANGUAGE c;


ALTER FUNCTION public.gtsvector_same(gtsvector, gtsvector, internal) OWNER TO postgres;

--
-- Name: gtsvector_union(internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION gtsvector_union(internal, internal) RETURNS integer[]
    AS '$libdir/tsearch2', 'gtsvector_union'
    LANGUAGE c;


ALTER FUNCTION public.gtsvector_union(internal, internal) OWNER TO postgres;

--
-- Name: headline(oid, text, tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION headline(oid, text, tsquery, text) RETURNS text
    AS '$libdir/tsearch2', 'headline'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.headline(oid, text, tsquery, text) OWNER TO postgres;

--
-- Name: headline(oid, text, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION headline(oid, text, tsquery) RETURNS text
    AS '$libdir/tsearch2', 'headline'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.headline(oid, text, tsquery) OWNER TO postgres;

--
-- Name: headline(text, text, tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION headline(text, text, tsquery, text) RETURNS text
    AS '$libdir/tsearch2', 'headline_byname'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.headline(text, text, tsquery, text) OWNER TO postgres;

--
-- Name: headline(text, text, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION headline(text, text, tsquery) RETURNS text
    AS '$libdir/tsearch2', 'headline_byname'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.headline(text, text, tsquery) OWNER TO postgres;

--
-- Name: headline(text, tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION headline(text, tsquery, text) RETURNS text
    AS '$libdir/tsearch2', 'headline_current'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.headline(text, tsquery, text) OWNER TO postgres;

--
-- Name: headline(text, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION headline(text, tsquery) RETURNS text
    AS '$libdir/tsearch2', 'headline_current'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.headline(text, tsquery) OWNER TO postgres;

--
-- Name: length(tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION length(tsvector) RETURNS integer
    AS '$libdir/tsearch2', 'tsvector_length'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.length(tsvector) OWNER TO postgres;

--
-- Name: lexize(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION lexize(oid, text) RETURNS text[]
    AS '$libdir/tsearch2', 'lexize'
    LANGUAGE c STRICT;


ALTER FUNCTION public.lexize(oid, text) OWNER TO postgres;

--
-- Name: lexize(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION lexize(text, text) RETURNS text[]
    AS '$libdir/tsearch2', 'lexize_byname'
    LANGUAGE c STRICT;


ALTER FUNCTION public.lexize(text, text) OWNER TO postgres;

--
-- Name: lexize(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION lexize(text) RETURNS text[]
    AS '$libdir/tsearch2', 'lexize_bycurrent'
    LANGUAGE c STRICT;


ALTER FUNCTION public.lexize(text) OWNER TO postgres;

--
-- Name: log_deleted_message(); Type: FUNCTION; Schema: public; Owner: decimail
--

CREATE FUNCTION log_deleted_message() RETURNS "trigger"
    AS $$
  begin
    insert into delete_log values (old.msg_id);
    notify delete_log;
    return old;
  end;
$$
    LANGUAGE plpgsql;


ALTER FUNCTION public.log_deleted_message() OWNER TO decimail;

--
-- Name: notify_new_message(); Type: FUNCTION; Schema: public; Owner: decimail
--

CREATE FUNCTION notify_new_message() RETURNS "trigger"
    AS $$
  begin
    execute 'notify new_message_for_' || new.owner || ';';
    return null;
  end;
$$
    LANGUAGE plpgsql;


ALTER FUNCTION public.notify_new_message() OWNER TO decimail;

--
-- Name: numnode(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION numnode(tsquery) RETURNS integer
    AS '$libdir/tsearch2', 'tsquery_numnode'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.numnode(tsquery) OWNER TO postgres;

--
-- Name: parse(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION parse(oid, text) RETURNS SETOF tokenout
    AS '$libdir/tsearch2', 'parse'
    LANGUAGE c STRICT;


ALTER FUNCTION public.parse(oid, text) OWNER TO postgres;

--
-- Name: parse(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION parse(text, text) RETURNS SETOF tokenout
    AS '$libdir/tsearch2', 'parse_byname'
    LANGUAGE c STRICT;


ALTER FUNCTION public.parse(text, text) OWNER TO postgres;

--
-- Name: parse(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION parse(text) RETURNS SETOF tokenout
    AS '$libdir/tsearch2', 'parse_current'
    LANGUAGE c STRICT;


ALTER FUNCTION public.parse(text) OWNER TO postgres;

--
-- Name: plainto_tsquery(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION plainto_tsquery(oid, text) RETURNS tsquery
    AS '$libdir/tsearch2', 'plainto_tsquery'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.plainto_tsquery(oid, text) OWNER TO postgres;

--
-- Name: plainto_tsquery(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION plainto_tsquery(text, text) RETURNS tsquery
    AS '$libdir/tsearch2', 'plainto_tsquery_name'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.plainto_tsquery(text, text) OWNER TO postgres;

--
-- Name: plainto_tsquery(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION plainto_tsquery(text) RETURNS tsquery
    AS '$libdir/tsearch2', 'plainto_tsquery_current'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.plainto_tsquery(text) OWNER TO postgres;

--
-- Name: plpgsql_call_handler(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION plpgsql_call_handler() RETURNS language_handler
    AS '$libdir/plpgsql', 'plpgsql_call_handler'
    LANGUAGE c;


ALTER FUNCTION public.plpgsql_call_handler() OWNER TO postgres;

--
-- Name: prsd_end(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION prsd_end(internal) RETURNS void
    AS '$libdir/tsearch2', 'prsd_end'
    LANGUAGE c;


ALTER FUNCTION public.prsd_end(internal) OWNER TO postgres;

--
-- Name: prsd_getlexeme(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION prsd_getlexeme(internal, internal, internal) RETURNS integer
    AS '$libdir/tsearch2', 'prsd_getlexeme'
    LANGUAGE c;


ALTER FUNCTION public.prsd_getlexeme(internal, internal, internal) OWNER TO postgres;

--
-- Name: prsd_headline(internal, internal, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION prsd_headline(internal, internal, internal) RETURNS internal
    AS '$libdir/tsearch2', 'prsd_headline'
    LANGUAGE c;


ALTER FUNCTION public.prsd_headline(internal, internal, internal) OWNER TO postgres;

--
-- Name: prsd_lextype(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION prsd_lextype(internal) RETURNS internal
    AS '$libdir/tsearch2', 'prsd_lextype'
    LANGUAGE c;


ALTER FUNCTION public.prsd_lextype(internal) OWNER TO postgres;

--
-- Name: prsd_start(internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION prsd_start(internal, integer) RETURNS internal
    AS '$libdir/tsearch2', 'prsd_start'
    LANGUAGE c;


ALTER FUNCTION public.prsd_start(internal, integer) OWNER TO postgres;

--
-- Name: querytree(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION querytree(tsquery) RETURNS text
    AS '$libdir/tsearch2', 'tsquerytree'
    LANGUAGE c STRICT;


ALTER FUNCTION public.querytree(tsquery) OWNER TO postgres;

--
-- Name: rank(real[], tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank(real[], tsvector, tsquery) RETURNS real
    AS '$libdir/tsearch2', 'rank'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank(real[], tsvector, tsquery) OWNER TO postgres;

--
-- Name: rank(real[], tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank(real[], tsvector, tsquery, integer) RETURNS real
    AS '$libdir/tsearch2', 'rank'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank(real[], tsvector, tsquery, integer) OWNER TO postgres;

--
-- Name: rank(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank(tsvector, tsquery) RETURNS real
    AS '$libdir/tsearch2', 'rank_def'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank(tsvector, tsquery) OWNER TO postgres;

--
-- Name: rank(tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank(tsvector, tsquery, integer) RETURNS real
    AS '$libdir/tsearch2', 'rank_def'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank(tsvector, tsquery, integer) OWNER TO postgres;

--
-- Name: rank_cd(real[], tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank_cd(real[], tsvector, tsquery) RETURNS real
    AS '$libdir/tsearch2', 'rank_cd'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank_cd(real[], tsvector, tsquery) OWNER TO postgres;

--
-- Name: rank_cd(real[], tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank_cd(real[], tsvector, tsquery, integer) RETURNS real
    AS '$libdir/tsearch2', 'rank_cd'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank_cd(real[], tsvector, tsquery, integer) OWNER TO postgres;

--
-- Name: rank_cd(tsvector, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank_cd(tsvector, tsquery) RETURNS real
    AS '$libdir/tsearch2', 'rank_cd_def'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank_cd(tsvector, tsquery) OWNER TO postgres;

--
-- Name: rank_cd(tsvector, tsquery, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rank_cd(tsvector, tsquery, integer) RETURNS real
    AS '$libdir/tsearch2', 'rank_cd_def'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rank_cd(tsvector, tsquery, integer) OWNER TO postgres;

--
-- Name: reset_tsearch(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION reset_tsearch() RETURNS void
    AS '$libdir/tsearch2', 'reset_tsearch'
    LANGUAGE c STRICT;


ALTER FUNCTION public.reset_tsearch() OWNER TO postgres;

--
-- Name: rewrite(tsquery, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rewrite(tsquery, text) RETURNS tsquery
    AS '$libdir/tsearch2', 'tsquery_rewrite'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rewrite(tsquery, text) OWNER TO postgres;

--
-- Name: rewrite(tsquery, tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rewrite(tsquery, tsquery, tsquery) RETURNS tsquery
    AS '$libdir/tsearch2', 'tsquery_rewrite_query'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rewrite(tsquery, tsquery, tsquery) OWNER TO postgres;

--
-- Name: rewrite_accum(tsquery, tsquery[]); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rewrite_accum(tsquery, tsquery[]) RETURNS tsquery
    AS '$libdir/tsearch2', 'rewrite_accum'
    LANGUAGE c;


ALTER FUNCTION public.rewrite_accum(tsquery, tsquery[]) OWNER TO postgres;

--
-- Name: rewrite_finish(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rewrite_finish(tsquery) RETURNS tsquery
    AS '$libdir/tsearch2', 'rewrite_finish'
    LANGUAGE c;


ALTER FUNCTION public.rewrite_finish(tsquery) OWNER TO postgres;

--
-- Name: rexectsq(tsquery, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION rexectsq(tsquery, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'rexectsq'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.rexectsq(tsquery, tsvector) OWNER TO postgres;

--
-- Name: FUNCTION rexectsq(tsquery, tsvector); Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON FUNCTION rexectsq(tsquery, tsvector) IS 'boolean operation with text index';


--
-- Name: set_curcfg(integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION set_curcfg(integer) RETURNS void
    AS '$libdir/tsearch2', 'set_curcfg'
    LANGUAGE c STRICT;


ALTER FUNCTION public.set_curcfg(integer) OWNER TO postgres;

--
-- Name: set_curcfg(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION set_curcfg(text) RETURNS void
    AS '$libdir/tsearch2', 'set_curcfg_byname'
    LANGUAGE c STRICT;


ALTER FUNCTION public.set_curcfg(text) OWNER TO postgres;

--
-- Name: set_curdict(integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION set_curdict(integer) RETURNS void
    AS '$libdir/tsearch2', 'set_curdict'
    LANGUAGE c STRICT;


ALTER FUNCTION public.set_curdict(integer) OWNER TO postgres;

--
-- Name: set_curdict(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION set_curdict(text) RETURNS void
    AS '$libdir/tsearch2', 'set_curdict_byname'
    LANGUAGE c STRICT;


ALTER FUNCTION public.set_curdict(text) OWNER TO postgres;

--
-- Name: set_curprs(integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION set_curprs(integer) RETURNS void
    AS '$libdir/tsearch2', 'set_curprs'
    LANGUAGE c STRICT;


ALTER FUNCTION public.set_curprs(integer) OWNER TO postgres;

--
-- Name: set_curprs(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION set_curprs(text) RETURNS void
    AS '$libdir/tsearch2', 'set_curprs_byname'
    LANGUAGE c STRICT;


ALTER FUNCTION public.set_curprs(text) OWNER TO postgres;

--
-- Name: setweight(tsvector, "char"); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION setweight(tsvector, "char") RETURNS tsvector
    AS '$libdir/tsearch2', 'setweight'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.setweight(tsvector, "char") OWNER TO postgres;

--
-- Name: show_curcfg(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION show_curcfg() RETURNS oid
    AS '$libdir/tsearch2', 'show_curcfg'
    LANGUAGE c STRICT;


ALTER FUNCTION public.show_curcfg() OWNER TO postgres;

--
-- Name: snb_en_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION snb_en_init(internal) RETURNS internal
    AS '$libdir/tsearch2', 'snb_en_init'
    LANGUAGE c;


ALTER FUNCTION public.snb_en_init(internal) OWNER TO postgres;

--
-- Name: snb_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION snb_lexize(internal, internal, integer) RETURNS internal
    AS '$libdir/tsearch2', 'snb_lexize'
    LANGUAGE c STRICT;


ALTER FUNCTION public.snb_lexize(internal, internal, integer) OWNER TO postgres;

--
-- Name: snb_ru_init_koi8(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION snb_ru_init_koi8(internal) RETURNS internal
    AS '$libdir/tsearch2', 'snb_ru_init_koi8'
    LANGUAGE c;


ALTER FUNCTION public.snb_ru_init_koi8(internal) OWNER TO postgres;

--
-- Name: snb_ru_init_utf8(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION snb_ru_init_utf8(internal) RETURNS internal
    AS '$libdir/tsearch2', 'snb_ru_init_utf8'
    LANGUAGE c;


ALTER FUNCTION public.snb_ru_init_utf8(internal) OWNER TO postgres;

--
-- Name: spell_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION spell_init(internal) RETURNS internal
    AS '$libdir/tsearch2', 'spell_init'
    LANGUAGE c;


ALTER FUNCTION public.spell_init(internal) OWNER TO postgres;

--
-- Name: spell_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION spell_lexize(internal, internal, integer) RETURNS internal
    AS '$libdir/tsearch2', 'spell_lexize'
    LANGUAGE c STRICT;


ALTER FUNCTION public.spell_lexize(internal, internal, integer) OWNER TO postgres;

--
-- Name: stat(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION stat(text) RETURNS SETOF statinfo
    AS '$libdir/tsearch2', 'ts_stat'
    LANGUAGE c STRICT;


ALTER FUNCTION public.stat(text) OWNER TO postgres;

--
-- Name: stat(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION stat(text, text) RETURNS SETOF statinfo
    AS '$libdir/tsearch2', 'ts_stat'
    LANGUAGE c STRICT;


ALTER FUNCTION public.stat(text, text) OWNER TO postgres;

--
-- Name: strip(tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION strip(tsvector) RETURNS tsvector
    AS '$libdir/tsearch2', 'strip'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.strip(tsvector) OWNER TO postgres;

--
-- Name: syn_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION syn_init(internal) RETURNS internal
    AS '$libdir/tsearch2', 'syn_init'
    LANGUAGE c;


ALTER FUNCTION public.syn_init(internal) OWNER TO postgres;

--
-- Name: syn_lexize(internal, internal, integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION syn_lexize(internal, internal, integer) RETURNS internal
    AS '$libdir/tsearch2', 'syn_lexize'
    LANGUAGE c STRICT;


ALTER FUNCTION public.syn_lexize(internal, internal, integer) OWNER TO postgres;

--
-- Name: thesaurus_init(internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION thesaurus_init(internal) RETURNS internal
    AS '$libdir/tsearch2', 'thesaurus_init'
    LANGUAGE c;


ALTER FUNCTION public.thesaurus_init(internal) OWNER TO postgres;

--
-- Name: thesaurus_lexize(internal, internal, integer, internal); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION thesaurus_lexize(internal, internal, integer, internal) RETURNS internal
    AS '$libdir/tsearch2', 'thesaurus_lexize'
    LANGUAGE c STRICT;


ALTER FUNCTION public.thesaurus_lexize(internal, internal, integer, internal) OWNER TO postgres;

--
-- Name: to_tsquery(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION to_tsquery(oid, text) RETURNS tsquery
    AS '$libdir/tsearch2', 'to_tsquery'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.to_tsquery(oid, text) OWNER TO postgres;

--
-- Name: to_tsquery(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION to_tsquery(text, text) RETURNS tsquery
    AS '$libdir/tsearch2', 'to_tsquery_name'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.to_tsquery(text, text) OWNER TO postgres;

--
-- Name: to_tsquery(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION to_tsquery(text) RETURNS tsquery
    AS '$libdir/tsearch2', 'to_tsquery_current'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.to_tsquery(text) OWNER TO postgres;

--
-- Name: to_tsvector(oid, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION to_tsvector(oid, text) RETURNS tsvector
    AS '$libdir/tsearch2', 'to_tsvector'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.to_tsvector(oid, text) OWNER TO postgres;

--
-- Name: to_tsvector(text, text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION to_tsvector(text, text) RETURNS tsvector
    AS '$libdir/tsearch2', 'to_tsvector_name'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.to_tsvector(text, text) OWNER TO postgres;

--
-- Name: to_tsvector(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION to_tsvector(text) RETURNS tsvector
    AS '$libdir/tsearch2', 'to_tsvector_current'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.to_tsvector(text) OWNER TO postgres;

--
-- Name: token_type(integer); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION token_type(integer) RETURNS SETOF tokentype
    AS '$libdir/tsearch2', 'token_type'
    LANGUAGE c STRICT;


ALTER FUNCTION public.token_type(integer) OWNER TO postgres;

--
-- Name: token_type(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION token_type(text) RETURNS SETOF tokentype
    AS '$libdir/tsearch2', 'token_type_byname'
    LANGUAGE c STRICT;


ALTER FUNCTION public.token_type(text) OWNER TO postgres;

--
-- Name: token_type(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION token_type() RETURNS SETOF tokentype
    AS '$libdir/tsearch2', 'token_type_current'
    LANGUAGE c STRICT;


ALTER FUNCTION public.token_type() OWNER TO postgres;

--
-- Name: ts_debug(text); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION ts_debug(text) RETURNS SETOF tsdebug
    AS $_$
select 
        m.ts_name,
        t.alias as tok_type,
        t.descr as description,
        p.token,
        m.dict_name,
        strip(to_tsvector(p.token)) as tsvector
from
        parse( _get_parser_from_curcfg(), $1 ) as p,
        token_type() as t,
        pg_ts_cfgmap as m,
        pg_ts_cfg as c
where
        t.tokid=p.tokid and
        t.alias = m.tok_alias and 
        m.ts_name=c.ts_name and 
        c.oid=show_curcfg() 
$_$
    LANGUAGE sql STRICT;


ALTER FUNCTION public.ts_debug(text) OWNER TO postgres;

--
-- Name: tsearch2(); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsearch2() RETURNS "trigger"
    AS '$libdir/tsearch2', 'tsearch2'
    LANGUAGE c;


ALTER FUNCTION public.tsearch2() OWNER TO postgres;

--
-- Name: tsq_mcontained(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsq_mcontained(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsq_mcontained'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsq_mcontained(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsq_mcontains(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsq_mcontains(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsq_mcontains'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsq_mcontains(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_and(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_and(tsquery, tsquery) RETURNS tsquery
    AS '$libdir/tsearch2', 'tsquery_and'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_and(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_cmp(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_cmp(tsquery, tsquery) RETURNS integer
    AS '$libdir/tsearch2', 'tsquery_cmp'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_cmp(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_eq(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_eq(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsquery_eq'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_eq(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_ge(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_ge(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsquery_ge'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_ge(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_gt(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_gt(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsquery_gt'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_gt(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_le(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_le(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsquery_le'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_le(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_lt(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_lt(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsquery_lt'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_lt(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_ne(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_ne(tsquery, tsquery) RETURNS boolean
    AS '$libdir/tsearch2', 'tsquery_ne'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_ne(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsquery_not(tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_not(tsquery) RETURNS tsquery
    AS '$libdir/tsearch2', 'tsquery_not'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_not(tsquery) OWNER TO postgres;

--
-- Name: tsquery_or(tsquery, tsquery); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsquery_or(tsquery, tsquery) RETURNS tsquery
    AS '$libdir/tsearch2', 'tsquery_or'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsquery_or(tsquery, tsquery) OWNER TO postgres;

--
-- Name: tsvector_cmp(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_cmp(tsvector, tsvector) RETURNS integer
    AS '$libdir/tsearch2', 'tsvector_cmp'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_cmp(tsvector, tsvector) OWNER TO postgres;

--
-- Name: tsvector_eq(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_eq(tsvector, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'tsvector_eq'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_eq(tsvector, tsvector) OWNER TO postgres;

--
-- Name: tsvector_ge(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_ge(tsvector, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'tsvector_ge'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_ge(tsvector, tsvector) OWNER TO postgres;

--
-- Name: tsvector_gt(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_gt(tsvector, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'tsvector_gt'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_gt(tsvector, tsvector) OWNER TO postgres;

--
-- Name: tsvector_le(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_le(tsvector, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'tsvector_le'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_le(tsvector, tsvector) OWNER TO postgres;

--
-- Name: tsvector_lt(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_lt(tsvector, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'tsvector_lt'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_lt(tsvector, tsvector) OWNER TO postgres;

--
-- Name: tsvector_ne(tsvector, tsvector); Type: FUNCTION; Schema: public; Owner: postgres
--

CREATE FUNCTION tsvector_ne(tsvector, tsvector) RETURNS boolean
    AS '$libdir/tsearch2', 'tsvector_ne'
    LANGUAGE c IMMUTABLE STRICT;


ALTER FUNCTION public.tsvector_ne(tsvector, tsvector) OWNER TO postgres;

--
-- Name: update_mailboxes(); Type: FUNCTION; Schema: public; Owner: decimail
--

CREATE FUNCTION update_mailboxes() RETURNS "trigger"
    AS $$
  begin
    truncate mailboxes;
    insert into mailboxes (username, mailbox_name, query)
        select username, mailbox_name, query from mailboxes_view;
    return null;
  end;
$$
    LANGUAGE plpgsql;


ALTER FUNCTION public.update_mailboxes() OWNER TO decimail;

--
-- Name: rewrite(tsquery[]); Type: AGGREGATE; Schema: public; Owner: postgres
--

CREATE AGGREGATE rewrite(tsquery[]) (
    SFUNC = rewrite_accum,
    STYPE = tsquery,
    FINALFUNC = rewrite_finish
);


ALTER AGGREGATE public.rewrite(tsquery[]) OWNER TO postgres;

--
-- Name: !!; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR !! (
    PROCEDURE = tsquery_not,
    RIGHTARG = tsquery
);


ALTER OPERATOR public.!! (NONE, tsquery) OWNER TO postgres;

--
-- Name: &&; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR && (
    PROCEDURE = tsquery_and,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = &&,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.&& (tsquery, tsquery) OWNER TO postgres;

--
-- Name: <; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR < (
    PROCEDURE = tsvector_lt,
    LEFTARG = tsvector,
    RIGHTARG = tsvector,
    COMMUTATOR = >,
    NEGATOR = >=,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.< (tsvector, tsvector) OWNER TO postgres;

--
-- Name: <; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR < (
    PROCEDURE = tsquery_lt,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = >,
    NEGATOR = >=,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.< (tsquery, tsquery) OWNER TO postgres;

--
-- Name: <=; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR <= (
    PROCEDURE = tsvector_le,
    LEFTARG = tsvector,
    RIGHTARG = tsvector,
    COMMUTATOR = >=,
    NEGATOR = >,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.<= (tsvector, tsvector) OWNER TO postgres;

--
-- Name: <=; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR <= (
    PROCEDURE = tsquery_le,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = >=,
    NEGATOR = >,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.<= (tsquery, tsquery) OWNER TO postgres;

--
-- Name: <>; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR <> (
    PROCEDURE = tsvector_ne,
    LEFTARG = tsvector,
    RIGHTARG = tsvector,
    COMMUTATOR = <>,
    NEGATOR = =,
    RESTRICT = neqsel,
    JOIN = neqjoinsel
);


ALTER OPERATOR public.<> (tsvector, tsvector) OWNER TO postgres;

--
-- Name: <>; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR <> (
    PROCEDURE = tsquery_ne,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = <>,
    NEGATOR = =,
    RESTRICT = neqsel,
    JOIN = neqjoinsel
);


ALTER OPERATOR public.<> (tsquery, tsquery) OWNER TO postgres;

--
-- Name: <@; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR <@ (
    PROCEDURE = tsq_mcontained,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = @>,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.<@ (tsquery, tsquery) OWNER TO postgres;

--
-- Name: =; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR = (
    PROCEDURE = tsvector_eq,
    LEFTARG = tsvector,
    RIGHTARG = tsvector,
    COMMUTATOR = =,
    NEGATOR = <>,
    RESTRICT = eqsel,
    JOIN = eqjoinsel,
    SORT1 = <,
    SORT2 = <,
    LTCMP = <,
    GTCMP = >
);


ALTER OPERATOR public.= (tsvector, tsvector) OWNER TO postgres;

--
-- Name: =; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR = (
    PROCEDURE = tsquery_eq,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = =,
    NEGATOR = <>,
    RESTRICT = eqsel,
    JOIN = eqjoinsel,
    SORT1 = <,
    SORT2 = <,
    LTCMP = <,
    GTCMP = >
);


ALTER OPERATOR public.= (tsquery, tsquery) OWNER TO postgres;

--
-- Name: >; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR > (
    PROCEDURE = tsvector_gt,
    LEFTARG = tsvector,
    RIGHTARG = tsvector,
    COMMUTATOR = <,
    NEGATOR = <=,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.> (tsvector, tsvector) OWNER TO postgres;

--
-- Name: >; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR > (
    PROCEDURE = tsquery_gt,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = <,
    NEGATOR = <=,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.> (tsquery, tsquery) OWNER TO postgres;

--
-- Name: >=; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR >= (
    PROCEDURE = tsvector_ge,
    LEFTARG = tsvector,
    RIGHTARG = tsvector,
    COMMUTATOR = <=,
    NEGATOR = <,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.>= (tsvector, tsvector) OWNER TO postgres;

--
-- Name: >=; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR >= (
    PROCEDURE = tsquery_ge,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = <=,
    NEGATOR = <,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.>= (tsquery, tsquery) OWNER TO postgres;

--
-- Name: @; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR @ (
    PROCEDURE = tsq_mcontains,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = ~,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.@ (tsquery, tsquery) OWNER TO postgres;

--
-- Name: @>; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR @> (
    PROCEDURE = tsq_mcontains,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = <@,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.@> (tsquery, tsquery) OWNER TO postgres;

--
-- Name: @@; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR @@ (
    PROCEDURE = rexectsq,
    LEFTARG = tsquery,
    RIGHTARG = tsvector,
    COMMUTATOR = @@,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.@@ (tsquery, tsvector) OWNER TO postgres;

--
-- Name: @@; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR @@ (
    PROCEDURE = exectsq,
    LEFTARG = tsvector,
    RIGHTARG = tsquery,
    COMMUTATOR = @@,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.@@ (tsvector, tsquery) OWNER TO postgres;

--
-- Name: @@@; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR @@@ (
    PROCEDURE = rexectsq,
    LEFTARG = tsquery,
    RIGHTARG = tsvector,
    COMMUTATOR = @@@,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.@@@ (tsquery, tsvector) OWNER TO postgres;

--
-- Name: @@@; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR @@@ (
    PROCEDURE = exectsq,
    LEFTARG = tsvector,
    RIGHTARG = tsquery,
    COMMUTATOR = @@@,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.@@@ (tsvector, tsquery) OWNER TO postgres;

--
-- Name: ||; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR || (
    PROCEDURE = concat,
    LEFTARG = tsvector,
    RIGHTARG = tsvector
);


ALTER OPERATOR public.|| (tsvector, tsvector) OWNER TO postgres;

--
-- Name: ||; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR || (
    PROCEDURE = tsquery_or,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = ||,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.|| (tsquery, tsquery) OWNER TO postgres;

--
-- Name: ~; Type: OPERATOR; Schema: public; Owner: postgres
--

CREATE OPERATOR ~ (
    PROCEDURE = tsq_mcontained,
    LEFTARG = tsquery,
    RIGHTARG = tsquery,
    COMMUTATOR = @,
    RESTRICT = contsel,
    JOIN = contjoinsel
);


ALTER OPERATOR public.~ (tsquery, tsquery) OWNER TO postgres;

--
-- Name: gin_tsvector_ops; Type: OPERATOR CLASS; Schema: public; Owner: postgres
--

CREATE OPERATOR CLASS gin_tsvector_ops
    DEFAULT FOR TYPE tsvector USING gin AS
    STORAGE text ,
    OPERATOR 1 @@(tsvector,tsquery) ,
    OPERATOR 2 @@@(tsvector,tsquery) RECHECK ,
    FUNCTION 1 bttextcmp(text,text) ,
    FUNCTION 2 gin_extract_tsvector(tsvector,internal) ,
    FUNCTION 3 gin_extract_tsquery(tsquery,internal,internal) ,
    FUNCTION 4 gin_ts_consistent(internal,internal,tsquery);


ALTER OPERATOR CLASS public.gin_tsvector_ops USING gin OWNER TO postgres;

--
-- Name: gist_tp_tsquery_ops; Type: OPERATOR CLASS; Schema: public; Owner: postgres
--

CREATE OPERATOR CLASS gist_tp_tsquery_ops
    DEFAULT FOR TYPE tsquery USING gist AS
    STORAGE gtsq ,
    OPERATOR 7 @>(tsquery,tsquery) RECHECK ,
    OPERATOR 8 <@(tsquery,tsquery) RECHECK ,
    OPERATOR 13 @(tsquery,tsquery) RECHECK ,
    OPERATOR 14 ~(tsquery,tsquery) RECHECK ,
    FUNCTION 1 gtsq_consistent(gtsq,internal,integer) ,
    FUNCTION 2 gtsq_union(bytea,internal) ,
    FUNCTION 3 gtsq_compress(internal) ,
    FUNCTION 4 gtsq_decompress(internal) ,
    FUNCTION 5 gtsq_penalty(internal,internal,internal) ,
    FUNCTION 6 gtsq_picksplit(internal,internal) ,
    FUNCTION 7 gtsq_same(gtsq,gtsq,internal);


ALTER OPERATOR CLASS public.gist_tp_tsquery_ops USING gist OWNER TO postgres;

--
-- Name: gist_tsvector_ops; Type: OPERATOR CLASS; Schema: public; Owner: postgres
--

CREATE OPERATOR CLASS gist_tsvector_ops
    DEFAULT FOR TYPE tsvector USING gist AS
    STORAGE gtsvector ,
    OPERATOR 1 @@(tsvector,tsquery) RECHECK ,
    FUNCTION 1 gtsvector_consistent(gtsvector,internal,integer) ,
    FUNCTION 2 gtsvector_union(internal,internal) ,
    FUNCTION 3 gtsvector_compress(internal) ,
    FUNCTION 4 gtsvector_decompress(internal) ,
    FUNCTION 5 gtsvector_penalty(internal,internal,internal) ,
    FUNCTION 6 gtsvector_picksplit(internal,internal) ,
    FUNCTION 7 gtsvector_same(gtsvector,gtsvector,internal);


ALTER OPERATOR CLASS public.gist_tsvector_ops USING gist OWNER TO postgres;

--
-- Name: tsquery_ops; Type: OPERATOR CLASS; Schema: public; Owner: postgres
--

CREATE OPERATOR CLASS tsquery_ops
    DEFAULT FOR TYPE tsquery USING btree AS
    OPERATOR 1 <(tsquery,tsquery) ,
    OPERATOR 2 <=(tsquery,tsquery) ,
    OPERATOR 3 =(tsquery,tsquery) ,
    OPERATOR 4 >=(tsquery,tsquery) ,
    OPERATOR 5 >(tsquery,tsquery) ,
    FUNCTION 1 tsquery_cmp(tsquery,tsquery);


ALTER OPERATOR CLASS public.tsquery_ops USING btree OWNER TO postgres;

--
-- Name: tsvector_ops; Type: OPERATOR CLASS; Schema: public; Owner: postgres
--

CREATE OPERATOR CLASS tsvector_ops
    DEFAULT FOR TYPE tsvector USING btree AS
    OPERATOR 1 <(tsvector,tsvector) ,
    OPERATOR 2 <=(tsvector,tsvector) ,
    OPERATOR 3 =(tsvector,tsvector) ,
    OPERATOR 4 >=(tsvector,tsvector) ,
    OPERATOR 5 >(tsvector,tsvector) ,
    FUNCTION 1 tsvector_cmp(tsvector,tsvector);


ALTER OPERATOR CLASS public.tsvector_ops USING btree OWNER TO postgres;



--
-- Name: actions; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE actions (
    mailbox_pattern text NOT NULL,
    create_action text,
    delete_action text,
    rename_action text,
    copy_action text,
    username text NOT NULL
);


ALTER TABLE public.actions OWNER TO decimail;

--
-- Name: imap_mailbox_flags; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE imap_mailbox_flags (
    username text NOT NULL,
    mailbox_name text NOT NULL,
    flag text NOT NULL
);


ALTER TABLE public.imap_mailbox_flags OWNER TO decimail;

--
-- Name: imap_message_flags; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE imap_message_flags (
    username text NOT NULL,
    msg_id integer NOT NULL,
    flag text NOT NULL
);


ALTER TABLE public.imap_message_flags OWNER TO decimail;

--
-- Name: messages; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE messages (
    msg_id integer NOT NULL,
    "owner" text,
    subject text,
    msgdate timestamp with time zone,
    from_addr text,
    headers bytea,
    body bytea,
    rfc822_messageid text
);


ALTER TABLE public.messages OWNER TO decimail;

--
-- Name: recipients; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE recipients (
    recip_type text NOT NULL,
    addr text,
    msg_id integer NOT NULL
);


ALTER TABLE public.recipients OWNER TO decimail;

--
-- Name: address_info; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE address_info (
    email text NOT NULL,
    name text NOT NULL
);


ALTER TABLE public.address_info OWNER TO decimail;

--
-- Name: months; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE months (
    monthnum integer NOT NULL,
    monthname text
);


ALTER TABLE public.months OWNER TO decimail;

--
-- Name: years; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE years (
    "year" integer NOT NULL
);


ALTER TABLE public.years OWNER TO decimail;

--
-- Name: month_timeranges; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW month_timeranges AS
    SELECT ((('Chronological/'::text || (years."year")::text) || '/'::text) || months.monthname) AS mailbox_name, (((((years."year")::text || '-'::text) || (months.monthnum)::text) || '-01 00:00:00'::text))::timestamp with time zone AS start_time, ((((((years."year")::text || '-'::text) || (months.monthnum)::text) || '-01 00:00:00'::text))::timestamp with time zone + '1 mon'::interval) AS end_time FROM years, months;


ALTER TABLE public.month_timeranges OWNER TO decimail;

--
-- Name: year_timeranges; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW year_timeranges AS
    SELECT (('Chronological/'::text || (years."year")::text) || '/All Messages'::text) AS mailbox_name, (((years."year")::text || '-01-01 00:00:00'::text))::timestamp with time zone AS start_time, ((((years."year" + 1))::text || '-01-01 00:00:00'::text))::timestamp with time zone AS end_time FROM years;


ALTER TABLE public.year_timeranges OWNER TO decimail;

--
-- Name: all_timeranges; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW all_timeranges AS
    SELECT year_timeranges.mailbox_name, year_timeranges.start_time, year_timeranges.end_time FROM year_timeranges UNION SELECT month_timeranges.mailbox_name, month_timeranges.start_time, month_timeranges.end_time FROM month_timeranges;


ALTER TABLE public.all_timeranges OWNER TO decimail;

--
-- Name: auto_users; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE auto_users (
    username text,
    addr text NOT NULL,
    random_template text NOT NULL
);


ALTER TABLE public.auto_users OWNER TO decimail;

--
-- Name: bcc_addrs; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE bcc_addrs (
    addr text,
    msg_id integer NOT NULL
);


ALTER TABLE public.bcc_addrs OWNER TO decimail;

--
-- Name: cc_addrs; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE cc_addrs (
    addr text,
    msg_id integer NOT NULL
);


ALTER TABLE public.cc_addrs OWNER TO decimail;

--
-- Name: misc_common_mailboxes; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE misc_common_mailboxes (
    mailbox_name text NOT NULL,
    query text NOT NULL
);


ALTER TABLE public.misc_common_mailboxes OWNER TO decimail;

--
-- Name: recent_common_mailboxes; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE recent_common_mailboxes (
    mailbox_name text NOT NULL,
    query text NOT NULL
);


ALTER TABLE public.recent_common_mailboxes OWNER TO decimail;

--
-- Name: timerange_common_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW timerange_common_mailboxes AS
    SELECT all_timeranges.mailbox_name, (((('select msg_id from u_messages where msgdate between timestamp with time zone '''::text || (all_timeranges.start_time)::text) || ''' and timestamp with time zone '''::text) || (all_timeranges.end_time)::text) || ''''::text) AS query FROM all_timeranges ORDER BY all_timeranges.start_time;


ALTER TABLE public.timerange_common_mailboxes OWNER TO decimail;

--
-- Name: common_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW common_mailboxes AS
    (SELECT timerange_common_mailboxes.mailbox_name, timerange_common_mailboxes.query FROM timerange_common_mailboxes UNION SELECT recent_common_mailboxes.mailbox_name, recent_common_mailboxes.query FROM recent_common_mailboxes) UNION SELECT misc_common_mailboxes.mailbox_name, misc_common_mailboxes.query FROM misc_common_mailboxes;


ALTER TABLE public.common_mailboxes OWNER TO decimail;

--
-- Name: users; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE users (
    username text NOT NULL,
    passwd text
);


ALTER TABLE public.users OWNER TO decimail;

--
-- Name: common_mailboxes_per_user; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW common_mailboxes_per_user AS
    SELECT users.username, common_mailboxes.mailbox_name, common_mailboxes.query FROM (users CROSS JOIN common_mailboxes);


ALTER TABLE public.common_mailboxes_per_user OWNER TO decimail;

--
-- Name: configuration; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE configuration (
    variable text NOT NULL,
    "type" text NOT NULL,
    value text NOT NULL
);


ALTER TABLE public.configuration OWNER TO decimail;

--
-- Name: custom_domains; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE custom_domains (
    username text,
    "domain" text NOT NULL,
    custom_addr text NOT NULL
);


ALTER TABLE public.custom_domains OWNER TO decimail;

--
-- Name: custom_recipients; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE custom_recipients (
    username text NOT NULL,
    recipient text NOT NULL,
    custom_addr text NOT NULL
);


ALTER TABLE public.custom_recipients OWNER TO decimail;

--
-- Name: lists; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE lists (
    username text NOT NULL,
    list_name text NOT NULL,
    submit_addr text,
    custom_addr text
);


ALTER TABLE public.lists OWNER TO decimail;

--
-- Name: custom_addrs; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW custom_addrs AS
    (SELECT lists.username, lists.submit_addr AS correspondent_pat, lists.custom_addr FROM lists UNION SELECT custom_domains.username, ('%'::text || custom_domains."domain") AS correspondent_pat, custom_domains.custom_addr FROM custom_domains) UNION SELECT custom_recipients.username, custom_recipients.recipient AS correspondent_pat, custom_recipients.custom_addr FROM custom_recipients;


ALTER TABLE public.custom_addrs OWNER TO decimail;

--
-- Name: delete_log; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE delete_log (
    msg_id integer
);


ALTER TABLE public.delete_log OWNER TO decimail;

--
-- Name: domains; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE domains (
    username text NOT NULL,
    "domain" text NOT NULL
);


ALTER TABLE public.domains OWNER TO decimail;

--
-- Name: domain_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW domain_mailboxes AS
    SELECT domains.username, ('Domains/'::text || domains."domain") AS mailbox_name, (((('select m.msg_id from messages m where lower(split_part(from_addr,''@'',2)) = lower('''::text || domains."domain") || ''') and owner='''::text) || domains.username) || ''''::text) AS query FROM domains;


ALTER TABLE public.domain_mailboxes OWNER TO decimail;

--
-- Name: spam_addresses; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE spam_addresses (
    username text NOT NULL,
    spamtype text NOT NULL,
    email text NOT NULL,
    time_added timestamp with time zone DEFAULT now()
);


ALTER TABLE public.spam_addresses OWNER TO decimail;

--
-- Name: filter_recipients; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW filter_recipients AS
    SELECT spam_addresses.email FROM spam_addresses WHERE (spam_addresses.spamtype = 'Filter'::text);


ALTER TABLE public.filter_recipients OWNER TO decimail;

--
-- Name: foo; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE foo (
    a text
);


ALTER TABLE public.foo OWNER TO decimail;

--
-- Name: imap_unseen_messages; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW imap_unseen_messages AS
    SELECT imap_message_flags.msg_id FROM imap_message_flags WHERE (imap_message_flags.flag = '\\Unseen'::text);


ALTER TABLE public.imap_unseen_messages OWNER TO decimail;

--
-- Name: imap_seen_messages; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW imap_seen_messages AS
    SELECT messages.msg_id FROM messages EXCEPT SELECT imap_unseen_messages.msg_id FROM imap_unseen_messages;


ALTER TABLE public.imap_seen_messages OWNER TO decimail;

--
-- Name: imap_subscribed_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW imap_subscribed_mailboxes AS
    SELECT imap_mailbox_flags.username, imap_mailbox_flags.mailbox_name FROM imap_mailbox_flags WHERE (imap_mailbox_flags.flag = 'SUBSCRIBE'::text);


ALTER TABLE public.imap_subscribed_mailboxes OWNER TO decimail;

--
-- Name: incoming_addresses; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE incoming_addresses (
    address_pat text,
    username text
);


ALTER TABLE public.incoming_addresses OWNER TO decimail;

--
-- Name: keywords; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE keywords (
    username text NOT NULL,
    keyword text NOT NULL
);


ALTER TABLE public.keywords OWNER TO decimail;

--
-- Name: keyword_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW keyword_mailboxes AS
    SELECT keywords.username, ('Keywords/'::text || keywords.keyword) AS mailbox_name, (((('select pt.msg_id from part_tsearch pt join messages m using(msg_id) where pt.data_tsidx @@ to_tsquery(''default'','''::text || keywords.keyword) || ''')and m.owner='''::text) || keywords.username) || ''''::text) AS query FROM keywords;


ALTER TABLE public.keyword_mailboxes OWNER TO decimail;

--
-- Name: labels; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE labels (
    username text NOT NULL,
    label text NOT NULL
);


ALTER TABLE public.labels OWNER TO decimail;

--
-- Name: label_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW label_mailboxes AS
    SELECT labels.username, ('Labels/'::text || labels.label) AS mailbox_name, (((('select msg_id from labeled_messages where username='''::text || labels.username) || '''and label='''::text) || labels.label) || ''''::text) AS query FROM labels;


ALTER TABLE public.label_mailboxes OWNER TO decimail;

--
-- Name: labeled_messages; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE labeled_messages (
    username text NOT NULL,
    label text NOT NULL,
    msg_id integer NOT NULL
);


ALTER TABLE public.labeled_messages OWNER TO decimail;

--
-- Name: mailing_lists; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE mailing_lists (
    username text,
    list_name text NOT NULL,
    submit_addr text NOT NULL,
    custom_addr text NOT NULL
);


ALTER TABLE public.mailing_lists OWNER TO decimail;

--
-- Name: list_common_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW list_common_mailboxes AS
    SELECT ('Lists/'::text || mailing_lists.list_name) AS mailbox_name, (('select msg_id from to_addrs where addr='''::text || mailing_lists.submit_addr) || ''''::text) AS query FROM mailing_lists;


ALTER TABLE public.list_common_mailboxes OWNER TO decimail;

--
-- Name: lists_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW lists_mailboxes AS
    SELECT lists.username, ('Lists/'::text || lists.list_name) AS mailbox_name, CASE WHEN (lists.submit_addr IS NULL) THEN 'select 0 as msg_id where false'::text ELSE (('select msg_id from u_recipients where addr='''::text || lists.submit_addr) || ''''::text) END AS query FROM lists;


ALTER TABLE public.lists_mailboxes OWNER TO decimail;

--
-- Name: mailboxes; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE mailboxes (
    username text NOT NULL,
    mailbox_name text NOT NULL,
    query text NOT NULL
);


ALTER TABLE public.mailboxes OWNER TO decimail;

--
-- Name: people; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE people (
    username text NOT NULL,
    name text NOT NULL
);


ALTER TABLE public.people OWNER TO decimail;

--
-- Name: people_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW people_mailboxes AS
    SELECT people.username, ('People/'::text || people.name) AS mailbox_name, (((((((('select m.msg_id from u_messages m join people_addresses pa on (m.from_addr = pa.email) where pa.username='''::text || people.username) || '''and pa.name='''::text) || people.name) || '''union select m.msg_id from u_messages m join u_recipients r using(msg_id) join people_addresses pa on (r.addr = pa.email) where pa.username='''::text) || people.username) || '''and pa.name='''::text) || people.name) || ''''::text) AS query FROM people;


ALTER TABLE public.people_mailboxes OWNER TO decimail;

--
-- Name: spamtypes; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE spamtypes (
    username text NOT NULL,
    spamtype text NOT NULL
);


ALTER TABLE public.spamtypes OWNER TO decimail;

--
-- Name: spam_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW spam_mailboxes AS
    SELECT spamtypes.username, ('Spam/'::text || spamtypes.spamtype) AS mailbox_name, 'select 0 as msg_id where false'::text AS query FROM spamtypes;


ALTER TABLE public.spam_mailboxes OWNER TO decimail;

--
-- Name: subjects; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE subjects (
    username text NOT NULL,
    subject text NOT NULL
);


ALTER TABLE public.subjects OWNER TO decimail;

--
-- Name: subject_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW subject_mailboxes AS
    SELECT subjects.username, ('Subjects/'::text || subjects.subject) AS mailbox_name, (((('select m.msg_id from messages m where subject_tsidx @@ to_tsquery(''default'','''::text || subjects.subject) || ''')and owner='''::text) || subjects.username) || ''''::text) AS query FROM subjects;


ALTER TABLE public.subject_mailboxes OWNER TO decimail;

--
-- Name: mailboxes_view; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW mailboxes_view AS
    ((((((SELECT common_mailboxes_per_user.username, common_mailboxes_per_user.mailbox_name, common_mailboxes_per_user.query FROM common_mailboxes_per_user UNION SELECT people_mailboxes.username, people_mailboxes.mailbox_name, people_mailboxes.query FROM people_mailboxes) UNION SELECT domain_mailboxes.username, domain_mailboxes.mailbox_name, domain_mailboxes.query FROM domain_mailboxes) UNION SELECT subject_mailboxes.username, subject_mailboxes.mailbox_name, subject_mailboxes.query FROM subject_mailboxes) UNION SELECT label_mailboxes.username, label_mailboxes.mailbox_name, label_mailboxes.query FROM label_mailboxes) UNION SELECT spam_mailboxes.username, spam_mailboxes.mailbox_name, spam_mailboxes.query FROM spam_mailboxes) UNION SELECT lists_mailboxes.username, lists_mailboxes.mailbox_name, lists_mailboxes.query FROM lists_mailboxes) UNION SELECT keyword_mailboxes.username, keyword_mailboxes.mailbox_name, keyword_mailboxes.query FROM keyword_mailboxes;


ALTER TABLE public.mailboxes_view OWNER TO decimail;

--
-- Name: mailing_lists_backup; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE mailing_lists_backup (
    username text,
    list_name text,
    submit_addr text,
    custom_addr text
);


ALTER TABLE public.mailing_lists_backup OWNER TO decimail;

--
-- Name: messages_v; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW messages_v AS
    SELECT messages.msg_id, messages."owner", messages.subject, messages.msgdate, messages.from_addr, messages.headers, messages.body, ((length(messages.headers) + length(messages.body)) + 4) AS size FROM messages;


ALTER TABLE public.messages_v OWNER TO decimail;

--
-- Name: msg_ids; Type: SEQUENCE; Schema: public; Owner: decimail
--

CREATE SEQUENCE msg_ids
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.msg_ids OWNER TO decimail;

--
-- Name: part_tsearch; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE part_tsearch (
    msg_id integer NOT NULL,
    part text NOT NULL,
    data_tsidx tsvector NOT NULL
);


ALTER TABLE public.part_tsearch OWNER TO decimail;

--
-- Name: people_addresses; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE people_addresses (
    username text NOT NULL,
    name text NOT NULL,
    email text NOT NULL
);


ALTER TABLE public.people_addresses OWNER TO decimail;


--
-- Name: pg_ts_cfg; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pg_ts_cfg (
    ts_name text NOT NULL,
    prs_name text NOT NULL,
    locale text
);


ALTER TABLE public.pg_ts_cfg OWNER TO postgres;

--
-- Name: pg_ts_cfgmap; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pg_ts_cfgmap (
    ts_name text NOT NULL,
    tok_alias text NOT NULL,
    dict_name text[]
);


ALTER TABLE public.pg_ts_cfgmap OWNER TO postgres;

--
-- Name: pg_ts_dict; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pg_ts_dict (
    dict_name text NOT NULL,
    dict_init regprocedure,
    dict_initoption text,
    dict_lexize regprocedure NOT NULL,
    dict_comment text
);


ALTER TABLE public.pg_ts_dict OWNER TO postgres;

--
-- Name: pg_ts_parser; Type: TABLE; Schema: public; Owner: postgres; Tablespace: 
--

CREATE TABLE pg_ts_parser (
    prs_name text NOT NULL,
    prs_start regprocedure NOT NULL,
    prs_nexttoken regprocedure NOT NULL,
    prs_end regprocedure NOT NULL,
    prs_headline regprocedure NOT NULL,
    prs_lextype regprocedure NOT NULL,
    prs_comment text
);


ALTER TABLE public.pg_ts_parser OWNER TO postgres;


--
-- Name: random_addrs; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE random_addrs (
    username text NOT NULL,
    addr text NOT NULL,
    date_allocated timestamp with time zone DEFAULT now() NOT NULL,
    description text
);


ALTER TABLE public.random_addrs OWNER TO decimail;

--
-- Name: realnames; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE realnames (
    realname text NOT NULL,
    email text NOT NULL
);


ALTER TABLE public.realnames OWNER TO decimail;

--
-- Name: relaytofrom; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE relaytofrom (
    id integer NOT NULL,
    relay_ip inet,
    from_domain text,
    block_expires timestamp without time zone DEFAULT (now() + '00:01:00'::interval) NOT NULL,
    record_expires timestamp without time zone DEFAULT (now() + '7 days'::interval) NOT NULL,
    origin_type text DEFAULT 'AUTO'::text NOT NULL,
    create_time timestamp without time zone DEFAULT now() NOT NULL,
    CONSTRAINT relaytofrom_origin_type_check CHECK ((origin_type = ANY (ARRAY['MANUAL'::text, 'AUTO'::text])))
);


ALTER TABLE public.relaytofrom OWNER TO decimail;

--
-- Name: relaytofrom_id_seq; Type: SEQUENCE; Schema: public; Owner: decimail
--

CREATE SEQUENCE relaytofrom_id_seq
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


ALTER TABLE public.relaytofrom_id_seq OWNER TO decimail;

--
-- Name: relaytofrom_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: decimail
--

ALTER SEQUENCE relaytofrom_id_seq OWNED BY relaytofrom.id;


--
-- Name: spam_recipients; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW spam_recipients AS
    SELECT spam_addresses.email FROM spam_addresses WHERE (spam_addresses.spamtype = 'Spam'::text);


ALTER TABLE public.spam_recipients OWNER TO decimail;

--
-- Name: to_addrs; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE to_addrs (
    addr text,
    msg_id integer NOT NULL
);


ALTER TABLE public.to_addrs OWNER TO decimail;

--
-- Name: www; Type: TABLE; Schema: public; Owner: decimail; Tablespace: 
--

CREATE TABLE www (
    name text NOT NULL,
    addr text NOT NULL
);


ALTER TABLE public.www OWNER TO decimail;

--
-- Name: www_common_mailboxes; Type: VIEW; Schema: public; Owner: decimail
--

CREATE VIEW www_common_mailboxes AS
    SELECT ('WWW/'::text || www.name) AS mailbox_name, (('select msg_id from to_addrs where addr='''::text || www.addr) || ''''::text) AS query FROM www;


ALTER TABLE public.www_common_mailboxes OWNER TO decimail;

--
-- Name: id; Type: DEFAULT; Schema: public; Owner: decimail
--

ALTER TABLE relaytofrom ALTER COLUMN id SET DEFAULT nextval('relaytofrom_id_seq'::regclass);


--
-- Name: custom_recipients_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY custom_recipients
    ADD CONSTRAINT custom_recipients_pkey PRIMARY KEY (username, recipient);


--
-- Name: domains_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY domains
    ADD CONSTRAINT domains_pkey PRIMARY KEY (username, "domain");


--
-- Name: imap_mailbox_flags_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY imap_mailbox_flags
    ADD CONSTRAINT imap_mailbox_flags_pkey PRIMARY KEY (username, mailbox_name, flag);


--
-- Name: imap_message_flags_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY imap_message_flags
    ADD CONSTRAINT imap_message_flags_pkey PRIMARY KEY (username, msg_id, flag);


--
-- Name: keywords_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY keywords
    ADD CONSTRAINT keywords_pkey PRIMARY KEY (username, keyword);


--
-- Name: labeled_messages_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY labeled_messages
    ADD CONSTRAINT labeled_messages_pkey PRIMARY KEY (username, label, msg_id);


--
-- Name: labels_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY labels
    ADD CONSTRAINT labels_pkey PRIMARY KEY (username, label);


--
-- Name: lists_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY lists
    ADD CONSTRAINT lists_pkey PRIMARY KEY (username, list_name);


--
-- Name: mailboxes_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY mailboxes
    ADD CONSTRAINT mailboxes_pkey PRIMARY KEY (username, mailbox_name);


--
-- Name: messages_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY messages
    ADD CONSTRAINT messages_pkey PRIMARY KEY (msg_id);


--
-- Name: part_tsearch_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY part_tsearch
    ADD CONSTRAINT part_tsearch_pkey PRIMARY KEY (msg_id, part);


--
-- Name: people_addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY people_addresses
    ADD CONSTRAINT people_addresses_pkey PRIMARY KEY (username, name, email);


--
-- Name: people_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY people
    ADD CONSTRAINT people_pkey PRIMARY KEY (username, name);


--
-- Name: pg_ts_cfg_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pg_ts_cfg
    ADD CONSTRAINT pg_ts_cfg_pkey PRIMARY KEY (ts_name);


--
-- Name: pg_ts_cfgmap_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pg_ts_cfgmap
    ADD CONSTRAINT pg_ts_cfgmap_pkey PRIMARY KEY (ts_name, tok_alias);


--
-- Name: pg_ts_dict_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pg_ts_dict
    ADD CONSTRAINT pg_ts_dict_pkey PRIMARY KEY (dict_name);


--
-- Name: pg_ts_parser_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres; Tablespace: 
--

ALTER TABLE ONLY pg_ts_parser
    ADD CONSTRAINT pg_ts_parser_pkey PRIMARY KEY (prs_name);


--
-- Name: spam_addresses_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY spam_addresses
    ADD CONSTRAINT spam_addresses_pkey PRIMARY KEY (username, spamtype, email);


--
-- Name: spamtypes_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY spamtypes
    ADD CONSTRAINT spamtypes_pkey PRIMARY KEY (username, spamtype);


--
-- Name: subjects_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY subjects
    ADD CONSTRAINT subjects_pkey PRIMARY KEY (username, subject);


--
-- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: decimail; Tablespace: 
--

ALTER TABLE ONLY users
    ADD CONSTRAINT users_pkey PRIMARY KEY (username);


--
-- Name: address_info_by_name; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX address_info_by_name ON address_info USING btree (name);


--
-- Name: bcc_addrs_by_addr; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX bcc_addrs_by_addr ON bcc_addrs USING btree (addr);


--
-- Name: bcc_addrs_by_msg_id; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX bcc_addrs_by_msg_id ON bcc_addrs USING btree (msg_id);


--
-- Name: cc_addrs_by_addr; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX cc_addrs_by_addr ON cc_addrs USING btree (addr);


--
-- Name: cc_addrs_by_msg_id; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX cc_addrs_by_msg_id ON cc_addrs USING btree (msg_id);


--
-- Name: imap_message_flags_by_msg_id; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX imap_message_flags_by_msg_id ON imap_message_flags USING btree (msg_id);


--
-- Name: messages_by_date; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX messages_by_date ON messages USING btree (msgdate);


--
-- Name: messages_by_from_addr; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX messages_by_from_addr ON messages USING btree (from_addr);


--
-- Name: messages_by_from_addr_domain; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX messages_by_from_addr_domain ON messages USING btree (lower(split_part(from_addr, '@'::text, 2)));


--
-- Name: messages_by_owner; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX messages_by_owner ON messages USING btree ("owner");


--
-- Name: messages_by_rfc822_messageid; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX messages_by_rfc822_messageid ON messages USING btree (rfc822_messageid);


--
-- Name: messages_by_subject; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX messages_by_subject ON messages USING btree (subject);


--
-- Name: part_tsearch_by_data_tsidx; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX part_tsearch_by_data_tsidx ON part_tsearch USING gist (data_tsidx);


--
-- Name: part_tsearch_by_msg_id; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX part_tsearch_by_msg_id ON part_tsearch USING btree (msg_id);


--
-- Name: realnames_by_realname; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX realnames_by_realname ON realnames USING btree (realname);


--
-- Name: recipients_by_addr; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX recipients_by_addr ON recipients USING btree (addr);


--
-- Name: recipients_by_msg_id; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX recipients_by_msg_id ON recipients USING btree (msg_id);


--
-- Name: spam_addresses_by_email; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX spam_addresses_by_email ON spam_addresses USING btree (email);


--
-- Name: to_addrs_by_addr; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX to_addrs_by_addr ON to_addrs USING btree (addr);


--
-- Name: to_addrs_by_msg_id; Type: INDEX; Schema: public; Owner: decimail; Tablespace: 
--

CREATE INDEX to_addrs_by_msg_id ON to_addrs USING btree (msg_id);


--
-- Name: address_info_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER address_info_changed
    AFTER INSERT OR DELETE OR UPDATE ON address_info
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: domains_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER domains_changed
    AFTER INSERT OR DELETE OR UPDATE ON domains
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: keywords_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER keywords_changed
    AFTER INSERT OR DELETE OR UPDATE ON keywords
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: labels_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER labels_changed
    AFTER INSERT OR DELETE OR UPDATE ON labels
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: lists_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER lists_changed
    AFTER INSERT OR DELETE OR UPDATE ON lists
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: mailing_lists_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER mailing_lists_changed
    AFTER INSERT OR DELETE OR UPDATE ON mailing_lists
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: message_deleted; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER message_deleted
    BEFORE DELETE ON messages
    FOR EACH ROW
    EXECUTE PROCEDURE log_deleted_message();


--
-- Name: new_messages; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER new_messages
    AFTER INSERT ON messages
    FOR EACH ROW
    EXECUTE PROCEDURE notify_new_message();


--
-- Name: people_addresses_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER people_addresses_changed
    AFTER INSERT OR DELETE OR UPDATE ON people_addresses
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: people_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER people_changed
    AFTER INSERT OR DELETE OR UPDATE ON people
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: spamtypes_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER spamtypes_changed
    AFTER INSERT OR DELETE OR UPDATE ON spamtypes
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: subjects_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER subjects_changed
    AFTER INSERT OR DELETE OR UPDATE ON subjects
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: users_changed; Type: TRIGGER; Schema: public; Owner: decimail
--

CREATE TRIGGER users_changed
    AFTER INSERT OR DELETE OR UPDATE ON users
    FOR EACH STATEMENT
    EXECUTE PROCEDURE update_mailboxes();


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY to_addrs
    ADD CONSTRAINT "$1" FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY cc_addrs
    ADD CONSTRAINT "$1" FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY bcc_addrs
    ADD CONSTRAINT "$1" FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY auto_users
    ADD CONSTRAINT "$1" FOREIGN KEY (username) REFERENCES users(username) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY mailing_lists
    ADD CONSTRAINT "$1" FOREIGN KEY (username) REFERENCES users(username);


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY custom_domains
    ADD CONSTRAINT "$1" FOREIGN KEY (username) REFERENCES users(username);


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY imap_message_flags
    ADD CONSTRAINT "$1" FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY people_addresses
    ADD CONSTRAINT "$1" FOREIGN KEY (username, name) REFERENCES people(username, name) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY labeled_messages
    ADD CONSTRAINT "$1" FOREIGN KEY (username, label) REFERENCES labels(username, label) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY labeled_messages
    ADD CONSTRAINT "$2" FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON DELETE CASCADE;


--
-- Name: custom_recipients_username_fkey; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY custom_recipients
    ADD CONSTRAINT custom_recipients_username_fkey FOREIGN KEY (username) REFERENCES users(username);


--
-- Name: part_tsearch_msg_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY part_tsearch
    ADD CONSTRAINT part_tsearch_msg_id_fkey FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: recipients_msg_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY recipients
    ADD CONSTRAINT recipients_msg_id_fkey FOREIGN KEY (msg_id) REFERENCES messages(msg_id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: spam_addresses_username_fkey; Type: FK CONSTRAINT; Schema: public; Owner: decimail
--

ALTER TABLE ONLY spam_addresses
    ADD CONSTRAINT spam_addresses_username_fkey FOREIGN KEY (username, spamtype) REFERENCES spamtypes(username, spamtype) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
-- Name: filter_recipients; Type: ACL; Schema: public; Owner: decimail
--

REVOKE ALL ON TABLE filter_recipients FROM PUBLIC;
REVOKE ALL ON TABLE filter_recipients FROM decimail;
GRANT ALL ON TABLE filter_recipients TO decimail;
GRANT SELECT ON TABLE filter_recipients TO wwwdata;


--
-- Name: pg_ts_cfg; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE pg_ts_cfg FROM PUBLIC;
REVOKE ALL ON TABLE pg_ts_cfg FROM postgres;
GRANT ALL ON TABLE pg_ts_cfg TO postgres;
GRANT ALL ON TABLE pg_ts_cfg TO decimail;


--
-- Name: pg_ts_cfgmap; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE pg_ts_cfgmap FROM PUBLIC;
REVOKE ALL ON TABLE pg_ts_cfgmap FROM postgres;
GRANT ALL ON TABLE pg_ts_cfgmap TO postgres;
GRANT ALL ON TABLE pg_ts_cfgmap TO decimail;


--
-- Name: pg_ts_dict; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE pg_ts_dict FROM PUBLIC;
REVOKE ALL ON TABLE pg_ts_dict FROM postgres;
GRANT ALL ON TABLE pg_ts_dict TO postgres;
GRANT ALL ON TABLE pg_ts_dict TO decimail;


--
-- Name: pg_ts_parser; Type: ACL; Schema: public; Owner: postgres
--

REVOKE ALL ON TABLE pg_ts_parser FROM PUBLIC;
REVOKE ALL ON TABLE pg_ts_parser FROM postgres;
GRANT ALL ON TABLE pg_ts_parser TO postgres;
GRANT ALL ON TABLE pg_ts_parser TO decimail;


--
-- Name: random_addrs; Type: ACL; Schema: public; Owner: decimail
--

REVOKE ALL ON TABLE random_addrs FROM PUBLIC;
REVOKE ALL ON TABLE random_addrs FROM decimail;
GRANT ALL ON TABLE random_addrs TO decimail;
GRANT INSERT ON TABLE random_addrs TO wwwdata;


--
-- Name: relaytofrom; Type: ACL; Schema: public; Owner: decimail
--

REVOKE ALL ON TABLE relaytofrom FROM PUBLIC;
REVOKE ALL ON TABLE relaytofrom FROM decimail;
GRANT ALL ON TABLE relaytofrom TO decimail;
GRANT SELECT,INSERT,UPDATE ON TABLE relaytofrom TO wwwdata;


--
-- Name: relaytofrom_id_seq; Type: ACL; Schema: public; Owner: decimail
--

REVOKE ALL ON SEQUENCE relaytofrom_id_seq FROM PUBLIC;
REVOKE ALL ON SEQUENCE relaytofrom_id_seq FROM decimail;
GRANT ALL ON SEQUENCE relaytofrom_id_seq TO decimail;
GRANT ALL ON SEQUENCE relaytofrom_id_seq TO wwwdata;


--
-- Name: spam_recipients; Type: ACL; Schema: public; Owner: decimail
--

REVOKE ALL ON TABLE spam_recipients FROM PUBLIC;
REVOKE ALL ON TABLE spam_recipients FROM decimail;
GRANT ALL ON TABLE spam_recipients TO decimail;
GRANT SELECT ON TABLE spam_recipients TO wwwdata;


--
--

