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
f0299325
Commit
f0299325
authored
Dec 23, 2004
by
Michael Meskes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PGTYPEStimestamp_add_interval written by Dave Cramer.
Fixed parsing of defines to make sure they used more than once.
parent
f8ffb604
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
6 deletions
+92
-6
src/interfaces/ecpg/pgtypeslib/dt.h
src/interfaces/ecpg/pgtypeslib/dt.h
+1
-0
src/interfaces/ecpg/pgtypeslib/dt_common.c
src/interfaces/ecpg/pgtypeslib/dt_common.c
+1
-1
src/interfaces/ecpg/pgtypeslib/timestamp.c
src/interfaces/ecpg/pgtypeslib/timestamp.c
+85
-0
src/interfaces/ecpg/preproc/pgc.l
src/interfaces/ecpg/preproc/pgc.l
+5
-5
No files found.
src/interfaces/ecpg/pgtypeslib/dt.h
View file @
f0299325
...
...
@@ -305,5 +305,6 @@ extern char *pgtypes_date_weekdays_short[];
extern
char
*
pgtypes_date_months
[];
extern
char
*
months
[];
extern
char
*
days
[];
extern
int
day_tab
[
2
][
13
];
#endif
/* DT_H */
src/interfaces/ecpg/pgtypeslib/dt_common.c
View file @
f0299325
...
...
@@ -8,7 +8,7 @@
#include "dt.h"
#include "pgtypes_timestamp.h"
static
int
day_tab
[
2
][
13
]
=
{
int
day_tab
[
2
][
13
]
=
{
{
31
,
28
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
,
0
},
{
31
,
29
,
31
,
30
,
31
,
30
,
31
,
31
,
30
,
31
,
30
,
31
,
0
}};
...
...
src/interfaces/ecpg/pgtypeslib/timestamp.c
View file @
f0299325
...
...
@@ -12,6 +12,7 @@
#include "pgtypes_timestamp.h"
#include "pgtypes_date.h"
int
PGTYPEStimestamp_defmt_scan
(
char
**
,
char
*
,
timestamp
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
,
int
*
);
...
...
@@ -844,3 +845,87 @@ PGTYPEStimestamp_defmt_asc(char *str, char *fmt, timestamp *d)
free
(
mfmt
);
return
i
;
}
/*
* add an interval to a time stamp
*
* *tout = tin + span
*
* returns 0 if successful
* returns -1 if it fails
*
*/
int
PGTYPEStimestamp_add_interval
(
timestamp
*
tin
,
interval
*
span
,
timestamp
*
tout
)
{
if
(
TIMESTAMP_NOT_FINITE
(
*
tin
))
*
tout
=
*
tin
;
else
{
if
(
span
->
month
!=
0
)
{
struct
tm
tt
,
*
tm
=
&
tt
;
fsec_t
fsec
;
if
(
timestamp2tm
(
*
tin
,
NULL
,
tm
,
&
fsec
,
NULL
)
!=
0
)
return
-
1
;
tm
->
tm_mon
+=
span
->
month
;
if
(
tm
->
tm_mon
>
12
)
{
tm
->
tm_year
+=
((
tm
->
tm_mon
-
1
)
/
12
);
tm
->
tm_mon
=
(((
tm
->
tm_mon
-
1
)
%
12
)
+
1
);
}
else
if
(
tm
->
tm_mon
<
1
)
{
tm
->
tm_year
+=
((
tm
->
tm_mon
/
12
)
-
1
);
tm
->
tm_mon
=
((
tm
->
tm_mon
%
12
)
+
12
);
}
/* adjust for end of month boundary problems... */
if
(
tm
->
tm_mday
>
day_tab
[
isleap
(
tm
->
tm_year
)][
tm
->
tm_mon
-
1
])
tm
->
tm_mday
=
(
day_tab
[
isleap
(
tm
->
tm_year
)][
tm
->
tm_mon
-
1
]);
if
(
tm2timestamp
(
tm
,
fsec
,
NULL
,
tin
)
!=
0
)
return
-
1
;
}
*
tin
+=
span
->
time
;
*
tout
=
*
tin
;
}
return
0
;
}
/*
* subtract an interval from a time stamp
*
* *tout = tin - span
*
* returns 0 if successful
* returns -1 if it fails
*
*/
int
PGTYPEStimestamp_sub_interval
(
timestamp
*
tin
,
interval
*
span
,
timestamp
*
tout
)
{
interval
tspan
;
tspan
.
month
=
-
span
->
month
;
tspan
.
time
=
-
span
->
time
;
return
PGTYPEStimestamp_add_interval
(
tin
,
&
tspan
,
tout
);
}
src/interfaces/ecpg/preproc/pgc.l
View file @
f0299325
...
...
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.13
2 2004/08/29 04:13:11 momjian
Exp $
* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/pgc.l,v 1.13
3 2004/12/23 10:46:10 meskes
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -611,9 +611,9 @@ cppline {space}*#(.*\\{space})+.*
yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno;
yb->filename = mm_strdup(input_filename);
ptr->used =
yb->next = yy_buffer;
yb->next = yy_buffer;
yy_buffer = yb;
ptr->used =
yy_buffer = yb;
yy_scan_string(ptr->new);
break;
...
...
@@ -712,9 +712,9 @@ cppline {space}*#(.*\\{space})+.*
yb->buffer = YY_CURRENT_BUFFER;
yb->lineno = yylineno;
yb->filename = mm_strdup(input_filename);
ptr->used =
yb->next = yy_buffer;
yb->next = yy_buffer;
yy_buffer = yb;
ptr->used =
yy_buffer = yb;
yy_scan_string(ptr->new);
break;
...
...
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