citus/cstore_fdw--1.7.sql

89 lines
1.9 KiB
PL/PgSQL

/* cstore_fdw/cstore_fdw--1.7.sql */
-- complain if script is sourced in psql, rather than via CREATE EXTENSION
\echo Use "CREATE EXTENSION cstore_fdw" to load this file. \quit
CREATE FUNCTION cstore_fdw_handler()
RETURNS fdw_handler
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FUNCTION cstore_fdw_validator(text[], oid)
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FOREIGN DATA WRAPPER cstore_fdw
HANDLER cstore_fdw_handler
VALIDATOR cstore_fdw_validator;
CREATE FUNCTION cstore_ddl_event_end_trigger()
RETURNS event_trigger
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE EVENT TRIGGER cstore_ddl_event_end
ON ddl_command_end
EXECUTE PROCEDURE cstore_ddl_event_end_trigger();
CREATE FUNCTION cstore_table_size(relation regclass)
RETURNS bigint
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION cstore_clean_table_resources(oid)
RETURNS void
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE OR REPLACE FUNCTION cstore_drop_trigger()
RETURNS event_trigger
LANGUAGE plpgsql
AS $csdt$
DECLARE v_obj record;
BEGIN
FOR v_obj IN SELECT * FROM pg_event_trigger_dropped_objects() LOOP
IF v_obj.object_type NOT IN ('table', 'foreign table') THEN
CONTINUE;
END IF;
PERFORM public.cstore_clean_table_resources(v_obj.objid);
END LOOP;
END;
$csdt$;
CREATE EVENT TRIGGER cstore_drop_event
ON SQL_DROP
EXECUTE PROCEDURE cstore_drop_trigger();
CREATE TABLE cstore_table_metadata(
relid oid,
version_major int,
version_minor int
);
CREATE TABLE cstore_stripe(
relid oid,
stripe bigint
);
CREATE TABLE cstore_column_block_skip_node(
relid oid,
stripe bigint,
attr int,
blockid int,
rowcount bigint,
min_value text,
max_value text,
value_offset bigint,
value_length bigint,
value_compression_type char,
exists_offset bigint,
exists_length bigint);
CREATE INDEX cstore_column_block_skip_node_idx
ON cstore_column_block_skip_node
USING BTREE(relid, stripe, attr, blockid);