timescaledb/sql/common/errors.sql
Erik Nordström 7b94c573ba Refactor directory structure and tests
- Directory structure now matches common practices
- Regression tests now run with pg_regress via the PGXS infrastructure.
- Unit tests do not integrate well with pg_regress and have to be run
  separately.
- Docker functionality is separate from main Makefile. Run with
  `make -f docker.mk` to build and `make -f docker.mk run` to run
  the database in a container.
2017-01-31 20:14:19 +01:00

38 lines
960 B
PL/PgSQL

-- Defines error codes used
-- PREFIX IO
-- IO000 - GROUP: query errors
-- IO001 - hypertable does not exist
-- IO002 - column does not exist
--IO100 - GROUP: DDL errors
--IO101 - operation not supported
--IO102 - bad hypertable definition
--IO110 - hypertable already exists
--I0120 - node already exists
--I0130 - user already exists
--IO500 - GROUP: internal error
--IO501 - unexpected state/event
--IO502 - communication/remote error
CREATE OR REPLACE FUNCTION _iobeamdb_internal.on_trigger_error(
tg_op TEXT,
tg_schema NAME,
tg_table NAME
)
RETURNS VOID LANGUAGE PLPGSQL AS
$BODY$
BEGIN
RAISE EXCEPTION 'Operation % not supported on %.%', tg_op, tg_schema, tg_table
USING ERRCODE = 'IO101';
END
$BODY$;
CREATE OR REPLACE FUNCTION _iobeamdb_internal.on_truncate_block()
RETURNS TRIGGER LANGUAGE PLPGSQL AS
$BODY$
BEGIN
PERFORM _iobeamdb_internal.on_trigger_error(TG_OP, TG_TABLE_SCHEMA, TG_TABLE_NAME);
END
$BODY$;