List:Internals« Previous MessageNext Message »
From:Michael Widenius Date:April 8 2009 3:31pm
Subject:re: Deep copy of Item
View as plain text  
Hi!

>>>>> "Patrick" == Patrick Lau <patro02@stripped> writes:

Patrick> Hi
Patrick> For our purpose we want to free Items during query execution.

Patrick> So my idea would be:

Patrick> 1) instantiate item with malloc:

Patrick> Item* tmp_item = (Item*)malloc(sizeof(Item));

Patrick> 2) invoke copy constructor
Patrick> List_iterator_fast<Item> it(*join->fields);
Patrick> item1=it++;
tmp_item-> Item(*item1);

May not work in the future as we are likely to prohibit the usage of
copy constructors (as this leads to error with normal usage of items).

Patrick> now the question:
Patrick> - how would the copy constructor Item(& item) look like - especially
Patrick> for join->result->send_data(...)....
Patrick> - Is it a good idea?

Probably not.

Patrick> Does a similiar method already exist?

A better way would be to create a separate 'arena' for your items that
you then free all at once with the free_items() call.

This way you can free a group of items at once, any time during the
execution.

Look at the Query_arena() class in sql_class.cc

This is how we ensure that item's in prepared statements that we don't
want to free at the same time as the items used when executing the query.

Regards,
Monty

MySQL + Maria + more = MariaDB


Thread
Deep copy of ItemPatrick Lau18 Mar
  • re: Deep copy of ItemMichael Widenius8 Apr