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

Commit8abd0e2

Browse files
committed
Fix volatile-safety issue in dblink's materializeQueryResult().
Some fields of the sinfo struct are modified within PG_TRY and thenreferenced within PG_CATCH, so as with recent patch to async.c, "volatile"is necessary for strict POSIX compliance; and that propagates to a coupleof subroutines as well as materializeQueryResult() itself. I think therisk of actual issues here is probably higher than in async.c, becausestoreQueryResult() is likely to get inlined into materializeQueryResult(),leaving the compiler free to conclude that its stores into sinfo fields aredead code.
1 parent3dd084c commit8abd0e2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎contrib/dblink/dblink.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ static void materializeQueryResult(FunctionCallInfo fcinfo,
8888
constchar*conname,
8989
constchar*sql,
9090
boolfail);
91-
staticPGresult*storeQueryResult(storeInfo*sinfo,PGconn*conn,constchar*sql);
92-
staticvoidstoreRow(storeInfo*sinfo,PGresult*res,boolfirst);
91+
staticPGresult*storeQueryResult(volatilestoreInfo*sinfo,PGconn*conn,constchar*sql);
92+
staticvoidstoreRow(volatilestoreInfo*sinfo,PGresult*res,boolfirst);
9393
staticremoteConn*getConnectionByName(constchar*name);
9494
staticHTAB*createConnHash(void);
9595
staticvoidcreateNewConnection(constchar*name,remoteConn*rconn);
@@ -958,13 +958,13 @@ materializeQueryResult(FunctionCallInfo fcinfo,
958958
{
959959
ReturnSetInfo*rsinfo= (ReturnSetInfo*)fcinfo->resultinfo;
960960
PGresult*volatileres=NULL;
961-
storeInfosinfo;
961+
volatilestoreInfosinfo;
962962

963963
/* prepTuplestoreResult must have been called previously */
964964
Assert(rsinfo->returnMode==SFRM_Materialize);
965965

966966
/* initialize storeInfo to empty */
967-
memset(&sinfo,0,sizeof(sinfo));
967+
memset((void*)&sinfo,0,sizeof(sinfo));
968968
sinfo.fcinfo=fcinfo;
969969

970970
PG_TRY();
@@ -1069,7 +1069,7 @@ materializeQueryResult(FunctionCallInfo fcinfo,
10691069
* Execute query, and send any result rows to sinfo->tuplestore.
10701070
*/
10711071
staticPGresult*
1072-
storeQueryResult(storeInfo*sinfo,PGconn*conn,constchar*sql)
1072+
storeQueryResult(volatilestoreInfo*sinfo,PGconn*conn,constchar*sql)
10731073
{
10741074
boolfirst= true;
10751075
intnestlevel=-1;
@@ -1137,7 +1137,7 @@ storeQueryResult(storeInfo *sinfo, PGconn *conn, const char *sql)
11371137
* (in this case the PGresult might contain either zero or one row).
11381138
*/
11391139
staticvoid
1140-
storeRow(storeInfo*sinfo,PGresult*res,boolfirst)
1140+
storeRow(volatilestoreInfo*sinfo,PGresult*res,boolfirst)
11411141
{
11421142
intnfields=PQnfields(res);
11431143
HeapTupletuple;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp