In connection with doing this:
http://archives.postgresql.org/message-id/22214.1315343818@sss.pgh.pa.us
I've run into the problem that tz_acceptable(), which needs to be
available to frontend-ish code if initdb is to use it, depends on these
symbols:

#define UNIX_EPOCH_JDATE 2440588 /* == date2j(1970, 1, 1) */
#define POSTGRES_EPOCH_JDATE 2451545 /* == date2j(2000, 1, 1) */
#define SECS_PER_DAY 86400

which are defined in backend-only include files such as
utils/timestamp.h. This immediately brought to mind the pgrminclude
fiasco of a couple days ago, which was at least in part due to the fact
that utils/timestamp.h got included into some very low-level header
files so that they could use typedef TimestampTz. So I think it's time
to do something about that.

I propose moving the Timestamp/Interval typedefs, as well as some basic
associated macros such as the ones mentioned above (basically, lines
25-100 of utils/timestamp.h, plus the DT_NOBEGIN/DT_NOEND stuff, plus
the Julian-date macros in datetime.h), into a separate header file that
contains no backend-only declarations (eg, not fmgr.h stuff; right
offhand I don't think it would depend on anything except c.h).

If you believe the idea I suggested a few days ago that we ought to try
to push basic typedefs into a separate set of headers, then this could
be the first instance of that, which would lead to naming it something
like "datatype/timestamp.h". If that seems premature, then I guess it
ought to go into utils/, but then we need some other name because
utils/timestamp.h is taken.

Thoughts?

regards, tom lane

Search Discussions

  • Brendan Jurd at Sep 8, 2011 at 12:35 am

    On 8 September 2011 10:22, Tom Lane wrote:
    If you believe the idea I suggested a few days ago that we ought to try
    to push basic typedefs into a separate set of headers, then this could
    be the first instance of that, which would lead to naming it something
    like "datatype/timestamp.h".  If that seems premature, then I guess it
    ought to go into utils/, but then we need some other name because
    utils/timestamp.h is taken.
    The separate headers for basic typedefs makes perfect sense to me.

    Cheers,
    BJ
  • Tom Lane at Sep 9, 2011 at 5:31 pm

    I wrote:
    I propose moving the Timestamp/Interval typedefs, as well as some basic
    associated macros such as the ones mentioned above (basically, lines
    25-100 of utils/timestamp.h, plus the DT_NOBEGIN/DT_NOEND stuff, plus
    the Julian-date macros in datetime.h), into a separate header file that
    contains no backend-only declarations (eg, not fmgr.h stuff; right
    offhand I don't think it would depend on anything except c.h).
    I've committed this patch, but there was one aspect that remains
    unfinished. I had hoped to remove the duplicative parts of ecpg's dt.h
    header in favor of including datatype/timestamp.h, along the lines of
    the attached patch. However, while ecpg itself compiles with that
    change, its test programs do not; apparently they include
    pgtypes_timestamp.h without previously including anything that defines
    typedef int32. I'm unsure if there's a reasonable way to work around
    that --- any thoughts?

    regards, tom lane

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-hackers @
categoriespostgresql
postedSep 8, '11 at 12:22a
activeSep 9, '11 at 5:31p
posts3
users2
websitepostgresql.org...
irc#postgresql

2 users in discussion

Tom Lane: 2 posts Brendan Jurd: 1 post

People

Translate

site design / logo © 2022 Grokbase