Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

sql/analyzer: do not use plan.Inspect to find available tables #708

Merged
merged 1 commit into from
May 14, 2019

Conversation

erizocosmico
Copy link
Contributor

Friday night this possible bug came to my mind, but PR was merged because I got a chance to fix it tomorrow 😅

Because of how plan.Inspect works, whenever a table is found in a branch the other branches are not inspected anymore. Instead, doing recursive calls all branches are visited.

@erizocosmico erizocosmico requested a review from a team May 13, 2019 12:03
return tables
}

func getNodesAvailableTables(tables map[string]string, nodes ...sql.Node) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it can also return a tables map - WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why this does not return a table map is because it takes one as a parameter to add stuff to it and avoid having to merge maps since this is called recursively. It could return a map but it's pointless because it will return the same map as the one it receives.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. It's still tail recursion, so OK.

Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
@erizocosmico
Copy link
Contributor Author

Shall we merge this, @ajnavarro?

@ajnavarro ajnavarro merged commit ca79a6d into src-d:master May 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants