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

Commit816b008

Browse files
author
Michael Meskes
committed
Applied patch by Itagaki Takahiro to fix incorrect status calculation in
ecpglib. Instead of parsing the statement just as ask the database server. Thispatch removes the whole client side track keeping of the current transactionstatus.
1 parent1a996d6 commit816b008

File tree

4 files changed

+4
-14
lines changed

4 files changed

+4
-14
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,23 @@ ECPGsetcommit(int lineno, const char *mode, const char *connection_name)
167167

168168
if (con->autocommit== true&&strncmp(mode,"off",strlen("off"))==0)
169169
{
170-
if (con->committed)
170+
if (PQtransactionStatus(con->connection)==PQTRANS_IDLE)
171171
{
172172
results=PQexec(con->connection,"begin transaction");
173173
if (!ecpg_check_PQresult(results,lineno,con->connection,ECPG_COMPAT_PGSQL))
174174
return false;
175175
PQclear(results);
176-
con->committed= false;
177176
}
178177
con->autocommit= false;
179178
}
180179
elseif (con->autocommit== false&&strncmp(mode,"on",strlen("on"))==0)
181180
{
182-
if (!con->committed)
181+
if (PQtransactionStatus(con->connection)!=PQTRANS_IDLE)
183182
{
184183
results=PQexec(con->connection,"commit");
185184
if (!ecpg_check_PQresult(results,lineno,con->connection,ECPG_COMPAT_PGSQL))
186185
return false;
187186
PQclear(results);
188-
con->committed= true;
189187
}
190188
con->autocommit= true;
191189
}
@@ -540,7 +538,6 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
540538
pthread_mutex_unlock(&connections_mutex);
541539
#endif
542540

543-
this->committed= true;
544541
this->autocommit=autocommit;
545542

546543
PQsetNoticeReceiver(this->connection,&ECPGnoticeReceiver, (void*)this);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,7 @@ ecpg_execute(struct statement * stmt)
14271427

14281428
/* The request has been build. */
14291429

1430-
if (stmt->connection->committed&& !stmt->connection->autocommit)
1430+
if (PQtransactionStatus(stmt->connection->connection)==PQTRANS_IDLE&& !stmt->connection->autocommit)
14311431
{
14321432
results=PQexec(stmt->connection->connection,"begin transaction");
14331433
if (!ecpg_check_PQresult(results,stmt->lineno,stmt->connection->connection,stmt->compat))
@@ -1436,7 +1436,6 @@ ecpg_execute(struct statement * stmt)
14361436
return false;
14371437
}
14381438
PQclear(results);
1439-
stmt->connection->committed= false;
14401439
}
14411440

14421441
ecpg_log("ecpg_execute on line %d: query: %s; with %d parameter(s) on connection %s\n",stmt->lineno,stmt->command,nParams,stmt->connection->name);

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ struct connection
7676
{
7777
char*name;
7878
PGconn*connection;
79-
boolcommitted;
8079
intautocommit;
8180
structECPGtype_information_cache*cache_head;
8281
structprepared_statement*prep_stmts;

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
206206
* developers have to take care themselves. However, if the command is
207207
* a begin statement, we just execute it once.
208208
*/
209-
if (con->committed&& !con->autocommit&&strncmp(transaction,"begin",5)!=0&&strncmp(transaction,"start",5)!=0)
209+
if (PQtransactionStatus(con->connection)==PQTRANS_IDLE&& !con->autocommit&&strncmp(transaction,"begin",5)!=0&&strncmp(transaction,"start",5)!=0)
210210
{
211211
res=PQexec(con->connection,"begin transaction");
212212
if (!ecpg_check_PQresult(res,lineno,con->connection,ECPG_COMPAT_PGSQL))
@@ -218,11 +218,6 @@ ECPGtrans(int lineno, const char *connection_name, const char *transaction)
218218
if (!ecpg_check_PQresult(res,lineno,con->connection,ECPG_COMPAT_PGSQL))
219219
return FALSE;
220220
PQclear(res);
221-
222-
if (strncmp(transaction,"commit",6)==0||strncmp(transaction,"rollback",8)==0)
223-
con->committed= true;
224-
else
225-
con->committed= false;
226221
}
227222

228223
return true;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp