Re: Accessing composite type elements

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Garfield Lewis <garfield(dot)lewis(at)lzlabs(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Accessing composite type elements
Date: 2022-06-02 16:23:45
Message-ID: 1026409.1654187025@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Garfield Lewis <garfield(dot)lewis(at)lzlabs(dot)com> writes:
> In my client-side C code I am using PQgetvalue to pull in the data from the row/column. However, since it is a composite type, it is unclear to me how to get the individual members from the data.

Binary representations are not too well documented :-(. However,
looking at record_send() helps here.

> My best guess right now is:
> * 0x2 is the number of members
> * 0x4 and 0x143 are the lengths of the individual members
> * 0x17 and 0x8e are the OID for the member type

Right, with the additional proviso that -1 "length" indicates a null
field value.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Garfield Lewis 2022-06-02 17:05:35 Re: [EXT] Re: Accessing composite type elements
Previous Message Garfield Lewis 2022-06-02 15:20:57 Accessing composite type elements