From: Michael Widenius Date: April 8 2009 3:31pm Subject: re: Deep copy of Item List-Archive: http://lists.mysql.com/internals/36518 Message-Id: <18908.49988.892912.788814@narttu.askmonty.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi! >>>>> "Patrick" == Patrick Lau 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 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