public inbox for [email protected]  
help / color / mirror / Atom feed
From: Tom Lane <[email protected]>
To: Sebastien FLAESCH <[email protected]>
Cc: [email protected]
Subject: Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter?
Date: Mon, 19 Feb 2018 11:06:23 -0500
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

Sebastien FLAESCH <[email protected]> writes:
> On 02/16/2018 04:15 PM, Tom Lane wrote:
>> 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?

> 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);

That might --- I don't recall offhand --- be the right decoding for
the typmod of a column of type NUMERIC.  It's certainly not right
for any other datatype.  Also, you don't seem to be accounting for
the fact that negative typmod always means "no typmod specified".

			regards, tom lane




view thread (11+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter?
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox