This repository was archived by the owner on Jan 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
Add support for VIEWs in SHOW TABLES statements #862
Draft
agarciamontoro
wants to merge
9
commits into
src-d:feature/views
Choose a base branch
from
agarciamontoro:feature.views.show
base: feature/views
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
02c010c
Make ViewKey struct public
agarciamontoro fc97414
Add Exists and DeleteList to ViewRegistry
agarciamontoro f6ff425
Parse and analyze DROP VIEW statements
agarciamontoro 889bd1e
Test parsing utility readQualifiedIdentifierList
agarciamontoro 38bf07f
Test DropView node
agarciamontoro cb3b61c
Make sure that DropView is not executed without write permissions
agarciamontoro 9b8ecfa
Make qualifiedName type private to parse package
agarciamontoro 1220b98
Add views to SHOW TABLES
agarciamontoro 0329486
Fix typo in documentation
agarciamontoro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,3 +516,65 @@ func maybeList(opening, separator, closing rune, list *[]string) parseFunc { | |
} | ||
} | ||
} | ||
|
||
// A qualifiedName represents an identifier of type "db_name.table_name" | ||
type qualifiedName struct { | ||
qualifier string | ||
name string | ||
} | ||
|
||
// readQualifiedIdentifierList reads a comma-separated list of qualifiedNames. | ||
// Any number of spaces between the qualified names are accepted. The qualifier | ||
// may be empty, in which case the period is optional. | ||
// An example of a correctly formed list is: | ||
// "my_db.myview, db_2.mytable , aTable" | ||
func readQualifiedIdentifierList(list *[]qualifiedName) parseFunc { | ||
return func(rd *bufio.Reader) error { | ||
for { | ||
var newItem []string | ||
err := parseFuncs{ | ||
skipSpaces, | ||
readIdentList('.', &newItem), | ||
skipSpaces, | ||
}.exec(rd) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(newItem) < 1 || len(newItem) > 2 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Personally I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, why do you think it is clearer? I see the interval (1,2) in the other case much more clear. But I guess that it only comes down to personal opinions. Although it would be cool to actually measure which one is faster! |
||
return errUnexpectedSyntax.New( | ||
"[qualifier.]name", | ||
strings.Join(newItem, "."), | ||
) | ||
} | ||
|
||
var qualifier, name string | ||
|
||
if len(newItem) == 1 { | ||
qualifier = "" | ||
name = newItem[0] | ||
} else { | ||
qualifier = newItem[0] | ||
name = newItem[1] | ||
} | ||
|
||
*list = append(*list, qualifiedName{qualifier, name}) | ||
|
||
r, _, err := rd.ReadRune() | ||
if err != nil { | ||
if err == io.EOF { | ||
return nil | ||
} | ||
return err | ||
} | ||
|
||
switch r { | ||
case ',': | ||
continue | ||
default: | ||
return rd.UnreadRune() | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.