From: | Sebastien FLAESCH <sf(at)4js(dot)com> |
---|---|
To: | pgsql-interfaces(at)lists(dot)postgresql(dot)org |
Subject: | Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter? |
Date: | 2018-02-19 11:16:45 |
Message-ID: | 91fabdcd-0eb3-c970-a28c-248a6ff8a360@4js.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
On 02/16/2018 04:15 PM, Tom Lane wrote:
> Sebastien FLAESCH <sf(at)4js(dot)com> writes:
>> Would be nice however to have some clear documentation about PQfmod() interpretation...
>> What means exactly 65531/0xFFFB?
>
> You could try running it through the typmodout function for the column's
> datatype. I don't offhand know of any built-in types for which that would
> be a really plausible typmod, though. Are you sure your client code isn't
> mistakenly narrowing it to int16 somewhere?
>
> regards, tom lane
>
>
As I wrote in my initial mail, I do the following:
#define VARHDRSZ 4
...
int pgfmod = PQfmod(st->pgResult, i);
int pgprec = (pgfmod >> 16);
int pgscal = ((pgfmod - VARHDRSZ) & 0xffff);
int pgleng = (pgfmod - VARHDRSZ);
As no clear documentation is available for PQfmod() interpretation I looked at the internal
header files and ECPG sources.
The VARHDRSZ is sizeof(int32), but it's not available in standard PostgreSQL PQ header files.
It can be found in include/postgresql/server/c.h:
#define VARHDRSZ ((int32) sizeof(int32))
In the ECPG sources you can see:
src/interfaces/ecpg/ecpglib/descriptor.c:
case ECPGd_scale:
if (!get_int_item(lineno, var, vartype, (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff))
{
va_end(args);
return (false);
}
ecpg_log("ECPGget_desc: SCALE = %d\n", (PQfmod(ECPGresult, index) - VARHDRSZ) & 0xffff);
break;
case ECPGd_precision:
if (!get_int_item(lineno, var, vartype, PQfmod(ECPGresult, index) >> 16))
{
va_end(args);
return (false);
}
ecpg_log("ECPGget_desc: PRECISION = %d\n", PQfmod(ECPGresult, index) >> 16);
break;
Seb
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2018-02-19 16:06:23 | Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter? |
Previous Message | Greg Sabino Mullane | 2018-02-18 15:32:32 | DBD::Pg version 3.7.4 released |