Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commit988fdce

Browse files
author
Michael Meskes
committed
- Removed space_or_nl and line_end from pgc.l.
- Fixed several bugs concerning arrays of structs including a memory allocation bug.
1 parentaed0c29 commit988fdce

File tree

22 files changed

+393
-268
lines changed

22 files changed

+393
-268
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,5 +1175,14 @@ Sun Dec 9 16:21:30 CET 2001
11751175

11761176
- Fixed several bugs concerning indicators and added error messages
11771177
instead of segfaults.
1178+
1179+
Thu Dec 20 14:15:56 CET 2001
1180+
1181+
- Removed space_or_nl and line_end from pgc.l.
1182+
1183+
Sun Dec 23 13:08:36 CET 2001
1184+
1185+
- Fixed several bugs concerning arrays of structs including a memory
1186+
allocation bug.
11781187
- Set ecpg version to 2.9.0.
11791188
- Set library version to 3.3.0.

‎src/interfaces/ecpg/include/ecpgerrno.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#defineECPG_MISSING_INDICATOR-209
2626
#defineECPG_NO_ARRAY-210
2727
#defineECPG_DATA_NOT_ARRAY-211
28+
#defineECPG_ARRAY_INSERT-212
2829

2930
#defineECPG_NO_CONN-220
3031
#defineECPG_NOT_CONN-221

‎src/interfaces/ecpg/lib/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile,v 1.13 2001/09/19 14:09:32 meskes Exp $
7+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile,v 1.14 2001/12/23 12:17:41 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

1111
subdir = src/interfaces/ecpg/lib
1212
top_builddir = ../../../..
1313
include$(top_builddir)/src/Makefile.global
1414

15+
CFLAGS=-g
16+
1517
NAME= ecpg
1618
SO_MAJOR_VERSION= 3
1719
SO_MINOR_VERSION= 3.0

‎src/interfaces/ecpg/lib/connect.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.16 2001/12/05 15:32:06 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/connect.c,v 1.17 2001/12/23 12:17:41 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -52,9 +52,9 @@ ecpg_finish(struct connection * act)
5252
if (actual_connection==act)
5353
actual_connection=all_connections;
5454

55-
for (cache=act->cache_head;cache;ptr=cache,cache=cache->next,free(ptr));
56-
free(act->name);
57-
free(act);
55+
for (cache=act->cache_head;cache;ptr=cache,cache=cache->next,ECPGfree(ptr));
56+
ECPGfree(act->name);
57+
ECPGfree(act);
5858
}
5959
else
6060
ECPGlog("ecpg_finish: called an extra time.\n");
@@ -348,15 +348,15 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
348348
ECPGlog("connect: socketname %s given for TCP connection in line %d\n",host,lineno);
349349
ECPGraise(lineno,ECPG_CONNECT,realname ?realname :"<DEFAULT>");
350350
if (host)
351-
free(host);
351+
ECPGfree(host);
352352
if (port)
353-
free(port);
353+
ECPGfree(port);
354354
if (options)
355-
free(options);
355+
ECPGfree(options);
356356
if (realname)
357-
free(realname);
357+
ECPGfree(realname);
358358
if (dbname)
359-
free(dbname);
359+
ECPGfree(dbname);
360360
return false;
361361
}
362362
}
@@ -371,15 +371,15 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
371371
ECPGlog("connect: non-localhost access via sockets in line %d\n",lineno);
372372
ECPGraise(lineno,ECPG_CONNECT,realname ?realname :"<DEFAULT>");
373373
if (host)
374-
free(host);
374+
ECPGfree(host);
375375
if (port)
376-
free(port);
376+
ECPGfree(port);
377377
if (options)
378-
free(options);
378+
ECPGfree(options);
379379
if (realname)
380-
free(realname);
380+
ECPGfree(realname);
381381
if (dbname)
382-
free(dbname);
382+
ECPGfree(dbname);
383383
return false;
384384
}
385385
}
@@ -431,28 +431,28 @@ ECPGconnect(int lineno, const char *name, const char *user, const char *passwd,
431431
lineno);
432432
ECPGraise(lineno,ECPG_CONNECT,realname ?realname :"<DEFAULT>");
433433
if (host)
434-
free(host);
434+
ECPGfree(host);
435435
if (port)
436-
free(port);
436+
ECPGfree(port);
437437
if (options)
438-
free(options);
438+
ECPGfree(options);
439439
if (realname)
440-
free(realname);
440+
ECPGfree(realname);
441441
if (dbname)
442-
free(dbname);
442+
ECPGfree(dbname);
443443
return false;
444444
}
445445

446446
if (host)
447-
free(host);
447+
ECPGfree(host);
448448
if (port)
449-
free(port);
449+
ECPGfree(port);
450450
if (options)
451-
free(options);
451+
ECPGfree(options);
452452
if (realname)
453-
free(realname);
453+
ECPGfree(realname);
454454
if (dbname)
455-
free(dbname);
455+
ECPGfree(dbname);
456456

457457
this->committed= true;
458458
this->autocommit=autocommit;

‎src/interfaces/ecpg/lib/data.c

Lines changed: 70 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.20 2001/12/05 15:32:06 meskes Exp $ */
1+
/* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/data.c,v 1.21 2001/12/23 12:17:41 meskes Exp $ */
22

33
#include"postgres_fe.h"
44

@@ -15,11 +15,11 @@ bool
1515
ECPGget_data(constPGresult*results,intact_tuple,intact_field,intlineno,
1616
enumECPGttypetype,enumECPGttypeind_type,
1717
void*var,void*ind,longvarcharsize,longoffset,
18-
boolisarray)
18+
longind_offset,boolisarray)
1919
{
2020
char*pval= (char*)PQgetvalue(results,act_tuple,act_field);
2121

22-
ECPGlog("ECPGget_data line %d: RESULT: %s\n",lineno,pval ?pval :"");
22+
ECPGlog("ECPGget_data line %d: RESULT: %s offset: %ld\n",lineno,pval ?pval :"",offset);
2323

2424
/* pval is a pointer to the value */
2525
/* let's check is it really is an array if it should be one */
@@ -53,23 +53,28 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
5353
{
5454
caseECPGt_short:
5555
caseECPGt_unsigned_short:
56-
((short*)ind)[act_tuple]=-PQgetisnull(results,act_tuple,act_field);
56+
/*((short *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
57+
*((short*) (ind+ind_offset*act_tuple))=-PQgetisnull(results,act_tuple,act_field);
5758
break;
5859
caseECPGt_int:
5960
caseECPGt_unsigned_int:
60-
((int*)ind)[act_tuple]=-PQgetisnull(results,act_tuple,act_field);
61+
/*((int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
62+
*((int*) (ind+ind_offset*act_tuple))=-PQgetisnull(results,act_tuple,act_field);
6163
break;
6264
caseECPGt_long:
6365
caseECPGt_unsigned_long:
64-
((long*)ind)[act_tuple]=-PQgetisnull(results,act_tuple,act_field);
66+
/*((long *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
67+
*((long*) (ind+ind_offset*act_tuple))=-PQgetisnull(results,act_tuple,act_field);
6568
break;
6669
#ifdefHAVE_LONG_LONG_INT_64
6770
caseECPGt_long_long:
68-
((long longint*)ind)[act_tuple]=-PQgetisnull(results,act_tuple,act_field);
69-
break;
7071
caseECPGt_unsigned_long_long:
71-
((unsigned long longint*)ind)[act_tuple]=-PQgetisnull(results,act_tuple,act_field);
72+
/*((long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);*/
73+
*((long longint*) (ind+ind_offset*act_tuple))=-PQgetisnull(results,act_tuple,act_field);
7274
break;
75+
/*case ECPGt_unsigned_long_long:
76+
((unsigned long long int *) ind)[act_tuple] = -PQgetisnull(results, act_tuple, act_field);
77+
break;*/
7378
#endif/* HAVE_LONG_LONG_INT_64 */
7479
caseECPGt_NO_INDICATOR:
7580
if (PQgetisnull(results,act_tuple,act_field))
@@ -112,13 +117,16 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
112117
switch (type)
113118
{
114119
caseECPGt_short:
115-
((short*)var)[act_tuple]= (short)res;
120+
/*((short *) var)[act_tuple] = (short) res;*/
121+
*((short*) (var+offset*act_tuple))= (short)res;
116122
break;
117123
caseECPGt_int:
118-
((int*)var)[act_tuple]= (int)res;
124+
/*((int *) var)[act_tuple] = (int) res;*/
125+
*((int*) (var+offset*act_tuple))= (int)res;
119126
break;
120127
caseECPGt_long:
121-
((long*)var)[act_tuple]=res;
128+
/*((long *) var)[act_tuple] = res;*/
129+
*((long*) (var+offset*act_tuple))= (long)res;
122130
break;
123131
default:
124132
/* Cannot happen */
@@ -145,13 +153,16 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
145153
switch (type)
146154
{
147155
caseECPGt_unsigned_short:
148-
((unsigned short*)var)[act_tuple]= (unsigned short)ures;
156+
/*((unsigned short *) var)[act_tuple] = (unsigned short) ures;*/
157+
*((unsigned short*) (var+offset*act_tuple))= (unsigned short)res;
149158
break;
150159
caseECPGt_unsigned_int:
151-
((unsignedint*)var)[act_tuple]= (unsignedint)ures;
160+
/*((unsigned int *) var)[act_tuple] = (unsigned int) ures;*/
161+
*((unsignedint*) (var+offset*act_tuple))= (unsignedint)res;
152162
break;
153163
caseECPGt_unsigned_long:
154-
((unsigned long*)var)[act_tuple]=ures;
164+
/*((unsigned long *) var)[act_tuple] = ures;*/
165+
*((unsigned long*) (var+offset*act_tuple))= (unsigned long)res;
155166
break;
156167
default:
157168
/* Cannot happen */
@@ -164,7 +175,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
164175
caseECPGt_long_long:
165176
if (pval)
166177
{
167-
((long longint*)var)[act_tuple]=strtoll(pval,&scan_length,10);
178+
/*((long long int *) var)[act_tuple] = strtoll(pval, &scan_length, 10);*/
179+
*((long longint*) (var+offset*act_tuple))=strtoll(pval,&scan_length,10);
168180
if ((isarray&&*scan_length!=','&&*scan_length!='}')
169181
|| (!isarray&&*scan_length!='\0'))/* Garbage left */
170182
{
@@ -173,15 +185,17 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
173185
}
174186
}
175187
else
176-
((long longint*)var)[act_tuple]= (long long)0;
188+
/*((long long int *) var)[act_tuple] = (long long) 0;*/
189+
*((long longint*) (var+offset*act_tuple))= (long long)0;
177190

178191
break;
179192
#endif/* HAVE_STRTOLL */
180193
#ifdefHAVE_STRTOULL
181194
caseECPGt_unsigned_long_long:
182195
if (pval)
183196
{
184-
((unsigned long longint*)var)[act_tuple]=strtoull(pval,&scan_length,10);
197+
/*((unsigned long long int *) var)[act_tuple] = strtoull(pval, &scan_length, 10);*/
198+
*((unsigned long longint*) (var+offset*act_tuple))=strtoull(pval,&scan_length,10);
185199
if ((isarray&&*scan_length!=','&&*scan_length!='}')
186200
|| (!isarray&&*scan_length!='\0'))/* Garbage left */
187201
{
@@ -190,7 +204,8 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
190204
}
191205
}
192206
else
193-
((unsigned long longint*)var)[act_tuple]= (long long)0;
207+
/*((unsigned long long int *) var)[act_tuple] = (long long) 0;*/
208+
*((unsigned long longint*) (var+offset*act_tuple))= (long long)0;
194209

195210
break;
196211
#endif/* HAVE_STRTOULL */
@@ -221,10 +236,12 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
221236
switch (type)
222237
{
223238
caseECPGt_float:
224-
((float*)var)[act_tuple]=dres;
239+
/*((float *) var)[act_tuple] = dres;*/
240+
*((float*) (var+offset*act_tuple))=dres;
225241
break;
226242
caseECPGt_double:
227-
((double*)var)[act_tuple]=dres;
243+
/*((double *) var)[act_tuple] = dres;*/
244+
*((double*) (var+offset*act_tuple))=dres;
228245
break;
229246
default:
230247
/* Cannot happen */
@@ -238,19 +255,23 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
238255
if (pval[0]=='f'&&pval[1]=='\0')
239256
{
240257
if (offset==sizeof(char))
241-
((char*)var)[act_tuple]= false;
258+
/*((char *) var)[act_tuple] = false;*/
259+
*((char*) (var+offset*act_tuple))= false;
242260
elseif (offset==sizeof(int))
243-
((int*)var)[act_tuple]= false;
261+
/*((int *) var)[act_tuple] = false;*/
262+
*((int*) (var+offset*act_tuple))= false;
244263
else
245264
ECPGraise(lineno,ECPG_CONVERT_BOOL,"different size");
246265
break;
247266
}
248267
elseif (pval[0]=='t'&&pval[1]=='\0')
249268
{
250269
if (offset==sizeof(char))
251-
((char*)var)[act_tuple]= true;
270+
/*((char *) var)[act_tuple] = true;*/
271+
*((char*) (var+offset*act_tuple))= true;
252272
elseif (offset==sizeof(int))
253-
((int*)var)[act_tuple]= true;
273+
/*((int *) var)[act_tuple] = true;*/
274+
*((int*) (var+offset*act_tuple))= true;
254275
else
255276
ECPGraise(lineno,ECPG_CONVERT_BOOL,"different size");
256277
break;
@@ -277,16 +298,25 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
277298
{
278299
caseECPGt_short:
279300
caseECPGt_unsigned_short:
280-
((short*)ind)[act_tuple]=strlen(pval);
301+
/*((short *) ind)[act_tuple] = strlen(pval);*/
302+
*((short*) (ind+ind_offset*act_tuple))=strlen(pval);
281303
break;
282304
caseECPGt_int:
283305
caseECPGt_unsigned_int:
284-
((int*)ind)[act_tuple]=strlen(pval);
306+
/*((int *) ind)[act_tuple] = strlen(pval);*/
307+
*((int*) (ind+ind_offset*act_tuple))=strlen(pval);
285308
break;
286309
caseECPGt_long:
287310
caseECPGt_unsigned_long:
288-
((long*)ind)[act_tuple]=strlen(pval);
311+
/*((long *) ind)[act_tuple] = strlen(pval);*/
312+
*((long*) (ind+ind_offset*act_tuple))=strlen(pval);
313+
break;
314+
#ifdefHAVE_LONG_LONG_INT_64
315+
caseECPGt_long_long:
316+
caseECPGt_unsigned_long_long:
317+
*((long longint*) (ind+ind_offset*act_tuple))=strlen(pval);
289318
break;
319+
#endif/* HAVE_LONG_LONG_INT_64 */
290320
default:
291321
break;
292322
}
@@ -313,16 +343,25 @@ ECPGget_data(const PGresult *results, int act_tuple, int act_field, int lineno,
313343
{
314344
caseECPGt_short:
315345
caseECPGt_unsigned_short:
316-
((short*)ind)[act_tuple]=variable->len;
346+
/*((short *) ind)[act_tuple] = variable->len;*/
347+
*((short*) (ind+offset*act_tuple))=variable->len;
317348
break;
318349
caseECPGt_int:
319350
caseECPGt_unsigned_int:
320-
((int*)ind)[act_tuple]=variable->len;
351+
/*((int *) ind)[act_tuple] = variable->len;*/
352+
*((int*) (ind+offset*act_tuple))=variable->len;
321353
break;
322354
caseECPGt_long:
323355
caseECPGt_unsigned_long:
324-
((long*)ind)[act_tuple]=variable->len;
356+
/*((long *) ind)[act_tuple] = variable->len;*/
357+
*((long*) (ind+offset*act_tuple))=variable->len;
358+
break;
359+
#ifdefHAVE_LONG_LONG_INT_64
360+
caseECPGt_long_long:
361+
caseECPGt_unsigned_long_long:
362+
*((long longint*) (ind+ind_offset*act_tuple))=variable->len;
325363
break;
364+
#endif/* HAVE_LONG_LONG_INT_64 */
326365
default:
327366
break;
328367
}

‎src/interfaces/ecpg/lib/descriptor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* dynamic SQL support routines
22
*
3-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.19 2001/11/14 11:11:49 meskes Exp $
3+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/descriptor.c,v 1.20 2001/12/23 12:17:41 meskes Exp $
44
*/
55

66
#include"postgres_fe.h"
@@ -374,9 +374,9 @@ ECPGdeallocate_desc(int line, const char *name)
374374
if (!strcmp(name,i->name))
375375
{
376376
*lastptr=i->next;
377-
free(i->name);
377+
ECPGfree(i->name);
378378
PQclear(i->result);
379-
free(i);
379+
ECPGfree(i);
380380
return true;
381381
}
382382
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp