/ db / views /
/db/views/_error_immutable.m4
1 dnl Copyright (C) 2012, 2014 The Meme Factory, Inc., http://www.meme.com/
2 dnl Copyright (C) 2007, 2008, Karl O. Pinc
3 dnl
4 dnl This file is part of Gombe-MI.
5 dnl
6 dnl Gombe-MI is free software; you can redistribute it and/or modify
7 dnl it under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3 of the License, or
9 dnl (at your option) any later version.
10 dnl
11 dnl This program is distributed in the hope that it will be useful,
12 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 dnl GNU General Public License for more details.
15 dnl
16 dnl You should have received a copy of the GNU General Public License
17 dnl along with Gombe-MI. If not, see <http://www.gnu.org/licenses/>.
18 dnl
19 dnl Deliver an error message on an attempt to change a computed value.
20 dnl Karl O. Pinc <kop@meme.com>
21 dnl
22 dnl
23 dnl m4 includes
24 include(`copyright.m4')
25 include(`constants.m4')
26 include(`macros.m4')
27 dnl
28
29 CREATE OR REPLACE FUNCTION
30 _error_immutable(col TEXT)
31 RETURNS INT
32 LANGUAGE plpgsql
33 gmi_function_set_search_path
34 AS $$
35
36 -- Raise error on an attempt to change an immutable column's value.
37 --
38 -- Copyright (C) 2014 The Meme Factory, Inc. http://www.meme.com/
39 -- GPL_notice(` --', `2007', `Karl O. Pinc <kop@meme.com>')
40 --
41 -- Syntax: _error_immutable(col TEXT)
42 --
43 -- Input:
44 -- col The immutable column.
45 --
46 -- Returns:
47 --
48 -- Side Effects:
49 -- Raises an exception.
50 --
51 -- Remarks:
52 -- Used when somebody tries to modify a view's computed column.
53
54
55 DECLARE
56
57 BEGIN
58 RAISE EXCEPTION '%: Attempt to insert or update a computed or otherwise immutable column'
59 , col;
60 RETURN 0;
61 END;
62 $$;
63
64 grant_func_priv(`_error_immutable(TEXT)')