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
791c0758
Commit
791c0758
authored
Mar 14, 1997
by
Marc G. Fournier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Date/Time updates from Thomas...
parent
53d8be3b
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
472 additions
and
223 deletions
+472
-223
src/include/postgres.h
src/include/postgres.h
+7
-6
src/include/utils/builtins.h
src/include/utils/builtins.h
+164
-140
src/include/utils/datetime.h
src/include/utils/datetime.h
+19
-1
src/include/utils/dt.h
src/include/utils/dt.h
+235
-0
src/include/utils/geo_decls.h
src/include/utils/geo_decls.h
+4
-4
src/include/utils/nabstime.h
src/include/utils/nabstime.h
+37
-66
src/interfaces/libpq/Makefile
src/interfaces/libpq/Makefile
+4
-4
src/test/regress/regress.c
src/test/regress/regress.c
+2
-2
No files found.
src/include/postgres.h
View file @
791c0758
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1995, Regents of the University of California
*
* $Id: postgres.h,v 1.
3 1996/12/10 07:03:40 bryanh
Exp $
* $Id: postgres.h,v 1.
4 1997/03/14 23:31:22 scrappy
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -29,7 +29,7 @@
* 2) varlena and array types
* 3) TransactionId and CommandId
* 4) genbki macros used by catalog/pg_xxx.h files
* 5) random SIGNBIT, MAXPGPATH, STATUS macros
* 5) random
C
SIGNBIT, MAXPGPATH, STATUS macros
*
* ----------------------------------------------------------------
*/
...
...
@@ -177,15 +177,16 @@ typedef uint16 CommandId;
/* ----------------------------------------------------------------
* Section 5: random stuff
* SIGNBIT, MAXPGPATH, STATUS...
*
C
SIGNBIT, MAXPGPATH, STATUS...
* ----------------------------------------------------------------
*/
/* msb for int/unsigned */
#define SIGNBIT (0x8000)
#define ISIGNBIT (0x80000000)
#define WSIGNBIT (0x8000)
/* msb for char */
#define CSIGNBIT (
1 << 7
)
#define CSIGNBIT (
0x80
)
/* ----------------
* global variables which should probably go someplace else.
...
...
src/include/utils/builtins.h
View file @
791c0758
This diff is collapsed.
Click to expand it.
src/include/utils/datetime.h
View file @
791c0758
...
...
@@ -6,13 +6,21 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: datetime.h,v 1.
1 1996/11/10 03:06:21 momjian
Exp $
* $Id: datetime.h,v 1.
2 1997/03/14 23:33:21 scrappy
Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DATETIME_H
#define DATETIME_H
#include "utils/dt.h"
#if USE_NEW_DATE
typedef
int32
DateADT
;
#else
/* these things look like structs, but we pass them by value so be careful
For example, passing an int -> DateADT is not portable! */
typedef
struct
DateADT
{
...
...
@@ -21,10 +29,20 @@ typedef struct DateADT {
short
year
;
}
DateADT
;
#endif
#if USE_NEW_TIME
typedef
float8
TimeADT
;
#else
typedef
struct
TimeADT
{
short
hr
;
short
min
;
float
sec
;
}
TimeADT
;
#endif
#endif
/* DATETIME_H */
src/include/utils/dt.h
0 → 100644
View file @
791c0758
/*-------------------------------------------------------------------------
*
* dt.h--
* Definitions for the date/time and other date/time support code.
* The support code is shared with other date data types,
* including abstime, reltime, date, and time.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: dt.h,v 1.1 1997/03/14 23:33:23 scrappy Exp $
*
*-------------------------------------------------------------------------
*/
#ifndef DT_H
#define DT_H
#include <time.h>
/*
* DateTime represents absolute time.
* TimeSpan represents delta time.
* Note that Postgres uses "time interval" to mean a bounded interval,
* consisting of a beginning and ending time, not a time span.
*/
typedef
double
DateTime
;
typedef
struct
{
double
time
;
/* all time units other than months and years */
int4
month
;
/* months and years */
}
TimeSpan
;
#define USE_NEW_TIME_CODE 1
#define USE_NEW_DATE 0
#define USE_NEW_TIME 0
/* ----------------------------------------------------------------
* time types + support macros
*
* String definitions for standard time quantities.
*
* These strings are the defaults used to form output time strings.
* Other alternate forms are hardcoded into token tables in dt.c.
* ----------------------------------------------------------------
*/
#define DAGO "ago"
#define DCURRENT "current"
#define EPOCH "epoch"
#define INVALID "invalid"
#define EARLY "-infinity"
#define LATE "infinity"
#define NOW "now"
#define TODAY "today"
#define TOMORROW "tomorrow"
#define YESTERDAY "yesterday"
#define ZULU "zulu"
#define DMICROSEC "usecond"
#define DMILLISEC "msecond"
#define DSECOND "second"
#define DMINUTE "minute"
#define DHOUR "hour"
#define DDAY "day"
#define DWEEK "week"
#define DMONTH "month"
#define DYEAR "year"
#define DDECADE "decade"
#define DCENTURY "century"
#define DMILLENIUM "millenium"
#define DA_D "ad"
#define DB_C "bc"
/*
* Fundamental time field definitions for parsing.
*
* Meridian: am, pm, or 24-hour style.
* Millenium: ad, bc
*/
#define AM 0
#define PM 1
#define HR24 2
#define AD 0
#define BC 1
/*
* Fields for time decoding.
* Can't have more of these than there are bits in an unsigned int
* since these are turned into bit masks during parsing and decoding.
*/
#define RESERV 0
#define MONTH 1
#define YEAR 2
#define DAY 3
#define TIME 4
#define TZ 5
#define DTZ 6
#define IGNORE 7
#define AMPM 8
#define HOUR 9
#define MINUTE 10
#define SECOND 11
#define DOY 12
#define DOW 13
#define UNITS 14
#define ADBC 15
/* these are only for relative dates */
#define ABS_BEFORE 14
#define ABS_AFTER 15
#define AGO 16
/*
* Token field definitions for time parsing and decoding.
* These need to fit into the datetkn table type.
* At the moment, that means keep them within [-127,127].
*/
#define DTK_NUMBER 0
#define DTK_STRING 1
#define DTK_DATETIME 2
#define DTK_DATE 3
#define DTK_TIME 4
#define DTK_TZ 5
#define DTK_SPECIAL 6
#define DTK_INVALID 7
#define DTK_CURRENT 8
#define DTK_EARLY 9
#define DTK_LATE 10
#define DTK_EPOCH 11
#define DTK_NOW 12
#define DTK_YESTERDAY 13
#define DTK_TODAY 14
#define DTK_TOMORROW 15
#define DTK_ZULU 16
#define DTK_DELTA 32
#define DTK_SECOND 33
#define DTK_MINUTE 34
#define DTK_HOUR 35
#define DTK_DAY 36
#define DTK_WEEK 37
#define DTK_MONTH 38
#define DTK_YEAR 39
#define DTK_DECADE 40
#define DTK_CENTURY 41
#define DTK_MILLENIUM 42
#define DTK_MILLISEC 43
#define DTK_MICROSEC 44
#define DTK_AGO 45
/*
* Bit mask definitions for time parsing.
*/
#define DTK_M(t) (0x01 << t)
#define DTK_DATE_M (DTK_M(YEAR) | DTK_M(MONTH) | DTK_M(DAY))
#define DTK_TIME_M (DTK_M(HOUR) | DTK_M(MINUTE) | DTK_M(SECOND))
#define MAXDATELEN 47
/* maximum possible length of an input date string */
#define MAXDATEFIELDS 25
/* maximum possible number of fields in a date string */
#define TOKMAXLEN 10
/* only this many chars are stored in datetktbl */
/* keep this struct small; it gets used a lot */
typedef
struct
{
#if defined(aix)
char
*
token
;
#else
char
token
[
TOKMAXLEN
];
#endif
/* aix */
char
type
;
char
value
;
/* this may be unsigned, alas */
}
datetkn
;
extern
int
EuroDates
;
extern
void
GetCurrentTime
(
struct
tm
*
tm
);
/*
* dt.c prototypes
*/
extern
DateTime
*
datetime_in
(
char
*
str
);
extern
char
*
datetime_out
(
DateTime
*
dt
);
extern
TimeSpan
*
timespan_in
(
char
*
str
);
extern
char
*
timespan_out
(
TimeSpan
*
span
);
extern
TimeSpan
*
datetime_sub
(
DateTime
*
dt1
,
DateTime
*
dt2
);
extern
DateTime
*
datetime_add_span
(
DateTime
*
dt
,
TimeSpan
*
span
);
extern
DateTime
*
datetime_sub_span
(
DateTime
*
dt
,
TimeSpan
*
span
);
extern
TimeSpan
*
timespan_add
(
TimeSpan
*
span1
,
TimeSpan
*
span2
);
extern
TimeSpan
*
timespan_sub
(
TimeSpan
*
span1
,
TimeSpan
*
span2
);
extern
DateTime
dt2local
(
DateTime
dt
,
int
timezone
);
extern
void
j2date
(
int
jd
,
int
*
year
,
int
*
month
,
int
*
day
);
extern
int
date2j
(
int
year
,
int
month
,
int
day
);
extern
int
j2day
(
int
jd
);
extern
double
time2t
(
const
int
hour
,
const
int
min
,
const
double
sec
);
extern
void
dt2time
(
DateTime
dt
,
int
*
hour
,
int
*
min
,
double
*
sec
);
/*
extern void GetCurrentTime(struct tm *tm);
*/
extern
int
ParseDateTime
(
char
*
timestr
,
char
*
lowstr
,
char
*
field
[],
int
ftype
[],
int
maxfields
,
int
*
numfields
);
extern
int
DecodeDateTime
(
char
*
field
[],
int
ftype
[],
int
nf
,
int
*
dtype
,
struct
tm
*
tm
,
double
*
fsec
,
int
*
tzp
);
extern
int
DecodeDate
(
char
*
str
,
int
fmask
,
int
*
tmask
,
struct
tm
*
tm
);
extern
int
DecodeNumber
(
int
flen
,
char
*
field
,
int
fmask
,
int
*
tmask
,
struct
tm
*
tm
,
double
*
fsec
);
extern
int
DecodeNumberField
(
int
len
,
char
*
str
,
int
fmask
,
int
*
tmask
,
struct
tm
*
tm
,
double
*
fsec
);
extern
int
DecodeTime
(
char
*
str
,
int
fmask
,
int
*
tmask
,
struct
tm
*
tm
,
double
*
fsec
);
extern
int
DecodeTimeOnly
(
char
*
field
[],
int
ftype
[],
int
nf
,
int
*
dtype
,
struct
tm
*
tm
,
double
*
fsec
);
extern
int
DecodeTimezone
(
char
*
str
,
int
*
tzp
);
extern
int
DecodeSpecial
(
int
field
,
char
*
lowtoken
,
int
*
val
);
extern
int
DecodeDateDelta
(
char
*
field
[],
int
ftype
[],
int
nf
,
int
*
dtype
,
struct
tm
*
tm
,
double
*
fsec
);
extern
int
DecodeUnits
(
int
field
,
char
*
lowtoken
,
int
*
val
);
extern
int
EncodeSpecialDateTime
(
DateTime
*
dt
,
char
*
str
);
extern
int
EncodePostgresDate
(
struct
tm
*
tm
,
double
fsec
,
char
*
str
);
extern
int
EncodePostgresSpan
(
struct
tm
*
tm
,
double
fsec
,
char
*
str
);
extern
datetkn
*
datebsearch
(
char
*
key
,
datetkn
*
base
,
unsigned
int
nel
);
#endif
/* DT_H */
src/include/utils/geo
-
decls.h
→
src/include/utils/geo
_
decls.h
View file @
791c0758
/*-------------------------------------------------------------------------
*
* geo
-
decls.h--
* geo
_
decls.h--
* Declarations for various 2D constructs.
*
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: geo
-decls.h,v 1.4 1996/11/10 03:06:32 momjian
Exp $
* $Id: geo
_decls.h,v 1.1 1997/03/14 23:33:27 scrappy
Exp $
*
* NOTE
* These routines do *not* use the float types from adt/.
...
...
@@ -114,7 +114,7 @@ typedef struct {
/*
* in geo
-
ops.h
* in geo
_
ops.h
*/
extern
BOX
*
box_in
(
char
*
str
);
extern
char
*
box_out
(
BOX
*
box
);
...
...
@@ -235,7 +235,7 @@ extern long poly_overlap(POLYGON *polya, POLYGON *polyb);
extern
long
poly_contain
(
POLYGON
*
polya
,
POLYGON
*
polyb
);
extern
long
poly_contained
(
POLYGON
*
polya
,
POLYGON
*
polyb
);
/* geo
-
selfuncs.c */
/* geo
_
selfuncs.c */
extern
float64
areasel
(
Oid
opid
,
Oid
relid
,
AttrNumber
attno
,
char
*
value
,
int32
flag
);
extern
float64
areajoinsel
(
Oid
opid
,
Oid
relid
,
AttrNumber
attno
,
...
...
src/include/utils/nabstime.h
View file @
791c0758
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: nabstime.h,v 1.
4 1996/11/04 07:18:45
scrappy Exp $
* $Id: nabstime.h,v 1.
5 1997/03/14 23:33:29
scrappy Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -14,6 +14,8 @@
#define NABSTIME_H
#include <time.h>
#include "utils/dt.h"
/* ----------------------------------------------------------------
* time types + support macros
...
...
@@ -30,11 +32,21 @@ typedef struct {
}
TimeIntervalData
;
typedef
TimeIntervalData
*
TimeInterval
;
/*
* Reserved values
* Epoch is Unix system time zero, but needs to be kept as a reserved
* value rather than converting to time since timezone calculations
* might move it away from 1970-01-01 00:00:00Z - tgl 97/02/20
*
* Pre-v6.1 code had large decimal numbers for reserved values.
* These were chosen as special 32-bit bit patterns,
* so redefine them explicitly using these bit patterns. - tgl 97/02/24
*/
#define EPOCH_ABSTIME ((AbsoluteTime) 0)
#define INVALID_ABSTIME ((AbsoluteTime)
2147483647)
/*
2^31 - 1 */
#define CURRENT_ABSTIME ((AbsoluteTime)
2147483646)
/*
2^31 - 2 */
#define NOEND_ABSTIME ((AbsoluteTime)
2147483645)
/*
2^31 - 3 */
#define INVALID_ABSTIME ((AbsoluteTime)
0x4FFFFFFE)
/* 2147483647 ==
2^31 - 1 */
#define CURRENT_ABSTIME ((AbsoluteTime)
0x4FFFFFFD)
/* 2147483646 ==
2^31 - 2 */
#define NOEND_ABSTIME ((AbsoluteTime)
0x4FFFFFFC)
/* 2147483645 ==
2^31 - 3 */
#define BIG_ABSTIME ((AbsoluteTime) 0x4FFFFFFB)
/* 2147483644 == 2^31 - 4 */
#if defined(aix)
/*
...
...
@@ -47,15 +59,10 @@ typedef TimeIntervalData *TimeInterval;
#define NOSTART_ABSTIME ((AbsoluteTime) INT_MIN)
#else
/*#define NOSTART_ABSTIME ((AbsoluteTime) 2147483648)*/
/* - 2^31 */
#define NOSTART_ABSTIME ((AbsoluteTime)
-2147483647)
/*
- 2^31 */
#define NOSTART_ABSTIME ((AbsoluteTime)
0x80000001)
/* -2147483647 ==
- 2^31 */
#endif
/* aix */
#define INVALID_RELTIME ((RelativeTime) 2147483647)
/* 2^31 - 1 */
/* ----------------
* time support macros (from tim.h)
* ----------------
*/
#define INVALID_RELTIME ((RelativeTime) 0x4FFFFFFE)
/* 2147483647 == 2^31 - 1 */
#define AbsoluteTimeIsValid(time) \
((bool) ((time) != INVALID_ABSTIME))
...
...
@@ -77,9 +84,17 @@ typedef TimeIntervalData *TimeInterval;
#define RelativeTimeIsValid(time) \
((bool) (((RelativeTime) time) != INVALID_RELTIME))
#if USE_NEW_TIME_CODE
extern
AbsoluteTime
GetCurrentAbsoluteTime
(
void
);
#else
#define GetCurrentAbsoluteTime() \
((AbsoluteTime) getSystemTime())
#endif
/*
* getSystemTime --
* Returns system time.
...
...
@@ -87,73 +102,29 @@ typedef TimeIntervalData *TimeInterval;
#define getSystemTime() \
((time_t) (time(0l)))
/*
* Meridian: am, pm, or 24-hour style.
*/
#define AM 0
#define PM 1
#define HR24 2
/* can't have more of these than there are bits in an unsigned long */
#define MONTH 1
#define YEAR 2
#define DAY 3
#define TIME 4
#define TZ 5
#define DTZ 6
#define PG_IGNORE 7
#define AMPM 8
/* below here are unused so far */
#define SECONDS 9
#define MONTHS 10
#define YEARS 11
#define NUMBER 12
/* these are only for relative dates */
#define ABS_BEFORE 13
#define ABS_AFTER 14
#define AGO 15
#define SECS(n) ((time_t)(n))
#define MINS(n) ((time_t)(n) * SECS(60))
#define HOURS(n) ((time_t)(n) * MINS(60))
/* 3600 secs */
#define DAYS(n) ((time_t)(n) * HOURS(24))
/* 86400 secs */
/* months and years are not constant length, must be specially dealt with */
#define TOKMAXLEN 6
/* only this many chars are stored in datetktbl */
/* keep this struct small; it gets used a lot */
typedef
struct
{
#if defined(aix)
char
*
token
;
#else
char
token
[
TOKMAXLEN
];
#endif
/* aix */
char
type
;
char
value
;
/* this may be unsigned, alas */
}
datetkn
;
/*
* nabstime.c prototypes
*/
extern
AbsoluteTime
nabstimein
(
char
*
timestr
);
extern
int
prsabsdate
(
char
*
timestr
,
struct
tm
*
tm
,
int
*
tzp
);
extern
int
tryabsdate
(
char
*
fields
[],
int
nf
,
struct
tm
*
tm
,
int
*
tzp
);
extern
int
parsetime
(
char
*
time
,
struct
tm
*
tm
);
extern
int
split
(
char
*
string
,
char
*
fields
[],
int
nfields
,
char
*
sep
);
extern
char
*
nabstimeout
(
AbsoluteTime
time
);
extern
AbsoluteTime
dateconv
(
struct
tm
*
tm
,
int
zone
);
extern
time_t
qmktime
(
struct
tm
*
tp
);
extern
datetkn
*
datetoktype
(
char
*
s
,
int
*
bigvalp
);
extern
datetkn
*
datebsearch
(
char
*
key
,
datetkn
*
base
,
unsigned
int
nel
);
extern
bool
AbsoluteTimeIsBefore
(
AbsoluteTime
time1
,
AbsoluteTime
time2
);
extern
bool
AbsoluteTimeIsAfter
(
AbsoluteTime
time1
,
AbsoluteTime
time2
);
extern
int32
abstimeeq
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
int32
abstimene
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
int32
abstimelt
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
int32
abstimegt
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
int32
abstimele
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
int32
abstimege
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
bool
abstimeeq
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
bool
abstimene
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
bool
abstimelt
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
bool
abstimegt
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
bool
abstimele
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
bool
abstimege
(
AbsoluteTime
t1
,
AbsoluteTime
t2
);
extern
AbsoluteTime
dateconv
(
struct
tm
*
tm
,
int
zone
);
extern
time_t
qmktime
(
struct
tm
*
tp
);
#endif
/* NABSTIME_H */
src/interfaces/libpq/Makefile
View file @
791c0758
...
...
@@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.2
7 1997/01/20 00:51:38 bryanh
Exp $
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Makefile,v 1.2
8 1997/03/14 23:34:03 scrappy
Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -81,7 +81,7 @@ install-headers: beforeinstall-headers c.h \
../include/postgres.h ../include/postgres_ext.h
\
../include/config.h ../include/libpq/pqcomm.h
\
../include/libpq/libpq-fs.h ../include/lib/dllist.h
\
../include/utils/geo
-
decls.h libpq-fe.h
../include/utils/geo
_
decls.h libpq-fe.h
$(INSTALL)
$(INSTLOPTS)
../include/config.h
\
$(HEADERDIR)
/config.h
$(INSTALL)
$(INSTLOPTS)
../include/postgres.h
\
...
...
@@ -94,8 +94,8 @@ install-headers: beforeinstall-headers c.h \
$(HEADERDIR)
/libpq/libpq-fs.h
$(INSTALL)
$(INSTLOPTS)
../include/lib/dllist.h
\
$(HEADERDIR)
/lib/dllist.h
$(INSTALL)
$(INSTLOPTS)
../include/utils/geo
-
decls.h
\
$(HEADERDIR)
/utils/geo
-
decls.h
$(INSTALL)
$(INSTLOPTS)
../include/utils/geo
_
decls.h
\
$(HEADERDIR)
/utils/geo
_
decls.h
$(INSTALL)
$(INSTLOPTS)
../include/utils/elog.h
\
$(HEADERDIR)
/utils/elog.h
$(INSTALL)
$(INSTLOPTS)
../include/utils/palloc.h
\
...
...
src/test/regress/regress.c
View file @
791c0758
/*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.
4 1996/12/09 01:24:53 bryanh
Exp $
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.
5 1997/03/14 23:34:16 scrappy
Exp $
*/
#include <float.h>
/* faked on sunos */
...
...
@@ -8,7 +8,7 @@
#include <postgres.h>
#include "utils/geo
-
decls.h"
/* includes <math.h> */
#include "utils/geo
_
decls.h"
/* includes <math.h> */
#include "executor/executor.h"
/* For GetAttributeByName */
#define P_MAXDIG 12
...
...
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