Re: How to get Relation tuples in C function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to get Relation tuples in C function
Дата
Msg-id 1814477.1613251420@sss.pgh.pa.us
обсуждение исходный текст
Ответ на How to get Relation tuples in C function  (Patrick Handja <patrick.bungama@gmail.com>)
Ответы Re: How to get Relation tuples in C function  (Andy Fan <zhihui.fan1213@gmail.com>)
Список pgsql-hackers
Patrick Handja <patrick.bungama@gmail.com> writes:
> I would like to know if there is a better way to pass a relation or if the
> relation name (CString) as a parameter in a C function and thus be able to
> manipulate its tuples. The documentation is available here:
> https://www.postgresql.org/docs/13/xfunc-c.html#id-1.8.3.13.11. But it is
> not quite clear enough on how to retrieve tuples.

The thing I'd recommend you do is use SPI [1], which lets you execute
SQL queries from inside a C function.  If you don't want to do that
for whatever reason, you need to open the relation, set up a scan,
and fetch tuples from the scan, relying on low-level APIs that tend
to change from version to version.  contrib/pageinspect or
contrib/pgstattuple might offer usable sample code, although with any
prototype you might look at, it's going to be hard to see the forest
for the trees.

            regards, tom lane

[1] https://www.postgresql.org/docs/current/spi.html



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Zhihong Yu
Дата:
Сообщение: Re: Possible dereference null return (src/backend/replication/logical/reorderbuffer.c)
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: WIP: WAL prefetch (another approach)