-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
alter_statement_statistics_index_recommendations.go
42 lines (37 loc) · 1.33 KB
/
alter_statement_statistics_index_recommendations.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2022 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package upgrades
import (
"context"
"github.com/cockroachdb/cockroach/pkg/clusterversion"
"github.com/cockroachdb/cockroach/pkg/jobs"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/sql/catalog/systemschema"
"github.com/cockroachdb/cockroach/pkg/upgrade"
)
const addIndexRecommendationsCol = `
ALTER TABLE system.statement_statistics
ADD COLUMN IF NOT EXISTS "index_recommendations" STRING[]
FAMILY "primary"
`
func alterSystemStatementStatisticsAddIndexRecommendations(
ctx context.Context, cs clusterversion.ClusterVersion, d upgrade.TenantDeps, _ *jobs.Job,
) error {
op := operation{
name: "add-statement-statistics-index-recommendations-col",
schemaList: []string{"index_rec"},
query: addIndexRecommendationsCol,
schemaExistsFn: hasColumn,
}
if err := migrateTable(ctx, cs, d, op, keys.StatementStatisticsTableID, systemschema.StatementStatisticsTable); err != nil {
return err
}
return nil
}