| From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
|---|---|
| To: | Jim Nasby <decibel(at)decibel(dot)org> |
| Cc: | "pgsql-general(at)postgresql(dot)org general" <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Dealing with table names in functions |
| Date: | 2007-03-22 13:40:10 |
| Message-ID: | 20070322134010.GC4102@alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Jim Nasby wrote:
> Is there a safe way to deal with tables being passed into a function,
> specifically in terms of what schema they're in? I can just blindly
> accept a text string and hope that it's always evaluated in the
> correct search_path context, but that doesn't seem so good. OTOH, if
> I accept an OID, there's no great way to pass that to most of the
> rest of the system... I can cast the OID to regclass, but that
> doesn't get me a fully-qualified name.
Pass the optionally qualified name and cast it to regclass. It will
work correctly when the name is not qualified, applying search_path, and
it will also work when the name is qualified.
--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lutz Broedel | 2007-03-22 13:40:33 | using 'ALTER ROLE' in a function |
| Previous Message | Andy Dale | 2007-03-22 13:36:32 | xpath_list() function |