From: a <372660931@qq.com>
To: pgsql-general <pgsql-general@postgresql.org>
Subject: How to manipulate tuples in C functions?
Date: Tue, 8 May 2018 04:20:16 +0800
Message-ID: <tencent_4D3931CA0E0CFAE14D86AA55@qq.com> (raw)
Hey all:
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.
The only thing I can find from the doc is very simple stuff like 'GetAttributeByName' or 'GetAttributeByNum' to retrieve data, or use a 'BlessTupleDesc' to initialize a 'TupleDesc' variable and 'heap_form_tuple' to return a 'HeapTuple' and return a 'HeapTupleGetDatum(HeapTuple tuple)' to convert to a 'Datum' type.
However not only the illustration of the previous listed functions are not fully described (e.g. return and input of each functions) but also any complex situation are stated. What if I have a composite type inside a composite type? What if I have a array inside a composite type? What if I have a variable length type?
Furthermore, to write a compatible procedures, I would need at least 2 more information: 1, The total number of entry inside a tuple; 2, The total space the tuple took.
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!!
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: 372660931@qq.com
Subject: Re: How to manipulate tuples in C functions?
In-Reply-To: <tencent_4D3931CA0E0CFAE14D86AA55@qq.com>
References: <tencent_4D3931CA0E0CFAE14D86AA55@qq.com>
* 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