-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix parsing of encryption attribute for create database #10249
Fix parsing of encryption attribute for create database #10249
Conversation
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.
Changes look good to me!
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Bug fixes
Non-trivial changes
New/Existing features
Backward compatibility
|
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 looked at the shift-reduce conflict that is being generated because of these changes. Essentially they are coming from ALTER DATABASE
command. In this command the database name is optional and if it is not provided, then we use the current database in use.
Since Encryption is a non-reserved keyword, on ALTER DATABASE ENCRYPTION
there is a shift-reduce conflict. Reduction would mean that we are assuming we have no database name provided, shifting would mean that we are using ENCRYPTION as the database name.
The full parsing info for it -
ALTER {DATABASE | SCHEMA} [db_name]
alter_option ...
alter_option: {
[DEFAULT] CHARACTER SET [=] charset_name
| [DEFAULT] COLLATE [=] collation_name
| [DEFAULT] ENCRYPTION [=] {'Y' | 'N'}
| READ ONLY [=] {DEFAULT | 0 | 1}
}
We can remove the shift-reduce conflict using precedence rules (like we did in #10053) , but not doing so is also fine because this is a one-off conflict and we already have 1 in our parser. Adding precedence rules adds more complexity and I am not a fan of it. We should document this however, so that later if we look at the conflicts, we know where it is coming from. To fix the CI, the expectedOutput in |
Shift-reduce conflicts default to shifting and I can verify MySQL does the same - mysql [localhost:8026] {msandbox} (rails_app) > alter database encryption = 'y';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= 'y'' at line 1
mysql [localhost:8026] {msandbox} (rails_app) > alter database encryption encryption = 'y';
ERROR 3503 (42Y07): Database 'encryption' doesn't exist |
4913583
to
6a49045
Compare
Applied in 6a49045 and added a comment there as well for this case. |
The create database statement also allows for an encryption value to be set, so this fixes parsing support for that. It also renames the `CharsetAndCollation` to `DatabaseOption` since `CharsetAndCollationAndEncryption` seems overdoing things and `DatabaseOption` more matches how we call this in other places, like a `TableOption`. Updates the test to parse unconditional with no magic comments so we don't depend on the version and the comment logic is already tested separately somewhere else, so I think it's better to not mix those here. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
6a49045
to
b1ad801
Compare
The create database statement also allows for an encryption value to be set, so this fixes parsing support for that.
It also renames the
CharsetAndCollation
toDatabaseOption
sinceCharsetAndCollationAndEncryption
seems overdoing things andDatabaseOption
more matches how we call this in other places, like aTableOption
.Updates the test to parse unconditional with no magic comments so we don't depend on the version and the comment logic is already tested separately somewhere else, so I think it's better to not mix those here.
Related Issue(s)
Found as part of #10203
Checklist