← Back to team overview

randgen team mailing list archive

Re: Validating only a single query of a multi-query statement



You are right it may be more flexible if Validators are allowed to process all queries in a multi-query statement together, but it will mean that each Validator must have an extra loop that consumes each result set in turn. Maybe in the future we can declare some validators as multi_statement_capable so that backwards compatibility with the existing way of doing things is preserved, thus keeping most validators one-liners and loop-free.

In the meantime, it seems that you are on the right path with your SELECT 1 idea, but instead you can use a comment such as /* END OF SEQUENCE */ and then use a regexp to look for this comment in your Validator. It is more descriptive than SELECT 1, a bit less hackish and has the added benefit that it will be recorded in the query log.

Alternatively, you can put your code in a Reporter, which means that it will be called once every 10 seconds, and the first call will be 10 seconds after the start of the test, plenty of time for the data to be created.

With respect to testing dump/restore , two options come in mind:

- issue all queries against two servers, but only dump/restore on the first one, keeping the second server as a reference; - restore your dump on one server, and restore from the binary log on a second server, and then compare the two

Philip Stoev

----- Original Message ----- From: "Patrick Crews" <gleebix@xxxxxxxxx>
To: <randgen@xxxxxxxxxxxxxxxxxxx>
Sent: Friday, August 06, 2010 12:02 AM
Subject: [Randgen] Validating only a single query of a multi-query statement


I'm writing as I've hit a problem and figured asking about it might lead to
some help.

Basically, I am writing a grammar that executes multi-query statements, as
listed here:

Such as:
 create_table ; populate_table ; alter_table ;

I'm also writing a validator that will work in conjunction with this

The issue is that the validator is receiving / working on every query of the compound statement, when things will only be in a testable state once *all*
of the queries composing a statement have been processed.

I was thinking of issuing a signal query such as SELECT 1 at the end of a
statement / having a test for such a result in the Validator and only
processing if the query received matched the signal (VERY hackish seeming to
me, but I think it will work).

Can you recommend any other approaches for this / code to use / etc?

If anyone is interested, I'm testing drizzledump + restore.  I'm loading a
test database with randomly created / populated tables, then wanting do dump
them, reload them to a different database, and compare table contents /

The validator is handling the dump / restore / compare portion of things,
but I only want it to kick in after I have created / populated all of the
test tables (multi-query statement = CREATE TABLE t1...INSERT INTO
t1...CREATE TABLE t2...etc).



Mailing list: https://launchpad.net/~randgen
Post to     : randgen@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~randgen
More help   : https://help.launchpad.net/ListHelp