Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions go/vt/sqlparser/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,41 +275,3 @@ func OverwriteAuthTargetNames(node SQLNode, targetNames []string, walkChildren b
}
return node
}

// WalkAuthNodes walks the node tree to find all nodes that implement AuthNode. This allows for fine-grained control of
// modifying AuthInformation within a tree.
func WalkAuthNodes(node SQLNode, f func(node AuthNode, authInfo AuthInformation)) {
if authNode, ok := node.(AuthNode); ok {
authInfo := authNode.GetAuthInformation()
f(authNode, authInfo)
}
if walkableNode, ok := node.(WalkableSQLNode); ok {
_ = walkableNode.walkSubtree(func(node SQLNode) (bool, error) {
if authNode, ok := node.(AuthNode); ok {
authInfo := authNode.GetAuthInformation()
f(authNode, authInfo)
}
return true, nil
})
}
}

// handleCTEAuth handles auth with CTEs, since we want to ignore any mentions of CTEs as far as auth is concerned. The
// CTE declarations will contain their own auth checks.
func handleCTEAuth(node SQLNode, with *With) {
if with == nil || node == nil {
return
}
aliases := make(map[string]struct{})
for _, cte := range with.Ctes {
aliases[cte.As.String()] = struct{}{}
}
WalkAuthNodes(node, func(node AuthNode, authInfo AuthInformation) {
for _, targetName := range authInfo.TargetNames {
if _, ok := aliases[targetName]; ok {
node.SetAuthType(AuthType_IGNORE)
break
}
}
})
}
Loading
Loading