AW: More on elog and error codes - Mailing list pgsql-hackers

From Zeugswetter Andreas SB
Subject AW: More on elog and error codes
Date
Msg-id 11C1E6749A55D411A9670001FA687963368256@sdexcsrv1.f000.d0188.sd.spardat.at
Whole thread Raw
Responses Re: AW: More on elog and error codes  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> #define PGERR_TYPE 1854

#define PGSQLSTATE_TYPE    "S0021"    // char(5) SQLSTATE 

The standard calls this error variable SQLSTATE 
(look up in ESQL standard)

first 2 chars are class next 3 are subclass

"00000"  is e.g. Success 
"02000"  is Data not found
"U0xxx" user defined routine error xxx is user defined

> /* somewhere... */
> 
> elogc(ERROR, PGERR_TYPE, "type %s cannot be created because it already exists", ...)

PGELOG(ERROR, PGSQLSTATE_TYPE, ("type %s cannot be created because it already exists", ...))

put varargs into parentheses to avoid need for ... macros see Tom's proposal

I also agree, that we can group different text messages into the same SQLSTATE,
if it seems appropriate for the client to handle them alike.

Andreas


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: AW: Re: More on elog and error codes
Next
From: Larry Rosenman
Date:
Subject: Re: AW: Re: More on elog and error codes