Re: libpq binary transfer of the numeric data type - II

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Brijesh Shrivastav <Bshrivastav(at)esri(dot)com>
Cc: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: libpq binary transfer of the numeric data type - II
Date: 2004-08-02 23:35:20
Message-ID: 16572.1091489720@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Brijesh Shrivastav <Bshrivastav(at)esri(dot)com> writes:
> Has anyone had success with fetching numeric data in binary format?
> I tried to follow Tom's advice below and try to reverse engineer from
> recv/send function. It seemes the end structure that user will
> get is of Numeric type (see struct below)

No, it isn't. What you get is a series of int16 fields:

pq_sendint(&buf, x.ndigits, sizeof(int16));
pq_sendint(&buf, x.weight, sizeof(int16));
pq_sendint(&buf, x.sign, sizeof(int16));
pq_sendint(&buf, x.dscale, sizeof(int16));
for (i = 0; i < x.ndigits; i++)
pq_sendint(&buf, x.digits[i], sizeof(NumericDigit));

Note that the "digits" are base-10000 digits.

regards, tom lane

In response to

Browse pgsql-interfaces by date

  From Date Subject
Next Message Brijesh Shrivastav 2004-08-03 00:29:26 Re: libpq binary transfer of the numeric data type -
Previous Message Brijesh Shrivastav 2004-08-02 21:43:50 libpq binary transfer of the numeric data type - II