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

Commitbf5cdcf

Browse files
committed
Avoid crash in rare case of concurrent DROP
When a role being dropped contains is referenced by catalog objects thatare concurrently also being dropped, a crash can result while trying toconstruct the string that describes the objects. Suppress that byignoring objects whose descriptions are returned as NULL.The majority of relevant codesites were already cautious about thisalready; we had just missed a couple.This is an old bug, so backpatch all the way back.Reported-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/17126-21887f04508cb5c8@postgresql.org
1 parentb7299b6 commitbf5cdcf

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,6 +1109,10 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
11091109

11101110
objDesc=getObjectDescription(obj);
11111111

1112+
/* An object being dropped concurrently doesn't need to be reported */
1113+
if (objDesc==NULL)
1114+
continue;
1115+
11121116
/*
11131117
* If, at any stage of the recursive search, we reached the object via
11141118
* an AUTO, INTERNAL, PARTITION, or EXTENSION dependency, then it's
@@ -1133,23 +1137,28 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
11331137
{
11341138
char*otherDesc=getObjectDescription(&extra->dependee);
11351139

1136-
if (numReportedClient<MAX_REPORTED_DEPS)
1140+
if (otherDesc)
11371141
{
1142+
if (numReportedClient<MAX_REPORTED_DEPS)
1143+
{
1144+
/* separate entries with a newline */
1145+
if (clientdetail.len!=0)
1146+
appendStringInfoChar(&clientdetail,'\n');
1147+
appendStringInfo(&clientdetail,_("%s depends on %s"),
1148+
objDesc,otherDesc);
1149+
numReportedClient++;
1150+
}
1151+
else
1152+
numNotReportedClient++;
11381153
/* separate entries with a newline */
1139-
if (clientdetail.len!=0)
1140-
appendStringInfoChar(&clientdetail,'\n');
1141-
appendStringInfo(&clientdetail,_("%s depends on %s"),
1154+
if (logdetail.len!=0)
1155+
appendStringInfoChar(&logdetail,'\n');
1156+
appendStringInfo(&logdetail,_("%s depends on %s"),
11421157
objDesc,otherDesc);
1143-
numReportedClient++;
1158+
pfree(otherDesc);
11441159
}
11451160
else
11461161
numNotReportedClient++;
1147-
/* separate entries with a newline */
1148-
if (logdetail.len!=0)
1149-
appendStringInfoChar(&logdetail,'\n');
1150-
appendStringInfo(&logdetail,_("%s depends on %s"),
1151-
objDesc,otherDesc);
1152-
pfree(otherDesc);
11531162
ok= false;
11541163
}
11551164
else

‎src/backend/catalog/pg_shdepend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,12 @@ storeObjectDescription(StringInfo descs,
11971197
{
11981198
char*objdesc=getObjectDescription(object);
11991199

1200+
/*
1201+
* An object being dropped concurrently doesn't need to be reported.
1202+
*/
1203+
if (objdesc==NULL)
1204+
return;
1205+
12001206
/* separate entries with a newline */
12011207
if (descs->len!=0)
12021208
appendStringInfoChar(descs,'\n');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp