sql: implement alter sequence/view owner#59049
Conversation
arulajmani
left a comment
There was a problem hiding this comment.
Some minor comments, but otherwise looks good
Reviewed 2 of 14 files at r1.
Reviewable status:complete! 0 of 0 LGTMs obtained (waiting on @pbardea, @RichardJCai, and @solongordon)
pkg/ccl/importccl/read_import_pgdump.go, line 543 at r1 (raw file):
// the auto stats stuff will pick up the changes and run if needed. case *tree.AlterTableOwner: // ignore
Why'd this move?
pkg/sql/alter_table_owner.go, line 25 at r1 (raw file):
type alterTableOwnerNode struct { owner security.SQLUsername tableDesc *tabledesc.Mutable
nit: s/tableDesc/desc
pkg/sql/alter_table_owner.go, line 40 at r1 (raw file):
tn := n.Name.ToTableName() requiredTableKind := tree.ResolveAnyTableKind
This deserves a comment indicating that an ALTER TABLE OWNER applies to views and sequences as well, and that's why we're resolving any descriptor as opposed to a table desc explicitly.
pkg/sql/alter_table_owner.go, line 94 at r1 (raw file):
// checkCanAlterTableAndSetNewOwner handles privilege checking and setting new owner. // Called in ALTER TABLE and REASSIGN OWNED BY.
nit: comment over 80 characters. Also, could you remove the "Called in ALTER ..." seems more effort to maintain than its usefulness.
pkg/sql/logictest/testdata/logic_test/alter_view_owner, line 44 at r1 (raw file):
# MATERIALIZED keyword must be present to change the owner of materialized views. statement error pq: "mvx" is a materialized view
What if you say ALTER TABLE mvx OWNER TO ...? Does that work with Postgres? Either way, it's worth adding a test for that case
RichardJCai
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @arulajmani, @pbardea, and @solongordon)
pkg/ccl/importccl/read_import_pgdump.go, line 543 at r1 (raw file):
Previously, arulajmani (Arul Ajmani) wrote…
Why'd this move?
I split this out from being a general AlterTable subcommand to its own statement (so it could also used for VIEWS/SEQUENCES) so it no longer a subcase of *tree.AlterTable.
Not sure if this case ignore is actually needed though.
pkg/sql/alter_table_owner.go, line 40 at r1 (raw file):
Previously, arulajmani (Arul Ajmani) wrote…
This deserves a comment indicating that an ALTER TABLE OWNER applies to views and sequences as well, and that's why we're resolving any descriptor as opposed to a table desc explicitly.
Done.
pkg/sql/logictest/testdata/logic_test/alter_view_owner, line 44 at r1 (raw file):
Previously, arulajmani (Arul Ajmani) wrote…
What if you say
ALTER TABLE mvx OWNER TO ...? Does that work with Postgres? Either way, it's worth adding a test for that case
Good call! That indeed does work with Postgres, adding a case.
ca27b89 to
507d06a
Compare
arulajmani
left a comment
There was a problem hiding this comment.
Reviewable status:
complete! 1 of 0 LGTMs obtained (waiting on @pbardea, @RichardJCai, and @solongordon)
pkg/ccl/importccl/read_import_pgdump.go, line 543 at r1 (raw file):
Previously, RichardJCai (Richard Cai) wrote…
I split this out from being a general AlterTable subcommand to its own statement (so it could also used for VIEWS/SEQUENCES) so it no longer a subcase of *tree.AlterTable.
Not sure if this case ignore is actually needed though.
Ah makes sense, I was just curious.
041ff8a to
cd48947
Compare
Release note (sql change): Add support for ALTER VIEW/SEQUENCE OWNER TO commands.
cd48947 to
3f69983
Compare
|
bors r=arulajmani |
|
Build succeeded: |
Resolves #57965
Release note (sql change): Add support for ALTER VIEW/SEQUENCE OWNER TO commands.