Re: review: CHECK FUNCTION statement

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Greg Smith <greg(at)2ndquadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Subject: Re: review: CHECK FUNCTION statement
Date: 2012-01-01 12:01:08
Message-ID: CAFj8pRDKfy3qAzuiszsYhAf5zcfnG0PubP-T2=BTp10+FXq7Xw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
check_function-2012-01-01-1.diff.gz application/x-gzip 29.8 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2012-01-01 13:18:16 Re: backup_label during crash recovery: do we know how to solve it?
Previous Message Manabu Ori 2012-01-01 11:37:32 Re: spinlocks on powerpc