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

Handle Percona compressed column extension #17660

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go/vt/sqlparser/ast_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2261,6 +2261,8 @@ func (columnFormat ColumnFormat) ToString() string {
return keywordStrings[DYNAMIC]
case DefaultFormat:
return keywordStrings[DEFAULT]
case CompressedFormat:
return keywordStrings[COMPRESSED]
default:
return "Unknown column format type"
}
Expand Down
1 change: 1 addition & 0 deletions go/vt/sqlparser/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ const (
FixedFormat
DynamicFormat
DefaultFormat
CompressedFormat
)

// Transaction access mode
Expand Down
13 changes: 12 additions & 1 deletion go/vt/sqlparser/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6347,14 +6347,25 @@ func TestParseVersionedComments(t *testing.T) {
partition by range (id)
(partition x values less than (5) engine InnoDB,
partition t values less than (20) engine InnoDB)`,
}, {
input: "CREATE TABLE `TABLE_NAME` (\n `col1` longblob /*!50633 COLUMN_FORMAT COMPRESSED */,\n `id` bigint unsigned NOT NULL,\n PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPRESSED",
mysqlVersion: "8.0.1",
output: `create table TABLE_NAME (
col1 longblob column_format compressed,
id bigint unsigned not null,
primary key (id)
) ENGINE InnoDB,
CHARSET utf8mb4,
COLLATE utf8mb4_bin,
ROW_FORMAT COMPRESSED`,
},
}

for _, testcase := range testcases {
t.Run(testcase.input+":"+testcase.mysqlVersion, func(t *testing.T) {
parser, err := New(Options{MySQLServerVersion: testcase.mysqlVersion})
require.NoError(t, err)
tree, err := parser.Parse(testcase.input)
tree, err := parser.ParseStrictDDL(testcase.input)
require.NoError(t, err, testcase.input)
out := String(tree)
require.Equal(t, testcase.output, out)
Expand Down
Loading
Loading