[parser] parser: support table option: 'ENCRYPTION' (#520)

This commit is contained in:
Du Chuan
2019-08-26 15:23:42 +08:00
committed by Ti Chi Robot
parent 931f80b9ee
commit 7c57e6ca07
6 changed files with 3523 additions and 3491 deletions

View File

@ -1580,6 +1580,7 @@ const (
TableOptionSecondaryEngineNull
TableOptionInsertMethod
TableOptionTableCheckSum
TableOptionEncryption
)
// RowFormat types
@ -1785,6 +1786,10 @@ func (n *TableOption) Restore(ctx *RestoreCtx) error {
ctx.WriteKeyWord("TABLE_CHECKSUM ")
ctx.WritePlain("= ")
ctx.WritePlainf("%d", n.UintValue)
case TableOptionEncryption:
ctx.WriteKeyWord("ENCRYPTION ")
ctx.WritePlain("= ")
ctx.WriteString(n.StrValue)
default:
return errors.Errorf("invalid TableOption: %d", n.Tp)
}

View File

@ -898,6 +898,7 @@ const (
ErrJSONUsedAsKey = 3152
ErrInvalidJSONPathArrayCell = 3165
ErrBadUser = 3162
ErrInvalidEncryptionOption = 3184
ErrRoleNotGranted = 3530
ErrWindowNoSuchWindow = 3579
ErrWindowCircularityInWindowGraph = 3580

View File

@ -893,6 +893,7 @@ var MySQLErrName = map[uint16]string{
ErrInvalidJSONContainsPathType: "The second argument can only be either 'one' or 'all'.",
ErrJSONUsedAsKey: "JSON column '%-.192s' cannot be used in key specification.",
ErrInvalidJSONPathArrayCell: "A path expression is not a path to a cell in an array.",
ErrInvalidEncryptionOption: "Invalid encryption option.",
ErrWindowNoSuchWindow: "Window name '%s' is not defined.",
ErrWindowCircularityInWindowGraph: "There is a circularity in the window dependency graph.",
ErrWindowNoChildPartitioning: "A window which depends on another cannot define partitioning.",

File diff suppressed because it is too large Load Diff

View File

@ -8422,6 +8422,13 @@ TableOption:
yylex.AppendError(yylex.Errorf("The SECONDARY_ENGINE clause is parsed but ignored by all storage engines."))
parser.lastErrorAsWarn()
}
| "ENCRYPTION" EqOpt stringLit
{
// Parse it but will ignore it
$$ = &ast.TableOption{Tp: ast.TableOptionEncryption, StrValue: $3}
yylex.AppendError(yylex.Errorf("The ENCRYPTION clause is parsed but ignored by all storage engines."))
parser.lastErrorAsWarn()
}
StatsPersistentVal:
"DEFAULT"

View File

@ -2102,6 +2102,12 @@ func (s *testParserSuite) TestDDL(c *C) {
// For reference_definition in column_definition.
{"CREATE TABLE followers ( f1 int NOT NULL REFERENCES user_profiles (uid) );", true, "CREATE TABLE `followers` (`f1` INT NOT NULL REFERENCES `user_profiles`(`uid`))"},
// For table option `ENCRYPTION`
{"create table t (a int) encryption = 'n';", true, "CREATE TABLE `t` (`a` INT) ENCRYPTION = 'n'"},
{"create table t (a int) encryption 'n';", true, "CREATE TABLE `t` (`a` INT) ENCRYPTION = 'n'"},
{"alter table t encryption = 'y';", true, "ALTER TABLE `t` ENCRYPTION = 'y'"},
{"alter table t encryption 'y';", true, "ALTER TABLE `t` ENCRYPTION = 'y'"},
// for alter database/schema/table
{"ALTER DATABASE t CHARACTER SET = 'utf8'", true, "ALTER DATABASE `t` CHARACTER SET = utf8"},
{"ALTER DATABASE CHARACTER SET = 'utf8'", true, "ALTER DATABASE CHARACTER SET = utf8"},