From: Tom Lane <tgl@sss.pgh.pa.us>
To: a <372660931@qq.com>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re: How to manipulate tuples in C functions?
Date: Mon, 07 May 2018 17:59:06 -0400
Message-ID: <11564.1525730346@sss.pgh.pa.us> (raw)
In-Reply-To: <tencent_4D3931CA0E0CFAE14D86AA55@qq.com>
References: <tencent_4D3931CA0E0CFAE14D86AA55@qq.com>
"=?ISO-8859-1?B?YQ==?=" <372660931@qq.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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: tgl@sss.pgh.pa.us, 372660931@qq.com
Subject: Re: How to manipulate tuples in C functions?
In-Reply-To: <11564.1525730346@sss.pgh.pa.us>
References: <tencent_4D3931CA0E0CFAE14D86AA55@qq.com> <11564.1525730346@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox