From: | "Joel Burton" <joel(at)joelburton(dot)com> |
---|---|
To: | "Joe Conway" <mail(at)joeconway(dot)com> |
Cc: | "Pgsql-Hackers(at)Postgresql(dot) Org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Exposed function to find table in schema search list? |
Date: | 2002-05-19 21:28:16 |
Message-ID: | JGEPJNMCKODMDHGOBKDNAEMDCOAA.joel@joelburton.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> -----Original Message-----
> From: Joe Conway [mailto:mail(at)joeconway(dot)com]
> Sent: Sunday, May 19, 2002 5:25 PM
> To: Joel Burton
> Cc: Pgsql-Hackers(at)Postgresql(dot) Org
> Subject: Re: [HACKERS] Exposed function to find table in schema search
> list?
>
>
> Joel Burton wrote:
> > 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 of s.foo
> >
> > I can write something in plpgsql (iterating over the array,
> checking each,
> > etc.), however, it would be nice if something was already there.
>
> I think this already exists:
>
> test=# select 'joe.foo'::regclass::oid;
> oid
> --------
> 125532
> (1 row)
>
> test=# select 'public.foo'::regclass::oid;
> oid
> --------
> 125475
> (1 row)
>
> test=# select 'foo'::regclass::oid;
> oid
> --------
> 125475
> (1 row)
>
> test=# select current_schema();
> current_schema
> ----------------
> public
> (1 row)
Perfect! I was hoping to avoid re-creating the wheel. Thanks, Joe.
Is the use of regclass going to prove to be very implementation-specific?
Would it make sense for us to create a function that abstracts this?
- J.
Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Knowledge Management & Technology Consultant
From | Date | Subject | |
---|---|---|---|
Next Message | Bear Giles | 2002-05-19 21:38:51 | Re: pq_eof() broken with SSL |
Previous Message | Tom Lane | 2002-05-19 21:27:17 | Re: SRF patch (was Re: [HACKERS] troubleshooting pointers) |