Re: [INTERFACES] Detecting existance of table

From: "Gene Selkov Jr(dot)" <selkovjr(at)xnet(dot)com>
To: "Brett W(dot) McCoy" <bmccoy(at)lan2wan(dot)com>, pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Detecting existance of table
Date: 1999-04-21 20:45:16
Message-ID: 199904212145.QAA23534@antares.mcs.anl.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> 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

Browse pgsql-interfaces by date

  From Date Subject
Next Message Brett W. McCoy 1999-04-21 23:00:20 Detecting existance of table
Previous Message Gene Selkov, Jr. 1999-04-21 19:36:08 Re: [SQL] perl and postgres. . .