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

Commitdabda64

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 parent168a809 commitdabda64

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
@@ -94,8 +94,8 @@ static void materializeQueryResult(FunctionCallInfo fcinfo,
9494
constchar*conname,
9595
constchar*sql,
9696
boolfail);
97-
staticPGresult*storeQueryResult(storeInfo*sinfo,PGconn*conn,constchar*sql);
98-
staticvoidstoreRow(storeInfo*sinfo,PGresult*res,boolfirst);
97+
staticPGresult*storeQueryResult(volatilestoreInfo*sinfo,PGconn*conn,constchar*sql);
98+
staticvoidstoreRow(volatilestoreInfo*sinfo,PGresult*res,boolfirst);
9999
staticremoteConn*getConnectionByName(constchar*name);
100100
staticHTAB*createConnHash(void);
101101
staticvoidcreateNewConnection(constchar*name,remoteConn*rconn);
@@ -966,13 +966,13 @@ materializeQueryResult(FunctionCallInfo fcinfo,
966966
{
967967
ReturnSetInfo*rsinfo= (ReturnSetInfo*)fcinfo->resultinfo;
968968
PGresult*volatileres=NULL;
969-
storeInfosinfo;
969+
volatilestoreInfosinfo;
970970

971971
/* prepTuplestoreResult must have been called previously */
972972
Assert(rsinfo->returnMode==SFRM_Materialize);
973973

974974
/* initialize storeInfo to empty */
975-
memset(&sinfo,0,sizeof(sinfo));
975+
memset((void*)&sinfo,0,sizeof(sinfo));
976976
sinfo.fcinfo=fcinfo;
977977

978978
PG_TRY();
@@ -1077,7 +1077,7 @@ materializeQueryResult(FunctionCallInfo fcinfo,
10771077
* Execute query, and send any result rows to sinfo->tuplestore.
10781078
*/
10791079
staticPGresult*
1080-
storeQueryResult(storeInfo*sinfo,PGconn*conn,constchar*sql)
1080+
storeQueryResult(volatilestoreInfo*sinfo,PGconn*conn,constchar*sql)
10811081
{
10821082
boolfirst= true;
10831083
intnestlevel=-1;
@@ -1145,7 +1145,7 @@ storeQueryResult(storeInfo *sinfo, PGconn *conn, const char *sql)
11451145
* (in this case the PGresult might contain either zero or one row).
11461146
*/
11471147
staticvoid
1148-
storeRow(storeInfo*sinfo,PGresult*res,boolfirst)
1148+
storeRow(volatilestoreInfo*sinfo,PGresult*res,boolfirst)
11491149
{
11501150
intnfields=PQnfields(res);
11511151
HeapTupletuple;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp