PostgreSQL allow only catch exception (elevel ERROR). SQL/PSM requires that warnings are catchable too. Simply solution's is adding one callback to error's processing of errors on level WARNING.

typedef struct WarningHandlerCallback
       bool            (*callback) (void *arg, ErrorData *edata);
       void       *arg;
} WarningHandlerCallback;

extern DLLIMPORT WarningHandlerCallback *warning_handler;

Callback function returns true if accept warning and process it. This function is called from errfinish()

* Emit the message to the right places. If warning_handler is defined, * try use warning_handler. Emit message only if handler don't accept * message (returns false). Warning handlers are used in PL/pgPSM language.
       if (elevel == WARNING)
               bool handled = false;

               if (warning_handler)
handled = (*warning_handler->callback)(warning_handler->arg,edata);

               if (!handled)

It's propably usable only for SQL/PSM implementation, and it's one from two necessery hacks to core for this PL (second is scrollable cursor's support). But without this hook I cannot simply distribute plpgpsm.

Any comments?

Best regards

Pavel Stehule

Chcete sdilet sve obrazky a hudbu s prateli? http://messenger.msn.cz/

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to