Skip to content

Commit

Permalink
schemachanger: remove mr fallbacks in schema changer
Browse files Browse the repository at this point in the history
Draft
  • Loading branch information
annrpom committed Oct 14, 2024
1 parent ea1419c commit 789b610
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ func alterTableAddColumn(
b BuildCtx, tn *tree.TableName, tbl *scpb.Table, stmt tree.Statement, t *tree.AlterTableAddColumn,
) {
d := t.ColumnDef
// We don't support handling zone config related properties for tables, so
// throw an unsupported error.
fallBackIfSubZoneConfigExists(b, t, tbl.TableID)
fallBackIfRegionalByRowTable(b, t, tbl.TableID)

// Check column non-existence.
{
elts := b.ResolveColumn(tbl.TableID, d.Name, ResolveParams{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ func alterPrimaryKey(
// be removed to fully support `ALTER PRIMARY KEY`.
fallBackIfShardedIndexExists(b, t, tbl.TableID)
fallBackIfPartitionedIndexExists(b, t, tbl.TableID)
fallBackIfRegionalByRowTable(b, t.n, tbl.TableID)
fallBackIfSubZoneConfigExists(b, t.n, tbl.TableID)

inflatedChain := getInflatedPrimaryIndexChain(b, tbl.TableID)
if !haveSameIndexColsByKind(b, tbl.TableID, inflatedChain.oldSpec.primary.IndexID,
Expand Down Expand Up @@ -434,18 +432,6 @@ func fallBackIfShardedIndexExists(b BuildCtx, t alterPrimaryKeySpec, tableID cat
})
}

// fallBackIfRegionalByRowTable panics with an unimplemented
// error if it's a REGIONAL BY ROW table because we need to
// include the implicit REGION column when constructing the
// new primary key.
func fallBackIfRegionalByRowTable(b BuildCtx, t tree.NodeFormatter, tableID catid.DescID) {
_, _, rbrElem := scpb.FindTableLocalityRegionalByRow(b.QueryByID(tableID))
if rbrElem != nil {
panic(scerrors.NotImplementedErrorf(t, "ALTER PRIMARY KEY on a REGIONAL BY ROW table "+
"is not yet supported."))
}
}

func mustRetrieveCurrentPrimaryIndexElement(
b BuildCtx, tableID catid.DescID,
) (res *scpb.PrimaryIndex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ func alterTableDropColumn(
stmt tree.Statement,
n *tree.AlterTableDropColumn,
) {
fallBackIfSubZoneConfigExists(b, n, tbl.TableID)
fallBackIfRegionalByRowTable(b, n, tbl.TableID)
checkSafeUpdatesForDropColumn(b)
checkRegionalByRowColumnConflict(b, tbl, n)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ func CreateIndex(b BuildCtx, n *tree.CreateIndex) {
panic(pgerror.Newf(pgcode.DuplicateRelation, "index with name %q already exists", n.Name))
}
}
// We don't support handling zone config related properties for tables required
// for regional by row tables.
if _, _, tbl := scpb.FindTable(relationElements); tbl != nil {
fallBackIfRegionalByRowTable(b, n, tbl.TableID)
}
_, _, partitioning := scpb.FindTablePartitioning(relationElements)
if partitioning != nil && n.PartitionByIndex != nil &&
n.PartitionByIndex.ContainsPartitions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ func maybeDropIndex(
if sie == nil {
panic(errors.AssertionFailedf("programming error: cannot find secondary index element."))
}
// We don't support handling zone config related properties for tables, so
// throw an unsupported error.
fallBackIfSubZoneConfigExists(b, nil, sie.TableID)
panicIfSchemaChangeIsDisallowed(b.QueryByID(sie.TableID), n)
// Cannot drop the index if not CASCADE and a unique constraint depends on it.
if n.DropBehavior != tree.DropCascade && sie.IsUnique && !sie.IsCreatedExplicitly {
Expand Down
14 changes: 0 additions & 14 deletions pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -858,20 +858,6 @@ func makeSwapIndexSpec(
return in, temp
}

// fallBackIfSubZoneConfigExists determines if the table has a subzone
// config. Normally this logic is used to limit index related operations,
// since dropping indexes will need to remove entries of sub zones from
// the zone config.
func fallBackIfSubZoneConfigExists(b BuildCtx, n tree.NodeFormatter, id catid.DescID) {
{
tableElts := b.QueryByID(id)
if _, _, elem := scpb.FindIndexZoneConfig(tableElts); elem != nil {
panic(scerrors.NotImplementedErrorf(n,
"sub zone configs are not supported"))
}
}
}

// ExtractColumnIDsInExpr extracts column IDs used in expr. It's similar to
// schemaexpr.ExtractColumnIDs but this function can also extract columns
// added in the same transaction (e.g. for `ADD COLUMN j INT CHECK (j > 0);`,
Expand Down

0 comments on commit 789b610

Please sign in to comment.