pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Garfield Lewis <garfield.lewis@lzlabs.com>
Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>
Subject: Re: Accessing composite type elements
Date: Thu, 02 Jun 2022 12:23:45 -0400
Message-ID: <1026409.1654187025@sss.pgh.pa.us> (raw)
In-Reply-To: <VI1PR0502MB398150C23E5450CCC30BE666E3DE9@VI1PR0502MB3981.eurprd05.prod.outlook.com>
References: <VI1PR0502MB398150C23E5450CCC30BE666E3DE9@VI1PR0502MB3981.eurprd05.prod.outlook.com>

Garfield Lewis <garfield.lewis@lzlabs.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





view thread (5+ messages)  latest in thread

Message-ID: <1026409.1654187025@sss.pgh.pa.us>
Permalink:  ../1026409.1654187025@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1026409.1654187025@sss.pgh.pa.us

 · 

reply

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, garfield.lewis@lzlabs.com
  Subject: Re: Accessing composite type elements
  In-Reply-To: <1026409.1654187025@sss.pgh.pa.us>
  References: <VI1PR0502MB398150C23E5450CCC30BE666E3DE9@VI1PR0502MB3981.eurprd05.prod.outlook.com> <1026409.1654187025@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