-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
implement show hosts #80
Conversation
Can one of the admins verify this patch? |
jenkins go |
Build succeeded. |
@@ -663,6 +664,13 @@ update_edge_sentence | |||
} | |||
; | |||
|
|||
show_sentence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would support to SHOW many kinds of informations in future, so what's your plan on this, one sentence/executor for each kind of info?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think one kind show command should correspond to one sentence/executor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be tooo many.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this makes sense. I use one sentence/executor to all kinds of show command。
src/parser/parser.yy
Outdated
@@ -685,6 +693,7 @@ sentence | |||
| piped_sentence {} | |||
| assignment_sentence {} | |||
| mutate_sentence {} | |||
| show_sentence {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO. this belongs to maintainance_sentence
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, I also think so. But maintainance_sentence include define_tag_sentence, define_edge_sentence, alter_tag_sentence , alter_edge_sentence, describe_tag_sentence, describe_edge_sentence。
These sentences should be different from show sentence.
here I move show_sentence to belongs to maintainance_sentence.
src/parser/scanner.lex
Outdated
@@ -19,95 +19,101 @@ static constexpr size_t MAX_STRING = 4096; | |||
%} | |||
|
|||
%x STR | |||
|
|||
GO ([Gg][Oo]) | |||
/* These tokens are kept sorted for human lookup */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think this rationale is strong enough to make these order changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when I add a token, firstly I have to make sure the token doesn't exist before.
when these tokens are kept sorted, It's easy to find whether a token exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, but it's still not a strong reason, since every editor has searching in support. Besides, if you define a duplicated token, the generator would tell you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense.
Keep the tokens sorted to easy search and maintain. I also referred to other database.
I will rollback these code.
src/parser/scanner.lex
Outdated
FALSE ([Ff][Aa][Ll][Ss][Ee]) | ||
FROM ([Ff][Rr][Oo][Mm]) | ||
GO ([Gg][Oo]) | ||
HOST ([Hh][Oo][Ss][Tt]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it be plural?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think The SQL “show hosts” should be better。
CHECK_SEMANTIC_VALUE("\"\\110ello\"", TokenType::STRING, "Hello"), | ||
CHECK_SEMANTIC_VALUE("\"\110ello\"", TokenType::STRING, "Hello"), | ||
|
||
CHECK_SEMANTIC_VALUE("\"\110 \"", TokenType::STRING, "H "), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea what the following lines are testing for. They seems covered by above tests already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here test the string with multiple escape characters.
Thanks for your review @sherman-the-tank @dutor |
src/parser/parser.yy
Outdated
@@ -663,6 +664,13 @@ update_edge_sentence | |||
} | |||
; | |||
|
|||
show_sentence | |||
: KW_SHOW KW_ALL KW_HOST { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about just SHOW HOSTS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I couldn't agree more。 mysql has similar sql , for example show databases, show tables, show variables.👍
update the code. |
src/parser/ShowSentences.h
Outdated
|
||
class ShowSentence final : public Sentence { | ||
public: | ||
explicit ShowSentence(std::string cmdstr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why bother to use a string instead of the enum directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I use enum directly.
src/parser/ShowSentences.h
Outdated
public: | ||
explicit ShowSentence(std::string cmdstr) { | ||
kind_ = Kind::kShow; | ||
if (cmdstr.compare("hosts") == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI. cmdstr == "hosts"
works.
styling: always put the if/else block into braces.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense. I will update
@@ -108,6 +111,8 @@ OCT ([0-7]) | |||
{OVERWRITE} { return TokenType::KW_OVERWRITE; } | |||
{TRUE} { yylval->boolval = true; return TokenType::BOOL; } | |||
{FALSE} { yylval->boolval = false; return TokenType::BOOL; } | |||
{SHOW} { return TokenType::KW_SHOW; } | |||
{HOSTS} { return TokenType::KW_HOSTS; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you need add tests on these two keywords in ScannerTest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
@steppenwolfyuetong Could you please perform a rebase from upon upstream/master? |
Rebased. Please review. |
Jenkins go |
Build succeeded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution!
Co-authored-by: Aiee <[email protected]>
implement show hosts syntax
ShowAllHostExecutor::execute interface not implement,
when StorageClient fininshed, then implement this interface