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

Commitbc8a39b

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parentab0c8c6 commitbc8a39b

File tree

3 files changed

+65
-25
lines changed

3 files changed

+65
-25
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extern"C"
5959
constchar*descriptor,constchar*query);
6060
boolECPGdeallocate_desc(intline,constchar*name);
6161
boolECPGallocate_desc(intline,constchar*name);
62-
voidECPGraise(intline,intcode);
62+
voidECPGraise(intline,intcode,constchar*str);
6363
boolECPGget_desc_header(int,char*,int*);
6464

6565

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

Lines changed: 53 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,25 @@
22
*
33
* Copyright (c) 2000, Christof Petig <christof.petig@wtal.de>
44
*
5-
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.3 2000/02/1814:34:05 meskes Exp $
5+
* $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/dynamic.c,v 1.4 2000/02/1816:02:49 meskes Exp $
66
*/
77

88
/* I borrowed the include files from ecpglib.c, maybe we don't need all of them */
99

1010
#include<sql3types.h>
1111

1212
staticstructdescriptor
13-
{char*name;
13+
{
14+
char*name;
1415
PGresult*result;
1516
structdescriptor*next;
1617
}*all_descriptors=NULL;
1718

1819
PGconn*ECPG_internal_get_connection(char*name);
1920

2021
unsignedintECPGDynamicType(Oidtype)
21-
{switch(type)
22+
{
23+
switch(type)
2224
{case16:returnSQL3_BOOLEAN;/* bool */
2325
case21:returnSQL3_SMALLINT;/* int2 */
2426
case23:returnSQL3_INTEGER;/* int4 */
@@ -204,7 +206,7 @@ bool ECPGdo_descriptor(int line,const char *connection,
204206
return (status);
205207
}
206208
}
207-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR);
209+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,NULL);
208210
return false;
209211
}
210212

@@ -217,7 +219,7 @@ PGresult *ECPGresultByDescriptor(int line,const char *name)
217219
if (!strcmp(name,i->name))returni->result;
218220
}
219221

220-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR);
222+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,NULL);
221223

222224
returnNULL;
223225
}
@@ -236,7 +238,7 @@ bool ECPGdeallocate_desc(int line,const char *name)
236238
return true;
237239
}
238240
}
239-
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR);
241+
ECPGraise(line,ECPG_UNKNOWN_DESCRIPTOR,NULL);
240242
return false;
241243
}
242244

@@ -252,30 +254,69 @@ bool ECPGallocate_desc(int line,const char *name)
252254
return true;
253255
}
254256

255-
voidECPGraise(intline,intcode)
257+
void
258+
ECPGraise(intline,intcode,constchar*str)
256259
{
260+
structauto_mem*am;
261+
257262
sqlca.sqlcode=code;
258263
switch (code)
259264
{
260265
caseECPG_NOT_FOUND:
261266
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
262-
"No data found line %d.",line);
267+
"No data found line %d.",line);
268+
break;
269+
270+
caseECPG_OUT_OF_MEMORY:
271+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
272+
"Out of memory in line %d.",line);
263273
break;
274+
275+
caseECPG_UNSUPPORTED:
276+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
277+
"Unsupported type %s in line %d.",str,line);
278+
break;
279+
280+
caseECPG_TOO_MANY_ARGUMENTS:
281+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
282+
"Too many arguments in line %d.",line);
283+
break;
284+
285+
caseECPG_TOO_FEW_ARGUMENTS:
286+
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
287+
"Too few arguments in line %d.",line);
288+
break;
289+
264290
caseECPG_MISSING_INDICATOR:
265291
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
266-
"NULL value without indicator, line %d.",line);
292+
"NULL value without indicator, line %d.",line);
267293
break;
294+
268295
caseECPG_UNKNOWN_DESCRIPTOR:
269296
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
270-
"descriptor not found, line %d.",line);
297+
"descriptor not found, line %d.",line);
271298
break;
299+
272300
caseECPG_INVALID_DESCRIPTOR_INDEX:
273301
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
274-
"descriptor index out of range, line %d.",line);
302+
"descriptor index out of range, line %d.",line);
275303
break;
304+
276305
default:
277306
snprintf(sqlca.sqlerrm.sqlerrmc,sizeof(sqlca.sqlerrm.sqlerrmc),
278-
"SQL error #%d, line %d.",code,line);
307+
"SQL error #%d, line %d.",code,line);
279308
break;
280309
}
310+
311+
/* free all memory we have allocated for the user */
312+
for (am=auto_allocs;am;)
313+
{
314+
structauto_mem*act=am;
315+
316+
am=am->next;
317+
free(act->pointer);
318+
free(act);
319+
}
320+
321+
auto_allocs=NULL;
281322
}

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

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ ecpg_alloc(long size, int lineno)
190190
if (!new)
191191
{
192192
ECPGlog("out of memory\n");
193-
register_error(ECPG_OUT_OF_MEMORY,"Out of memory in line %d",lineno);
193+
ECPGraise(ECPG_OUT_OF_MEMORY,lineno,NULL);
194194
returnNULL;
195195
}
196196

@@ -206,7 +206,7 @@ ecpg_strdup(const char *string, int lineno)
206206
if (!new)
207207
{
208208
ECPGlog("out of memory\n");
209-
register_error(ECPG_OUT_OF_MEMORY,"Out of memory in line %d",lineno);
209+
ECPGraise(ECPG_OUT_OF_MEMORY,lineno,NULL);
210210
returnNULL;
211211
}
212212

@@ -634,8 +634,7 @@ ECPGexecute(struct statement * stmt)
634634

635635
default:
636636
/* Not implemented yet */
637-
register_error(ECPG_UNSUPPORTED,"Unsupported type %s on line %d.",
638-
ECPGtype_name(var->type),stmt->lineno);
637+
ECPGraise(ECPG_UNSUPPORTED,stmt->lineno,ECPGtype_name(var->type));
639638
return false;
640639
break;
641640
}
@@ -658,7 +657,7 @@ ECPGexecute(struct statement * stmt)
658657
* We have an argument but we dont have the matched up string
659658
* in the string
660659
*/
661-
register_error(ECPG_TOO_MANY_ARGUMENTS,"Too many arguments line %d.",stmt->lineno);
660+
ECPGraise(ECPG_TOO_MANY_ARGUMENTS,stmt->lineno,NULL);
662661
return false;
663662
}
664663
else
@@ -695,7 +694,7 @@ ECPGexecute(struct statement * stmt)
695694
/* Check if there are unmatched things left. */
696695
if (next_insert(copiedquery)!=NULL)
697696
{
698-
register_error(ECPG_TOO_FEW_ARGUMENTS,"Too few arguments line %d.",stmt->lineno);
697+
ECPGraise(ECPG_TOO_FEW_ARGUMENTS,stmt->lineno,NULL);
699698
return false;
700699
}
701700

@@ -743,7 +742,7 @@ ECPGexecute(struct statement * stmt)
743742
{
744743
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d\n",
745744
stmt->lineno,ntuples);
746-
register_error(ECPG_NOT_FOUND,"No data found line %d.",stmt->lineno);
745+
ECPGraise(ECPG_NOT_FOUND,stmt->lineno,NULL);
747746
status= false;
748747
break;
749748
}
@@ -757,7 +756,7 @@ ECPGexecute(struct statement * stmt)
757756
if (var==NULL)
758757
{
759758
ECPGlog("ECPGexecute line %d: Too few arguments.\n",stmt->lineno);
760-
register_error(ECPG_TOO_FEW_ARGUMENTS,"Too few arguments line %d.",stmt->lineno);
759+
ECPGraise(ECPG_TOO_FEW_ARGUMENTS,stmt->lineno,NULL);
761760
return (false);
762761
}
763762

@@ -779,7 +778,7 @@ ECPGexecute(struct statement * stmt)
779778
{
780779
ECPGlog("ECPGexecute line %d: Incorrect number of matches: %d don't fit into array of %d\n",
781780
stmt->lineno,ntuples,var->arrsize);
782-
register_error(ECPG_TOO_MANY_MATCHES,"Too many matches line %d.",stmt->lineno);
781+
ECPGraise(ECPG_TOO_MANY_MATCHES,stmt->lineno,NULL);
783782
status= false;
784783
break;
785784
}
@@ -854,7 +853,7 @@ ECPGexecute(struct statement * stmt)
854853
}
855854
break;
856855
default:
857-
register_error(ECPG_UNSUPPORTED,"Unsupported indicator type %s on line %d.",ECPGtype_name(var->ind_type),stmt->lineno);
856+
ECPGraise(ECPG_UNSUPPORTED,stmt->lineno,ECPGtype_name(var->ind_type));
858857
status= false;
859858
break;
860859
}
@@ -1058,7 +1057,7 @@ ECPGexecute(struct statement * stmt)
10581057
break;
10591058

10601059
default:
1061-
register_error(ECPG_UNSUPPORTED,"Unsupported type %s on line %d.",ECPGtype_name(var->type),stmt->lineno);
1060+
ECPGraise(ECPG_UNSUPPORTED,stmt->lineno,ECPGtype_name(var->type));
10621061
status= false;
10631062
break;
10641063
}
@@ -1068,7 +1067,7 @@ ECPGexecute(struct statement * stmt)
10681067

10691068
if (status&&var!=NULL)
10701069
{
1071-
register_error(ECPG_TOO_MANY_ARGUMENTS,"Too many arguments line %d.",stmt->lineno);
1070+
ECPGraise(ECPG_TOO_MANY_ARGUMENTS,stmt->lineno,NULL);
10721071
status= false;
10731072
}
10741073

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp