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

Commit231c593

Browse files
author
Michael Meskes
committed
*** empty log message ***
1 parent9995ba3 commit231c593

File tree

5 files changed

+67
-71
lines changed

5 files changed

+67
-71
lines changed

‎src/interfaces/ecpg/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,3 +638,8 @@ Fri Sep 17 07:43:55 CEST 1999
638638
- Fixed bug in parsing operators.
639639
- Set ecpg version to 2.6.4
640640

641+
Fri Sep 17 18:16:34 CEST 1999
642+
643+
- Made sure sqlca is initialized everytime.
644+
- Set library version to 3.0.3
645+

‎src/interfaces/ecpg/lib/Makefile.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
# Copyright (c) 1994, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.46 1999/09/15 08:29:14 meskes Exp $
9+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/lib/Attic/Makefile.in,v 1.47 1999/09/17 18:28:10 meskes Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

1313
NAME= ecpg
1414
SO_MAJOR_VERSION= 3
15-
SO_MINOR_VERSION= 0.2
15+
SO_MINOR_VERSION= 0.3
1616

1717
SRCDIR= @top_srcdir@
1818
include$(SRCDIR)/Makefile.global

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

Lines changed: 58 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,25 @@ get_connection(const char *connection_name)
140140
returnNULL;
141141
}
142142

143+
staticbool
144+
ecpg_init(conststructconnection*con,constchar*connection_name,constintlineno)
145+
{
146+
memcpy((char*)&sqlca, (char*)&sqlca_init,sizeof(sqlca));
147+
if (con==NULL)
148+
{
149+
register_error(ECPG_NO_CONN,"No such connection %s in line %d.",connection_name ?connection_name :"NULL",lineno);
150+
return (false);
151+
}
152+
153+
return (true);
154+
}
155+
143156
staticvoid
144-
ECPGfinish(structconnection*act)
157+
ecpg_finish(structconnection*act)
145158
{
146159
if (act!=NULL)
147160
{
148-
ECPGlog("ECPGfinish: finishing %s.\n",act->name);
161+
ECPGlog("ecpg_finish: finishing %s.\n",act->name);
149162
PQfinish(act->connection);
150163
/* remove act from the list */
151164
if (act==all_connections)
@@ -166,7 +179,7 @@ ECPGfinish(struct connection * act)
166179
free(act);
167180
}
168181
else
169-
ECPGlog("ECPGfinish: called an extra time.\n");
182+
ECPGlog("ecpg_finish: called an extra time.\n");
170183
}
171184

172185
staticchar*
@@ -383,8 +396,6 @@ ECPGexecute(struct statement * stmt)
383396
PGnotify*notify;
384397
structvariable*var;
385398

386-
memcpy((char*)&sqlca, (char*)&sqlca_init,sizeof(sqlca));
387-
388399
copiedquery=ecpg_strdup(stmt->command,stmt->lineno);
389400

390401
/*
@@ -1029,11 +1040,8 @@ ECPGdo(int lineno, const char *connection_name, char *query,...)
10291040
structconnection*con=get_connection(connection_name);
10301041
boolstatus;
10311042

1032-
if (con==NULL)
1033-
{
1034-
register_error(ECPG_NO_CONN,"No such connection %s in line %d.",connection_name ?connection_name :"NULL",lineno);
1035-
return (false);
1036-
}
1043+
if (!ecpg_init(con,connection_name,lineno))
1044+
return(false);
10371045

10381046
va_start(args,query);
10391047
if (create_statement(lineno,con,&stmt,query,args)== false)
@@ -1058,11 +1066,8 @@ ECPGstatus(int lineno, const char *connection_name)
10581066
{
10591067
structconnection*con=get_connection(connection_name);
10601068

1061-
if (con==NULL)
1062-
{
1063-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
1064-
return (false);
1065-
}
1069+
if (!ecpg_init(con,connection_name,lineno))
1070+
return(false);
10661071

10671072
/* are we connected? */
10681073
if (con->connection==NULL)
@@ -1081,11 +1086,8 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
10811086
PGresult*res;
10821087
structconnection*con=get_connection(connection_name);
10831088

1084-
if (con==NULL)
1085-
{
1086-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
1087-
return (false);
1088-
}
1089+
if (!ecpg_init(con,connection_name,lineno))
1090+
return(false);
10891091

10901092
ECPGlog("ECPGtrans line %d action = %s connection = %s\n",lineno,transaction,con->name);
10911093

@@ -1124,41 +1126,36 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
11241126
structconnection*con=get_connection(connection_name);
11251127
PGresult*results;
11261128

1127-
if (con)
1129+
if (!ecpg_init(con,connection_name,lineno))
1130+
return(false);
1131+
1132+
if (con->autocommit== true&&strncmp(mode,"OFF",strlen("OFF"))==0)
11281133
{
1129-
if (con->autocommit== true&&strncmp(mode,"OFF",strlen("OFF"))==0)
1134+
if (con->committed)
11301135
{
1131-
if (con->committed)
1136+
if ((results=PQexec(con->connection,"begin transaction"))==NULL)
11321137
{
1133-
if ((results=PQexec(con->connection,"begin transaction"))==NULL)
1134-
{
1135-
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
1136-
return false;
1137-
}
1138-
PQclear(results);
1139-
con->committed= false;
1138+
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
1139+
return false;
11401140
}
1141-
con->autocommit= false;
1141+
PQclear(results);
1142+
con->committed= false;
11421143
}
1143-
elseif (con->autocommit== false&&strncmp(mode,"ON",strlen("ON"))==0)
1144+
con->autocommit= false;
1145+
}
1146+
elseif (con->autocommit== false&&strncmp(mode,"ON",strlen("ON"))==0)
1147+
{
1148+
if (!con->committed)
11441149
{
1145-
if (!con->committed)
1150+
if ((results=PQexec(con->connection,"commit"))==NULL)
11461151
{
1147-
if ((results=PQexec(con->connection,"commit"))==NULL)
1148-
{
1149-
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
1150-
return false;
1151-
}
1152-
PQclear(results);
1153-
con->committed= true;
1152+
register_error(ECPG_TRANS,"Error in transaction processing line %d.",lineno);
1153+
return false;
11541154
}
1155-
con->autocommit= true;
1155+
PQclear(results);
1156+
con->committed= true;
11561157
}
1157-
}
1158-
else
1159-
{
1160-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
1161-
return false;
1158+
con->autocommit= true;
11621159
}
11631160

11641161
return true;
@@ -1169,24 +1166,22 @@ ECPGsetconn(int lineno, const char *connection_name)
11691166
{
11701167
structconnection*con=get_connection(connection_name);
11711168

1172-
if (con)
1173-
{
1174-
actual_connection=con;
1175-
return true;
1176-
}
1177-
else
1178-
{
1179-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
1180-
return false;
1181-
}
1169+
if (!ecpg_init(con,connection_name,lineno))
1170+
return(false);
1171+
1172+
actual_connection=con;
1173+
return true;
11821174
}
11831175

11841176
bool
11851177
ECPGconnect(intlineno,constchar*dbname,constchar*user,constchar*passwd,constchar*connection_name,intautocommit)
11861178
{
1187-
structconnection*this= (structconnection*)ecpg_alloc(sizeof(structconnection),lineno);
1179+
structconnection*this;
11881180

1189-
if (!this)
1181+
1182+
memcpy((char*)&sqlca, (char*)&sqlca_init,sizeof(sqlca));
1183+
1184+
if ((this= (structconnection*)ecpg_alloc(sizeof(structconnection),lineno))==NULL)
11901185
return false;
11911186

11921187
if (dbname==NULL&&connection_name==NULL)
@@ -1213,7 +1208,7 @@ ECPGconnect(int lineno, const char *dbname, const char *user, const char *passwd
12131208

12141209
if (PQstatus(this->connection)==CONNECTION_BAD)
12151210
{
1216-
ECPGfinish(this);
1211+
ecpg_finish(this);
12171212
ECPGlog("connect: could not open database %s %s%s in line %d\n",dbname ?dbname :"<DEFAULT>",user ?"for user " :"",user ?user :"",lineno);
12181213
register_error(ECPG_CONNECT,"connect: could not open database %s.",dbname ?dbname :"<DEFAULT>");
12191214
return false;
@@ -1237,21 +1232,17 @@ ECPGdisconnect(int lineno, const char *connection_name)
12371232
structconnection*f=con;
12381233

12391234
con=con->next;
1240-
ECPGfinish(f);
1235+
ecpg_finish(f);
12411236
}
12421237
}
12431238
else
12441239
{
12451240
con=get_connection(connection_name);
12461241

1247-
if (con==NULL)
1248-
{
1249-
ECPGlog("disconnect: not connected to connection %s\n",connection_name ?connection_name :"NULL");
1250-
register_error(ECPG_NO_CONN,"No such connection %s in line %d",connection_name ?connection_name :"NULL",lineno);
1251-
return false;
1252-
}
1242+
if (!ecpg_init(con,connection_name,lineno))
1243+
return(false);
12531244
else
1254-
ECPGfinish(con);
1245+
ecpg_finish(con);
12551246
}
12561247

12571248
return true;

‎src/interfaces/ecpg/test/test2.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ exec sql end declare section;
117117
exec sql commit;
118118

119119
strcpy(msg, "disconnect");
120-
121120
exec sql disconnect;
121+
122122
if (dbgs != NULL)
123123
fclose(dbgs);
124124

‎src/interfaces/ecpg/test/test3.pgc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ exec sql end declare section;
109109
exec sql commit;
110110

111111
strcpy(msg, "disconnect");
112-
113112
exec sql disconnect;
113+
114114
if (dbgs != NULL)
115115
fclose(dbgs);
116116

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp