pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gene Selkov Jr. <selkovjr@xnet.com>
To: Brett W. McCoy <bmccoy@lan2wan.com>
To: pgsql-interfaces@postgreSQL.org
Subject: Re: [INTERFACES] Detecting existance of table
Date: Wed, 21 Apr 1999 16:45:16 -0400
Message-ID: <199904212145.QAA23534@antares.mcs.anl.gov> (raw)
In-Reply-To: <Pine.BSI.3.91.990421184714.10411U-100000@access1.lan2wan.com>

> Is there a way of detecting the existance of a table via a function call? 

Not through the client library, as far as I can tell. Why would you
need a function call?  Send a query, like this one:

http://wit.mcs.anl.gov/EMP/list-classes.cgi?database=emp

> Actually, can an exception be caught somehow?  I'm 
> mainly doing this with PHP3, but I also need to do it via the Perl Pg.pm

That's easy in perl:

  eval {local $SIG{__DIE__}; do soemthing wrong here }

This piece of code will catch an exception caused by eval() and do
nothing.  Refer to the following document for an extensive discussion
of signal handling (__DIE__ is just a signal):

http://theory.uwinnipeg.ca/CPAN/data/pod2texi/perlipc.html

However, I don't see how anything you do in Pg might lead to an
exception (other than FPE). Queries against non-existent objects will
generate errors in the backend, of which your code will be notified
via Pg. But that will not cause any exceptions. You will just get
a different result code.

But I agree that filling your server log with harmless error messages
is not good. Query pg_class first.

--Gene



view thread (3+ messages)  latest in thread

Message-ID: <199904212145.QAA23534@antares.mcs.anl.gov>
Permalink:  ../199904212145.QAA23534@antares.mcs.anl.gov/
Also on:    postgresql.org/message-id/199904212145.QAA23534@antares.mcs.anl.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: selkovjr@xnet.com, bmccoy@lan2wan.com
  Subject: Re: [INTERFACES] Detecting existance of table
  In-Reply-To: <199904212145.QAA23534@antares.mcs.anl.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox