Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-interfaces by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group