agora inbox for pgsql-interfaces@postgresql.org
help / color / mirror / Atom feedFrom: Tom Lane <tgl@sss.pgh.pa.us>
To: Mark Crosland <mark.crosland@gmail.com>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: Traversing the catalog using heap_open, systable_beginscan, ...
Date: Sat, 09 Nov 2013 11:12:17 -0500
Message-ID: <31976.1384013537@sss.pgh.pa.us> (raw)
In-Reply-To: <CAJjS_dOXaAkKRoso1J3ShQXoBmA=SFxtiN9vNqGHq9fn4bbYhw@mail.gmail.com>
References: <CAJjS_dOXaAkKRoso1J3ShQXoBmA=SFxtiN9vNqGHq9fn4bbYhw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-interfaces>
Mark Crosland <mark.crosland@gmail.com> writes:
> Hello,
> I am writing a foreign data wrapper and following the oracle example. Are
> there docs that discuss heap_open, systable_beginscan and systable_getnext?
> I currently just need to do simple stuff, like translate an Oid that is
> received via a FDW callback into the text name of a table. I see all of the
> catalog headers, pg_class.h, etc... but not seeing the pattern of which
> args to pass into ScanKeyInit to traverse the catalog correctly.
Well, you *can* look that sort of stuff up that way, but usually there's
a better way; in particular, if at all possible you should consult the
catalog caches instead. Look into src/backend/utils/cache/lsyscache.c
for convenience routines that do this sort of thing. The particular need
you cite above is addressed by get_rel_name(), and even if you don't see
an exact fit, the routines provide good examples for fetching fields out
of catalog entries.
Also, once you've got a Relation pointer, much of what you might want
to know about that table is available directly out of the relcache
entry.
regards, tom lane
--
Sent via pgsql-interfaces mailing list (pgsql-interfaces@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-interfaces
view thread (4+ messages) latest in thread
Message-ID: <31976.1384013537@sss.pgh.pa.us>
Permalink: ../31976.1384013537@sss.pgh.pa.us/
Also on: postgresql.org/message-id/31976.1384013537@sss.pgh.pa.us
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: tgl@sss.pgh.pa.us, mark.crosland@gmail.com
Subject: Re: Traversing the catalog using heap_open, systable_beginscan, ...
In-Reply-To: <31976.1384013537@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox