github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/sql/sem/tree/data_placement.go (about) 1 // Copyright 2020 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 package tree 12 13 import "github.com/cockroachdb/errors" 14 15 // DataPlacement represents the desired data placement strategy for a given 16 // database. 17 type DataPlacement uint32 18 19 const ( 20 // DataPlacementUnspecified indicates an unspecified placement policy. 21 // This will get translated to the default value when persisted. 22 DataPlacementUnspecified DataPlacement = iota 23 // DataPlacementDefault indicates specified default data placement policy, 24 DataPlacementDefault 25 // DataPlacementRestricted indicates the database will not use non-voters for 26 // REGIONAL BY [TABLE | ROW] tables. 27 DataPlacementRestricted 28 ) 29 30 // Format implements the NodeFormatter interface. 31 func (node *DataPlacement) Format(ctx *FmtCtx) { 32 switch *node { 33 case DataPlacementRestricted: 34 ctx.WriteString("PLACEMENT RESTRICTED") 35 case DataPlacementDefault: 36 ctx.WriteString("PLACEMENT DEFAULT") 37 case DataPlacementUnspecified: 38 default: 39 panic(errors.AssertionFailedf("unknown data placement strategy: %d", *node)) 40 } 41 } 42 43 // TelemetryName returns a representation of DataPlacement suitable for 44 // telemetry. 45 func (node *DataPlacement) TelemetryName() string { 46 switch *node { 47 case DataPlacementRestricted: 48 return "restricted" 49 case DataPlacementDefault: 50 return "default" 51 case DataPlacementUnspecified: 52 return "unspecified" 53 default: 54 panic(errors.AssertionFailedf("unknown data placement: %d", *node)) 55 } 56 }