pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: [INTERFACES] Detecting existance of table
3+ messages / 3 participants
[nested] [flat]
* Re: [INTERFACES] Detecting existance of table
@ 1999-04-21 20:45 Gene Selkov Jr. <selkovjr@xnet.com>
parent: Brett W. McCoy <bmccoy@lan2wan.com>
1 sibling, 0 replies; 3+ messages in thread
From: Gene Selkov Jr. @ 1999-04-21 20:45 UTC (permalink / raw)
To: Brett W. McCoy <bmccoy@lan2wan.com>; 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Detecting existance of table
@ 1999-04-21 23:00 Brett W. McCoy <bmccoy@lan2wan.com>
0 siblings, 2 replies; 3+ messages in thread
From: Brett W. McCoy @ 1999-04-21 23:00 UTC (permalink / raw)
To: pgsql-interfaces
Is there a way of detecting the existance of a table via a function call?
I'm trying to implement a 'saved search' feature in a search engine, and
need to query a database to see if a particular table exists without
throwing an error. 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
Brett W. McCoy
http://www.lan2wan.com/~bmccoy
-----------------------------------------------------------------------
Why is the alphabet in that order? Is it because of that song?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [INTERFACES] Detecting existance of table
@ 1999-04-22 12:02 José Soares <jose@sferacarta.com>
parent: Brett W. McCoy <bmccoy@lan2wan.com>
1 sibling, 0 replies; 3+ messages in thread
From: José Soares @ 1999-04-22 12:02 UTC (permalink / raw)
To: Brett W. McCoy <bmccoy@lan2wan.com>; +Cc: pgsql-interfaces
Try this:
select TRUE from pg_class where relname = 'my_table' and relkind = 'r';
José
"Brett W. McCoy" ha scritto:
> Is there a way of detecting the existance of a table via a function call?
> I'm trying to implement a 'saved search' feature in a search engine, and
> need to query a database to see if a particular table exists without
> throwing an error. 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
>
> Brett W. McCoy
> http://www.lan2wan.com/~bmccoy
> -----------------------------------------------------------------------
> Why is the alphabet in that order? Is it because of that song?
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1999-04-22 12:02 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-21 23:00 Detecting existance of table Brett W. McCoy <bmccoy@lan2wan.com>
1999-04-21 20:45 ` Gene Selkov Jr. <selkovjr@xnet.com>
1999-04-22 12:02 ` José Soares <jose@sferacarta.com>
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