Skip to content
Open
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
3 changes: 3 additions & 0 deletions __fixtures__/validations/bad-sql-dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ ALTER TABLE wp_options
ADD KEY `autoload` (`autoload`);

SET UNIQUE_CHECKS = 0;

INSERT INTO wp_posts (ID, post_content) VALUES (1, 'Try our search engine = the best! ENGINE=MyISAM');
,(2, 'mydumper continuation row with ENGINE = SPAM content')
6 changes: 6 additions & 0 deletions __tests__/lib/validations/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ describe( 'lib/validations/sql', () => {
it( 'instances of ENGINE != InnoDB', () => {
expect( output ).toContain( 'ENGINE != InnoDB on line(s) 14' );
} );
it( 'no ENGINE != InnoDB false positives on row data containing "engine =" strings', () => {
// Lines 43-44 are an INSERT statement and a mydumper-style `,(...)` VALUES row
// whose *content* mentions non-InnoDB engines; they must not be flagged. The
// trailing period asserts line 14 is the *only* flagged line.
expect( output ).toContain( 'ENGINE != InnoDB on line(s) 14.' );
} );
it( 'use statement should be ok', () => {
expect( output ).not.toContain(
"'USE <DATABASE_NAME>' should not be present (case-insensitive)"
Expand Down
5 changes: 4 additions & 1 deletion src/lib/validations/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,10 @@ const checks: Checks = {
recommendation: "Use search-replace to change environment's domain",
},
engineInnoDB: {
matcher: /\sENGINE\s?=(?!(\s?InnoDB))/i,
// Skip lines holding row data (`INSERT ...`/`REPLACE ...` statements and `(...)` /
// `,(...)` VALUES rows): user content routinely contains "engine =" strings, which
// produced false positives on large dumps. ENGINE clauses only matter in DDL.
matcher: /^(?!\s*(?:INSERT|REPLACE)\b|\s*[(,]).*\sENGINE\s?=(?!(\s?InnoDB))/i,
matchHandler: lineNumber => ( { lineNumber } ),
outputFormatter: lineNumberCheckFormatter,
results: [],
Expand Down
Loading