Re: unpacking result (in binary form)

From: Ruslan R(dot) Laishev <zator(at)yandex(dot)ru>
To: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: unpacking result (in binary form)
Date: 2017-10-30 12:37:44
Message-ID: 589761509367064@web3o.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

<div><span style="font-family:courier new,monospace;">Hi !</span></div><div> </div><div><span style="font-family:courier new,monospace;">Resolved.</span></div><div> </div><div><div><span style="font-family:courier new,monospace;">#pragma    pack(push, 1)</span></div><div> </div><div><span style="font-family:courier new,monospace;">/* Decsriptor of the PG Array single element = longword prefixed data block    */</span></div><div><span style="font-family:courier new,monospace;">typedef    struct __pg_data_dsc__ {</span></div><div><span style="font-family:courier new,monospace;">    unsigned    length;</span></div><div><span style="font-family:courier new,monospace;">    unsigned char    data[0];</span></div><div><span style="font-family:courier new,monospace;">} PG_DATA_DSC;</span></div><div> </div><div><span style="font-family:courier new,monospace;">/* Descriptor of the PG Array in the binary form, as it is returned by PGgetvalue*/</span></div><div><span style="font-family:courier new,monospace;">typedef    struct __pg_array_dsc__ {</span></div><div><span style="font-family:courier new,monospace;">    unsigned    ndim;    /* N Dimensions    */</span></div><div> </div><div><span style="font-family:courier new,monospace;">    unsigned    undef;</span></div><div> </div><div><span style="font-family:courier new,monospace;">    Oid        type;    /* OID of the elements            */</span></div><div><span style="font-family:courier new,monospace;">    unsigned    asize;    /* Array size - number of elements    */</span></div><div> </div><div><span style="font-family:courier new,monospace;">    unsigned    undef2;</span></div><div><span style="font-family:courier new,monospace;">                /* A place holder of the first element    */</span></div><div><span style="font-family:courier new,monospace;">    PG_DATA_DSC    elm[0];</span></div><div> </div><div><span style="font-family:courier new,monospace;">} PG_ARRAY_DSC;</span></div><div><span style="font-family:courier new,monospace;">#pragma    pack(pop)</span></div><div> </div><div><span style="font-family:courier new,monospace;">...</span></div><div><div><span style="font-family:courier new,monospace;">    p_arr = PQgetvalue(res, ...);</span></div><div><span style="font-family:courier new,monospace;">  </span></div> <div> </div><div><span style="font-family:courier new,monospace;">    p_arr-&gt;asize = ntohl(p_arr-&gt;asize);</span></div><div><span style="font-family:courier new,monospace;">    p_arr-&gt;ndim = ntohl(p_arr-&gt;ndim);</span></div><div><span style="font-family:courier new,monospace;">    p_arr-&gt;type = ntohl(p_arr-&gt;type);</span></div><div> </div><div><span style="font-family:courier new,monospace;">p_elem = p_arr-&gt;elm;</span></div></div></div><div> </div><div> </div><div><span style="font-family:courier new,monospace;">30.10.2017, 13:20, "Ruslan R. Laishev" &lt;zator(at)yandex(dot)ru&gt;:</span></div><blockquote type="cite"><div><span style="font-family:courier new,monospace;">Hi All!</span></div><div> </div><div><span style="font-family:courier new,monospace;">Can someone point me to a structure which has been described a form of array?</span></div><div><span style="font-family:courier new,monospace;">I can get a pointer to some area with PQgetvalue but I'm need to retrieve every element from the array.</span></div><div> </div><div> </div><div><span style="font-family:courier new,monospace;">TIA.</span></div><div> </div><div> </div><div> </div><div><span style="font-family:courier new,monospace;">-- </span></div><div><span style="font-family:courier new,monospace;">С уважением,<br />Ruslan R. Laishev</span></div><div><span style="font-family:courier new,monospace;">OpenVMS bigot, natural born system/network progger, C contractor.</span></div><div><span style="font-family:courier new,monospace;">+79013163222</span></div><div><span style="font-family:courier new,monospace;">+79910009922</span></div><div> </div></blockquote><div> </div><div> </div><div><span style="font-family:courier new,monospace;">-- </span></div><div><span style="font-family:courier new,monospace;">С уважением,<br />Ruslan R. Laishev</span></div><div><span style="font-family:courier new,monospace;">OpenVMS bigot, natural born system/network progger, C contractor.</span></div><div><span style="font-family:courier new,monospace;">+79013163222</span></div><div><span style="font-family:courier new,monospace;">+79910009922</span></div><div> </div>

Attachment Content-Type Size
unknown_filename text/html 4.5 KB

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Froehlich 2017-10-31 19:01:50 How to list partitions of a table in PostgreSQL 10
Previous Message Ruslan R. Laishev 2017-10-30 10:19:41 unpacking result (in binary form)