Re: trigger functions broken?
От | Alvaro Herrera |
---|---|
Тема | Re: trigger functions broken? |
Дата | |
Msg-id | 20081008195148.GE4164@alvh.no-ip.org обсуждение исходный текст |
Ответ на | Re: trigger functions broken? ("A. Kretschmer" <andreas.kretschmer@schollglas.com>) |
Список | pgsql-hackers |
A. Kretschmer wrote: > am Wed, dem 08.10.2008, um 14:29:23 -0400 mailte Alvaro Herrera folgendes: > > Hi, > > > > Trigger functions are supposed to be able to be called only as triggers, > > but apparently the check is not working in CVS HEAD: > > > > alvherre=# create or replace function foo () returns trigger as $$ begin perform 1; return new; end; $$ language plpgsql; > > CREATE FUNCTION > > alvherre=# select foo(); > > foo > > ----- > > > > (1 fila) > > And? And the source says that this is not allowed: /* Disallow pseudotype result, except VOID or RECORD */ /* (note we already replaced polymorphic types)*/ if (typeStruct->typtype == TYPTYPE_PSEUDO) { if (rettypeid == VOIDOID || rettypeid == RECORDOID) /* okay */ ; else if (rettypeid == TRIGGEROID) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("trigger functions can only be called as triggers"))); else ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("plpgsql functions cannotreturn type %s", format_type_be(rettypeid)))); } > The function returns a TRIGGER, not a value. Precisely. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.
В списке pgsql-hackers по дате отправления: