I have been attempting to remove the templatized Array class in
Drizzle/MySQL, defined in sql/sql_array.h in favor of the STL vector<>
template container class.
The JOIN class has a member sj_subselects, defined as:
I've run into an issue where I am uncertain how to instantiate a
semijoin Item_in_subselect properly from within JOIN::prepare. The
constructors available for Item_in_subselect are as follows:
Item_in_subselect(Item * left_expr, Select_Lex *select_lex);
:Item_exists_subselect(), left_expr_cache(0), first_execution(true),
optimizer(0), abort_on_null(0), pushed_cond_guards(NULL),
However, in JOIN::prepare, the following is what is used in order to add
a (new?) Item_in_subselect to the Array:
where "in_subs" is of type pointer to Item_in_subselect of the current
where "subselect" is defined as:
Item_subselect *subselect= select_lex->master_unit()->item;
The Array<Item_in_subselect>::append method appears to simply assign the
supplied pointer into the Array's storage buffer of pointers:
So, Array is simply a block of mem-root-allocated pointers. Disregarding
the mem-root allocation, I would presume that changing the sj_subselects
std::vector<Item_in_subselect *> sj_subselects;
would produce an equivalent vector.
However, after changing the Array to std::vector<> semantics in
JOIN::prepare and JOIN::flatten_subqueries, it appears that I cannot
simply push an existing pointer into a vector, as one would presume.
So, changing this:
Does not work. There is some loss of state happening at some point.
So, I tried to make a copy of the in_subs instead of supplying a
pointer, like so:
Item_in_subselect *sj_sub= new Item_in_subselect(in_subs->left_expr,
This works better, but GDB vomits in Item_subselect::fix_fields(),
complaining that the Item_subselect::engine->cols() is undefined...
If anyone has any advice or can spot a mistake in the logic above, I'd
appreciate some assistance...