dnl Copyright (C) 2012, 2014 The Meme Factory, Inc., http://www.meme.com/
dnl Copyright (C) 2007, 2008, Karl O. Pinc
dnl
dnl This file is part of Gombe-MI.
dnl
dnl Gombe-MI is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 3 of the License, or
dnl (at your option) any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with Gombe-MI. If not, see .
dnl
dnl Deliver an error message on an attempt to change a computed value.
dnl Karl O. Pinc
dnl
dnl
dnl m4 includes
include(`copyright.m4')
include(`constants.m4')
include(`macros.m4')
dnl
CREATE OR REPLACE FUNCTION
_error_immutable(col TEXT)
RETURNS INT
LANGUAGE plpgsql
gmi_function_set_search_path
AS $$
-- Raise error on an attempt to change an immutable column's value.
--
-- Copyright (C) 2014 The Meme Factory, Inc. http://www.meme.com/
-- GPL_notice(` --', `2007', `Karl O. Pinc ')
--
-- Syntax: _error_immutable(col TEXT)
--
-- Input:
-- col The immutable column.
--
-- Returns:
--
-- Side Effects:
-- Raises an exception.
--
-- Remarks:
-- Used when somebody tries to modify a view's computed column.
DECLARE
BEGIN
RAISE EXCEPTION '%: Attempt to insert or update a computed or otherwise immutable column'
, col;
RETURN 0;
END;
$$;
grant_func_priv(`_error_immutable(TEXT)')