Skip to content

Commit ba12dbb

Browse files
committed
Mark 2 MAXVALUE rows as syntax errors in the corpus
MySQL 8.4.10 rejects these rows with 1064, from a check in a parse tree class (PT_part_value_item_max). Their test also allows ER_MAXVALUE_IN_VALUES_IN, so they were regular rows, and they passed because the parser accepts them. Marking them shows the difference, so the pinned failures go from 133 to 135.
1 parent 707f9f0 commit ba12dbb

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72581,12 +72581,12 @@ partition by range columns (a,b)
7258172581
(partition p0 values less than (NULL, maxvalue))"
7258272582
"create table t1 (a int, b int)
7258372583
partition by list columns(a,b)
72584-
( partition p0 values in ((maxvalue, 0)))"
72584+
( partition p0 values in ((maxvalue, 0)))",,syntax_error
7258572585
"create table t1 (a int, b int)
7258672586
partition by list columns (a,b)
7258772587
( partition p0 values in ((0,0)))"
7258872588
"alter table t1 add partition
72589-
(partition p1 values in (maxvalue, maxvalue))"
72589+
(partition p1 values in (maxvalue, maxvalue))",,syntax_error
7259072590
"create table t1 (a int, b int)
7259172591
partition by key (a,a)"
7259272592
"create table t1 (a int, b int)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class WP_MySQL_Server_Suite_Parser_Tests extends TestCase {
2020
* input, which needs the CLIENT_MULTI_STATEMENTS client flag. MySQL rejects them
2121
* too without it.
2222
*
23-
* 90 failures are marked rows that the parser accepts:
24-
* - 88 are rejected by checks that run during MySQL's parsing, in grammar actions
23+
* 92 failures are marked rows that the parser accepts:
24+
* - 90 are rejected by checks that run during MySQL's parsing, in grammar actions
2525
* and parse tree classes. This parser has neither.
2626
* - 2 use "?" outside a prepared statement. MySQL allows it only when preparing,
2727
* and this lexer always allows it.
@@ -30,7 +30,7 @@ class WP_MySQL_Server_Suite_Parser_Tests extends TestCase {
3030
* language legitimately changes.
3131
*/
3232
const EXPECTED_QUERIES = 77319;
33-
const EXPECTED_FAILURES = 133;
33+
const EXPECTED_FAILURES = 135;
3434

3535
public function test_corpus_acceptance_rate(): void {
3636
$parser = WP_MySQL_Parser_Factory::create_parser();
@@ -131,6 +131,7 @@ public function data_query_markers(): array {
131131
'--error with another error listed' => array( 'explain select cast(1 as decimal(4294967296))', $regular ),
132132
'a listed query with another error' => array( 'explain select cast(1 as decimal(64, 999999999999999999999999999999))', $syntax_error ),
133133
'a listed query after a semantic one' => array( 'GET DIAGNOSTICS var', $syntax_error ),
134+
'a listed query the parser accepts' => array( "alter table t1 add partition\n(partition p1 values in (maxvalue, maxvalue))", $syntax_error ),
134135
'--error that also allows success' => array( '((SELECT * FROM t1 LIMIT 1) LIMIT 2) LIMIT 3', $regular ),
135136
'PREPARE with text' => array( 'prepare stmt from "select ??"', $regular ),
136137
'PREPARE after an --error comment' => array( "prepare s from 'select GROUP_CONCAT(DISTINCT ?,? ORDER BY ? SEPARATOR ?)'", $regular ),

‎packages/mysql-parser/tests/data/corpus-failures.csv‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ END"
412412
"XA START '1', 0x01, 18446744073709551615"
413413
"alter table t1 add b integer;
414414
call p1"
415+
"alter table t1 add partition
416+
(partition p1 values in (maxvalue, maxvalue))"
415417
"create function bug12812() returns char(2)
416418
begin
417419
return 'ok';
@@ -504,6 +506,9 @@ subpartition by hash(a)
504506
partition p1 values in (1) (subpartition sp0))"
505507
"create table t1 (a int, b int)
506508
partition by list columns(a,b)
509+
( partition p0 values in ((maxvalue, 0)))"
510+
"create table t1 (a int, b int)
511+
partition by list columns(a,b)
507512
(partition p0 values in ((maxvalue,maxvalue)))"
508513
"create table t1 (a int, b int)
509514
partition by range (a)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ function ( $command ) {
225225
"create procedure proc_26503_error_3()\nbegin\nretry:\nrepeat\nbegin\ndeclare continue handler for sqlexception\nbegin\nleave retry;\nend\n\nselect \"do something\";\nend\nuntil true end repeat retry;\nend",
226226
"create procedure proc_26503_error_4()\nbegin\nretry:\nrepeat\nbegin\ndeclare continue handler for sqlexception\nleave retry;\n\nselect \"do something\";\nend\nuntil true end repeat retry;\nend",
227227
'explain select cast(1 as decimal(64, 999999999999999999999999999999))',
228+
"create table t1 (a int, b int)\npartition by list columns(a,b)\n( partition p0 values in ((maxvalue, 0)))",
229+
"alter table t1 add partition\n(partition p1 values in (maxvalue, maxvalue))",
228230
);
229231

230232
$queries = array();

0 commit comments

Comments
 (0)