Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9897e35

Browse files
author
Michael Meskes
committed
Added Joachim's changes for MinGW.
Added SET DATESTYLE to one test so the output format is defined.
1 parent 0f8fc35 commit 9897e35

13 files changed

+230
-128
lines changed

src/interfaces/ecpg/pgtypeslib/dt_common.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/dt_common.c,v 1.35 2006/06/21 10:24:41 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/pgtypeslib/dt_common.c,v 1.36 2006/09/26 07:56:56 meskes Exp $ */
22

33
#include "postgres_fe.h"
44

@@ -1165,6 +1165,11 @@ DetermineLocalTimeZone(struct tm * tm)
11651165
* reassemble to get a representation of local time.
11661166
*/
11671167
tmp = localtime(&mytime);
1168+
if (!tmp)
1169+
{
1170+
tm->tm_isdst = 0;
1171+
return 0;
1172+
}
11681173
day = (date2j(tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday) -
11691174
date2j(1970, 1, 1));
11701175
locsec = tmp->tm_sec + (tmp->tm_min + (day * HOURS_PER_DAY + tmp->tm_hour) * MINS_PER_HOUR) * SECS_PER_MINUTE;
@@ -1194,6 +1199,11 @@ DetermineLocalTimeZone(struct tm * tm)
11941199
mysec += delta1;
11951200
mytime = (time_t) mysec;
11961201
tmp = localtime(&mytime);
1202+
if (!tmp)
1203+
{
1204+
tm->tm_isdst = 0;
1205+
return 0;
1206+
}
11971207
day = (date2j(tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday) -
11981208
date2j(1970, 1, 1));
11991209
locsec = tmp->tm_sec + (tmp->tm_min + (day * HOURS_PER_DAY + tmp->tm_hour) * MINS_PER_HOUR) * SECS_PER_MINUTE;
@@ -1203,6 +1213,11 @@ DetermineLocalTimeZone(struct tm * tm)
12031213
mysec += (delta2 - delta1);
12041214
mytime = (time_t) mysec;
12051215
tmp = localtime(&mytime);
1216+
if (!tmp)
1217+
{
1218+
tm->tm_isdst = 0;
1219+
return 0;
1220+
}
12061221
day = (date2j(tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday) -
12071222
date2j(1970, 1, 1));
12081223
locsec = tmp->tm_sec + (tmp->tm_min + (day * HOURS_PER_DAY + tmp->tm_hour) * MINS_PER_HOUR) * SECS_PER_MINUTE;

src/interfaces/ecpg/test/compat_informix/dec_test.pgc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@
77

88
exec sql include ../regression;
99

10+
11+
/*
12+
13+
NOTE: This file has a different expect file for regression tests on MinGW32
14+
15+
*/
16+
17+
18+
19+
1020
/*
1121
TODO:
1222
deccmp => DECUNKNOWN

src/interfaces/ecpg/test/expected/compat_informix-dec_test.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@
2727
#line 8 "dec_test.pgc"
2828

2929

30+
31+
/*
32+
33+
NOTE: This file has a different expect file for regression tests on MinGW32
34+
35+
*/
36+
37+
38+
39+
3040
/*
3141
TODO:
3242
deccmp => DECUNKNOWN

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

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
#line 6 "num_test.pgc"
2424

2525

26+
27+
/*
28+
29+
NOTE: This file has a different expect file for regression tests on MinGW32
30+
31+
*/
32+
33+
2634
int
2735
main(void)
2836
{
@@ -32,38 +40,38 @@ main(void)
3240

3341
/* = {0, 0, 0, 0, 0, NULL, NULL} ; */
3442

35-
#line 14 "num_test.pgc"
43+
#line 22 "num_test.pgc"
3644
numeric * des ;
3745
/* exec sql end declare section */
38-
#line 16 "num_test.pgc"
46+
#line 24 "num_test.pgc"
3947

4048
double d;
4149
long l1, l2;
4250
int i;
4351

4452
ECPGdebug(1, stderr);
4553
/* exec sql whenever sqlerror do sqlprint ( ) ; */
46-
#line 22 "num_test.pgc"
54+
#line 30 "num_test.pgc"
4755

4856

4957
{ ECPGconnect(__LINE__, 0, "regress1" , NULL,NULL , NULL, 0);
50-
#line 24 "num_test.pgc"
58+
#line 32 "num_test.pgc"
5159

5260
if (sqlca.sqlcode < 0) sqlprint ( );}
53-
#line 24 "num_test.pgc"
61+
#line 32 "num_test.pgc"
5462

5563

5664
{ ECPGsetcommit(__LINE__, "off", NULL);
57-
#line 26 "num_test.pgc"
65+
#line 34 "num_test.pgc"
5866

5967
if (sqlca.sqlcode < 0) sqlprint ( );}
60-
#line 26 "num_test.pgc"
68+
#line 34 "num_test.pgc"
6169

6270
{ ECPGdo(__LINE__, 0, 1, NULL, "create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) ", ECPGt_EOIT, ECPGt_EORT);
63-
#line 27 "num_test.pgc"
71+
#line 35 "num_test.pgc"
6472

6573
if (sqlca.sqlcode < 0) sqlprint ( );}
66-
#line 27 "num_test.pgc"
74+
#line 35 "num_test.pgc"
6775

6876

6977
value1 = PGTYPESnumeric_new();
@@ -92,10 +100,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
92100
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into test ( text , num ) values( 'test' , ? ) ",
93101
ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric),
94102
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);
95-
#line 52 "num_test.pgc"
103+
#line 60 "num_test.pgc"
96104

97105
if (sqlca.sqlcode < 0) sqlprint ( );}
98-
#line 52 "num_test.pgc"
106+
#line 60 "num_test.pgc"
99107

100108

101109
value2 = PGTYPESnumeric_from_asc("2369.7", NULL);
@@ -105,10 +113,10 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
105113
{ ECPGdo(__LINE__, 0, 1, NULL, "select num from test where text = 'test' ", ECPGt_EOIT,
106114
ECPGt_numeric,&(des),(long)1,(long)0,sizeof(numeric),
107115
ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
108-
#line 58 "num_test.pgc"
116+
#line 66 "num_test.pgc"
109117

110118
if (sqlca.sqlcode < 0) sqlprint ( );}
111-
#line 58 "num_test.pgc"
119+
#line 66 "num_test.pgc"
112120

113121

114122
PGTYPESnumeric_mul(res, des, res);
@@ -134,16 +142,16 @@ if (sqlca.sqlcode < 0) sqlprint ( );}
134142
PGTYPESnumeric_free(res);
135143

136144
{ ECPGtrans(__LINE__, NULL, "rollback");
137-
#line 82 "num_test.pgc"
145+
#line 90 "num_test.pgc"
138146

139147
if (sqlca.sqlcode < 0) sqlprint ( );}
140-
#line 82 "num_test.pgc"
148+
#line 90 "num_test.pgc"
141149

142150
{ ECPGdisconnect(__LINE__, "CURRENT");
143-
#line 83 "num_test.pgc"
151+
#line 91 "num_test.pgc"
144152

145153
if (sqlca.sqlcode < 0) sqlprint ( );}
146-
#line 83 "num_test.pgc"
154+
#line 91 "num_test.pgc"
147155

148156

149157
return (0);

src/interfaces/ecpg/test/expected/pgtypeslib-num_test.stderr

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22
[NO_PID]: sqlca: code: 0, state: 00000
33
[NO_PID]: ECPGconnect: opening database regress1 on <DEFAULT> port <DEFAULT>
44
[NO_PID]: sqlca: code: 0, state: 00000
5-
[NO_PID]: ECPGsetcommit line 26 action = off connection = regress1
5+
[NO_PID]: ECPGsetcommit line 34 action = off connection = regress1
66
[NO_PID]: sqlca: code: 0, state: 00000
7-
[NO_PID]: ECPGexecute line 27: QUERY: create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) on connection regress1
7+
[NO_PID]: ECPGexecute line 35: QUERY: create table test ( text char ( 5 ) , num numeric ( 14 , 7 ) ) on connection regress1
88
[NO_PID]: sqlca: code: 0, state: 00000
9-
[NO_PID]: ECPGexecute line 27 Ok: CREATE TABLE
9+
[NO_PID]: ECPGexecute line 35 Ok: CREATE TABLE
1010
[NO_PID]: sqlca: code: 0, state: 00000
11-
[NO_PID]: ECPGexecute line 52: QUERY: insert into test ( text , num ) values( 'test' , 2369.7 ) on connection regress1
11+
[NO_PID]: ECPGexecute line 60: QUERY: insert into test ( text , num ) values ( 'test' , 2369.7 ) on connection regress1
1212
[NO_PID]: sqlca: code: 0, state: 00000
13-
[NO_PID]: ECPGexecute line 52 Ok: INSERT 0 1
13+
[NO_PID]: ECPGexecute line 60 Ok: INSERT 0 1
1414
[NO_PID]: sqlca: code: 0, state: 00000
15-
[NO_PID]: ECPGexecute line 58: QUERY: select num from test where text = 'test' on connection regress1
15+
[NO_PID]: ECPGexecute line 66: QUERY: select num from test where text = 'test' on connection regress1
1616
[NO_PID]: sqlca: code: 0, state: 00000
17-
[NO_PID]: ECPGexecute line 58: Correctly got 1 tuples with 1 fields
17+
[NO_PID]: ECPGexecute line 66: Correctly got 1 tuples with 1 fields
1818
[NO_PID]: sqlca: code: 0, state: 00000
19-
[NO_PID]: ECPGget_data line 58: RESULT: 2369.7000000 offset: -1 array: Yes
19+
[NO_PID]: ECPGget_data line 66: RESULT: 2369.7000000 offset: -1 array: Yes
2020
[NO_PID]: sqlca: code: 0, state: 00000
21-
[NO_PID]: ECPGtrans line 82 action = rollback connection = regress1
21+
[NO_PID]: ECPGtrans line 90 action = rollback connection = regress1
2222
[NO_PID]: sqlca: code: 0, state: 00000
2323
[NO_PID]: ecpg_finish: Connection regress1 closed.
2424
[NO_PID]: sqlca: code: 0, state: 00000

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
#line 7 "num_test2.pgc"
2525

2626

27+
28+
/*
29+
30+
NOTE: This file has a different expect file for regression tests on MinGW32
31+
32+
*/
33+
34+
2735
char* nums[] = { "2E394", "-2", ".794", "3.44", "592.49E21", "-32.84e4",
2836
"2E-394", ".1E-2", "+.0", "-592.49E-07", "+32.84e-4",
2937
".500001", "-.5000001",

src/interfaces/ecpg/test/expected/preproc-variable.c

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -126,64 +126,72 @@ if (sqlca.sqlcode < 0) sqlprint();}
126126
#line 43 "variable.pgc"
127127

128128

129-
strcpy(msg, "create");
130-
{ ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT);
129+
strcpy(msg, "set");
130+
{ ECPGdo(__LINE__, 0, 1, NULL, "set datestyle to iso", ECPGt_EOIT, ECPGt_EORT);
131131
#line 46 "variable.pgc"
132132

133133
if (sqlca.sqlcode < 0) sqlprint();}
134134
#line 46 "variable.pgc"
135135

136136

137-
strcpy(msg, "insert");
138-
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
137+
strcpy(msg, "create");
138+
{ ECPGdo(__LINE__, 0, 1, NULL, "create table family ( name char ( 8 ) , born integer , age smallint , married date , children integer ) ", ECPGt_EOIT, ECPGt_EORT);
139139
#line 49 "variable.pgc"
140140

141141
if (sqlca.sqlcode < 0) sqlprint();}
142142
#line 49 "variable.pgc"
143143

144+
145+
strcpy(msg, "insert");
146+
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , married , children ) values ( 'Mum' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
147+
#line 52 "variable.pgc"
148+
149+
if (sqlca.sqlcode < 0) sqlprint();}
150+
#line 52 "variable.pgc"
151+
144152
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , born , married , children ) values ( 'Dad' , '19610721' , '19870714' , 3 ) ", ECPGt_EOIT, ECPGt_EORT);
145-
#line 50 "variable.pgc"
153+
#line 53 "variable.pgc"
146154

147155
if (sqlca.sqlcode < 0) sqlprint();}
148-
#line 50 "variable.pgc"
156+
#line 53 "variable.pgc"
149157

150158
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 1' , 16 ) ", ECPGt_EOIT, ECPGt_EORT);
151-
#line 51 "variable.pgc"
159+
#line 54 "variable.pgc"
152160

153161
if (sqlca.sqlcode < 0) sqlprint();}
154-
#line 51 "variable.pgc"
162+
#line 54 "variable.pgc"
155163

156164
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 2' , 14 ) ", ECPGt_EOIT, ECPGt_EORT);
157-
#line 52 "variable.pgc"
165+
#line 55 "variable.pgc"
158166

159167
if (sqlca.sqlcode < 0) sqlprint();}
160-
#line 52 "variable.pgc"
168+
#line 55 "variable.pgc"
161169

162170
{ ECPGdo(__LINE__, 0, 1, NULL, "insert into family ( name , age ) values ( 'Child 3' , 9 ) ", ECPGt_EOIT, ECPGt_EORT);
163-
#line 53 "variable.pgc"
171+
#line 56 "variable.pgc"
164172

165173
if (sqlca.sqlcode < 0) sqlprint();}
166-
#line 53 "variable.pgc"
174+
#line 56 "variable.pgc"
167175

168176

169177
strcpy(msg, "commit");
170178
{ ECPGtrans(__LINE__, NULL, "commit");
171-
#line 56 "variable.pgc"
179+
#line 59 "variable.pgc"
172180

173181
if (sqlca.sqlcode < 0) sqlprint();}
174-
#line 56 "variable.pgc"
182+
#line 59 "variable.pgc"
175183

176184

177185
strcpy(msg, "open");
178186
{ ECPGdo(__LINE__, 0, 1, NULL, "declare cur cursor for select name , born , age , married , children from family ", ECPGt_EOIT, ECPGt_EORT);
179-
#line 59 "variable.pgc"
187+
#line 62 "variable.pgc"
180188

181189
if (sqlca.sqlcode < 0) sqlprint();}
182-
#line 59 "variable.pgc"
190+
#line 62 "variable.pgc"
183191

184192

185193
/* exec sql whenever not found break ; */
186-
#line 61 "variable.pgc"
194+
#line 64 "variable.pgc"
187195

188196

189197
p=&personal;
@@ -202,13 +210,13 @@ if (sqlca.sqlcode < 0) sqlprint();}
202210
ECPGt_long,&(ind_married),(long)1,(long)1,sizeof(long),
203211
ECPGt_int,&(children.integer),(long)1,(long)1,sizeof(int),
204212
ECPGt_short,&(ind_children.smallint),(long)1,(long)1,sizeof(short), ECPGt_EORT);
205-
#line 68 "variable.pgc"
213+
#line 71 "variable.pgc"
206214

207215
if (sqlca.sqlcode == ECPG_NOT_FOUND) break;
208-
#line 68 "variable.pgc"
216+
#line 71 "variable.pgc"
209217

210218
if (sqlca.sqlcode < 0) sqlprint();}
211-
#line 68 "variable.pgc"
219+
#line 71 "variable.pgc"
212220

213221
printf("%8.8s", personal.name.arr);
214222
if (i->ind_birth.born >= 0)
@@ -227,34 +235,34 @@ if (sqlca.sqlcode < 0) sqlprint();}
227235

228236
strcpy(msg, "close");
229237
{ ECPGdo(__LINE__, 0, 1, NULL, "close cur", ECPGt_EOIT, ECPGt_EORT);
230-
#line 85 "variable.pgc"
238+
#line 88 "variable.pgc"
231239

232240
if (sqlca.sqlcode < 0) sqlprint();}
233-
#line 85 "variable.pgc"
241+
#line 88 "variable.pgc"
234242

235243

236244
strcpy(msg, "drop");
237245
{ ECPGdo(__LINE__, 0, 1, NULL, "drop table family ", ECPGt_EOIT, ECPGt_EORT);
238-
#line 88 "variable.pgc"
246+
#line 91 "variable.pgc"
239247

240248
if (sqlca.sqlcode < 0) sqlprint();}
241-
#line 88 "variable.pgc"
249+
#line 91 "variable.pgc"
242250

243251

244252
strcpy(msg, "commit");
245253
{ ECPGtrans(__LINE__, NULL, "commit");
246-
#line 91 "variable.pgc"
254+
#line 94 "variable.pgc"
247255

248256
if (sqlca.sqlcode < 0) sqlprint();}
249-
#line 91 "variable.pgc"
257+
#line 94 "variable.pgc"
250258

251259

252260
strcpy(msg, "disconnect");
253261
{ ECPGdisconnect(__LINE__, "CURRENT");
254-
#line 94 "variable.pgc"
262+
#line 97 "variable.pgc"
255263

256264
if (sqlca.sqlcode < 0) sqlprint();}
257-
#line 94 "variable.pgc"
265+
#line 97 "variable.pgc"
258266

259267

260268
return (0);

0 commit comments

Comments
 (0)