From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Mark Crosland <mark(dot)crosland(at)gmail(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: Traversing the catalog using heap_open, systable_beginscan, ... |
Date: | 2013-11-09 16:12:17 |
Message-ID: | 31976.1384013537@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Mark Crosland <mark(dot)crosland(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Crosland | 2013-11-11 22:01:00 | Re: Traversing the catalog using heap_open, systable_beginscan, ... |
Previous Message | Mark Crosland | 2013-11-09 05:37:02 | Traversing the catalog using heap_open, systable_beginscan, ... |