Thread: C exception code

C exception code

From
Bruce Momjian
Date:
Are we interested in adding Try/Catch exception code to PostgreSQL. 
This looks interesting:
http://www.cs.berkeley.edu/~amc/cexcept/

--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: C exception code

From
Giles Lean
Date:
> Are we interested in adding Try/Catch exception code to PostgreSQL. 
> This looks interesting:
> 
>     http://www.cs.berkeley.edu/~amc/cexcept/

IMHO using the C pre-processor to make C look like some other language:

- makes the code harder to read as readers have to learn the dialect first

- makes the code harder to debug, since debugging tools don't know the dialect but only the C it is translated into

This exception implementation has the obvious(?) problem of using
setjump()/longjmp() where sigsetjmp()/siglongjmp() would probably be
necessary for postgresql.

There are places too where this implementation would just plain not
work and so couldn't be used: setjmp(), longjmp(), sigsetjump(), and
siglongjmp() are not async safe signal functions and so can't be
called in signal handlers, for a start.

Regards,

Giles





Re: C exception code

From
Bruce Momjian
Date:
Oh, well.  At least I asked.  :-)


> 
> > Are we interested in adding Try/Catch exception code to PostgreSQL. 
> > This looks interesting:
> > 
> >     http://www.cs.berkeley.edu/~amc/cexcept/
> 
> IMHO using the C pre-processor to make C look like some other language:
> 
> - makes the code harder to read as readers have to learn the dialect
>   first
> 
> - makes the code harder to debug, since debugging tools don't know the
>   dialect but only the C it is translated into
> 
> This exception implementation has the obvious(?) problem of using
> setjump()/longjmp() where sigsetjmp()/siglongjmp() would probably be
> necessary for postgresql.
> 
> There are places too where this implementation would just plain not
> work and so couldn't be used: setjmp(), longjmp(), sigsetjump(), and
> siglongjmp() are not async safe signal functions and so can't be
> called in signal handlers, for a start.
> 
> Regards,
> 
> Giles
> 
> 
> 
> 


--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


Re: C exception code

From
Chris Bitmead
Date:
Bruce Momjian wrote:
> 
> Are we interested in adding Try/Catch exception code to PostgreSQL.
> This looks interesting:
> 
>         http://www.cs.berkeley.edu/~amc/cexcept/

How tricky is the error handling in Postgres?

As an aside, I have just started working on a Java project, nearly done
for a company where they have not used the Java exception model. I.e.
there are error codes, setErrorCode, and ifError everywhere. A bigger
mess you will not see. So I'm partial to a decent exception model, and
might even use the above in a project of my own.