Skip site navigation (1) Skip section navigation (2)

Re: Timestamp with libpq

From: Jakob Lechner <jakob(dot)lechner(at)applstrudl(dot)com>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Wilhansen Li <willi(dot)t1(at)gmail(dot)com>,pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Timestamp with libpq
Date: 2008-10-13 12:34:02
Message-ID: 1223901242.3502.54.camel@vie063.fabagl.fabasoft.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
Hi Michael,

Am Montag, den 13.10.2008, 12:46 +0200 schrieb Michael Meskes:

> Please keep in mind that there is no guarantee that your server sends a double
> in a binary query. This depens on whether integer-datatypes are configure or
> not. Or in other words, it might be a long long instead of a double.

Yes, you're right. The SLES postgres server transmits timestamps as long
long numbers (microseconds since 2000-01-01).

> Is there any reason to use a binary transfer? 

If I use textual transfer I'm losing precision. E.g. for timestamps the
returned string from my table is "1955-06-08 00:00:00". Thus I'm
restricted to timestamps with a granularity of 1 second.

> I would not recommend this in a
> general setup. If you just want to avoid some ascii translation hassle, how
> about using ecpg instead of libpq?

The generic database interface I'm writing is part of a basic library
used in our project. The interface serves as an abstraction for
accessing different database servers (Postgres, MSSQL, ...). I'm
currently working on the postgres implementation of the interface. 
As far as I've seen using ecpg means to hardcode SQL statements which of
course can't be done in a generic library.

Thanks for your helpful hints. But it's seems I don't have much choice
but to use ascii transfer mode.

Best regards
Jakob

-- 
Jakob Lechner
Research & Development
appl.strudl Software GmbH
Honauerstra├če 4
A-4020 Linz
Tel.: [+43] (70) 60 61 62
Fax: [+43] (70) 60 61 62-609
E-Mail: jakob(dot)lechner(at)applstrudl(dot)com
Web: http://www.applstrudl.com
Handelsgericht Linz, FN 303988 t

In response to

Responses

pgsql-interfaces by date

Next:From: Michael MeskesDate: 2008-10-13 12:59:29
Subject: Re: Timestamp with libpq
Previous:From: Michael MeskesDate: 2008-10-13 10:46:27
Subject: Re: Timestamp with libpq

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group