Re: How to manipulate tuples in C functions?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: a <372660931(at)qq(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How to manipulate tuples in C functions?
Date: 2018-05-07 21:59:06
Message-ID: 11564.1525730346@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"=?ISO-8859-1?B?YQ==?=" <372660931(at)qq(dot)com> writes:
> As far as I know, composite type and rows (trigger functions) are passed between PostgreSQL and C functions as tuple. However, I rarely find things relating on how to manipulate a tuple under C from documentation.

A lot of low-level stuff like that is only really documented in the server
source code. You shouldn't hesitate to look around in the server source
and crib from functions that do something related to what you want.

> So if anyone can tell me how to answer the above question? Or simply give an example of iterator that go through all entries of a tuple? Thank you so much!!

I'd suggest record_out() in src/backend/utils/adt/rowtypes.c as a
prototypical example of disassembling an arbitrary tuple passed as
a composite-type argument. (Note that the environment for trigger
functions is a bit different, mostly for historical reasons.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-05-07 22:37:13 Re: Run external command as part of an sql statement ?
Previous Message Tom Lane 2018-05-07 21:52:22 Re: Run external command as part of an sql statement ?