Re: review: CHECK FUNCTION statement - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: review: CHECK FUNCTION statement
Date
Msg-id CAFj8pRAmC5DMJB944NHUxg-+ocwqONOG6A4oMqPv26x33z=Zhw@mail.gmail.com
Whole thread Raw
In response to Re: review: CHECK FUNCTION statement  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Responses Re: review: CHECK FUNCTION statement  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
List pgsql-hackers
Hello

there is a updated patch.

it support multi check, options and custom check functions are not
supported yet. I don't plan to implement custom check functions in
this round - I has not any example of usage - but we have agreement on
syntax and behave, so this should not be problem. I changed reporting
- from exception to warnings.

postgres=# check function all in schema public;
NOTICE:  skip check function "hello()", it use C or internal language
NOTICE:  skip check function "tri()", it is trigger function
NOTICE:  skip check function "vloz_do_foo(integer)", language "sql"
hasn't checker function
NOTICE:  skip check function "mojefunc(integer)", language "sql"
hasn't checker function
NOTICE:  skip check function "myleft(text,integer)", language "sql"
hasn't checker function
NOTICE:  checked function "array_random(integer,integer)"
NOTICE:  skip check function "array_random1(integer,integer)",
language "sql" hasn't checker function
NOTICE:  checked function "vrattab(integer)"
NOTICE:  checked function "yyy()"
NOTICE:  checked function "xxx()"
WARNING:  error in function "zpracuj(integer)"
LINE 1: select h from hodnoty
               ^
DETAIL:  column "h" does not exist
QUERY:  select h from hodnoty
CONTEXT:  line 4 at FOR over SELECT rows
WARNING:  error in function "ii(integer)"
LINE 1: SELECT (select aa from i)
                       ^
DETAIL:  column "aa" does not exist
QUERY:  SELECT (select aa from i)
CONTEXT:  line 3 at RETURN
CHECK FUNCTION

postgres=# check function all in schema public in language plpgsql;
NOTICE:  skip check function "tri()", it is trigger function
NOTICE:  checked function "array_random(integer,integer)"
NOTICE:  checked function "vrattab(integer)"
NOTICE:  checked function "yyy()"
NOTICE:  checked function "xxx()"
WARNING:  error in function "zpracuj(integer)"
LINE 1: select h from hodnoty
               ^
DETAIL:  column "h" does not exist
QUERY:  select h from hodnoty
CONTEXT:  line 4 at FOR over SELECT rows
WARNING:  error in function "ii(integer)"
LINE 1: SELECT (select aa from i)
                       ^
DETAIL:  column "aa" does not exist
QUERY:  SELECT (select aa from i)
CONTEXT:  line 3 at RETURN
CHECK FUNCTION

postgres=# check function all in schema public in language plpgsql for role www;
NOTICE:  nothing to check
CHECK FUNCTION

please, try it

Regards

Pavel Stehule

2011/12/3 Albe Laurenz <laurenz.albe@wien.gv.at>:
> Pavel Stehule wrote:
>>> My attempt at a syntax that could also cover Peter's wish for multiple
>>> checker functions:
>>>
>>> CHECK FUNCTION { func(args) | ALL [IN SCHEMA schema] [FOR ROLE user] }
>>>  [ USING check_function ] OPTIONS (optname optarg [, ...])
>
>> check_function should be related to one language, so you have to
>> specify language if you would to specify check_function (if we would
>> to have more check functions for one language).
>
> Right, I forgot LANGUAGE:
>
> CHECK FUNCTION { func(args) | ALL IN LANGUAGE pl [IN SCHEMA schema] [FOR ROLE user] }
>  [ USING check_function ] OPTIONS (optname optarg [, ...])
>
> If func(args) is given, the language can be inferred.
>
> Yours,
> Laurenz Albe

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_upgrade and relkind filtering
Next
From: Shigeru Hanada
Date:
Subject: Re: pgsql_fdw, FDW for PostgreSQL server