Re: INTERVAL data type and libpq - what format?

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: INTERVAL data type and libpq - what format?
Дата
Msg-id b42b73150905181212u48ccaa2el446b35d4c5373287@mail.gmail.com
обсуждение исходный текст
Ответ на INTERVAL data type and libpq - what format?  (Sebastien FLAESCH <sf@4js.com>)
Список pgsql-hackers
On Mon, May 18, 2009 at 11:46 AM, Sebastien FLAESCH <sf@4js.com> wrote:
> Hello,
>
> I try to use the new 8.4 INTERVAL type with libpq, but get crazy with
> the input formatting rules...

[this question is more appropriate on -general]

> I use PQprepare() / PQexecPrepared() with parameter list, binding the
> INTERVAL values with the 1186 pg_type (is this ok?) and passing a
> string buffer with values like:

yes, that is the correct oid for interval (or you could probably pass
NULL for the oid vector which instructs the server to guess the type
based on context).

> "12345"   for an INTERVAL YEAR
>
> The INSERT works without error, but when selecting rows from the table
> in psql, I get "00:00:00" values ?!?!
>
> When inserting the value "12345" from the psql command tool it works...
>
> I must be doing something wrong, but I could not find any documentation
> on using INTERVAL in libpq...
>
> Can someone from the hackers just tell me if it's supposed to work and
> if yes what format is expected by the client library?

assuming you pass parameters in text, it should work exactly as in
psql.  I'm guessing you are either passing binary (incorrectly), or
there is a bug in your code that assembles the parameters.

merlin


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

Предыдущее
От: Sebastien FLAESCH
Дата:
Сообщение: INTERVAL data type and libpq - what format?
Следующее
От: Stefan Keller
Дата:
Сообщение: Proposal: functions get_text() or get_url()