MTR testcase creation fails due to a regex in test.Pm

Bug #791783 reported by Roel Van de Paar
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Random Query Generator
New
Undecided
Unassigned

Bug Description

MTR testcases containing the following code (using standard optimizer grammars) are created:

SELECT
(
SELECT MIN
( SUBQUERY1_t1.col_int_key )
FROM t3 AS SUBQUERY1_t1 STRAIGHT_JOIN
( t2 AS SUBQUERY1_t2 JOIN t1 AS SUBQUERY1_t3 ON SUBQUERY1_t3.col_int_key = SUBQUERY1_t2.pk )
ON SUBQUERY1_t3.col_varchar_key = SUBQUERY1_t2.col_varchar_key
WHERE SUBQUERY1_t2.col_varchar_key <> table1.col_varchar_nokey )
FROM t1 AS table1
RIGHT JOIN
(
SELECT *
FROM t3 )
AS table2 JOIN t1 AS table3 ON table3.col_varchar_key = table2.col_varchar_key ON table3.col_varchar_nokey = table2.col_varchar_key

This fails with:

1630: FUNCTION test.MIN does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual

Changing this:

SELECT MIN
( SUBQUERY1_t1.col_int_key )

to:

SELECT MIN(SUBQUERY1_t1.col_int_key)

Resolves the issue.

Revision history for this message
Roel Van de Paar (roel11) wrote :

May be a simple newline change/fixup in the code

Revision history for this message
Philip Stoev (pstoev-askmonty) wrote :

This is a result of a regexp on line 194 in lib/GenTest/Simplifier/Test.pm whose task was to pretty-print the SQL statement.

Revision history for this message
Roel Van de Paar (roel11) wrote :

How about if we remove the regex completely? The pretty print function makes the MTR testcases longer and less clean. It could potentially help devs to analyze the issue though.

Revision history for this message
Philip Stoev (pstoev-askmonty) wrote :

No problem. Feel free to remove and/or fix the regexp. You can also pretty-print the test cases manually when you file them, depending on the requirements of your developers.

Revision history for this message
John H. Embretsen (johnemb) wrote :

I find pretty-printing useful for two reasons:

1) Easier to read and understand the actual query (no need to have a 100" monitor to see the entire query). However, the current pretty printing is far from perfect in that regard, so I often tend to prettify the SQL more or less manually when I need to (for myself or for developers), anyway.

2) Further automatic simplification of MTR test cases. The RQG test simplifier works on a line-by-line basis, right? So if the query is split into multiple lines, it can more easily simplify the actual query. This seems especially useful when the initial automatic simplification fails for some reason, where you still may get a test case with the original query pretty-printed, which you can massage slightly and then initiate further simplification using simplify-mysqltest.pl.

Will removing the pretty-print regexp lead to a reduced ability to automatically simplify queries in Transformer / ResultsetComparator context?

If not, I guess removing it is fine. Otherwise, the regexp should take care so that function calls are not split (no whitespace between function name and opening parenthesis).

Revision history for this message
Roel Van de Paar (roel11) wrote : Re: MTR testcase creation fails in various cases

Seems to be happening in more cases. Another example:

/* GenTest::Transform::ExecuteAs
WhereSubquery */ DROP TABLE IF EXISTS transforms.
where_sub
select_14617; CREATE TABLE transforms.
where_sub
select_14617

summary: - MTR testcase creation fails for MIN()/MAX() functions
+ MTR testcase creation fails in various cases
Revision history for this message
Roel Van de Paar (roel11) wrote :

Looking at the example above:

- "WhereSubquery" was put on a new line while it is part of a comment
- where_sub was put on a new line, likely because it starts with "where" or because of the ".", but it should have been left as part of the db.tablename
- select_... was put on a new line while it was part of a tablename

Revision history for this message
Roel Van de Paar (roel11) wrote :

John, maybe the automatic simplification is sometimes failing exactly because of this chopping up...

Philip, what is your take on this/John's question?

Would be good to get this one fixed since it affects a lot of MTR testcase for transformer sets.

summary: - MTR testcase creation fails in various cases
+ MTR testcase creation fails due to a regex in test.Pm
Revision history for this message
Saikumar (saikumar-v) wrote :

Noticed a similar issue with ExecuteAsUpdateDelete
/* GenTest::Transform::ExecuteAsInsert
Select */ DROP TABLE IF EXISTS transforms.insert_
select_28983; CREATE TABLE transforms.insert_
select_28983

The $rewritten_query in test.pm may require a regex correction.

Revision history for this message
Saikumar (saikumar-v) wrote :

As well as ExecuteAsInsert transform.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.