Skip to content

Commit

Permalink
sql: return an error in writeZoneConfig if non-system tenant
Browse files Browse the repository at this point in the history
This code path was called directly from schema change code, resulting in errors
like "relation system.zones does not exist". This commit makes the reason for
the failure clearer (tenants cannot set zone configs).

Release note: None (multitenancy work)
  • Loading branch information
asubiotto committed Jun 11, 2020
1 parent 1476c5d commit 43ba173
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/sql/set_zone_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (p *planner) SetZoneConfig(ctx context.Context, n *tree.SetZoneConfig) (pla
return nil, err
}
if !p.ExecCfg().Codec.ForSystemTenant() {
return nil, errorutil.UnsupportedWithMultiTenancy()
return nil, errorutil.UnsupportedWithMultiTenancy(multitenancyZoneCfgIssueNo)
}

var yamlConfig tree.TypedExpr
Expand Down Expand Up @@ -837,6 +837,8 @@ func validateZoneAttrsAndLocalities(
return nil
}

const multitenancyZoneCfgIssueNo = 49854

func writeZoneConfig(
ctx context.Context,
txn *kv.Txn,
Expand All @@ -846,6 +848,9 @@ func writeZoneConfig(
execCfg *ExecutorConfig,
hasNewSubzones bool,
) (numAffected int, err error) {
if !execCfg.Codec.ForSystemTenant() {
return 0, errorutil.UnsupportedWithMultiTenancy(multitenancyZoneCfgIssueNo)
}
if len(zone.Subzones) > 0 {
st := execCfg.Settings
zone.SubzoneSpans, err = GenerateSubzoneSpans(
Expand Down

0 comments on commit 43ba173

Please sign in to comment.