Re: review: CHECK FUNCTION statement

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема Re: review: CHECK FUNCTION statement
Дата
Msg-id CAFj8pRDKfy3qAzuiszsYhAf5zcfnG0PubP-T2=BTp10+FXq7Xw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: review: CHECK FUNCTION statement  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: review: CHECK FUNCTION statement  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Re: review: CHECK FUNCTION statement  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
Re: review: CHECK FUNCTION statement  (Petr Jelínek <pjmodos@pjmodos.net>)
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Manabu Ori
Дата:
Сообщение: Re: spinlocks on powerpc
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Re: backup_label during crash recovery: do we know how to solve it?