Skip to content
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
8 changes: 7 additions & 1 deletion src/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,13 @@ private function getTableOptionDefs($table)
$defTableOptions = [];
$defTableOptions[] = "ENGINE=$table->ENGINE";
if (strcasecmp($table->ROW_FORMAT, 'COMPACT') != 0) {
$defTableOptions[] = "ROW_FORMAT=$table->ROW_FORMAT";
// ROW_FORMAT=FIXED is only valid for MyISAM; MySQL 8 errors with
// 1031 if applied to InnoDB. Drop it silently for InnoDB.
$skipRowFormat = strcasecmp((string) $table->ROW_FORMAT, 'FIXED') === 0
&& strcasecmp((string) $table->ENGINE, 'InnoDB') === 0;
if (!$skipRowFormat) {
$defTableOptions[] = "ROW_FORMAT=$table->ROW_FORMAT";
}
}
if ($table->AUTO_INCREMENT) {
$defTableOptions[] = "AUTO_INCREMENT=$table->AUTO_INCREMENT";
Expand Down
8 changes: 8 additions & 0 deletions src/Parse/TableOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,14 @@ public function toString()
] as $option) {
if ($this->options[$option] !== $this->defaultOptions[$option]) {
$value = $this->options[$option];
// ROW_FORMAT=FIXED is only valid for MyISAM; MySQL 8 errors with
// 1031 if applied to InnoDB. Drop it silently for InnoDB.
if ($option === 'ROW_FORMAT'
&& strcasecmp((string) $value, 'FIXED') === 0
&& strcasecmp((string) $this->engine, 'InnoDB') === 0
) {
continue;
}
if (in_array($option, ['COMMENT', 'CONNECTION'])) {
$value = Token::escapeString($value);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Parse/TableOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ public function parseProvider()

["row_format=default", "ENGINE=InnoDB"],
["row_format=dynamic", "ENGINE=InnoDB ROW_FORMAT=DYNAMIC"],
["row_format=fixed", "ENGINE=InnoDB ROW_FORMAT=FIXED"],
// ROW_FORMAT=FIXED is invalid for InnoDB on MySQL 8 (error 1031);
// morphism silently drops it so the table can be created.
["row_format=fixed", "ENGINE=InnoDB"],
["engine=MyISAM row_format=fixed", "ENGINE=MyISAM ROW_FORMAT=FIXED"],
["row_format=compressed", "ENGINE=InnoDB ROW_FORMAT=COMPRESSED"],
["row_format=redundant", "ENGINE=InnoDB ROW_FORMAT=REDUNDANT"],
["row_format=compact", "ENGINE=InnoDB ROW_FORMAT=COMPACT"],
Expand Down
Loading