Re: [NOVICE] unpacking result (in binary form) - Mailing list pgsql-novice

From Ruslan R. Laishev
Subject Re: [NOVICE] unpacking result (in binary form)
Date
Msg-id 589761509367064@web3o.yandex.ru
Whole thread Raw
In response to [NOVICE] unpacking result (in binary form)  (Ruslan R. Laishev <zator@yandex.ru>)
List pgsql-novice
Hi !
 
Resolved.
 
#pragma    pack(push, 1)
 
/* Decsriptor of the PG Array single element = longword prefixed data block    */
typedef    struct __pg_data_dsc__ {
    unsigned    length;
    unsigned char    data[0];
} PG_DATA_DSC;
 
/* Descriptor of the PG Array in the binary form, as it is returned by PGgetvalue*/
typedef    struct __pg_array_dsc__ {
    unsigned    ndim;    /* N Dimensions    */
 
    unsigned    undef;
 
    Oid        type;    /* OID of the elements            */
    unsigned    asize;    /* Array size - number of elements    */
 
    unsigned    undef2;
                /* A place holder of the first element    */
    PG_DATA_DSC    elm[0];
 
} PG_ARRAY_DSC;
#pragma    pack(pop)
 
...
    p_arr = PQgetvalue(res, ...);
 
 
 
    p_arr->asize = ntohl(p_arr->asize);
    p_arr->ndim = ntohl(p_arr->ndim);
    p_arr->type = ntohl(p_arr->type);
 
p_elem = p_arr->elm;
 
 
30.10.2017, 13:20, "Ruslan R. Laishev" <zator@yandex.ru>:
Hi All!
 
Can someone point me to a structure which has been described a form of array?
I can get a pointer to some area with PQgetvalue but I'm need to retrieve every element from the array.
 
 
TIA.
 
 
 
-- 
С уважением,
Ruslan R. Laishev
OpenVMS bigot, natural born system/network progger, C contractor.
+79013163222
+79910009922
 
 
 
-- 
С уважением,
Ruslan R. Laishev
OpenVMS bigot, natural born system/network progger, C contractor.
+79013163222
+79910009922
 

pgsql-novice by date:

Previous
From: Ruslan R. Laishev
Date:
Subject: [NOVICE] unpacking result (in binary form)
Next
From: Stephen Froehlich
Date:
Subject: [NOVICE] How to list partitions of a table in PostgreSQL 10