From: | Garfield Lewis <garfield(dot)lewis(at)lzlabs(dot)com> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Accessing composite type elements |
Date: | 2022-06-02 15:20:57 |
Message-ID: | VI1PR0502MB398150C23E5450CCC30BE666E3DE9@VI1PR0502MB3981.eurprd05.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi All,
I’m not sure if this is the actual place for this but I guess I can start here. The question I have is, I’ve created a composite type like this:
CREATE TYPE myxml AS { encoding_ int4, xml_ xml };
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. I have googled but I probably just am not googling the correct term because I cannot find any examples of this being done anywhere. A hex dump of the data gives me this:
0x0000000200000017000000046f0100000000008e000001433c637573746f6d6572696e666f20786d6c6e733d22687474703a2f2f6c7a6c6162732e637573742e636f6d22204369643d22543130303130303031223e3c6e616d653e5461626c6520584d4c…
I can tell that the green portion is my endcoding_ value and the blue section is the xml_ data.
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
Is this the proper layout of these composite types? Can I go ahead and use this without possibly having it broken in the future? Are there any existing supported APIs that I can use instead to get this information?
Regards
G
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-06-02 16:23:45 | Re: Accessing composite type elements |
Previous Message | houzj.fnst@fujitsu.com | 2022-06-02 12:14:00 | RE: Support logical replication of DDLs |