proposal: catch warnings

From: "Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: proposal: catch warnings
Date: 2007-01-07 08:59:52
Message-ID: BAY114-F38133B0D5D11B7CF019CE9F9BD0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2007-01-07 09:12:30 Re: [PATCHES] [Fwd: Index Advisor]
Previous Message Simon Riggs 2007-01-07 08:57:47 Re: 8.3 pending patch queue