Revision 14288
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/schemas/util.sql | ||
---|---|---|
5995 | 5995 |
|
5996 | 5996 |
CREATE FUNCTION view_is_automatically_updatable(view_def text) RETURNS boolean |
5997 | 5997 |
LANGUAGE sql IMMUTABLE |
5998 |
AS $_$ |
|
5999 |
SELECT $1 !~ '\y(?:JOIN|WITH|DISTINCT|GROUP BY|HAVING|LIMIT|OFFSET)\y' |
|
5998 |
AS $$ |
|
5999 |
SELECT util.view_body(view_def) |
|
6000 |
!~ '\y(?:JOIN|WITH|DISTINCT|GROUP BY|HAVING|LIMIT|OFFSET)\y' |
|
6000 | 6001 |
/* from http://www.postgresql.org/docs/9.3/static/sql-createview.html#SQL-CREATEVIEW-UPDATABLE-VIEWS */ |
6001 |
$_$;
|
|
6002 |
$$; |
|
6002 | 6003 |
|
6003 | 6004 |
|
6004 | 6005 |
-- |
... | ... | |
6007 | 6008 |
|
6008 | 6009 |
CREATE FUNCTION view_is_subset(view_def text) RETURNS boolean |
6009 | 6010 |
LANGUAGE sql IMMUTABLE |
6010 |
AS $_$
|
|
6011 |
SELECT util.view_is_automatically_updatable($1)
|
|
6012 |
AND $1 !~ '\y(?:WHERE)\y|\([^-]|[^-]\)' -- "(-x-)" in col name is OK
|
|
6013 |
$_$;
|
|
6011 |
AS $$ |
|
6012 |
SELECT util.view_is_automatically_updatable(view_def)
|
|
6013 |
AND util.view_body(view_def) !~ '\y(?:WHERE)\y|\([^-]|[^-]\)' --"(-x-)" in col name OK
|
|
6014 |
$$; |
|
6014 | 6015 |
|
6015 | 6016 |
|
6016 | 6017 |
-- |
Also available in: Unified diff
bugfix: schemas/util.sql: view_is_automatically_updatable(), view_is_subset(): use util.view_body() so not matching COMMENT statements, etc