Skip to content

Commit 52bc02a

Browse files
committed
Apply the error command in the corpus extractor
"error X;" works like "--error X" in mysqltest, but the extractor handled it as any other command, so the query after it stayed in the corpus even though it's expected to fail. This removes 2 queries, which both parse.
1 parent 7af8f11 commit 52bc02a

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

‎packages/mysql-parser/data/mysql-server-query-corpus/mysql-latest.csv‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57766,10 +57766,6 @@ end;
5776657766
"CREATE TABLE t1(id int)"
5776757767
"SET GLOBAL SERVER_ID = 2"
5776857768
"BINLOG '
57769-
RaNlZRMBAAAAMAAAAG0DAAAAAG8AAAAAAAEABHRlc3QAAnQxAAEDAAEBAQAg5VHP
57770-
RaNlZR4BAAAAKAAAAJUDAAAAAG8AAAAAAAEAAgAB/wACAAAAczmjEA==
57771-
'"
57772-
"BINLOG '
5777357769
YKFlZQ8BAAAAegAAAH4AAAABAAQAOC4zLjAtZGVidWcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
5777457770
AAAAAAAAAAAAAAAAAABgoWVlEwANAAgAAAAABAAEAAAAYgAEGggAAAAICAgCAAAACgoKKioAEjQA
5777557771
CigAAcmi5+o=
@@ -57782,10 +57778,6 @@ YKNlZR4BAAAAKAAAANMEAAAAAG8AAAAAAAEAAgAB/wADAAAA50UVkQ==
5778257778
4CdYRw8BAAAAYgAAAGYAAAAAAAQANS4xLjE1LW5kYi02LjEuMjQtZGVidWctbG9nAAAAAAAAAAAA
5778357779
AAAAAAAAAAAAAAAAAADgJ1hHEzgNAAgAEgAEBAQEEgAATwAEGggICAg=
5778457780
'"
57785-
"BINLOG '
57786-
jKNlZRMBAAAAMAAAAOkFAAAAAG8AAAAAAAEABHRlc3QAAnQxAAEDAAEBAQCwxzWH
57787-
jKNlZR4BAAAAKAAAABEGAAAAAG8AAAAAAAEAAgAB/wAFAAAAVI7NfA==
57788-
'"
5778957781
"CREATE TABLE t1(s INT)"
5779057782
"CREATE TABLE T1(s INT)"
5779157783
"SET @a= 10"

‎packages/mysql-parser/tests/WP_MySQL_Server_Suite_Parser_Tests.php‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class WP_MySQL_Server_Suite_Parser_Tests extends TestCase {
1919
* The exact failing set is pinned in FAILURES_PATH; update it when the accepted
2020
* language legitimately changes.
2121
*/
22-
const EXPECTED_QUERIES = 69372;
22+
const EXPECTED_QUERIES = 69370;
2323
const EXPECTED_FAILURES = 43;
2424

2525
public function test_corpus_acceptance_rate(): void {
@@ -91,6 +91,26 @@ public function data_query_texts(): array {
9191
);
9292
}
9393

94+
/**
95+
* Pin queries that test files expect to fail, using the "error" command instead of
96+
* "--error", because the tally can't see an additional query that parses.
97+
*
98+
* @dataProvider data_omitted_query_texts
99+
*/
100+
public function test_corpus_omits_query_text( string $query ): void {
101+
$this->assertNotContains( $query, $this->read_queries( self::CORPUS_PATH ) );
102+
}
103+
104+
/**
105+
* @return array<string,array{0:string}>
106+
*/
107+
public function data_omitted_query_texts(): array {
108+
return array(
109+
'error with a name' => array( "BINLOG '\nRaNlZRMBAAAAMAAAAG0DAAAAAG8AAAAAAAEABHRlc3QAAnQxAAEDAAEBAQAg5VHP\nRaNlZR4BAAAAKAAAAJUDAAAAAG8AAAAAAAEAAgAB/wACAAAAczmjEA==\n'" ),
110+
'error with a number' => array( "BINLOG '\njKNlZRMBAAAAMAAAAOkFAAAAAG8AAAAAAAEABHRlc3QAAnQxAAEDAAEBAQCwxzWH\njKNlZR4BAAAAKAAAABEGAAAAAG8AAAAAAAEAAgAB/wAFAAAAVI7NfA==\n'" ),
111+
);
112+
}
113+
94114
/**
95115
* Pin the SQL modes of queries that test files select them for in different ways,
96116
* because the tally can't see a change in the modes of a query that still parses.

‎packages/mysql-parser/tools/generate-query-corpus.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,8 @@ function ( $command ) {
346346
$sql_modes->run_query( $query );
347347
}
348348
}
349-
$skip_next = false;
349+
// The "error" command works like "--error", but it ends with a delimiter.
350+
$skip_next = 1 === preg_match( '/^error\b/i', $query );
350351

351352
$query = '';
352353

0 commit comments

Comments
 (0)