Re: review: CHECK FUNCTION statement
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: Greg Smith <greg@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org, Albe Laurenz <laurenz.albe@wien.gv.at>
Date: 2012-01-01T12:01:08Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Add const qualifiers to node inspection functions
- d5f23af6bfbc 9.2.0 cited
Attachments
- check_function-2012-01-01-1.diff.gz (application/x-gzip) patch 2012
Hello all
here is new version of CHECK FUNCTION patch
I changed implementation of interface:
* checked functions returns table instead raising exceptions - it
necessary for describing more issues inside one function - and it
allow to use better structured data then ExceptionData
postgres=# select lineno, statement, sqlstate, message, detail, hint,
level, "position", query from plpgsql_checker('f1()', 0, '{}', false);
lineno | statement | sqlstate | message
| detail | hint | level | position | query
--------+---------------+----------+--------------------------------------------+--------+--------+-------+----------+----------------------
4 | SQL statement | 42703 | column "c" of relation "t1" does
not exist | [null] | [null] | error | 15 | update t1 set c = 30
7 | RAISE | 42P01 | missing FROM-clause entry for
table "r" | [null] | [null] | error | 8 | SELECT r.c
7 | RAISE | 42601 | too few parameters specified for
RAISE | [null] | [null] | error | [null] | [null]
(3 rows)
* result of CHECK FUNCTION is simple table (like EXPLAIN - based on
Tom proposition)
postgres=# check function f1();
CHECK FUNCTION
------------------------------------------------------------------------
In function: 'f1()'
error:42703:4:SQL statement:column "c" of relation "t1" does not exist
query:update t1 set c = 30
^
error:42P01:7:RAISE:missing FROM-clause entry for table "r"
query:SELECT r.c
^
error:42601:7:RAISE:too few parameters specified for RAISE
(8 rows)
This change allow a more playing with output
postgres=# check function all in schema public;
CHECK FUNCTION
────────────────────────────────────────────────────────────────────────
In function: 'bubu(integer)'
error:42703:2:assignment:column "v" does not exist
query:SELECT a + v
^
error:42601:3:RETURN:query "SELECT 1,1" returned 2 columns
query:SELECT 1,1
In function: 'f1()'
error:42703:4:SQL statement:column "c" of relation "t1" does not exist
query:update t1 set c = 30
^
error:42P01:7:RAISE:missing FROM-clause entry for table "r"
query:SELECT r.c
^
error:42601:7:RAISE:too few parameters specified for RAISE
Function is valid: 'ff(integer)'
Function is valid: 'fff(integer)'
(18 rows)
Regards
Pavel Stehule