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

Commitdf6e504

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parentadf5422 commitdf6e504

File tree

4 files changed

+107
-49
lines changed

4 files changed

+107
-49
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,5 +544,17 @@ Mon Mar 22 19:22:38 CET 1999
544544

545545
- Fixed incorrect password entry in parser.
546546
- Made no_auto_trans available for each connection seperately.
547+
548+
Sat Apr 10 20:10:50 CEST 1999
549+
550+
- Allow ecpg handle a floating point constants.
551+
- Fix ecpg runtime library memory leak (patch by Masaaki Sakaida).
552+
553+
Mon Apr 12 17:56:14 CEST 1999
554+
555+
- Fixed ECPG variable handling.
556+
- Make no_auto_trans be accessible via SET command.
557+
- Do not eat comments so line numbering should be correct.
547558
- Set library version to 3.0.0
548559
- Set ecpg version to 2.6.0
560+

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ extern"C"
77

88
voidECPGdebug(int,FILE*);
99
boolECPGstatus(int,constchar*);
10+
boolECPGsetcommit(int,constchar*,constchar*);
1011
boolECPGsetconn(int,constchar*);
1112
boolECPGconnect(int,constchar*,constchar*,constchar*,constchar*,int);
1213
boolECPGdo(int,constchar*,char*,...);

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

Lines changed: 85 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,34 @@ create_statement(int lineno, struct connection *connection, struct statement **
370370
return (true);
371371
}
372372

373+
staticvoid
374+
free_variable(structvariable*var)
375+
{
376+
structvariable*var_next;
377+
378+
if(var== (structvariable*)NULL )
379+
return;
380+
var_next=var->next;
381+
free(var);
382+
383+
while(var_next)
384+
{
385+
var=var_next;
386+
var_next=var->next;
387+
free(var);
388+
}
389+
}
390+
391+
staticvoid
392+
free_statement(structstatement*stmt)
393+
{
394+
if(stmt== (structstatement*)NULL )
395+
return;
396+
free_variable(stmt->inlist);
397+
free_variable(stmt->outlist);
398+
free(stmt);
399+
}
400+
373401
staticchar*
374402
next_insert(char*text)
375403
{
@@ -981,7 +1009,6 @@ ECPGexecute(struct statement * stmt)
9811009
status= false;
9821010
}
9831011

984-
PQclear(results);
9851012
break;
9861013
casePGRES_EMPTY_QUERY:
9871014
/* do nothing */
@@ -1017,6 +1044,7 @@ ECPGexecute(struct statement * stmt)
10171044
status= false;
10181045
break;
10191046
}
1047+
PQclear(results);
10201048
}
10211049

10221050
/* check for asynchronous returns */
@@ -1037,10 +1065,11 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10371065
va_listargs;
10381066
structstatement*stmt;
10391067
structconnection*con=get_connection(connection_name);
1068+
boolstatus;
10401069

10411070
if (con==NULL)
10421071
{
1043-
register_error(ECPG_NO_CONN,"No such connection %s in line %d.",connection_name,lineno);
1072+
register_error(ECPG_NO_CONN,"No such connection %s in line %d.",connection_name ?connection_name :"NULL",lineno);
10441073
return (false);
10451074
}
10461075

@@ -1057,7 +1086,9 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10571086
return false;
10581087
}
10591088

1060-
return (ECPGexecute(stmt));
1089+
status=ECPGexecute(stmt);
1090+
free_statement(stmt);
1091+
return (status);
10611092
}
10621093

10631094
bool
@@ -1067,7 +1098,7 @@ ECPGstatus(int lineno, const char *connection_name)
10671098

10681099
if (con==NULL)
10691100
{
1070-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name,lineno);
1101+
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
10711102
return (false);
10721103
}
10731104

@@ -1090,7 +1121,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
10901121

10911122
if (con==NULL)
10921123
{
1093-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name,lineno);
1124+
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
10941125
return (false);
10951126
}
10961127

@@ -1125,6 +1156,52 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
11251156
return true;
11261157
}
11271158

1159+
bool
1160+
ECPGsetcommit(intlineno,constchar*mode,constchar*connection_name)
1161+
{
1162+
structconnection*con=get_connection(connection_name);
1163+
PGresult*results;
1164+
1165+
if (con)
1166+
{
1167+
if (con->no_auto_trans== true&&strncmp(mode,"ON",strlen("ON"))==0)
1168+
{
1169+
if (con->committed)
1170+
{
1171+
if ((results=PQexec(con->connection,"begin transaction"))==NULL)
1172+
{
1173+
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
1174+
return false;
1175+
}
1176+
PQclear(results);
1177+
con->committed= false;
1178+
}
1179+
con->no_auto_trans= false;
1180+
}
1181+
elseif (con->no_auto_trans== false&&strncmp(mode,"OFF",strlen("OFF"))==0)
1182+
{
1183+
if (!con->committed)
1184+
{
1185+
if ((results=PQexec(con->connection,"commit"))==NULL)
1186+
{
1187+
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
1188+
return false;
1189+
}
1190+
PQclear(results);
1191+
con->committed= true;
1192+
}
1193+
con->no_auto_trans= true;
1194+
}
1195+
}
1196+
else
1197+
{
1198+
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
1199+
return false;
1200+
}
1201+
1202+
return true;
1203+
}
1204+
11281205
bool
11291206
ECPGsetconn(intlineno,constchar*connection_name)
11301207
{
@@ -1137,7 +1214,7 @@ ECPGsetconn(int lineno, const char *connection_name)
11371214
}
11381215
else
11391216
{
1140-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name,lineno);
1217+
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
11411218
return false;
11421219
}
11431220
}
@@ -1207,8 +1284,8 @@ ECPGdisconnect(int lineno, const char *connection_name)
12071284

12081285
if (con==NULL)
12091286
{
1210-
ECPGlog("disconnect: not connected to connection %s\n",connection_name);
1211-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name,lineno);
1287+
ECPGlog("disconnect: not connected to connection %s\n",connection_name ?connection_name :"NULL");
1288+
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
12121289
return false;
12131290
}
12141291
else

‎src/interfaces/ecpg/preproc/pgc.l

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,18 @@ cppline{space}*#.*(\\{space}*\n)*\n*
178178
%%
179179
<SQL>{comment}{/* ignore */ }
180180

181-
{xcline}{/* ignore */ }
181+
{xcline}{ECHO; }
182182

183-
<xc>{xcstar}{/* ignore */ }
183+
<xc>{xcstar}{ECHO; }
184184
{xcstart}{
185185
before_comment = YYSTATE;
186+
ECHO;
186187
BEGIN(xc);
187188
}
188189

189-
<xc>{xcstop}{BEGIN(before_comment); }
190+
<xc>{xcstop}{ECHO;BEGIN(before_comment); }
190191

191-
<xc>{xcinside}{/* ignore */ }
192+
<xc>{xcinside}{ECHO; }
192193

193194
<SQL>{xbstart}{
194195
BEGIN(xb);
@@ -376,7 +377,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
376377
}
377378
}
378379
}
379-
<SQL>{integer}/{space}*-{number}{
380+
<C,SQL>{integer}/{space}*-{number}{
380381
char* endptr;
381382

382383
BEGIN(xm);
@@ -393,7 +394,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
393394
}
394395
return ICONST;
395396
}
396-
<SQL>{real}/{space}*-{number} {
397+
<C,SQL>{real}/{space}*-{number} {
397398
char* endptr;
398399

399400
BEGIN(xm);
@@ -403,7 +404,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
403404
yyerror("ERROR: Bad float8 input");
404405
return FCONST;
405406
}
406-
<SQL>{integer}{
407+
<C,SQL>{integer}{
407408
char* endptr;
408409

409410
errno =0;
@@ -419,7 +420,7 @@ cppline{space}*#.*(\\{space}*\n)*\n*
419420
}
420421
return ICONST;
421422
}
422-
<SQL>{real}{
423+
<C,SQL>{real}{
423424
char* endptr;
424425

425426
errno =0;
@@ -428,39 +429,6 @@ cppline{space}*#.*(\\{space}*\n)*\n*
428429
yyerror("ERROR: Bad float input");
429430
return FCONST;
430431
}
431-
<C>{integer}/{space}*-{number}{
432-
char* endptr;
433-
434-
BEGIN(xm);
435-
errno =0;
436-
yylval.ival =strtol((char *)yytext,&endptr,10);
437-
if (*endptr !='\0' || errno == ERANGE)
438-
{
439-
errno =0;
440-
yylval.dval =strtod(((char *)yytext),&endptr);
441-
if (*endptr !='\0' || errno == ERANGE)
442-
yyerror("ERROR: Bad integer input");
443-
yyerror("WARNING: Integer input is out of range; promoted to float");
444-
return FCONST;
445-
}
446-
return ICONST;
447-
}
448-
<C>{integer}{
449-
char* endptr;
450-
451-
errno =0;
452-
yylval.ival =strtol((char *)yytext,&endptr,10);
453-
if (*endptr !='\0' || errno == ERANGE)
454-
{
455-
errno =0;
456-
yylval.dval =strtod(((char *)yytext),&endptr);
457-
if (*endptr !='\0' || errno == ERANGE)
458-
yyerror("ERROR: Bad integer input");
459-
yyerror("WARNING: Integer input is out of range; promoted to float");
460-
return FCONST;
461-
}
462-
return ICONST;
463-
}
464432
<SQL>:{identifier}(("->"|\.){identifier})*{
465433
yylval.str =mm_strdup((char*)yytext+1);
466434
return(CVARIABLE);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp