Exposed function to find table in schema search list? - Mailing list pgsql-hackers

From Joel Burton
Subject Exposed function to find table in schema search list?
Date
Msg-id AHEDLOKJMIPAGOHCCBCDGEBJCBAA.joel@joelburton.com
Whole thread Raw
List pgsql-hackers
I'm writing a function that accepts a table name and digs some information
out about it. I'm developing on 7.3cvs w/schemas, and wanted my function to
use schemas.

If the user gives a full schema name (s.table), I find the table in pg_class
by comparing the ns oid and relname.

However, if the user doesn't give the full schema name, I have to find which
table they're looking for by examining current_schemas, iterating over each
schema in this path, and trying it.

Is there a function already in the backend to return a class oid, given a
name, by looking up the table in the current_schemas path? Would it make
sense for us to expose this, or write one, so that this small wheel doesn't
have to be re-invented everytime someone wants to find a table by just the
name?

Something like:
 findtable(text) returns oid   findtable("foo") -> oid of foo (given current search path)   findtable("s.foo") -> oid
ofs.foo
 

I can write something in plpgsql (iterating over the array, checking each,
etc.), however, it would be nice if something was already there.

Any ideas?

Thanks!

- J.


Joel BURTON | joel@joelburton.com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant



pgsql-hackers by date:

Previous
From: Joe Conway
Date:
Subject: Re: [PATCHES] SRF patch (was Re: troubleshooting pointers)
Next
From: Tom Lane
Date:
Subject: Re: [PATCHES] SRF patch (was Re: troubleshooting pointers)