Skip to content

Commit

Permalink
sql: enable comments for virtual views
Browse files Browse the repository at this point in the history
This commit makes it possible to define hardcoded comments for virtual
views, the same way it was already possible to do so for virtual tables.

Fixes #95427.

Release note: None
  • Loading branch information
Marius Posta committed Feb 1, 2023
1 parent 194f6a1 commit 7b341ff
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/sql/crdb_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -3697,6 +3697,7 @@ CREATE VIEW crdb_internal.ranges AS SELECT ` +
colinfo.RangesExtraRenders +
`FROM crdb_internal.ranges_no_leases`,
resultColumns: colinfo.Ranges,
comment: "ranges is a view which queries ranges_no_leases for system ranges",
}

// descriptorsByType is a utility function that iterates through a slice of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ TableCommentType 4294967235 0 "session variables (RAM)"
TableCommentType 4294967236 0 "session trace accumulated so far (RAM)"
TableCommentType 4294967237 0 "ongoing schema changes, across all descriptors accessible by current user (KV scan; expensive!)"
TableCommentType 4294967238 0 "server parameters, useful to construct connection URLs (RAM, local node only)"
TableCommentType 4294967239 0 "ranges is a view which queries ranges_no_leases for system ranges"
TableCommentType 4294967240 0 "range metadata without leaseholder details (KV join; expensive!)"
TableCommentType 4294967241 0 "defined partitions for all tables/indexes accessible by the current user in the current database (KV scan)"
TableCommentType 4294967242 0 "per-application transaction statistics (in-memory, not durable; local node only). This table is wiped periodically (by default, at least every two hours)"
Expand Down
5 changes: 4 additions & 1 deletion pkg/sql/virtual_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ type virtualSchemaTable struct {
type virtualSchemaView struct {
schema string
resultColumns colinfo.ResultColumns

// comment represents comment of virtual schema view.
comment string
}

// getSchema is part of the virtualSchemaDef interface.
Expand Down Expand Up @@ -366,7 +369,7 @@ func (v virtualSchemaView) initVirtualTableDesc(

// getComment is part of the virtualSchemaDef interface.
func (v virtualSchemaView) getComment() string {
return ""
return v.comment
}

// isUnimplemented is part of the virtualSchemaDef interface.
Expand Down

0 comments on commit 7b341ff

Please sign in to comment.