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

Commite0eaeaf

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 parent71aeaf2 commite0eaeaf

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
@@ -905,6 +905,10 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
905905

906906
objDesc=getObjectDescription(obj);
907907

908+
/* An object being dropped concurrently doesn't need to be reported */
909+
if (objDesc==NULL)
910+
continue;
911+
908912
/*
909913
* If, at any stage of the recursive search, we reached the object via
910914
* an AUTO, INTERNAL, or EXTENSION dependency, then it's okay to
@@ -928,23 +932,28 @@ reportDependentObjects(const ObjectAddresses *targetObjects,
928932
{
929933
char*otherDesc=getObjectDescription(&extra->dependee);
930934

931-
if (numReportedClient<MAX_REPORTED_DEPS)
935+
if (otherDesc)
932936
{
937+
if (numReportedClient<MAX_REPORTED_DEPS)
938+
{
939+
/* separate entries with a newline */
940+
if (clientdetail.len!=0)
941+
appendStringInfoChar(&clientdetail,'\n');
942+
appendStringInfo(&clientdetail,_("%s depends on %s"),
943+
objDesc,otherDesc);
944+
numReportedClient++;
945+
}
946+
else
947+
numNotReportedClient++;
933948
/* separate entries with a newline */
934-
if (clientdetail.len!=0)
935-
appendStringInfoChar(&clientdetail,'\n');
936-
appendStringInfo(&clientdetail,_("%s depends on %s"),
949+
if (logdetail.len!=0)
950+
appendStringInfoChar(&logdetail,'\n');
951+
appendStringInfo(&logdetail,_("%s depends on %s"),
937952
objDesc,otherDesc);
938-
numReportedClient++;
953+
pfree(otherDesc);
939954
}
940955
else
941956
numNotReportedClient++;
942-
/* separate entries with a newline */
943-
if (logdetail.len!=0)
944-
appendStringInfoChar(&logdetail,'\n');
945-
appendStringInfo(&logdetail,_("%s depends on %s"),
946-
objDesc,otherDesc);
947-
pfree(otherDesc);
948957
ok= false;
949958
}
950959
else

‎src/backend/catalog/pg_shdepend.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,6 +1073,12 @@ storeObjectDescription(StringInfo descs,
10731073
{
10741074
char*objdesc=getObjectDescription(object);
10751075

1076+
/*
1077+
* An object being dropped concurrently doesn't need to be reported.
1078+
*/
1079+
if (objdesc==NULL)
1080+
return;
1081+
10761082
/* separate entries with a newline */
10771083
if (descs->len!=0)
10781084
appendStringInfoChar(descs,'\n');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp