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
fbf12681
Commit
fbf12681
authored
Sep 20, 1997
by
Thomas G. Lockhart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include tinterval comparison functions for span of interval.
parent
59847461
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
206 additions
and
5 deletions
+206
-5
src/backend/utils/adt/date.c
src/backend/utils/adt/date.c
+206
-5
No files found.
src/backend/utils/adt/date.c
View file @
fbf12681
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.1
8 1997/09/08 21:48:21 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.1
9 1997/09/20 16:17:45 thomas
Exp $
*
* NOTES
* This code is actually (almost) unused.
...
...
@@ -565,16 +565,217 @@ reltimege(RelativeTime t1, RelativeTime t2)
/*
* intervaleq - returns 1, iff interval i1 is equal to interval i2
* intervalsame - returns 1, iff interval i1 is same as interval i2
* Check begin and end time.
*/
bool
interval
eq
(
TimeInterval
i1
,
TimeInterval
i2
)
interval
same
(
TimeInterval
i1
,
TimeInterval
i2
)
{
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
0
);
/* invalid interval */
return
(
FALSE
);
/* invalid interval */
return
(
abstimeeq
(
i1
->
data
[
0
],
i2
->
data
[
0
])
&&
abstimeeq
(
i1
->
data
[
1
],
i2
->
data
[
1
]));
}
}
/* intervalsame() */
/*
* intervaleq - returns 1, iff interval i1 is equal to interval i2
* Check length of intervals.
*/
bool
intervaleq
(
TimeInterval
i1
,
TimeInterval
i2
)
{
AbsoluteTime
t10
,
t11
,
t20
,
t21
;
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
FALSE
);
/* invalid interval */
t10
=
i1
->
data
[
0
];
t11
=
i1
->
data
[
1
];
t20
=
i2
->
data
[
0
];
t21
=
i2
->
data
[
1
];
if
((
t10
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t21
==
INVALID_ABSTIME
))
return
(
FALSE
);
if
(
t10
==
CURRENT_ABSTIME
)
t10
=
GetCurrentTransactionStartTime
();
if
(
t11
==
CURRENT_ABSTIME
)
t11
=
GetCurrentTransactionStartTime
();
if
(
t20
==
CURRENT_ABSTIME
)
t20
=
GetCurrentTransactionStartTime
();
if
(
t21
==
CURRENT_ABSTIME
)
t21
=
GetCurrentTransactionStartTime
();
return
((
t11
-
t10
)
==
(
t21
-
t20
));
}
/* intervaleq() */
/*
* intervalne - returns 1, iff interval i1 is not equal to interval i2
* Check length of intervals.
*/
bool
intervalne
(
TimeInterval
i1
,
TimeInterval
i2
)
{
AbsoluteTime
t10
,
t11
,
t20
,
t21
;
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
FALSE
);
/* invalid interval */
t10
=
i1
->
data
[
0
];
t11
=
i1
->
data
[
1
];
t20
=
i2
->
data
[
0
];
t21
=
i2
->
data
[
1
];
if
((
t10
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t21
==
INVALID_ABSTIME
))
return
(
FALSE
);
if
(
t10
==
CURRENT_ABSTIME
)
t10
=
GetCurrentTransactionStartTime
();
if
(
t11
==
CURRENT_ABSTIME
)
t11
=
GetCurrentTransactionStartTime
();
if
(
t20
==
CURRENT_ABSTIME
)
t20
=
GetCurrentTransactionStartTime
();
if
(
t21
==
CURRENT_ABSTIME
)
t21
=
GetCurrentTransactionStartTime
();
return
((
t11
-
t10
)
!=
(
t21
-
t20
));
}
/* intervalne() */
/*
* intervallt - returns TRUE, iff interval i1 is less than interval i2
* Check length of intervals.
*/
bool
intervallt
(
TimeInterval
i1
,
TimeInterval
i2
)
{
AbsoluteTime
t10
,
t11
,
t20
,
t21
;
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
FALSE
);
/* invalid interval */
t10
=
i1
->
data
[
0
];
t11
=
i1
->
data
[
1
];
t20
=
i2
->
data
[
0
];
t21
=
i2
->
data
[
1
];
if
((
t10
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t21
==
INVALID_ABSTIME
))
return
(
FALSE
);
if
(
t10
==
CURRENT_ABSTIME
)
t10
=
GetCurrentTransactionStartTime
();
if
(
t11
==
CURRENT_ABSTIME
)
t11
=
GetCurrentTransactionStartTime
();
if
(
t20
==
CURRENT_ABSTIME
)
t20
=
GetCurrentTransactionStartTime
();
if
(
t21
==
CURRENT_ABSTIME
)
t21
=
GetCurrentTransactionStartTime
();
return
((
t11
-
t10
)
<
(
t21
-
t20
));
}
/* intervallt() */
/*
* intervalle - returns TRUE, iff interval i1 is less than or equal to interval i2
* Check length of intervals.
*/
bool
intervalle
(
TimeInterval
i1
,
TimeInterval
i2
)
{
AbsoluteTime
t10
,
t11
,
t20
,
t21
;
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
FALSE
);
/* invalid interval */
t10
=
i1
->
data
[
0
];
t11
=
i1
->
data
[
1
];
t20
=
i2
->
data
[
0
];
t21
=
i2
->
data
[
1
];
if
((
t10
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t21
==
INVALID_ABSTIME
))
return
(
FALSE
);
if
(
t10
==
CURRENT_ABSTIME
)
t10
=
GetCurrentTransactionStartTime
();
if
(
t11
==
CURRENT_ABSTIME
)
t11
=
GetCurrentTransactionStartTime
();
if
(
t20
==
CURRENT_ABSTIME
)
t20
=
GetCurrentTransactionStartTime
();
if
(
t21
==
CURRENT_ABSTIME
)
t21
=
GetCurrentTransactionStartTime
();
return
((
t11
-
t10
)
<=
(
t21
-
t20
));
}
/* intervalle() */
/*
* intervalgt - returns TRUE, iff interval i1 is less than interval i2
* Check length of intervals.
*/
bool
intervalgt
(
TimeInterval
i1
,
TimeInterval
i2
)
{
AbsoluteTime
t10
,
t11
,
t20
,
t21
;
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
FALSE
);
/* invalid interval */
t10
=
i1
->
data
[
0
];
t11
=
i1
->
data
[
1
];
t20
=
i2
->
data
[
0
];
t21
=
i2
->
data
[
1
];
if
((
t10
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t21
==
INVALID_ABSTIME
))
return
(
FALSE
);
if
(
t10
==
CURRENT_ABSTIME
)
t10
=
GetCurrentTransactionStartTime
();
if
(
t11
==
CURRENT_ABSTIME
)
t11
=
GetCurrentTransactionStartTime
();
if
(
t20
==
CURRENT_ABSTIME
)
t20
=
GetCurrentTransactionStartTime
();
if
(
t21
==
CURRENT_ABSTIME
)
t21
=
GetCurrentTransactionStartTime
();
return
((
t11
-
t10
)
>
(
t21
-
t20
));
}
/* intervalgt() */
/*
* intervalge - returns TRUE, iff interval i1 is less than or equal to interval i2
* Check length of intervals.
*/
bool
intervalge
(
TimeInterval
i1
,
TimeInterval
i2
)
{
AbsoluteTime
t10
,
t11
,
t20
,
t21
;
if
(
i1
->
status
==
T_INTERVAL_INVAL
||
i2
->
status
==
T_INTERVAL_INVAL
)
return
(
FALSE
);
/* invalid interval */
t10
=
i1
->
data
[
0
];
t11
=
i1
->
data
[
1
];
t20
=
i2
->
data
[
0
];
t21
=
i2
->
data
[
1
];
if
((
t10
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t20
==
INVALID_ABSTIME
)
||
(
t21
==
INVALID_ABSTIME
))
return
(
FALSE
);
if
(
t10
==
CURRENT_ABSTIME
)
t10
=
GetCurrentTransactionStartTime
();
if
(
t11
==
CURRENT_ABSTIME
)
t11
=
GetCurrentTransactionStartTime
();
if
(
t20
==
CURRENT_ABSTIME
)
t20
=
GetCurrentTransactionStartTime
();
if
(
t21
==
CURRENT_ABSTIME
)
t21
=
GetCurrentTransactionStartTime
();
return
((
t11
-
t10
)
>=
(
t21
-
t20
));
}
/* intervalge() */
/*
* intervalleneq - returns 1, iff length of interval i is equal to
...
...
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