Re: Type scale returned by PQfmod() 65531 for time/timestamp outputparameter?

Поиск
Список
Период
Сортировка
От Sebastien FLAESCH
Тема Re: Type scale returned by PQfmod() 65531 for time/timestamp outputparameter?
Дата
Msg-id 91fabdcd-0eb3-c970-a28c-248a6ff8a360@4js.com
обсуждение исходный текст
Ответ на Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter?  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-interfaces
On 02/16/2018 04:15 PM, Tom Lane wrote:
> Sebastien FLAESCH <sf@4js.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


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "Greg Sabino Mullane"
Дата:
Сообщение: DBD::Pg version 3.7.4 released
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Type scale returned by PQfmod() 65531 for time/timestamp output parameter?