Re: timestamp datatype cleanup

Lists: pgsql-hackers
From: Warren Turkal <turkal(at)google(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: timestamp datatype cleanup
Date: 2008-03-09 08:32:20
Message-ID: 12050515403756-git-send-email-turkal@google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

PosgreSQL hackers,

Here's an initial bit of my attempt at cleaning up the the timestamp datatype.
I have gone through the backend and made a couple small changes to stop using
the HAVE_INT64_TIMESTAMP define to select a type in code by creating typedefs
in a header and using the typedef in the code. I think this small bit is ready
for inclusion for this small bit, but I have a couple questions for further
work.

1) Is there a reason that header information is duplicated between normal
posgresql include and ecpg includes instead of defining the info in one place
and #including it into the files that need it?

2) Would it be reasonable to change timestamp.h into a file that includes other
files that define the specific parts depending on HAVE_INT64_TIMESTAMP instead
of testing for HAVE_INT64_TIMESTAMP many times throughout timestamp.h? I think
this might more cleanly separate the logic for the different timestamp types.

Thanks,
wt


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Warren Turkal <turkal(at)google(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-09 11:03:38
Message-ID: 20080309110338.GA15136@feivel.credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sun, Mar 09, 2008 at 12:32:20AM -0800, Warren Turkal wrote:
> 1) Is there a reason that header information is duplicated between normal
> posgresql include and ecpg includes instead of defining the info in one place
> and #including it into the files that need it?

As long as both implementations are kept in sync I don't see a reason.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!


From: Andrew Chernow <ac(at)esilo(dot)com>
To: Warren Turkal <turkal(at)google(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-09 14:48:44
Message-ID: 47D3F8CC.9010907@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Meskes wrote:
> On Sun, Mar 09, 2008 at 12:32:20AM -0800, Warren Turkal wrote:
>> 1) Is there a reason that header information is duplicated between normal
>> posgresql include and ecpg includes instead of defining the info in one place
>> and #including it into the files that need it?

Merlin and I ran into this question while working on the libpq type system,
found here:

http://archives.postgresql.org/pgsql-patches/2008-03/msg00057.php

It opens up the binary parameterized interface in libpq by providing data type
converters, to and from external binary format and C data types, when performing
queries or getting results. This required copying and pasting some code from
the backend for a couple types ... like datetime and numeric. We had to work
around several backend compile-time checks by using run-time checks; being how
servers are compiled differently.

The most modular approach would be to abstract the backend/utils/adt API so the
backend and client stuff can share the functionality. We did mention this
during one of our patch submissions, but didn't push it as it is a large change
outside the scope of our patch.

>> As long as both implementations are kept in sync I don't see a reason.

Sharing the backend data type converters with client stuff is an obvious win,
but its a tedious process probably lacking any motivation. We did look at it
though, it is possible.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Andrew Chernow <ac(at)esilo(dot)com>
Cc: Warren Turkal <turkal(at)google(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-09 18:27:54
Message-ID: 20080309182754.GA25745@feivel.credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> >> As long as both implementations are kept in sync I don't see a reason.
>
> Sharing the backend data type converters with client stuff is an obvious
> win, but its a tedious process probably lacking any motivation. We did
> look at it though, it is possible.

I thought we were just talking about some definitions. If we were to
move the whole logic into one place we might be facing a
performance penalty inside the backend, maybe not a large one though.
Others around here are better suited to judge this.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!


From: Andrew Chernow <ac(at)esilo(dot)com>
To: Warren Turkal <turkal(at)google(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-09 19:37:21
Message-ID: 47D43C71.7070103@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>>I thought we were just talking about some definitions.

I was expanding on your "#1" question, which was directly talking about "shared"
headers rather than just cleaning out HAVE_INT64_TIMESTAMP. I had the same
experience but also ran into the need for "shared" library code; which BTW ecpg
could benefit from as well.

>> performance penalty inside the backend

The idea requires reorganizing, not reimplementing. There shouldn't be a change
in performance in either direction.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Andrew Chernow <ac(at)esilo(dot)com>, Warren Turkal <turkal(at)google(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-10 00:02:57
Message-ID: 16387.1205107377@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Michael Meskes <meskes(at)postgresql(dot)org> writes:
>>> As long as both implementations are kept in sync I don't see a reason.
>>
>> Sharing the backend data type converters with client stuff is an obvious
>> win, but its a tedious process probably lacking any motivation. We did
>> look at it though, it is possible.

> I thought we were just talking about some definitions. If we were to
> move the whole logic into one place we might be facing a
> performance penalty inside the backend, maybe not a large one though.
> Others around here are better suited to judge this.

It's already a huge maintenance problem that there are two copies of the
datetime code (and no, they are *not* being kept in sync; most patches
to the core code have not gone into ecpg). The prospect of extending
that mess to even more datatypes fills me with dread.

I don't know what we could do about it though. We can't really
replicate the conveniences of the backend coding environment in a
frontend application, and yet I surely don't want to tighten up the
expectations on backend datatypes to try to make them work in a
frontend-ish environment. The chances of that happening reliably
are about nil.

My feeling is that we should resist the temptation to provide any such
functionality on the frontend side (and yes, that inclues ripping out
ecpg's datetime stuff). It'll be a black hole sucking infinite numbers
of maintenance man-hours, with not nearly enough benefit in return.

regards, tom lane


From: Andrew Chernow <ac(at)esilo(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, Warren Turkal <turkal(at)google(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-10 01:04:19
Message-ID: 47D48913.1000705@esilo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

>>conveniences of the backend coding environment in a frontend application

I don't think this is required. I'm thinking about light-weight wrappers around
A-2-B style converters, no ties to the backend or client. A free standing util
library. The idea doesn't require a backend environment.

>>want to tighten up the expectations on backend datatypes to try
>>to make them work in a frontend-ish environment.

Making timestamp2tm or tm2timestamp (for example) work in the backend as well as
the client seems rather straight forward, unless I am missing something. I am
not talking about making the data type functional: like add, divide, multiply
funtions. I am only referring to data type converters.

>>The chances of that happening reliably are about nil.

Why? Again, I could be missing something.

--
Andrew Chernow
eSilo, LLC
every bit counts
http://www.esilo.com/


From: "Warren Turkal" <turkal(at)google(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-18 22:36:01
Message-ID: 8c3d85470803181536r127d04el8f62bf735f26ff85@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Give the discussion on this. Is this small patch being considered for
inclusion? If not, what do I need to change to make it acceptable?

Thanks,
wt

On Sun, Mar 9, 2008 at 1:32 AM, Warren Turkal <turkal(at)google(dot)com> wrote:
> PosgreSQL hackers,
>
> Here's an initial bit of my attempt at cleaning up the the timestamp datatype.
> I have gone through the backend and made a couple small changes to stop using
> the HAVE_INT64_TIMESTAMP define to select a type in code by creating typedefs
> in a header and using the typedef in the code. I think this small bit is ready
> for inclusion for this small bit, but I have a couple questions for further
> work.
>
> 1) Is there a reason that header information is duplicated between normal
> posgresql include and ecpg includes instead of defining the info in one place
> and #including it into the files that need it?
>
> 2) Would it be reasonable to change timestamp.h into a file that includes other
> files that define the specific parts depending on HAVE_INT64_TIMESTAMP instead
> of testing for HAVE_INT64_TIMESTAMP many times throughout timestamp.h? I think
> this might more cleanly separate the logic for the different timestamp types.
>
> Thanks,
> wt
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Warren Turkal" <turkal(at)google(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-19 02:49:10
Message-ID: 20734.1205894950@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Warren Turkal" <turkal(at)google(dot)com> writes:
> Give the discussion on this. Is this small patch being considered for
> inclusion? If not, what do I need to change to make it acceptable?

It's in the to-do queue for the current commit fest. The queue is kinda
long however :-(

regards, tom lane


From: "Warren Turkal" <turkal(at)google(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-19 03:26:15
Message-ID: 8c3d85470803182026x12189db8g25af6102b700111c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Is there anything I can do to help?

wt

On Tue, Mar 18, 2008 at 7:49 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Warren Turkal" <turkal(at)google(dot)com> writes:
> > Give the discussion on this. Is this small patch being considered for
> > inclusion? If not, what do I need to change to make it acceptable?
>
> It's in the to-do queue for the current commit fest. The queue is kinda
> long however :-(
>
> regards, tom lane
>


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Warren Turkal <turkal(at)google(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-21 00:22:48
Message-ID: 26606.1206058968@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Warren Turkal <turkal(at)google(dot)com> writes:
> Here's an initial bit of my attempt at cleaning up the the timestamp datatype.

I'm starting to work through this now. Your two messages of 3/09 are
still the latest version correct?

> 2) Would it be reasonable to change timestamp.h into a file that
> includes other files that define the specific parts depending on
> HAVE_INT64_TIMESTAMP instead of testing for HAVE_INT64_TIMESTAMP many
> times throughout timestamp.h? I think this might more cleanly separate
> the logic for the different timestamp types.

I think this is probably a bad idea on maintainability grounds. First,
you'd be duplicating the declarations that are the same, which would
leave you open to changing one copy and not the other. Second, having
both versions of any given declaration adjacent to each other makes it
easier to compare them and keep them in sync. Two separate files just
sounds like a recipe for code drift.

regards, tom lane


From: "Warren Turkal" <turkal(at)google(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-21 01:44:43
Message-ID: 8c3d85470803201844scc7f96cmc7c8d03067b0ce38@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Mar 20, 2008 at 5:22 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Warren Turkal <turkal(at)google(dot)com> writes:
>
> > Here's an initial bit of my attempt at cleaning up the the timestamp datatype.
>
> I'm starting to work through this now. Your two messages of 3/09 are
> still the latest version correct?

Yes, I can rebase it if neccessary.

> > 2) Would it be reasonable to change timestamp.h into a file that
> > includes other files that define the specific parts depending on
> > HAVE_INT64_TIMESTAMP instead of testing for HAVE_INT64_TIMESTAMP many
> > times throughout timestamp.h? I think this might more cleanly separate
> > the logic for the different timestamp types.
>
> I think this is probably a bad idea on maintainability grounds. First,
> you'd be duplicating the declarations that are the same, which would
> leave you open to changing one copy and not the other. Second, having
> both versions of any given declaration adjacent to each other makes it
> easier to compare them and keep them in sync. Two separate files just
> sounds like a recipe for code drift.

That was what I afraid of and why I posed the question.

I have to say, I am wondering more and more how real the need is for
the two representations of timestamps. Would it be better to deprecate
the float format or at least make the int64 format the default?

wt


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Warren Turkal" <turkal(at)google(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-21 01:48:38
Message-ID: 10932.1206064118@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Warren Turkal" <turkal(at)google(dot)com> writes:
> I have to say, I am wondering more and more how real the need is for
> the two representations of timestamps. Would it be better to deprecate
> the float format or at least make the int64 format the default?

This was gone over in great detail just recently ... didn't you see
that thread?

regards, tom lane


From: "Warren Turkal" <turkal(at)google(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp datatype cleanup
Date: 2008-03-21 16:44:19
Message-ID: 8c3d85470803210944v2c969d95i4dbb266b58b5f231@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Mar 20, 2008 at 6:48 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Warren Turkal" <turkal(at)google(dot)com> writes:
>
> > I have to say, I am wondering more and more how real the need is for
> > the two representations of timestamps. Would it be better to deprecate
> > the float format or at least make the int64 format the default?
>
> This was gone over in great detail just recently ... didn't you see
> that thread?

I actually hadnn't seen the resolution until just now. Thanks for
pointing it out.

wt