Re: [PATCHES] time_t timezone

2004-09-08 Thread Bruce Momjian

OK, I have applied the following patch to fix the Cygwin _timezone
issue.  I moved the TIMEZONE_GLOBAL up into port.h and change pgtz.c to
use that instead.  I also changed the configure test for INT_TIMEZONE to
test for _timezone on Cygwin.  This should fix all those problems.

You found a few problems in dirmod.c but have run out of time and will
deal with them in a few days.

---

Reini Urban wrote:
 Bruce Momjian schrieb:
 
  Reini Urban wrote:
  
# PGAC_VAR_INT_TIMEZONE
# -
# Check if the global variable `timezone' exists. If so, define
# HAVE_INT_TIMEZONE.
AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
[AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
[AC_TRY_LINK([#include time.h
int res;],
  [res = timezone / 60;],
  [pgac_cv_var_int_timezone=yes],
  [pgac_cv_var_int_timezone=no])])
if test x$pgac_cv_var_int_timezone = xyes ; then
  AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
variable 'int timezone'.])
fi])# PGAC_VAR_INT_TIMEZONE
 
 You can look in include/pg_config.h to see how it is defined.
 
 This test fails, because you cannot do arithmetic with time_t.
 cygwin has/had a special workaround in pg_config_manual.h
 See Tom above.
 
 sorry, my mistake. you can do arithmetic with time_t.
 
 All other platforms with time_t timezone should manually enable their 
 HAVE_INT_TIMEZONE and manually add the (int) timezone in 
 src/timezone/pgtz.c.
  
  OK, let's get some facts.  How is your timezone variable defined in your
  headers?  Is it _timezone?  How is time_t defined?  If you take the
  program above and compile it alone, how does it fail?
 
 yes, it's only _timezone.
 
 already sent to this list. here it is:
 
 /usr/include/time.h from newlib.
 ...
 /* defines for the opengroup specifications Derived from Issue 1 of the 
 SVID.  */
 extern __IMPORT time_t _timezone;
 extern __IMPORT int _daylight;
 extern __IMPORT char *_tzname[2];
 
 which resolves to (gcc -E):
 # 98 /usr/include/time.h 3 4
 extern __attribute__((dllimport)) time_t _timezone;
 extern __attribute__((dllimport)) int _daylight;
 extern __attribute__((dllimport)) char *_tzname[2];
 
 time_t is a typedef from sys/types.h:
 #ifndef __time_t_defined
 typedef _TIME_T_ time_t;
 #define __time_t_defined
 
 _TIME_T_ is a macro from machine/types.h:
 define _TIME_T_long
 
  Also, look at your config.log output to see why it fails or email it to
  my privately.
 ...
 configure:12843: checking for int timezone
 configure:12865: gcc -o conftest.exe -O2 -fno-strict-aliasing -Wall 
 -Wmissing-prototypes -Wmissing-declarations -fno-strict-aliasing 
 -L/usr/local/lib conftest.c -lssl -lcrypto -lz -lreadline -lcrypt 
 -lresolv -lm  5
 conftest.c: In function `main':
 conftest.c:67: error: invalid operands to binary /
 configure:12871: $? = 1
 configure: failed program was:
 ...
 
 #include time.h
 int res;
 int
 main ()
 {
 res = timezone / 60;
;
return 0;
 }
 
 so my patch and my whole point is wrong.
 just the underscore is needed for cygwin in pg_config_manual.h
 -- 
 Reini Urban
 http://xarch.tu-graz.ac.at/home/rurban/
 
 ---(end of broadcast)---
 TIP 7: don't forget to increase your free space map settings
 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073
Index: configure
===
RCS file: /cvsroot/pgsql-server/configure,v
retrieving revision 1.389
diff -c -c -r1.389 configure
*** configure   2 Sep 2004 20:39:57 -   1.389
--- configure   8 Sep 2004 19:36:18 -
***
*** 10725,10731 
--- 10725,10735 
  int
  main ()
  {
+ #ifndef __CYGWIN__
  res = timezone / 60;
+ #else
+ res = _timezone / 60;
+ #endif
;
return 0;
  }
Index: config/c-library.m4
===
RCS file: /cvsroot/pgsql-server/config/c-library.m4,v
retrieving revision 1.26
diff -c -c -r1.26 c-library.m4
*** config/c-library.m4 7 Jun 2004 22:39:44 -   1.26
--- config/c-library.m4 8 Sep 2004 19:36:19 -
***
*** 10,16 
  [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
  [AC_TRY_LINK([#include time.h
  int res;],
!   [res = timezone / 60;],
[pgac_cv_var_int_timezone=yes],
[pgac_cv_var_int_timezone=no])])
  if test x$pgac_cv_var_int_timezone = xyes ; then
--- 10,20 
  [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
  [AC_TRY_LINK([#include time.h
  int res;],
!   [#ifndef __CYGWIN__
! res = timezone / 60;
! #else
! res = _timezone / 60;
! #endif],
[pgac_cv_var_int_timezone=yes],
[pgac_cv_var_int_timezone=no])])
  if test 

Re: [PATCHES] time_t timezone

2004-09-08 Thread Bruce Momjian

I have done the same cleanup for _tzname for clarity and because some
files were using tzname as local variable names (pgtz.c).

---

Bruce Momjian wrote:
 
 OK, I have applied the following patch to fix the Cygwin _timezone
 issue.  I moved the TIMEZONE_GLOBAL up into port.h and change pgtz.c to
 use that instead.  I also changed the configure test for INT_TIMEZONE to
 test for _timezone on Cygwin.  This should fix all those problems.
 
 You found a few problems in dirmod.c but have run out of time and will
 deal with them in a few days.
 
 ---
 
 Reini Urban wrote:
  Bruce Momjian schrieb:
  
   Reini Urban wrote:
   
   # PGAC_VAR_INT_TIMEZONE
   # -
   # Check if the global variable `timezone' exists. If so, define
   # HAVE_INT_TIMEZONE.
   AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
   [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
   [AC_TRY_LINK([#include time.h
   int res;],
 [res = timezone / 60;],
 [pgac_cv_var_int_timezone=yes],
 [pgac_cv_var_int_timezone=no])])
   if test x$pgac_cv_var_int_timezone = xyes ; then
 AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
   variable 'int timezone'.])
   fi])# PGAC_VAR_INT_TIMEZONE
  
  You can look in include/pg_config.h to see how it is defined.
  
  This test fails, because you cannot do arithmetic with time_t.
  cygwin has/had a special workaround in pg_config_manual.h
  See Tom above.
  
  sorry, my mistake. you can do arithmetic with time_t.
  
  All other platforms with time_t timezone should manually enable their 
  HAVE_INT_TIMEZONE and manually add the (int) timezone in 
  src/timezone/pgtz.c.
   
   OK, let's get some facts.  How is your timezone variable defined in your
   headers?  Is it _timezone?  How is time_t defined?  If you take the
   program above and compile it alone, how does it fail?
  
  yes, it's only _timezone.
  
  already sent to this list. here it is:
  
  /usr/include/time.h from newlib.
  ...
  /* defines for the opengroup specifications Derived from Issue 1 of the 
  SVID.  */
  extern __IMPORT time_t _timezone;
  extern __IMPORT int _daylight;
  extern __IMPORT char *_tzname[2];
  
  which resolves to (gcc -E):
  # 98 /usr/include/time.h 3 4
  extern __attribute__((dllimport)) time_t _timezone;
  extern __attribute__((dllimport)) int _daylight;
  extern __attribute__((dllimport)) char *_tzname[2];
  
  time_t is a typedef from sys/types.h:
  #ifndef __time_t_defined
  typedef _TIME_T_ time_t;
  #define __time_t_defined
  
  _TIME_T_ is a macro from machine/types.h:
  define _TIME_T_long
  
   Also, look at your config.log output to see why it fails or email it to
   my privately.
  ...
  configure:12843: checking for int timezone
  configure:12865: gcc -o conftest.exe -O2 -fno-strict-aliasing -Wall 
  -Wmissing-prototypes -Wmissing-declarations -fno-strict-aliasing 
  -L/usr/local/lib conftest.c -lssl -lcrypto -lz -lreadline -lcrypt 
  -lresolv -lm  5
  conftest.c: In function `main':
  conftest.c:67: error: invalid operands to binary /
  configure:12871: $? = 1
  configure: failed program was:
  ...
  
  #include time.h
  int res;
  int
  main ()
  {
  res = timezone / 60;
 ;
 return 0;
  }
  
  so my patch and my whole point is wrong.
  just the underscore is needed for cygwin in pg_config_manual.h
  -- 
  Reini Urban
  http://xarch.tu-graz.ac.at/home/rurban/
  
  ---(end of broadcast)---
  TIP 7: don't forget to increase your free space map settings
  
 
 -- 
   Bruce Momjian|  http://candle.pha.pa.us
   [EMAIL PROTECTED]   |  (610) 359-1001
   +  If your life is a hard drive, |  13 Roberts Road
   +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

 Index: configure
 ===
 RCS file: /cvsroot/pgsql-server/configure,v
 retrieving revision 1.389
 diff -c -c -r1.389 configure
 *** configure 2 Sep 2004 20:39:57 -   1.389
 --- configure 8 Sep 2004 19:36:18 -
 ***
 *** 10725,10731 
 --- 10725,10735 
   int
   main ()
   {
 + #ifndef __CYGWIN__
   res = timezone / 60;
 + #else
 + res = _timezone / 60;
 + #endif
 ;
 return 0;
   }
 Index: config/c-library.m4
 ===
 RCS file: /cvsroot/pgsql-server/config/c-library.m4,v
 retrieving revision 1.26
 diff -c -c -r1.26 c-library.m4
 *** config/c-library.m4   7 Jun 2004 22:39:44 -   1.26
 --- config/c-library.m4   8 Sep 2004 19:36:19 -
 ***
 *** 10,16 
   [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
   [AC_TRY_LINK([#include time.h
   int res;],
 !   [res = timezone / 60;],
 [pgac_cv_var_int_timezone=yes],
 [pgac_cv_var_int_timezone=no])])

Re: [PATCHES] time_t timezone

2004-09-03 Thread Reini Urban
Bruce Momjian schrieb:
Reini Urban wrote:
# PGAC_VAR_INT_TIMEZONE
# -
# Check if the global variable `timezone' exists. If so, define
# HAVE_INT_TIMEZONE.
AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
[AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
[AC_TRY_LINK([#include time.h
int res;],
  [res = timezone / 60;],
  [pgac_cv_var_int_timezone=yes],
  [pgac_cv_var_int_timezone=no])])
if test x$pgac_cv_var_int_timezone = xyes ; then
  AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
variable 'int timezone'.])
fi])# PGAC_VAR_INT_TIMEZONE
You can look in include/pg_config.h to see how it is defined.
This test fails, because you cannot do arithmetic with time_t.
cygwin has/had a special workaround in pg_config_manual.h
See Tom above.
sorry, my mistake. you can do arithmetic with time_t.
All other platforms with time_t timezone should manually enable their 
HAVE_INT_TIMEZONE and manually add the (int) timezone in 
src/timezone/pgtz.c.
OK, let's get some facts.  How is your timezone variable defined in your
headers?  Is it _timezone?  How is time_t defined?  If you take the
program above and compile it alone, how does it fail?
yes, it's only _timezone.
already sent to this list. here it is:
/usr/include/time.h from newlib.
...
/* defines for the opengroup specifications Derived from Issue 1 of the 
SVID.  */
extern __IMPORT time_t _timezone;
extern __IMPORT int _daylight;
extern __IMPORT char *_tzname[2];

which resolves to (gcc -E):
# 98 /usr/include/time.h 3 4
extern __attribute__((dllimport)) time_t _timezone;
extern __attribute__((dllimport)) int _daylight;
extern __attribute__((dllimport)) char *_tzname[2];
time_t is a typedef from sys/types.h:
#ifndef __time_t_defined
typedef _TIME_T_ time_t;
#define __time_t_defined
_TIME_T_ is a macro from machine/types.h:
define _TIME_T_long
Also, look at your config.log output to see why it fails or email it to
my privately.
...
configure:12843: checking for int timezone
configure:12865: gcc -o conftest.exe -O2 -fno-strict-aliasing -Wall 
-Wmissing-prototypes -Wmissing-declarations -fno-strict-aliasing 
-L/usr/local/lib conftest.c -lssl -lcrypto -lz -lreadline -lcrypt 
-lresolv -lm  5
conftest.c: In function `main':
conftest.c:67: error: invalid operands to binary /
configure:12871: $? = 1
configure: failed program was:
...

#include time.h
int res;
int
main ()
{
res = timezone / 60;
  ;
  return 0;
}
so my patch and my whole point is wrong.
just the underscore is needed for cygwin in pg_config_manual.h
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] time_t timezone

2004-09-02 Thread Reini Urban
Bruce Momjian schrieb:
Tom Lane wrote:
Reini Urban [EMAIL PROTECTED] writes:
Yes, they are talking about the localtime return value,
but nevertheless the newlib folks refer to that. Their fault.

Should I discuss that with them?
Probably.  They have a gratuitous variation from the Single Unix Spec.
But what may be more to the point is that AFAICS we make no assumption
about the exact datatype of the timezone variable.

Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib 
(src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c
Per my recent post in pghackers, I think that the datatype has nothing
to do with it anyway.  The real problem is the loss of this code that
was in pg_config_manual.h in 7.4 and before:
/*
* Define this if your operating system has _timezone rather than timezone
*/
#if defined(__CYGWIN__) || defined(WIN32)
#define HAVE_INT_TIMEZONE   /* has int _timezone */
#define HAVE_UNDERSCORE_TIMEZONE 1
#endif
I'm inclined to just put it back, rather than adding a configure test
that we never needed before.
OK, I backed out the int cast I had made for dt.h.  I agree time_t
should cast to int naturally.  I noticed that HAVE_INT_TIMEZONE is
already a configure test.  Is that test not working on Cygwin?  Seems it
is working on MinGW.  The test is this:

# PGAC_VAR_INT_TIMEZONE
# -
# Check if the global variable `timezone' exists. If so, define
# HAVE_INT_TIMEZONE.
AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
[AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
[AC_TRY_LINK([#include time.h
int res;],
  [res = timezone / 60;],
  [pgac_cv_var_int_timezone=yes],
  [pgac_cv_var_int_timezone=no])])
if test x$pgac_cv_var_int_timezone = xyes ; then
  AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
variable 'int timezone'.])
fi])# PGAC_VAR_INT_TIMEZONE
You can look in include/pg_config.h to see how it is defined.
This test fails, because you cannot do arithmetic with time_t.
cygwin has/had a special workaround in pg_config_manual.h
See Tom above.
All other platforms with time_t timezone should manually enable their 
HAVE_INT_TIMEZONE and manually add the (int) timezone in 
src/timezone/pgtz.c.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org


Re: [PATCHES] time_t timezone

2004-09-02 Thread Tom Lane
Reini Urban [EMAIL PROTECTED] writes:
 This test fails, because you cannot do arithmetic with time_t.

You apparently speak some different flavor of C than the rest of us.

regards, tom lane

---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster


Re: [PATCHES] time_t timezone

2004-09-02 Thread Bruce Momjian
Reini Urban wrote:
  # PGAC_VAR_INT_TIMEZONE
  # -
  # Check if the global variable `timezone' exists. If so, define
  # HAVE_INT_TIMEZONE.
  AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
  [AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
  [AC_TRY_LINK([#include time.h
  int res;],
[res = timezone / 60;],
[pgac_cv_var_int_timezone=yes],
[pgac_cv_var_int_timezone=no])])
  if test x$pgac_cv_var_int_timezone = xyes ; then
AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
  variable 'int timezone'.])
  fi])# PGAC_VAR_INT_TIMEZONE
  
  You can look in include/pg_config.h to see how it is defined.
 
 This test fails, because you cannot do arithmetic with time_t.
 cygwin has/had a special workaround in pg_config_manual.h
 See Tom above.
 
 All other platforms with time_t timezone should manually enable their 
 HAVE_INT_TIMEZONE and manually add the (int) timezone in 
 src/timezone/pgtz.c.

OK, let's get some facts.  How is your timezone variable defined in your
headers?  Is it _timezone?  How is time_t defined?  If you take the
program above and compile it alone, how does it fail?

Also, look at your config.log output to see why it fails or email it to
my privately.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] time_t timezone

2004-09-01 Thread Reini Urban
Tom Lane schrieb:
Reini Urban [EMAIL PROTECTED] writes:
Added configure time_t timezone check for the SUSV definition.
Kindly do not claim that this is per SUS spec.
http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html
oops! sorry :(
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] time_t timezone

2004-09-01 Thread Bruce Momjian

I am inclined to leave the #ifdef Cygwin test in the code rather than
add a configure check.

---

Reini Urban wrote:
 Tom Lane schrieb:
  Reini Urban [EMAIL PROTECTED] writes:
 Added configure time_t timezone check for the SUSV definition.
  
  Kindly do not claim that this is per SUS spec.
  
  http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html
 
 oops! sorry :(
 
 -- 
 Reini Urban
 http://xarch.tu-graz.ac.at/home/rurban/
 
 ---(end of broadcast)---
 TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]
 

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [PATCHES] time_t timezone

2004-09-01 Thread Reini Urban
Bruce Momjian schrieb:
I am inclined to leave the #ifdef Cygwin test in the code rather than
add a configure check.
No,
There are a lot of other systems with time_t timezone!
newlib explains it like this:
/* defines for the opengroup specifications Derived from Issue 1 of the 
SVID.  */
extern __IMPORT time_t _timezone;
extern __IMPORT int _daylight;
extern __IMPORT char *_tzname[2];

SVID (System V Interface Definition) seems to be an interesting spec, 
which I found here:
  http://www.caldera.com/developers/devspecs/vol1a.pdf
  (nothing about the type of timezone though)

But the time_t timezone issue is here:
  XSHd7 Aardvark Change Request Report
  http://www.opengroup.org/austin/docs/austin_97.txt
(ERN 20 Accept as marked, page 1177)
SUSV2 only defines it as long int
  http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html
Caldera, redhat and IRIX 6.2 at least use time_t
  http://uw713doc.sco.com/en/man/html.3C/ctime.3C.html
http://www.opensource.apple.com/darwinsource/10.0.4/tcl-3.1/tcl/unix/tcl.m4
Please google for time_t timezone and the accompanying autoconf .m4 
files. tcl.m4 could be quite useful, if you don't like my hack.
php also uses time_t and not long int.

PS: For compatibility newlib has:
#ifdef __CYGWIN__
#ifdef timezonevar
#ifndef timezone
#define timezone ((long int) _timezone)
#endif
#endif
Looks like we only have to define timezonevar in our hint,
eh Makefile.port, but then the other platforms will loose.
---
Reini Urban wrote:
Tom Lane schrieb:
Reini Urban [EMAIL PROTECTED] writes:
Added configure time_t timezone check for the SUSV definition.
Kindly do not claim that this is per SUS spec.
http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html
oops! sorry :(
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] time_t timezone

2004-09-01 Thread Tom Lane
Reini Urban [EMAIL PROTECTED] writes:
 But the time_t timezone issue is here:
XSHd7 Aardvark Change Request Report
http://www.opengroup.org/austin/docs/austin_97.txt
 (ERN 20 Accept as marked, page 1177)

There is nothing whatever on that page about the datatype of the
timezone variable.

 Caldera, redhat and IRIX 6.2 at least use time_t
http://uw713doc.sco.com/en/man/html.3C/ctime.3C.html

Red Hat certainly does not:

[EMAIL PROTECTED] include]$ grep timezone /usr/include/*h
/usr/include/time.h:   of *TIMER in the local timezone.  */
/usr/include/time.h:extern char *__tzname[2];   /* Current timezone names.  */
/usr/include/time.h:extern long int __timezone; /* Seconds west of UTC.  */
/usr/include/time.h:extern long int timezone;
[EMAIL PROTECTED] include]$

But what may be more to the point is that AFAICS we make no assumption
about the exact datatype of the timezone variable.  So long as it is
some signed integer type (which surely it must be), the code will work.
I see no reason to add a configure test to test something we do not care
about.

regards, tom lane

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [PATCHES] time_t timezone

2004-09-01 Thread Reini Urban
Tom Lane schrieb:
Reini Urban [EMAIL PROTECTED] writes:
But the time_t timezone issue is here:
  XSHd7 Aardvark Change Request Report
  http://www.opengroup.org/austin/docs/austin_97.txt
(ERN 20 Accept as marked, page 1177)
There is nothing whatever on that page about the datatype of the
timezone variable.
1) in POSIX, the time_t value is always related to local time by
the seconds since the Epoch expression and the timezone
information.
Yes, they are talking about the localtime return value,
but nevertheless the newlib folks refer to that. Their fault.
Should I discuss that with them? I will not do that.
newlib is happening in the real world, standards just a general 
consensus, how it should happen.
If some other platforms use newlib, you are lost with the make abort.

Caldera, redhat and IRIX 6.2 at least use time_t
  http://uw713doc.sco.com/en/man/html.3C/ctime.3C.html
Red Hat certainly does not:
[EMAIL PROTECTED] include]$ grep timezone /usr/include/*h
/usr/include/time.h:   of *TIMER in the local timezone.  */
/usr/include/time.h:extern char *__tzname[2];   /* Current timezone names.  */
/usr/include/time.h:extern long int __timezone; /* Seconds west of UTC.  */
/usr/include/time.h:extern long int timezone;
[EMAIL PROTECTED] include]$
dertainly depends which redhat. I have no redhat around and newlib is 
quite new. This pgtz timezone code is also quite new.

But what may be more to the point is that AFAICS we make no assumption
about the exact datatype of the timezone variable.  So long as it is
some signed integer type (which surely it must be), the code will work.
I see no reason to add a configure test to test something we do not care
about.
Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib 
(src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c

Fact is: src/timezone/pgtz.c does not compile on cygwin,
and will not compile on any other similar platform, as I saw from 
googling around, unless it is checked in configure.in or
- the dirty way - casted away in src/timezone/pgtz.c and the .m4 macro.

Since the current configure check does not define HAVE_INT_TIMEZONE (not 
casted there, so it fails), the whole pgtz #ifdef branch will abort.

http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/timezone/pgtz.c?rev=HEAD;content-type=text%2Fx-cvsweb-markup
and 
http://developer.postgresql.org/cvsweb.cgi/pgsql-server/config/c-library.m4?rev=HEAD;content-type=text%2Fx-cvsweb-markup
are wrong without the cast.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]


Re: [PATCHES] time_t timezone

2004-09-01 Thread Tom Lane
Reini Urban [EMAIL PROTECTED] writes:
 Yes, they are talking about the localtime return value,
 but nevertheless the newlib folks refer to that. Their fault.

 Should I discuss that with them?

Probably.  They have a gratuitous variation from the Single Unix Spec.

 But what may be more to the point is that AFAICS we make no assumption
 about the exact datatype of the timezone variable.

 Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib 
 (src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c

Per my recent post in pghackers, I think that the datatype has nothing
to do with it anyway.  The real problem is the loss of this code that
was in pg_config_manual.h in 7.4 and before:

/*
 * Define this if your operating system has _timezone rather than timezone
 */
#if defined(__CYGWIN__) || defined(WIN32)
#define HAVE_INT_TIMEZONE   /* has int _timezone */
#define HAVE_UNDERSCORE_TIMEZONE 1
#endif

I'm inclined to just put it back, rather than adding a configure test
that we never needed before.

regards, tom lane

---(end of broadcast)---
TIP 9: the planner will ignore your desire to choose an index scan if your
  joining column's datatypes do not match


Re: [PATCHES] time_t timezone

2004-09-01 Thread Reini Urban
Tom Lane schrieb:
Reini Urban [EMAIL PROTECTED] writes:
Yes, they are talking about the localtime return value,
but nevertheless the newlib folks refer to that. Their fault.

Should I discuss that with them?
Probably.  They have a gratuitous variation from the Single Unix Spec.
But what may be more to the point is that AFAICS we make no assumption
about the exact datatype of the timezone variable.

Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib 
(src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c

Per my recent post in pghackers, I think that the datatype has nothing
to do with it anyway.  The real problem is the loss of this code that
was in pg_config_manual.h in 7.4 and before:
/*
 * Define this if your operating system has _timezone rather than timezone
 */
#if defined(__CYGWIN__) || defined(WIN32)
#define HAVE_INT_TIMEZONE   /* has int _timezone */
#define HAVE_UNDERSCORE_TIMEZONE 1
#endif
I'm inclined to just put it back, rather than adding a configure test
that we never needed before.
Fine with me. I'm just doing the cygwin packaging.
And I can apply my cast to the pgtz.c code by myself also.
But upstream would be better.
I just wanted that you are aware of that. The configure test was more 
general and similar to other packages (tcl, php).
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

---(end of broadcast)---
TIP 6: Have you searched our list archives?
  http://archives.postgresql.org


Re: [PATCHES] time_t timezone

2004-09-01 Thread Bruce Momjian
Tom Lane wrote:
 Reini Urban [EMAIL PROTECTED] writes:
  Yes, they are talking about the localtime return value,
  but nevertheless the newlib folks refer to that. Their fault.
 
  Should I discuss that with them?
 
 Probably.  They have a gratuitous variation from the Single Unix Spec.
 
  But what may be more to the point is that AFAICS we make no assumption
  about the exact datatype of the timezone variable.
 
  Bruce' patch only assumes time_t on CYGWIN and it is only for pgtypeslib 
  (src/interfaces/ecpg/pgtypeslib/dt.h). Not for src/timezone/pgtz.c
 
 Per my recent post in pghackers, I think that the datatype has nothing
 to do with it anyway.  The real problem is the loss of this code that
 was in pg_config_manual.h in 7.4 and before:
 
 /*
  * Define this if your operating system has _timezone rather than timezone
  */
 #if defined(__CYGWIN__) || defined(WIN32)
 #define HAVE_INT_TIMEZONE /* has int _timezone */
 #define HAVE_UNDERSCORE_TIMEZONE 1
 #endif
 
 I'm inclined to just put it back, rather than adding a configure test
 that we never needed before.

OK, I backed out the int cast I had made for dt.h.  I agree time_t
should cast to int naturally.  I noticed that HAVE_INT_TIMEZONE is
already a configure test.  Is that test not working on Cygwin?  Seems it
is working on MinGW.  The test is this:

# PGAC_VAR_INT_TIMEZONE
# -
# Check if the global variable `timezone' exists. If so, define
# HAVE_INT_TIMEZONE.
AC_DEFUN([PGAC_VAR_INT_TIMEZONE],
[AC_CACHE_CHECK(for int timezone, pgac_cv_var_int_timezone,
[AC_TRY_LINK([#include time.h
int res;],
  [res = timezone / 60;],
  [pgac_cv_var_int_timezone=yes],
  [pgac_cv_var_int_timezone=no])])
if test x$pgac_cv_var_int_timezone = xyes ; then
  AC_DEFINE(HAVE_INT_TIMEZONE,, [Define to 1 if you have the global
variable 'int timezone'.])
fi])# PGAC_VAR_INT_TIMEZONE

You can look in include/pg_config.h to see how it is defined.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 3: if posting/reading through Usenet, please send an appropriate
  subscribe-nomail command to [EMAIL PROTECTED] so that your
  message can get through to the mailing list cleanly


Re: [PATCHES] time_t timezone

2004-08-31 Thread Reini Urban
Now I've found time to test beta2 and came up
with the attached better patch:
Added configure time_t timezone check for the SUSV definition.
Not only cygwin, all newlib installations without struct tm timezone.
Casted to (int) timezone.
(configure should really be re-created by autoconf. I patched it just 
for completeness in the forthcoming cygwin package.)

Bruce Momjian schrieb:
OK, patch attached and applied that casts _timezone to (int) on Cygwin.
---
Reini Urban wrote:
Bruce Momjian schrieb:
Should I apply this change?
#define TIMEZONE_GLOBAL ((int)_timezone)
yes, please.
I have no time yet, to come up with the better patch. It's already  monday.

---
Reini Urban wrote:

Bruce Momjian schrieb:

Your patch highlighted several bugs in our code.  First, I wasn't
testing for CYGWIN in the backend pgport_palloc code.  Second, I added
an #undef to prevent compiler warnings.  Third I added your Cygwin
includes with an #ifdef.  These will appear in beta2.
On the timezone issue, I see this in dt.h:

/* Global variable holding time zone information. */
#if !defined(__CYGWIN__)  !defined(WIN32)
#define TIMEZONE_GLOBAL timezone
#else
#define TIMEZONE_GLOBAL _timezone
#define tzname _tzname  /* should be in time.h? */
#endif
so are you saying your _timezone is time_t and not an int?  Sometimes it
is just a short because it is only minutes west of GMT, not an actually
seconds since 1970 or anything.  Making it time_t actually sounds like
overkill, but we can work around that in dt.h if indeed that is how your
OS defines it.  The easiest fix would probably be to add the cast to int
right in dt.h and only for Cygwin:
#define TIMEZONE_GLOBAL ((int)_timezone)
Does that work for you?
yes, that's better.
FYI /usr/include/time.h:
/* defines for the opengroup specifications Derived from Issue 1 of the 
SVID.  */
extern __IMPORT time_t _timezone;
...

BTW: I see that CYGWIN also has a struct timezone in sys/time.h, but 
configure didn't check for that.
I'll come with better patches after beta2.



---
Reini Urban wrote:

Attached patches are required for cygwin:
2004-08-24 21:23:53 [EMAIL PROTECTED]
* (postmaster/syslogger.c) struct timeval is
declared in sys/time.h, not in time.h
2004-08-24 20:20:54 rurban:
* (port/dirmod.c) cygwin needs different header locations,
and unlink is a macro. There are no pgport_palloc
versions yet
timezone/pgtz.c:
Pending is a patch against postgresql-8.0.0beta1/config/c-library.m4:
PGAC_VAR_INT_TIMEZONE
In the meantime I've hacked it with a cast from time_t to (int) in
timezone/pgtz.c: get_timezone_offset
but timezone really is of time_t, not int. I don't know what you are 
trying to do here.

There's on remaining issue for the cygwin build:
../../src/port/libpgport.a(dirmod.o)(.text+0x5ee):dirmod.c: undefined 
reference to `__imp__CurrentMemoryContext'
../../src/port/libpgport.a(dirmod.o)(.text+0x64b):dirmod.c: undefined 
reference to `__imp__CurrentMemoryContext'

which explains the pgport_palloc problem.
--
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/

2004-08-24 20:20:54 rurban: 
	* cygwin needs different header locations, and unlink is a macro
	* There are no pgport_palloc versions yet

--- postgresql-8.0.0beta1/src/port/dirmod.c.orig2004-08-08 07:44:36.0 
+0100
+++ postgresql-8.0.0beta1/src/port/dirmod.c 2004-08-24 19:20:56.557435000 +0100
@@ -33,16 +33,28 @@
#include miscadmin.h
+
+#ifdef __CYGWIN__
+#include windows.h
+#include w32api/winioctl.h
+#else
#include winioctl.h
+#undef unlink
+#endif
#undef rename
-#undef unlink
+/* 2004-08-24 20:20:54 rurban: There are no pgport_palloc versions yet */
+#if 0 
#ifndef FRONTEND
+#undef palloc
+#undef pstrdup
+#undef pfree
#define palloc(sz)	pgport_palloc(sz)
#define pstrdup(str)	pgport_pstrdup(str)
#define pfree(pointer)	pgport_pfree(pointer)
#endif
+#endif

/*

2004-08-24 21:23:53 [EMAIL PROTECTED]
* struct timeval is declared in sys/time.h, not in time.h
--- postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c.orig   2004-08-06 
20:17:31.0 +0100
+++ postgresql-8.0.0beta1/src/backend/postmaster/syslogger.c2004-08-24 
20:21:26.057851800 +0100
@@ -28,6 +28,7 @@
#include signal.h
#include time.h
#include unistd.h
+#include sys/time.h
#include sys/stat.h
#include libpq/pqsignal.h

--- postgresql-8.0.0beta1/src/timezone/pgtz.c.orig  2004-07-31 20:12:15.0 
+0100
+++ postgresql-8.0.0beta1/src/timezone/pgtz.c   2004-08-24 19:56:30.686367800 +0100
@@ -97,9 +97,9 @@
return tm-tm_gmtoff;
#elif defined(HAVE_INT_TIMEZONE)
#ifdef HAVE_UNDERSCORE_TIMEZONE
-   return -_timezone;
+   return -(int)_timezone;
#else
-   return -timezone;
+ 

Re: [PATCHES] time_t timezone

2004-08-31 Thread Tom Lane
Reini Urban [EMAIL PROTECTED] writes:
 Added configure time_t timezone check for the SUSV definition.

Kindly do not claim that this is per SUS spec.

http://www.opengroup.org/onlinepubs/007908799/xsh/timezone.html

regards, tom lane

---(end of broadcast)---
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]