RandomQueryGeneratorTransforms

Contents

[edit] Transforms Overview

Testing a database server requires that the results returned by queries are checked against a validated source of correct results. Usually, this is will be a human, as in а mysqltest test case, but it can be another database server (as are the comparison tests run with the RQG).

The third option is to compare each query to a rewritten version of it that is known to preserve the original properties (e.g. the rewritten query returns the same rows as the original one, or a subset or a superset of those rows). This way, the server can be checked against itself and one optimization can be verified against another.

Transformers are also useful to make sure that a particular SELECT can function properly in various circumstances, for example as a stored procedure, prepared statement or a subselect in a bigger query.

[edit] Running

If you use --validator=Transformer, then (almost) all available Transforms will be tried against each generated query.

Warning: You likely want to avoid executing a Transformer RQG run with anything more than 1 thread. What may happen (if you do not use --threads=1) is that a difference set/testcase is created due to the underlying data being modified by another thread.

[edit] Available Transforms

The following Transforms are currently available and most are enabled by default when you run the test with --validator=Transformer :

[edit] Selecting specific Transforms

To run the Transformer Validator with only certain Transforms available, you can edit randgen/lib/GenTest/Validator/Transformer.pm

[edit] Creating New Transforms

Each Transform is specified in a .pm package in the GenTest::Transform containing a transfrom($original_query, $executor, $original_result) method that takes three arguments:

The transform() method returns either a numeric status code, or an arrayref of query strings. If the return code is STATUS_WONT_HANDLE this signals that the Transform is not willing to process this particular query.

If an arrayref of query strings is included, those queries will be executed in order, and each query tagged with a TRANSFORM... tag will be will be used for validation purposes. Queries that do not return a result set (e.g. any DDL queries that create or destroy temporary database objects) or are not tagged will simply be executed and their result code will be disregarded. For example, the ExecuteAsView Transform uses such DDL queries to construct a temporary view that is then destroyed.

This returned queries that are to be used for the comparison/validation have to be tagged with one of the following tags inside a /* */ comment, to signal the way the result set from this query needs to be compared to the result set from the original query:

Retrieved from "http://forge.mysql.com/wiki/RandomQueryGeneratorTransforms"

This page has been accessed 3,204 times. This page was last modified 06:13, 23 January 2012.

Find

Browse
MySQLForge
Main Page
Current events
Recent changes
Random page
Help
Edit
Edit this page
Editing help
This page
Discuss this page
Post a comment
Printable version
Context
Page history
What links here
Related changes
My pages
Special pages
New pages
File list
Statistics
Bug reports
More...