proposal: catch warnings - Mailing list pgsql-hackers

From Pavel Stehule
Subject proposal: catch warnings
Date
Msg-id BAY114-F38133B0D5D11B7CF019CE9F9BD0@phx.gbl
Whole thread Raw
Responses Re: proposal: catch warnings
Re: proposal: catch warnings
List pgsql-hackers
Hello,

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)                       EmitErrorReport();       }       else
EmitErrorReport();

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/



pgsql-hackers by date:

Previous
From: "Simon Riggs"
Date:
Subject: Re: 8.3 pending patch queue
Next
From: "Simon Riggs"
Date:
Subject: Re: [PATCHES] [Fwd: Index Advisor]