Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c10e6bc

Browse files
committed
Attempting to insert a value of 'now' into a datetime type
results in a bogus datetime value under AlphaLinux. (Note that the link to submit a port-specific bug on your website is broken) -Test Case: ---------- testdb=> create table dttest (dt datetime); testdb=> insert into dttest values ('now'); -------------------------------------------------------------------------- Solution: --------- The basic problem is the typedefs of AbsoluteTime and RelativeTime, which are both 'int32'. These types appear to be used synonymously with the 'time_t' type, which on AlphaLinux is typedef'd as a 'long int', which is 64-bits (not 32). The solution included here fixes the datetime type (it now passes the regression test), but does not pass the absolute and relative time regression tests. Presumably, a more thorough investigation of how these types are used is warranted. The included patch is from the v6.3.2 source, but can be applied to the v6.4.2 source. Please note that there is also a RedHat-specific patch distributed with the PostgreSQL source package from RedHat that was applied first. Rich Edwards
1 parent e2c4d41 commit c10e6bc

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/backend/utils/adt/date.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.30 1999/02/21 03:49:27 scrappy Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.31 1999/03/14 16:44:01 momjian Exp $
1313
*
1414
* NOTES
1515
* This code is actually (almost) unused.
@@ -94,7 +94,7 @@ static int sec_tab[] = {
9494
* Function prototypes -- internal to this file only
9595
*/
9696

97-
static void reltime2tm(int32 time, struct tm * tm);
97+
static void reltime2tm(RelativeTime time, struct tm * tm);
9898

9999
#ifdef NOT_USED
100100
static int correct_unit(char *unit, int *unptr);
@@ -161,7 +161,7 @@ reltimein(char *str)
161161
* reltimeout - converts the internal format to a reltime string
162162
*/
163163
char *
164-
reltimeout(int32 time)
164+
reltimeout(RelativeTime time)
165165
{
166166
char *result;
167167
struct tm tt,
@@ -193,7 +193,7 @@ do { \
193193
} while(0)
194194

195195
static void
196-
reltime2tm(int32 time, struct tm * tm)
196+
reltime2tm(RelativeTime time, struct tm * tm)
197197
{
198198
TMODULO(time, tm->tm_year, 31536000);
199199
TMODULO(time, tm->tm_mon, 2592000);

src/include/utils/builtins.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: builtins.h,v 1.75 1999/03/14 05:09:05 momjian Exp $
9+
* $Id: builtins.h,v 1.76 1999/03/14 16:44:01 momjian Exp $
1010
*
1111
* NOTES
1212
* This should normally only be included by fmgr.h.
@@ -195,8 +195,8 @@ extern int32 pqtest(struct varlena * vlena);
195195
/* arrayfuncs.c */
196196

197197
/* date.c */
198-
extern int32 reltimein(char *timestring);
199-
extern char *reltimeout(int32 timevalue);
198+
extern RelativeTime reltimein(char *timestring);
199+
extern char *reltimeout(RelativeTime timevalue);
200200
extern TimeInterval tintervalin(char *intervalstr);
201201
extern char *tintervalout(TimeInterval interval);
202202
extern RelativeTime timespan_reltime(TimeSpan *timespan);

src/include/utils/nabstime.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nabstime.h,v 1.18 1999/02/13 23:22:25 momjian Exp $
9+
* $Id: nabstime.h,v 1.19 1999/03/14 16:44:02 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -23,8 +23,13 @@
2323
*
2424
* ----------------------------------------------------------------
2525
*/
26-
typedef int32 AbsoluteTime;
27-
typedef int32 RelativeTime;
26+
/* The original typedefs are bogus - they assume that the system's 'time_t'
27+
* type is of size 32-bits. Under AlphaLinux, time_t is a long int, which
28+
* is 64-bits. Therefore, typedef these both as simply 'time_t', and let
29+
* the OS define what the size really is. -- RME 3/5/99
30+
*/
31+
typedef time_t AbsoluteTime;
32+
typedef time_t RelativeTime;
2833

2934
typedef struct
3035
{

0 commit comments

Comments
 (0)