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

Commite84c019

Browse files
committed
Fix maintenance hazards caused by ill-considered use of default: cases.
Remove default cases from assorted switches over ObjectClass and somerelated enum types, so that we'll get compiler warnings when someoneadds a new enum value without accounting for it in all these places.In passing, re-order some switch cases as needed to match the declarationof enum ObjectClass. OK, that's just neatnik-ism, but I dislike codethat looks like it was assembled with the help of a dartboard.Discussion:https://postgr.es/m/20170512221010.nglatgt5azzdxjlj@alvherre.pgsql
1 parentb5b0db1 commite84c019

File tree

4 files changed

+259
-180
lines changed

4 files changed

+259
-180
lines changed

‎src/backend/catalog/dependency.c

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,10 @@ doDeletion(const ObjectAddress *object, int flags)
12041204
RemoveSchemaById(object->objectId);
12051205
break;
12061206

1207+
caseOCLASS_STATISTIC_EXT:
1208+
RemoveStatisticsById(object->objectId);
1209+
break;
1210+
12071211
caseOCLASS_TSPARSER:
12081212
RemoveTSParserById(object->objectId);
12091213
break;
@@ -1265,13 +1269,20 @@ doDeletion(const ObjectAddress *object, int flags)
12651269
DropTransformById(object->objectId);
12661270
break;
12671271

1268-
caseOCLASS_STATISTIC_EXT:
1269-
RemoveStatisticsById(object->objectId);
1272+
/*
1273+
* These global object types are not supported here.
1274+
*/
1275+
caseOCLASS_ROLE:
1276+
caseOCLASS_DATABASE:
1277+
caseOCLASS_TBLSPACE:
1278+
caseOCLASS_SUBSCRIPTION:
1279+
elog(ERROR,"global objects cannot be deleted by doDeletion");
12701280
break;
12711281

1272-
default:
1273-
elog(ERROR,"unrecognized object class: %u",
1274-
object->classId);
1282+
/*
1283+
* There's intentionally no default: case here; we want the
1284+
* compiler to warn if a new OCLASS hasn't been handled above.
1285+
*/
12751286
}
12761287
}
12771288

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp