Re: poll: CHECK TRIGGER? - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: poll: CHECK TRIGGER?
Date
Msg-id CAFj8pRA=mf9+5uq99R2Bn2Yo7iXYdf6eNcxeo+aAm6kzadki0A@mail.gmail.com
Whole thread Raw
In response to Re: poll: CHECK TRIGGER?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello

2012/3/7 Tom Lane <tgl@sss.pgh.pa.us>:
> Robert Haas <robertmhaas@gmail.com> writes:
>> Just to be clear, I am not proposing that we get rid of CHECK TRIGGER
>> and keep CHECK FUNCTION.  I'm proposing that we get rid of all of the
>> dedicated syntax support, and expose it all through one or more
>> SQL-callable functions.
>
> This seems entirely reasonable to me.  The syntax support is not the
> value-add in this patch, and it's been clear since day one that it would
> be difficult for the syntax to cover all the likely permutations of
> "which functions do you want to check?".  A function-based interface
> seems like both less work and more functionality.  Yes, it's marginally
> less convenient for simple cases, but I'm not even sure that we know
> which "simple cases" are going to be popular.  We can and should
> postpone that decision until we have some field experience to base it on.
>
>> If we need both
>> plpgsql_check_function(procoid) and plpgsql_check_trigger(tgoid), no
>> problem.
>
> FWIW, I would suggest check_trigger(regclass, name) not tgoid, because
> we do not have a regtrigger convenience type (and I don't think it's
> worth adding one).
>
> More importantly, I do not agree with requiring the user to specify the
> language name --- that is, it should be check_function(procoid) and have
> that look up a language-specific checker.  Otherwise, scenarios like
> "check all my functions regardless of language" are too painful.
> There is value-added in providing that much infrastructure.

here is implementation of reduced patch - it is not final - no doc, no
regress test, just only functional interface

postgres=> \sf fx
CREATE OR REPLACE FUNCTION public.fx()
 RETURNS SETOF text
 LANGUAGE plpgsql
AS $function$
begin
  return next 'In function f1():';
  return next 'error:afasdf:asfsafdsgfsgf' || a;
  return;
end;
$function$
postgres=> select pg_check_function('fx()');
                  pg_check_function
-----------------------------------------------------
 In function fx():
 error:42703:4:RETURN NEXT:column "a" does not exist
 Query: SELECT 'error:afasdf:asfsafdsgfsgf' || a
 --                                            ^
(4 rows)

caret is on correct position

I'll prepare check_trigger function tomorrow

Regards

Pavel

>
>                        regards, tom lane

Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: poll: CHECK TRIGGER?
Next
From: Pavel Stehule
Date:
Subject: Re: WARNING: concurrent insert in progress within table "resource"