8000 Added missing constuctor/destructor for interval and date. · postgrespro/postgres_cluster@0f0d676 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0f0d676

Browse files
author
Michael Meskes
committed
Added missing constuctor/destructor for interval and date.
1 parent f8fe328 commit 0f0d676

File tree

8 files changed

+79
-7
lines changed

8 files changed

+79
-7
lines changed

src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2144,5 +2144,10 @@ Tu 5. Sep 11:49:08 CEST 2006
21442144
- Fixed port number setting in regression suite.
21452145
- Added some interval checks to regression suite.
21462146
- Started to cleanup complex tests.
2147+
2148+
Th 14. Sep 09:47:03 CEST 2006
2149+
2150+
- Completely removed complex tests.
2151+
- Added missing constuctor/destructor for interval and date.
21472152
- Set ecpg library version to 5.2.
21482153
- Set ecpg version to 4.2.1.

src/interfaces/ecpg/include/pgtypes_date.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_date.h,v 1.9 2006/03/11 04:38:39 momjian Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_date.h,v 1.10 2006/09/14 08:02:38 meskes Exp $ */
22

33
#ifndef PGTYPES_DATETIME
44
#define PGTYPES_DATETIME
@@ -12,6 +12,8 @@ extern "C"
1212
{
1313
#endif
1414

15+
extern date *PGTYPESdate_new(void);
16+
extern void PGTYPESdate_free(date *);
1517
extern date PGTYPESdate_from_asc(char *, char **);
1618
extern char *PGTYPESdate_to_asc(date);
1719
extern date PGTYPESdate_from_timestamp(timestamp);

src/interfaces/ecpg/include/pgtypes_interval.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.11 2006/08/24 10:48:21 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/include/pgtypes_interval.h,v 1.12 2006/09/14 08:02:38 meskes Exp $ */
22

33
#ifndef PGTYPES_INTERVAL
44
#define PGTYPES_INTERVAL
@@ -49,6 +49,8 @@ extern "C"
4949
{
5050
#endif
5151

52+
extern interval *PGTYPESinterval_new(void);
53+
extern void PGTYPESinterval_free(interval *);
5254
extern interval *PGTYPESinterval_from_asc(char *, char **);
5355
extern char *PGTYPESinterval_to_asc(interval *);
5456
extern int PGTYPESinterval_copy(interval *, interval *);

src/interfaces/ecpg/pgtypeslib/datetime.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.30 2006/08/15 06:40:19 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/datetime.c,v 1.31 2006/09/14 08:02:38 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -12,6 +12,21 @@
1212
#include "pgtypes_error.h"
1313
#include "pgtypes_date.h"
1414

15+
date *
16+
PGTYPESdate_new(void)
17+
{
18+
date *result;
19+
result = (date *) pgtypes_alloc(sizeof(date));
20+
/* result can be NULL if we run out of memory */
21+
return result;
22+
}
23+
24+
void
25+
PGTYPESdate_free(date *d)
26+
{
27+
free(d);
28+
}
29+
1530
date
1631
PGTYPESdate_from_timestamp(timestamp dt)
1732
{

src/interfaces/ecpg/pgtypeslib/interval.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.34 2006/09/05 12:17:09 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/interval.c,v 1.35 2006/09/14 08:02:38 meskes Exp $ */
22

33
#include "postgres_fe.h"
44
#include <time.h>
@@ -753,6 +753,21 @@ tm2interval(struct tm * tm, fsec_t fsec, interval * span)
753753
return 0;
754754
} /* tm2interval() */
755755

756+
interval *
757+
PGTYPESinterval_new(void)
758+
{
759+
interval *result;
760+
result = (interval *) pgtypes_alloc(sizeof(interval));
761+
/* result can be NULL if we run out of memory */
762+
return result;
763+
}
764+
765+
void
766+
PGTYPESinterval_free(interval *intvl)
767+
{
768+
free(intvl);
769+
}
770+
756771
interval *
757772
PGTYPESinterval_from_asc(char *str, char **endptr)
758773
{

src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ main(void)
7070

7171

7272

73+
7374

7475
#line 51 "dt_test2.pgc"
7576
date date1 ;
@@ -82,8 +83,11 @@ main(void)
8283

8384
#line 54 "dt_test2.pgc"
8485
interval * i1 ;
85-
/* exec sql end declare section */
86+
8687
#line 55 "dt_test2.pgc"
88+
date * dc ;
89+
/* exec sql end declare section */
90+
#line 56 "dt_test2.pgc"
8791

8892

8993
int i, j;
@@ -98,9 +102,12 @@ main(void)
98102
free(text);
99103

100104
date1 = PGTYPESdate_from_timestamp(ts1);
101-
text = PGTYPESdate_to_asc(date1);
105+
dc = PGTYPESdate_new();
106+
*dc = date1;
107+
text = PGTYPESdate_to_asc(*dc);
102108
printf("Date of timestamp: %s\n", text);
103109
free(text);
110+
PGTYPESdate_free(dc);
104111

105112
for (i = 0; dates[i]; i++)
106113
{
@@ -139,6 +146,7 @@ main(void)
139146

140147
for (i = 0; intervals[i]; i++)
141148
{
149+
interval *ic;
142150
i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
143151
if (*endptr)
144152
printf("endptr set to %s\n", endptr);
@@ -153,6 +161,13 @@ main(void)
153161
text = PGTYPESinterval_to_asc(i1);
154162
printf("interval[%d]: %s\n", i, text ? text : "-");
155163
free(text);
164+
165+
ic = PGTYPESinterval_new();
166+
PGTYPESinterval_copy(i1, ic);
167+
text = PGTYPESinterval_to_asc(i1);
168+
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
169+
free(text);
170+
PGTYPESinterval_free(ic);
156171
}
157172

158173
return (0);

src/interfaces/ecpg/test/expected/pgtypeslib-dt_test2.stdout

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,15 @@ TS[19,0]: 0099-01-08 00:04:00 BC
8888
TS[19,1]: 0099-01-08 01:59:00 BC
8989
TS[19,2]: 0099-01-08 13:24:40 BC
9090
interval[0]: @ 1 min
91+
interval_copy[0]: @ 1 min
9192
interval[1]: @ 1 day 12 hours 59 mins 10 secs
93+
interval_copy[1]: @ 1 day 12 hours 59 mins 10 secs
9294
interval[2]: @ 2 days 12 hours 59 mins 10 secs
95+
interval_copy[2]: @ 2 days 12 hours 59 mins 10 secs
9396
interval[3]: @ 1 day 12 hours 59 mins 10 secs
97+
interval_copy[3]: @ 1 day 12 hours 59 mins 10 secs
9498
interval[4]: @ 1 day 1 hour 1 min 1 sec
99+
interval_copy[4]: @ 1 day 1 hour 1 min 1 sec
95100
interval[5]: @ 1 year 59 mins
101+
interval_copy[5]: @ 1 year 59 mins
96102
Error parsing interval 6

src/interfaces/ecpg/test/pgtypeslib/dt_test2.pgc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ main(void)
5252
timestamp ts1, ts2;
5353
char *text;
5454
interval *i1;
55+
date *dc;
5556
exec sql end declare section;
5657

5758
int i, j;
@@ -66,9 +67,12 @@ main(void)
6667
free(text);
6768

6869
date1 = PGTYPESdate_from_timestamp(ts1);
69-
text = PGTYPESdate_to_asc(date1);
70+
dc = PGTYPESdate_new();
71+
*dc = date1;
72+
text = PGTYPESdate_to_asc(*dc);
7073
printf("Date of timestamp: %s\n", text);
7174
free(text);
75+
PGTYPESdate_free(dc);
7276

7377
for (i = 0; dates[i]; i++)
7478
{
@@ -107,6 +111,7 @@ main(void)
107111

108112
for (i = 0; intervals[i]; i++)
109113
{
114+
interval *ic;
110115
i1 = PGTYPESinterval_from_asc(intervals[i], &endptr);
111116
if (*endptr)
112117
printf("endptr set to %s\n", endptr);
@@ -121,6 +126,13 @@ main(void)
121126
text = PGTYPESinterval_to_asc(i1);
122127
printf("interval[%d]: %s\n", i, text ? text : "-");
123128
free(text);
129+
130+
ic = PGTYPESinterval_new();
131+
PGTYPESinterval_copy(i1, ic);
132+
text = PGTYPESinterval_to_asc(i1);
133+
printf("interval_copy[%d]: %s\n", i, text ? text : "-");
134+
free(text);
135+
PGTYPESinterval_free(ic);
124136
}
125137

126138
return (0);

0 commit comments

Comments
 (0)
0