Saturday, May 21, 2016

Building items clones

Finially I finished my project on recursive CTE, so I can resume working on my project of GSOC 2016.

As I said in my previous post, I decided to start with building items clones (items are used to build different kinds of expressions in MySQL).

Items are typical tree structures. If I just copy a node in the item structure, pointers to the subtrees won't be right. Fortunately this pointers can be fixed in the method Item_func_or_sum::build_clone. To copy nodes we use copy constructor. As we don't know the type of the node in general the copy constructor should be virtual. I called it get_copy. It should be implemented for each terminal class of items. There are dozens of such classes.

How they could be caught?

I used the following trick.
My get_copy for the base class Item is 'pseudo-abstract':

Item *tem::get_copy(...) { dbug_print_item(this); DBUG_ASSERT(0); return 0; }

Here dbug_print_item(this) helps me to understand for which class get_copy is missed.
If I call now method build_clone, for example in JOIN::optimize_inner(), to build a clone for the WHERE condition, and launch tests, it'll be easy for me to understand for which classes lack implementations of get_copy.

Here I've faced some minor problem: how to skip the queries that are excuted by mtr before it starts running the tests.
Anybody knows?
(Now I have a workaround: call build_clone() conditinally and manually trigger the condition. Of course it's not nice.)

No comments:

Post a Comment