Skip to content

Commit

Permalink
sql/schemachanger: check nil table name for comment on column
Browse files Browse the repository at this point in the history
throw pg error instead of panic on nil pointer.

Release note: None.
  • Loading branch information
chengxiong-ruan committed Jul 5, 2022
1 parent 933b684 commit df380db
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
package scbuildstmt

import (
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror"
"github.com/cockroachdb/cockroach/pkg/sql/privilege"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scpb"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/screl"
Expand Down Expand Up @@ -102,6 +104,9 @@ func CommentOnTable(b BuildCtx, n *tree.CommentOnTable) {

// CommentOnColumn implements COMMENT ON COLUMN xxx IS xxx statement.
func CommentOnColumn(b BuildCtx, n *tree.CommentOnColumn) {
if n.ColumnItem.TableName == nil {
panic(pgerror.New(pgcode.Syntax, "column name must be qualified"))
}
tableElements := b.ResolveTable(n.ColumnItem.TableName, commentResolveParams)
_, _, table := scpb.FindTable(tableElements)
columnElements := b.ResolveColumn(table.TableID, n.ColumnItem.ColumnName, commentResolveParams)
Expand Down

0 comments on commit df380db

Please sign in to comment.