Skip to content

Commit

Permalink
Merge pull request #10270 from a-robinson/showpriv
Browse files Browse the repository at this point in the history
sql: Fix privileges required for SHOW CREATE VIEW
  • Loading branch information
a-robinson authored Oct 30, 2016
2 parents 7207111 + 8c3d8f8 commit bf9269d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/sql/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,12 @@ func (p *planner) ShowCreateView(n *parser.ShowCreateView) (planNode, error) {
if !ok {
return nil, errors.Errorf("failed to parse underlying query from view %q as a select", tn)
}

// When constructing the Select plan, make sure we don't require any
// privileges on the underlying tables.
p.skipSelectPrivilegeChecks = true
defer func() { p.skipSelectPrivilegeChecks = false }()

sourcePlan, err := p.Select(sel, []parser.Type{}, false)
if err != nil {
return nil, err
Expand Down
8 changes: 8 additions & 0 deletions pkg/sql/testdata/views
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ SELECT * FROM v1;
query error user testuser does not have SELECT privilege on view v6
SELECT * FROM v6;

query error user testuser has no privileges on view v1
SHOW CREATE VIEW v1;

user root

statement ok
Expand All @@ -183,6 +186,11 @@ SELECT * FROM v1;
query error user testuser does not have SELECT privilege on view v6
SELECT * FROM v6;

query TT
SHOW CREATE VIEW v1;
----
v1 CREATE VIEW v1 AS SELECT a, b FROM test.t

user root

statement ok
Expand Down

0 comments on commit bf9269d

Please sign in to comment.