Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
e6b72d6a
Commit
e6b72d6a
authored
Jul 21, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update DAYS_PER_MONTH comment.
Add SECS_PER_YEAR and MINS_PER_HOUR macros.
parent
a0407f50
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
82 additions
and
71 deletions
+82
-71
src/backend/postmaster/syslogger.c
src/backend/postmaster/syslogger.c
+2
-2
src/backend/utils/adt/date.c
src/backend/utils/adt/date.c
+9
-9
src/backend/utils/adt/datetime.c
src/backend/utils/adt/datetime.c
+16
-16
src/backend/utils/adt/nabstime.c
src/backend/utils/adt/nabstime.c
+7
-7
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/timestamp.c
+12
-13
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+2
-2
src/include/utils/timestamp.h
src/include/utils/timestamp.h
+9
-3
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt.h
+8
-2
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/dt_common.c
+14
-14
src/interfaces/ecpg/pgtypeslib/interval.c
src/interfaces/ecpg/pgtypeslib/interval.c
+1
-1
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
+2
-2
No files found.
src/backend/postmaster/syslogger.c
View file @
e6b72d6a
...
...
@@ -18,7 +18,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.1
7 2005/07/21 03:56:11
momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/syslogger.c,v 1.1
8 2005/07/21 18:06:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -60,7 +60,7 @@
* start, but the rest can change at SIGHUP.
*/
bool
Redirect_stderr
=
false
;
int
Log_RotationAge
=
HOURS_PER_DAY
*
SECS_PER_MINUTE
;
int
Log_RotationAge
=
HOURS_PER_DAY
*
MINS_PER_HOUR
;
int
Log_RotationSize
=
10
*
1024
;
char
*
Log_directory
=
NULL
;
char
*
Log_filename
=
NULL
;
...
...
src/backend/utils/adt/date.c
View file @
e6b72d6a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.11
5 2005/07/21 04:41:43
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/date.c,v 1.11
6 2005/07/21 18:06:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -917,10 +917,10 @@ static int
tm2time
(
struct
pg_tm
*
tm
,
fsec_t
fsec
,
TimeADT
*
result
)
{
#ifdef HAVE_INT64_TIMESTAMP
*
result
=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
result
=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
;
#else
*
result
=
((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
*
result
=
((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
#endif
return
0
;
}
...
...
@@ -1347,10 +1347,10 @@ timestamp_time(PG_FUNCTION_ARGS)
* Could also do this with time = (timestamp / USECS_PER_DAY *
* USECS_PER_DAY) - timestamp;
*/
result
=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
result
=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
;
#else
result
=
((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
result
=
((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
#endif
PG_RETURN_TIMEADT
(
result
);
...
...
@@ -1384,10 +1384,10 @@ timestamptz_time(PG_FUNCTION_ARGS)
* Could also do this with time = (timestamp / USECS_PER_DAY *
* USECS_PER_DAY) - timestamp;
*/
result
=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
result
=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
;
#else
result
=
((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
result
=
((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
#endif
PG_RETURN_TIMEADT
(
result
);
...
...
@@ -1714,10 +1714,10 @@ static int
tm2timetz
(
struct
pg_tm
*
tm
,
fsec_t
fsec
,
int
tz
,
TimeTzADT
*
result
)
{
#ifdef HAVE_INT64_TIMESTAMP
result
->
time
=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
result
->
time
=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
;
#else
result
->
time
=
((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
result
->
time
=
((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
;
#endif
result
->
zone
=
tz
;
...
...
src/backend/utils/adt/datetime.c
View file @
e6b72d6a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.15
4 2005/07/21 04:41:43
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/datetime.c,v 1.15
5 2005/07/21 18:06:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1447,7 +1447,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
1
;
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
*
tzp
+=
val
*
SECS_PER_MINUTE
;
*
tzp
+=
val
*
MINS_PER_HOUR
;
break
;
case
DTZ
:
...
...
@@ -1460,7 +1460,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
1
;
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
*
tzp
=
val
*
SECS_PER_MINUTE
;
*
tzp
=
val
*
MINS_PER_HOUR
;
ftype
[
i
]
=
DTK_TZ
;
break
;
...
...
@@ -1468,7 +1468,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
0
;
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
*
tzp
=
val
*
SECS_PER_MINUTE
;
*
tzp
=
val
*
MINS_PER_HOUR
;
ftype
[
i
]
=
DTK_TZ
;
break
;
...
...
@@ -1667,7 +1667,7 @@ DetermineLocalTimeZone(struct pg_tm * tm)
day
=
((
pg_time_t
)
date
)
*
SECS_PER_DAY
;
if
(
day
/
SECS_PER_DAY
!=
date
)
goto
overflow
;
sec
=
tm
->
tm_sec
+
(
tm
->
tm_min
+
tm
->
tm_hour
*
SECS_PER_MINUTE
)
*
SECS_PER_MINUTE
;
sec
=
tm
->
tm_sec
+
(
tm
->
tm_min
+
tm
->
tm_hour
*
MINS_PER_HOUR
)
*
SECS_PER_MINUTE
;
mytime
=
day
+
sec
;
/* since sec >= 0, overflow could only be from +day to -mytime */
if
(
mytime
<
0
&&
day
>
0
)
...
...
@@ -1679,7 +1679,7 @@ DetermineLocalTimeZone(struct pg_tm * tm)
* that DST boundaries can't be closer together than 48 hours, so
* backing up 24 hours and finding the "next" boundary will work.
*/
prevtime
=
mytime
-
(
HOURS_PER_DAY
*
SECS_PER_MINUTE
*
SECS_PER_MINUTE
)
;
prevtime
=
mytime
-
SECS_PER_DAY
;
if
(
mytime
<
0
&&
prevtime
>
0
)
goto
overflow
;
...
...
@@ -2167,7 +2167,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
1
;
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
*
tzp
+=
val
*
SECS_PER_MINUTE
;
*
tzp
+=
val
*
MINS_PER_HOUR
;
break
;
case
DTZ
:
...
...
@@ -2180,7 +2180,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
1
;
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
*
tzp
=
val
*
SECS_PER_MINUTE
;
*
tzp
=
val
*
MINS_PER_HOUR
;
ftype
[
i
]
=
DTK_TZ
;
break
;
...
...
@@ -2188,7 +2188,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
0
;
if
(
tzp
==
NULL
)
return
DTERR_BAD_FORMAT
;
*
tzp
=
val
*
SECS_PER_MINUTE
;
*
tzp
=
val
*
MINS_PER_HOUR
;
ftype
[
i
]
=
DTK_TZ
;
break
;
...
...
@@ -2833,7 +2833,7 @@ DecodeTimezone(char *str, int *tzp)
if
(
min
<
0
||
min
>=
60
)
return
DTERR_TZDISP_OVERFLOW
;
tz
=
(
hr
*
SECS_PER_MINUTE
+
min
)
*
SECS_PER_MINUTE
;
tz
=
(
hr
*
MINS_PER_HOUR
+
min
)
*
SECS_PER_MINUTE
;
if
(
*
str
==
'-'
)
tz
=
-
tz
;
...
...
@@ -2890,7 +2890,7 @@ DecodePosixTimezone(char *str, int *tzp)
{
case
DTZ
:
case
TZ
:
*
tzp
=
(
val
*
SECS_PER_MINUTE
)
-
tz
;
*
tzp
=
(
val
*
MINS_PER_HOUR
)
-
tz
;
break
;
default:
...
...
@@ -3510,7 +3510,7 @@ EncodeTimeOnly(struct pg_tm * tm, fsec_t fsec, int *tzp, int style, char *str)
min
;
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
...
...
@@ -3583,7 +3583,7 @@ EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style,
if
(
tzp
!=
NULL
&&
tm
->
tm_isdst
>=
0
)
{
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
...
...
@@ -3633,7 +3633,7 @@ EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style,
else
{
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
}
...
...
@@ -3681,7 +3681,7 @@ EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style,
else
{
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
}
...
...
@@ -3747,7 +3747,7 @@ EncodeDateTime(struct pg_tm * tm, fsec_t fsec, int *tzp, char **tzn, int style,
* 2001-10-19
*/
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
" %+03d:%02d"
:
" %+03d"
,
hour
,
min
);
}
}
...
...
src/backend/utils/adt/nabstime.c
View file @
e6b72d6a
...
...
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.13
8 2005/07/21 04:41:43
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/nabstime.c,v 1.13
9 2005/07/21 18:06:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -199,7 +199,7 @@ tm2abstime(struct pg_tm * tm, int tz)
return
INVALID_ABSTIME
;
/* convert to seconds */
sec
=
tm
->
tm_sec
+
tz
+
(
tm
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tm
->
tm_hour
)
*
SECS_PER_MINUTE
)
*
SECS_PER_MINUTE
;
sec
=
tm
->
tm_sec
+
tz
+
(
tm
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tm
->
tm_hour
)
*
MINS_PER_HOUR
)
*
SECS_PER_MINUTE
;
/* check for overflow */
if
((
day
==
MAX_DAYNUM
&&
sec
<
0
)
||
...
...
@@ -638,8 +638,8 @@ reltimein(PG_FUNCTION_ARGS)
switch
(
dtype
)
{
case
DTK_DELTA
:
result
=
((
tm
->
tm_hour
*
SECS_PER_MINUTE
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
;
result
+=
tm
->
tm_year
*
36525
*
864
+
((
tm
->
tm_mon
*
DAYS_PER_MONTH
)
+
tm
->
tm_mday
)
*
SECS_PER_DAY
;
result
=
((
tm
->
tm_hour
*
MINS_PER_HOUR
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
;
result
+=
tm
->
tm_year
*
SECS_PER_YEAR
+
((
tm
->
tm_mon
*
DAYS_PER_MONTH
)
+
tm
->
tm_mday
)
*
SECS_PER_DAY
;
break
;
default:
...
...
@@ -884,8 +884,8 @@ reltime_interval(PG_FUNCTION_ARGS)
default:
#ifdef HAVE_INT64_TIMESTAMP
year
=
reltime
/
(
36525
*
864
)
;
reltime
-=
year
*
(
36525
*
864
)
;
year
=
reltime
/
SECS_PER_YEAR
;
reltime
-=
year
*
SECS_PER_YEAR
;
month
=
reltime
/
(
DAYS_PER_MONTH
*
SECS_PER_DAY
);
reltime
-=
month
*
(
DAYS_PER_MONTH
*
SECS_PER_DAY
);
day
=
reltime
/
SECS_PER_DAY
;
...
...
@@ -893,7 +893,7 @@ reltime_interval(PG_FUNCTION_ARGS)
result
->
time
=
(
reltime
*
USECS_PER_SEC
);
#else
TMODULO
(
reltime
,
year
,
36525
*
864
);
TMODULO
(
reltime
,
year
,
SECS_PER_YEAR
);
TMODULO
(
reltime
,
month
,
DAYS_PER_MONTH
*
SECS_PER_DAY
);
TMODULO
(
reltime
,
day
,
SECS_PER_DAY
);
...
...
src/backend/utils/adt/timestamp.c
View file @
e6b72d6a
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.13
7 2005/07/21 05:18:26
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.13
8 2005/07/21 18:06:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -748,7 +748,6 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod)
interval
->
time
-=
hour
*
USECS_PER_HOUR
;
interval
->
time
=
(
interval
->
time
/
USECS_PER_MINUTE
)
*
USECS_PER_MINUTE
;
#else
TMODULO
(
interval
->
time
,
hour
,
(
double
)
SECS_PER_HOUR
);
interval
->
time
=
((
int
)(
interval
->
time
/
SECS_PER_MINUTE
))
*
(
double
)
SECS_PER_MINUTE
;
...
...
@@ -1212,7 +1211,7 @@ tm2interval(struct pg_tm *tm, fsec_t fsec, Interval *span)
tm
->
tm_min
)
*
INT64CONST
(
60
))
+
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
;
#else
span
->
time
=
(((
tm
->
tm_hour
*
(
double
)
SECS_PER_MINUTE
)
+
span
->
time
=
(((
tm
->
tm_hour
*
(
double
)
MINS_PER_HOUR
)
+
tm
->
tm_min
)
*
(
double
)
SECS_PER_MINUTE
)
+
tm
->
tm_sec
;
span
->
time
=
JROUND
(
span
->
time
+
fsec
);
...
...
@@ -1225,14 +1224,14 @@ tm2interval(struct pg_tm *tm, fsec_t fsec, Interval *span)
static
int64
time2t
(
const
int
hour
,
const
int
min
,
const
int
sec
,
const
fsec_t
fsec
)
{
return
(((((
hour
*
SECS_PER_MINUTE
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
)
*
USECS_PER_SEC
)
+
fsec
;
return
(((((
hour
*
MINS_PER_HOUR
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
)
*
USECS_PER_SEC
)
+
fsec
;
}
/* time2t() */
#else
static
double
time2t
(
const
int
hour
,
const
int
min
,
const
int
sec
,
const
fsec_t
fsec
)
{
return
(((
hour
*
SECS_PER_MINUTE
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
+
fsec
;
return
(((
hour
*
MINS_PER_HOUR
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
+
fsec
;
}
/* time2t() */
#endif
...
...
@@ -2475,7 +2474,7 @@ timestamp_age(PG_FUNCTION_ARGS)
while
(
tm
->
tm_min
<
0
)
{
tm
->
tm_min
+=
SECS_PER_MINUTE
;
tm
->
tm_min
+=
MINS_PER_HOUR
;
tm
->
tm_hour
--
;
}
...
...
@@ -2589,7 +2588,7 @@ timestamptz_age(PG_FUNCTION_ARGS)
while
(
tm
->
tm_min
<
0
)
{
tm
->
tm_min
+=
SECS_PER_MINUTE
;
tm
->
tm_min
+=
MINS_PER_HOUR
;
tm
->
tm_hour
--
;
}
...
...
@@ -3492,10 +3491,10 @@ timestamp_part(PG_FUNCTION_ARGS)
case
DTK_JULIAN
:
result
=
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
);
#ifdef HAVE_INT64_TIMESTAMP
result
+=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
result
+=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
(
fsec
/
1000000
.
0
))
/
(
double
)
SECS_PER_DAY
;
#else
result
+=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
result
+=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
)
/
(
double
)
SECS_PER_DAY
;
#endif
break
;
...
...
@@ -3628,8 +3627,8 @@ timestamptz_part(PG_FUNCTION_ARGS)
case
DTK_TZ_MINUTE
:
result
=
-
tz
;
result
/=
SECS_PER_MINUTE
;
FMODULO
(
result
,
dummy
,
(
double
)
SECS_PER_MINUTE
);
result
/=
MINS_PER_HOUR
;
FMODULO
(
result
,
dummy
,
(
double
)
MINS_PER_HOUR
);
break
;
case
DTK_TZ_HOUR
:
...
...
@@ -3720,10 +3719,10 @@ timestamptz_part(PG_FUNCTION_ARGS)
case
DTK_JULIAN
:
result
=
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
);
#ifdef HAVE_INT64_TIMESTAMP
result
+=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
result
+=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
(
fsec
/
1000000
.
0
))
/
(
double
)
SECS_PER_DAY
;
#else
result
+=
((((
tm
->
tm_hour
*
SECS_PER_MINUTE
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
result
+=
((((
tm
->
tm_hour
*
MINS_PER_HOUR
)
+
tm
->
tm_min
)
*
SECS_PER_MINUTE
)
+
tm
->
tm_sec
+
fsec
)
/
(
double
)
SECS_PER_DAY
;
#endif
break
;
...
...
src/backend/utils/misc/guc.c
View file @
e6b72d6a
...
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.27
5 2005/07/21 03:56:21
momjian Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.27
6 2005/07/21 18:06:12
momjian Exp $
*
*--------------------------------------------------------------------
*/
...
...
@@ -1349,7 +1349,7 @@ static struct config_int ConfigureNamesInt[] =
NULL
},
&
Log_RotationAge
,
HOURS_PER_DAY
*
SECS_PER_MINUTE
,
0
,
INT_MAX
/
SECS_PER_MINUTE
,
NULL
,
NULL
HOURS_PER_DAY
*
MINS_PER_HOUR
,
0
,
INT_MAX
/
MINS_PER_HOUR
,
NULL
,
NULL
},
{
...
...
src/include/utils/timestamp.h
View file @
e6b72d6a
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.5
0 2005/07/21 15:16:27
momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.5
1 2005/07/21 18:06:13
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -65,16 +65,22 @@ typedef struct
#define MONTHS_PER_YEAR 12
/*
* DAYS_PER_MONTH is very imprecise. The more accurate value is
* 365.2
5/12 = 30.4375, or '30 days 10:30:00
'. Right now we only
* 365.2
425/12 = 30.436875, or '30 days 10:29:06
'. Right now we only
* return an integral number of days, but someday perhaps we should
* also return a 'time' value to be used as well.
*/
#define DAYS_PER_MONTH 30
/* assumes exactly 30 days per month */
#define HOURS_PER_DAY 24
/* assume no daylight savings time changes */
#define SECS_PER_DAY 86400
/* assumes no leap second */
/*
* This doesn't adjust for uneven daylight savings time intervals, nor
* leap seconds.
*/
#define SECS_PER_YEAR (36525 * 864)
/* avoid floating-point computation */
#define SECS_PER_DAY 86400
#define SECS_PER_HOUR 3600
#define SECS_PER_MINUTE 60
#define MINS_PER_HOUR 60
#ifdef HAVE_INT64_TIMESTAMP
#define USECS_PER_DAY INT64CONST(86400000000)
...
...
src/interfaces/ecpg/pgtypeslib/dt.h
View file @
e6b72d6a
...
...
@@ -221,16 +221,22 @@ do { \
#define MONTHS_PER_YEAR 12
/*
* DAYS_PER_MONTH is very imprecise. The more accurate value is
* 365.2
5/12 = 30.4375, or '30 days 10:30:00
'. Right now we only
* 365.2
425/12 = 30.436875, or '30 days 10:29:06
'. Right now we only
* return an integral number of days, but someday perhaps we should
* also return a 'time' value to be used as well.
*/
#define DAYS_PER_MONTH 30
/* assumes exactly 30 days per month */
#define HOURS_PER_DAY 24
/* assume no daylight savings time changes */
#define SECS_PER_DAY 86400
/* assumes no leap second */
/*
* This doesn't adjust for uneven daylight savings time intervals, nor
* leap seconds.
*/
#define SECS_PER_YEAR (36525 * 864)
/* avoid floating-point computation */
#define SECS_PER_DAY 86400
#define SECS_PER_HOUR 3600
#define SECS_PER_MINUTE 60
#define MINS_PER_HOUR 60
#ifdef HAVE_INT64_TIMESTAMP
#define USECS_PER_DAY INT64CONST(86400000000)
...
...
src/interfaces/ecpg/pgtypeslib/dt_common.c
View file @
e6b72d6a
...
...
@@ -814,7 +814,7 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
if
(
tzp
!=
NULL
&&
tm
->
tm_isdst
>=
0
)
{
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
break
;
...
...
@@ -862,7 +862,7 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
else
{
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
}
...
...
@@ -908,7 +908,7 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
else
{
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
"%+03d:%02d"
:
"%+03d"
,
hour
,
min
);
}
}
...
...
@@ -971,7 +971,7 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha
* 2001-10-19
*/
hour
=
-
(
*
tzp
/
SECS_PER_HOUR
);
min
=
(
abs
(
*
tzp
)
/
SECS_PER_MINUTE
)
%
SECS_PER_MINUTE
;
min
=
(
abs
(
*
tzp
)
/
MINS_PER_HOUR
)
%
MINS_PER_HOUR
;
sprintf
(
str
+
strlen
(
str
),
(
min
!=
0
)
?
" %+03d:%02d"
:
" %+03d"
,
hour
,
min
);
}
}
...
...
@@ -1161,7 +1161,7 @@ DetermineLocalTimeZone(struct tm * tm)
day
=
(
date2j
(
tm
->
tm_year
,
tm
->
tm_mon
,
tm
->
tm_mday
)
-
date2j
(
1970
,
1
,
1
));
mysec
=
tm
->
tm_sec
+
(
tm
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tm
->
tm_hour
)
*
SECS_PER_MINUTE
)
*
SECS_PER_MINUTE
;
mysec
=
tm
->
tm_sec
+
(
tm
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tm
->
tm_hour
)
*
MINS_PER_HOUR
)
*
SECS_PER_MINUTE
;
mytime
=
(
time_t
)
mysec
;
/*
...
...
@@ -1171,7 +1171,7 @@ DetermineLocalTimeZone(struct tm * tm)
tmp
=
localtime
(
&
mytime
);
day
=
(
date2j
(
tmp
->
tm_year
+
1900
,
tmp
->
tm_mon
+
1
,
tmp
->
tm_mday
)
-
date2j
(
1970
,
1
,
1
));
locsec
=
tmp
->
tm_sec
+
(
tmp
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tmp
->
tm_hour
)
*
SECS_PER_MINUTE
)
*
SECS_PER_MINUTE
;
locsec
=
tmp
->
tm_sec
+
(
tmp
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tmp
->
tm_hour
)
*
MINS_PER_HOUR
)
*
SECS_PER_MINUTE
;
/*
* The local time offset corresponding to that GMT time is now
...
...
@@ -1201,7 +1201,7 @@ DetermineLocalTimeZone(struct tm * tm)
tmp
=
localtime
(
&
mytime
);
day
=
(
date2j
(
tmp
->
tm_year
+
1900
,
tmp
->
tm_mon
+
1
,
tmp
->
tm_mday
)
-
date2j
(
1970
,
1
,
1
));
locsec
=
tmp
->
tm_sec
+
(
tmp
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tmp
->
tm_hour
)
*
SECS_PER_MINUTE
)
*
SECS_PER_MINUTE
;
locsec
=
tmp
->
tm_sec
+
(
tmp
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tmp
->
tm_hour
)
*
MINS_PER_HOUR
)
*
SECS_PER_MINUTE
;
delta2
=
mysec
-
locsec
;
if
(
delta2
!=
delta1
)
{
...
...
@@ -1210,7 +1210,7 @@ DetermineLocalTimeZone(struct tm * tm)
tmp
=
localtime
(
&
mytime
);
day
=
(
date2j
(
tmp
->
tm_year
+
1900
,
tmp
->
tm_mon
+
1
,
tmp
->
tm_mday
)
-
date2j
(
1970
,
1
,
1
));
locsec
=
tmp
->
tm_sec
+
(
tmp
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tmp
->
tm_hour
)
*
SECS_PER_MINUTE
)
*
SECS_PER_MINUTE
;
locsec
=
tmp
->
tm_sec
+
(
tmp
->
tm_min
+
(
day
*
HOURS_PER_DAY
+
tmp
->
tm_hour
)
*
MINS_PER_HOUR
)
*
SECS_PER_MINUTE
;
delta2
=
mysec
-
locsec
;
}
tm
->
tm_isdst
=
tmp
->
tm_isdst
;
...
...
@@ -1712,7 +1712,7 @@ DecodeTimezone(char *str, int *tzp)
else
min
=
0
;
tz
=
(
hr
*
SECS_PER_MINUTE
+
min
)
*
SECS_PER_MINUTE
;
tz
=
(
hr
*
MINS_PER_HOUR
+
min
)
*
SECS_PER_MINUTE
;
if
(
*
str
==
'-'
)
tz
=
-
tz
;
...
...
@@ -1752,7 +1752,7 @@ DecodePosixTimezone(char *str, int *tzp)
{
case
DTZ
:
case
TZ
:
*
tzp
=
(
val
*
SECS_PER_MINUTE
)
-
tz
;
*
tzp
=
(
val
*
MINS_PER_HOUR
)
-
tz
;
break
;
default:
...
...
@@ -2398,7 +2398,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
1
;
if
(
tzp
==
NULL
)
return
-
1
;
*
tzp
+=
val
*
SECS_PER_MINUTE
;
*
tzp
+=
val
*
MINS_PER_HOUR
;
break
;
case
DTZ
:
...
...
@@ -2411,7 +2411,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
1
;
if
(
tzp
==
NULL
)
return
-
1
;
*
tzp
=
val
*
SECS_PER_MINUTE
;
*
tzp
=
val
*
MINS_PER_HOUR
;
ftype
[
i
]
=
DTK_TZ
;
break
;
...
...
@@ -2419,7 +2419,7 @@ DecodeDateTime(char **field, int *ftype, int nf,
tm
->
tm_isdst
=
0
;
if
(
tzp
==
NULL
)
return
-
1
;
*
tzp
=
val
*
SECS_PER_MINUTE
;
*
tzp
=
val
*
MINS_PER_HOUR
;
ftype
[
i
]
=
DTK_TZ
;
break
;
...
...
@@ -3108,7 +3108,7 @@ PGTYPEStimestamp_defmt_scan(char **str, char *fmt, timestamp *d,
* timezone value of the datetktbl table is in
* quarter hours
*/
*
tz
=
-
15
*
SECS_PER_MINUTE
*
datetktbl
[
j
].
value
;
*
tz
=
-
15
*
MINS_PER_HOUR
*
datetktbl
[
j
].
value
;
break
;
}
}
...
...
src/interfaces/ecpg/pgtypeslib/interval.c
View file @
e6b72d6a
...
...
@@ -723,7 +723,7 @@ tm2interval(struct tm *tm, fsec_t fsec, interval *span)
tm
->
tm_sec
)
*
USECS_PER_SEC
)
+
fsec
;
#else
span
->
time
=
(((((
tm
->
tm_mday
*
(
double
)
HOURS_PER_DAY
)
+
tm
->
tm_hour
)
*
(
double
)
SECS_PER_MINUTE
)
+
tm
->
tm_hour
)
*
(
double
)
MINS_PER_HOUR
)
+
tm
->
tm_min
)
*
(
double
)
SECS_PER_MINUTE
)
+
tm
->
tm_sec
;
span
->
time
=
JROUND
(
span
->
time
+
fsec
);
...
...
src/interfaces/ecpg/pgtypeslib/timestamp.c
View file @
e6b72d6a
...
...
@@ -20,14 +20,14 @@ int PGTYPEStimestamp_defmt_scan(char **, char *, timestamp *, int *, int *, int
static
int64
time2t
(
const
int
hour
,
const
int
min
,
const
int
sec
,
const
fsec_t
fsec
)
{
return
(((((
hour
*
SECS_PER_MINUTE
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
)
*
USECS_PER_SEC
)
+
fsec
;
return
(((((
hour
*
MINS_PER_HOUR
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
)
*
USECS_PER_SEC
)
+
fsec
;
}
/* time2t() */
#else
static
double
time2t
(
const
int
hour
,
const
int
min
,
const
int
sec
,
const
fsec_t
fsec
)
{
return
(((
hour
*
SECS_PER_MINUTE
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
+
fsec
;
return
(((
hour
*
MINS_PER_HOUR
)
+
min
)
*
SECS_PER_MINUTE
)
+
sec
+
fsec
;
}
/* time2t() */
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment