Skip to content

Commit 1c73c6f

Browse files
committed
sql: fix DROP REGION error messages
The format arguments were not correct, and the error was misleading for the system database. Release note: None
1 parent 2dce1ce commit 1c73c6f

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

pkg/sql/alter_database.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,25 @@ func (p *planner) AlterDatabaseDropRegion(
442442
)
443443
}
444444

445+
// The system database, once it's been made multi-region, must not be
446+
// allowed to go back.
445447
isSystemDatabase := dbDesc.ID == keys.SystemDatabaseID
446-
if allowDrop := allowDropFinalRegion.Get(&p.execCfg.Settings.SV); !allowDrop ||
447-
// The system database, once it's been made multi-region, must not be
448-
// allowed to go back.
449-
isSystemDatabase {
448+
if isSystemDatabase {
450449
return nil, pgerror.Newf(
451450
pgcode.InvalidDatabaseDefinition,
452-
"databases in this cluster must have at least 1 region",
451+
"cannot drop %s; system database must have at least 1 region",
453452
n.Region,
454-
sqlclustersettings.DefaultPrimaryRegionClusterSettingName,
453+
)
454+
}
455+
if allowDrop := allowDropFinalRegion.Get(&p.execCfg.Settings.SV); !allowDrop {
456+
return nil, errors.WithHintf(
457+
pgerror.Newf(
458+
pgcode.InvalidDatabaseDefinition,
459+
"cannot drop %s; databases in this cluster must have at least 1 region",
460+
n.Region,
461+
),
462+
"Try enabling the %s cluster setting.",
463+
allowDropFinalRegion.Name(),
455464
)
456465
}
457466

0 commit comments

Comments
 (0)