Skip to content
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

parser: implement Restore for PrivElem, GrantStmt and RevokeStmt #198

Merged
merged 4 commits into from
Feb 12, 2019

Conversation

exialin
Copy link
Contributor

@exialin exialin commented Feb 3, 2019

What problem does this PR solve?

Implement Restore for PrivElem, GrantStmt and RevokeStmt.
Waiting for some helper Restores implemented in #197 .

Issue: pingcap/tidb#8532

Check List

Tests

  • Unit test

ast/misc.go Outdated
@@ -93,6 +93,18 @@ type AuthOption struct {
// TODO: support auth_plugin
}

// Restore implements Node interface.
func (n *AuthOption) Restore(ctx *RestoreCtx) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Restore "IDENTIFIED WITH" will get "IDENTIFIED BY" ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

And there is no test to cover AutoOption ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tiancaiamao

  1. According to parser.y, it looks like syntax IDENTIFIED WITH string has no effect:

    parser/parser.y

    Lines 7302 to 7319 in 63e2db7

    | "IDENTIFIED" "BY" AuthString
    {
    $$ = &ast.AuthOption {
    AuthString: $3.(string),
    ByAuthString: true,
    }
    }
    | "IDENTIFIED" "WITH" StringName
    {
    $$ = nil
    }
    | "IDENTIFIED" "WITH" StringName "BY" AuthString
    {
    $$ = &ast.AuthOption {
    AuthString: $5.(string),
    ByAuthString: true,
    }
    }

  2. To test Restore of AuthOption (and UserSpec, UserIdentity), and to follow the testing routine of other types, it should be promoted as a Node and add Accept for it. Is that suitable?

@tiancaiamao
Copy link
Collaborator

LGTM

@tiancaiamao
Copy link
Collaborator

PTAL @leoppro

Copy link
Contributor

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

Rest LGTM

ast/misc.go Show resolved Hide resolved
Copy link
Contributor

@zier-one zier-one left a comment

Choose a reason for hiding this comment

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

LGTM

@tiancaiamao tiancaiamao added status/LGT2 LGT2 and removed status/LGT1 LGT1 labels Feb 12, 2019
@tiancaiamao tiancaiamao merged commit 03c4011 into pingcap:master Feb 12, 2019
case ObjectTypeNone:
// do nothing
case ObjectTypeTable:
ctx.WriteKeyWord("TABLE ")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ctx.WriteKeyWord("TABLE ")
ctx.WriteKeyWord("TABLE")

This also means line 1389 and 1447 would need to look like this 🤷‍♂️:

if n.ObjectType != ObjectTypeNone {
	if err := n.ObjectType.Restore(ctx); err != nil {
		return errors.Annotate(err, "An error occurred while restore RevokeStmt.ObjectType")
	} 
	ctx.WritePlain(" ")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is better. Should I create a new pull request to fix it? Sorry for the trouble.

Copy link
Contributor

Choose a reason for hiding this comment

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

@exialin Yes please. Thanks.

exialin added a commit to exialin/parser that referenced this pull request Feb 12, 2019
zier-one pushed a commit that referenced this pull request Feb 12, 2019
@exialin exialin deleted the restore-priv branch February 12, 2019 16:13
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
tiancaiamao pushed a commit to tiancaiamao/parser that referenced this pull request Apr 27, 2021
lyonzhi pushed a commit to lyonzhi/parser that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants