-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schemachanger: zone config refactor #129065
Conversation
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
4fc5b47
to
5eeeb4c
Compare
5eeeb4c
to
da03426
Compare
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR? 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
f4f6915
to
1f4f1f4
Compare
Ready for review -- the unit tests failing are just error message diffs; will fix! |
I'm still not entirely satisfied -- trying to think about what i can do to |
2394fd6
to
d96da2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this refactor—it makes the applyZoneConfig
functions easier to follow. There’s still some code duplication between handling index and table/database objects, but I think that's unavoidable.
Reviewed 3 of 7 files at r1, all commit messages.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @annrpom)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/configure_zone.go
line 41 at r1 (raw file):
// - Partition/row // - System Ranges zoneConfigObject := astToZoneConfigObject(b, n)
I suggest returning the object along with an error. For unsupported modes, we can provide more meaningful error messages. For example, when n.Discard
is true, we previously returned an error stating "CONFIGURE ZONE DISCARD is not supported in the DSC." Retaining these specific errors would be beneficial, and returning the error will allow you to do that.
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/database_zone_config.go
line 66 at r1 (raw file):
return sqlerrors.NewInsufficientPrivilegeOnDescriptorError(b.CurrentUser(), reqNonAdminPrivs, string(catalog.Database), mustRetrieveNamespaceElem(b, dbElem.DatabaseID).Name)
Will we have a namespace element for a database? I thought those only made sense in the context of table-specific elements.
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go
line 1705 at r1 (raw file):
// mustRetrievePhysicalTableElem will resolve a tableID to a physical table // element. A "physical" table element includes tables, views, and sequences. func mustRetrievePhysicalTableElem(b BuildCtx, tableID catid.DescID) scpb.Element {
nit: I suggest renaming tableID
to descID
or something similar. It won't always be a table ID; for example, it could represent a view or sequence ID.
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/table_zone_config.go
line 71 at r1 (raw file):
reqNonAdminPrivs := []privilege.Kind{privilege.ZONECONFIG, privilege.CREATE} if zs.Database == "system" {
Will ever be true for table zone configs? I thought zs.Database
would be an empty string.
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
line 71 at r1 (raw file):
// getSeqNum returns the sequence number of the zone config object. getSeqNum() uint32
Do we use this function anywhere? I couldn't find any usages of it myself.
d96da2a
to
64ba635
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @spilchen)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/configure_zone.go
line 41 at r1 (raw file):
Previously, spilchen wrote…
I suggest returning the object along with an error. For unsupported modes, we can provide more meaningful error messages. For example, when
n.Discard
is true, we previously returned an error stating "CONFIGURE ZONE DISCARD is not supported in the DSC." Retaining these specific errors would be beneficial, and returning the error will allow you to do that.
done -- good point
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/database_zone_config.go
line 66 at r1 (raw file):
Previously, spilchen wrote…
Will we have a namespace element for a database? I thought those only made sense in the context of table-specific elements.
yes; see
cockroach/pkg/sql/catalog/dbdesc/database_desc.go
Lines 594 to 597 in eef5580
// SkipNamespace implements the descriptor interface. | |
func (desc *immutable) SkipNamespace() bool { | |
return false | |
} |
cockroach/pkg/sql/schemachanger/scdecomp/decomp.go
Lines 91 to 98 in 4625d8b
if !w.desc.SkipNamespace() { | |
w.ev(scpb.Status_PUBLIC, &scpb.Namespace{ | |
DatabaseID: w.desc.GetParentID(), | |
SchemaID: w.desc.GetParentSchemaID(), | |
DescriptorID: w.desc.GetID(), | |
Name: w.desc.GetName(), | |
}) | |
} |
fwiw, though: the namespace element for a db is just the DescriptorID
and Name
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/helpers.go
line 1705 at r1 (raw file):
Previously, spilchen wrote…
nit: I suggest renaming
tableID
todescID
or something similar. It won't always be a table ID; for example, it could represent a view or sequence ID.
done!
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/table_zone_config.go
line 71 at r1 (raw file):
Previously, spilchen wrote…
Will ever be true for table zone configs? I thought
zs.Database
would be an empty string.
done -- bad copy & paste
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/zone_config_helpers.go
line 71 at r1 (raw file):
Previously, spilchen wrote…
Do we use this function anywhere? I couldn't find any usages of it myself.
done -- removed since no longer used!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r2, all commit messages.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @annrpom)
pkg/sql/schemachanger/scbuild/internal/scbuildstmt/database_zone_config.go
line 66 at r1 (raw file):
Previously, annrpom (annie pompa) wrote…
yes; see
andcockroach/pkg/sql/catalog/dbdesc/database_desc.go
Lines 594 to 597 in eef5580
// SkipNamespace implements the descriptor interface. func (desc *immutable) SkipNamespace() bool { return false } cockroach/pkg/sql/schemachanger/scdecomp/decomp.go
Lines 91 to 98 in 4625d8b
if !w.desc.SkipNamespace() { w.ev(scpb.Status_PUBLIC, &scpb.Namespace{ DatabaseID: w.desc.GetParentID(), SchemaID: w.desc.GetParentSchemaID(), DescriptorID: w.desc.GetID(), Name: w.desc.GetName(), }) } fwiw, though: the namespace element for a db is just the
DescriptorID
andName
Thanks for the explanation.
This patch refactors some of the zone config logic in the DSC. Release note: None
64ba635
to
22d89ca
Compare
Needed to rebase to get a test-flake-fix in! TFTR! ('-')7 |
bors r=spilchen |
This patch refactors some of the zone config logic
in the DSC.
Epic: CRDB-31473
Informs: #129889
Release note: None