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

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




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]
  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