AW: AW: AW: AW: Re: tinterval - operator problems on AI X
The correct thing to do instead of the #if defined (_AIX) would be to use
something like #ifdef NO_NEGATIVE_MKTIME and set that with a configure.
Thomas, are you volunteering ?Actually, I can volunteer to be supportive of your efforts ;) I'm
traveling at the moment, and don't have the original thread(s) which
describe in detail what we need to do for platforms I don't have.If Peter E. would be willing to do a configure test for this mktime()
problem, then you or I can massage the actual code. Peter, is this
something you could pick up?I do not have the original thread where Andreas describes the behavior
of mktime() on his machine. Andreas, can you suggest a simple configure
test to be used?
#include <time.h>
int main()
{
struct tm tt, *tm=&tt;
int i = -50000000;
tm = localtime (&i);
i = mktime (tm);
if (i != -50000000) /* on AIX this check could also be (i == -1) */
{
printf("ERROR: mktime(3) does not correctly support datetimes before 1970\n");
return(1);
}
}
Andreas
Zeugswetter Andreas SB writes:
I do not have the original thread where Andreas describes the behavior
of mktime() on his machine. Andreas, can you suggest a simple configure
test to be used?#include <time.h>
int main()
{
struct tm tt, *tm=&tt;
int i = -50000000;
tm = localtime (&i);
i = mktime (tm);
if (i != -50000000) /* on AIX this check could also be (i == -1) */
{
printf("ERROR: mktime(3) does not correctly support datetimes before 1970\n");
return(1);
}
}
You don't need to put this check into configure, you can just do the check
after mktime() is used.
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/
I agree that configure is the way to go. What if someone has
installed a third party library to provide a better mktime() and
localtime()?Exactly. What if someone has a binary PostgreSQL package installed, then
updates his time library to something supposedly binary compatible and
finds out that PostgreSQL still doesn't use the enhanced capabilities?
Runtime behaviour checks are done at runtime, it's as simple as that.
So, you are suggesting to call mktime after every call to localtime,
just to check whether to output the time in DST before 1970 on all platforms ?
Beleive me, we need a configure check.
Besides, mktime is in libc on AIX and all available versions show the same behavior,
thus I do not think that it is going to change soon. The only way would be to link
with a third party lib, and that would definitely need a new configure run anyway.
This configure is needed to avoid an otherwise necessary
#if defined(_AIX) || defined(__sgi)
If, and only if, you say the above is better then we don't need a configure check.
Andreas
Import Notes
Resolved by subject fallback
The other category is run-time behaviour, which is the present case of
testing whether mktime() behaves a certain way when given certain
arguments. Another item that has been thrown around over the years is
whether the system supports Unix domain sockets (essentially a run-time
behaviour check of socket()). You do not need to check these things in
configure; you can just do it when the program runs and adjust
accordingly.
I think in PostgreSQL there is also a third category: "features" that affect on disk
storage of data. Those can definitely not be changed at runtime, because
a change would corrupt that database. It is very hard to judge what "feature"
really has an on disk effect. It can e.g. be an application that selected a
row that was inserted before the feature existed, do some calculations
and insert a new row with the feature now available. Thus I think available
features should be as immune to OS feature changes as possible, but let us
postpone that discussion until after 7.1 release.
So I would currently suggest that you define
#ifdef AIX || IRIX
# define NO_DST_BEFORE_1970
#endif
That would be OK for me. Where do we put that ? Imho a good place would be
config.h.
One problem though is, that I don't have a patch, that really turns off DST before
1970 (which would be considerably more work). I only have a patch that makes
platforms, that don't have a working mktime for values before 1970, behave like
NO_DST_... Thus more wanting a #define NO_MKTIME_BEFORE_1970.
Andreas
Import Notes
Resolved by subject fallback
Zeugswetter Andreas SB writes:
I think in PostgreSQL there is also a third category: "features" that affect on disk
storage of data.
We have those already, for example the locale collation order. They are
determined when initdb is run and are then fixed for the database cluster.
So I would currently suggest that you define
#ifdef AIX || IRIX
# define NO_DST_BEFORE_1970
#endifThat would be OK for me. Where do we put that ? Imho a good place would be
config.h.
That or maybe c.h. Don't care.
--
Peter Eisentraut peter_e@gmx.net http://yi.org/peter-e/