drizzle
Profile
Search
 
Powered by SoftLayer
Replace-LIST

Drizzle code-cleanup-c++-replace-list

This page is to track the changes i hopefully make on the blueprints:

code-cleanup-c++-replace-list

So i intend to work on mainly the drizzled/*.{cc,h} code and replace the use of sql_list.cc the custom I_List being used in the code to using stl::vector/list/queue where it is apropriate! Hope this cleanup goes ok, for current contributions and features try your best to use your own stl::vector/* so as this makes this code cleanup easier to merge with.

I'll try and keep this updated as much as i can on my work through this anyways :)

I'll try and keep a branch of my code up on: launchpad-branch

So just starting to get time to work on this now, so lets look at sql_list.h

typedef struct st_sql_list {

 uint32_t elements;
 unsigned char *first;
 unsigned char **next;
 st_sql_list() {}                              /* Remove gcc warning */
 inline void empty()
 {
   elements=0;
   first=0;
   next= &first;
 }
 inline void link_in_list(unsigned char *element,unsigned char **next_ptr)
 {
   elements++;
   (*next)=element;
   next= next_ptr;
   *next=0;
 }
 inline void save_and_clear(struct st_sql_list *save)
 {
   *save= *this;
   empty();
 }
 inline void push_front(struct st_sql_list *save)
 {
   *save->next= first;				/* link current list last */
   first= save->first;
   elements+= save->elements;
 }
 inline void push_back(struct st_sql_list *save)
 {
   if (save->first)
   {
     *next= save->first;
     next= save->next;
     elements+= save->elements;
   }
 }

} SQL_LIST;

This all seems to me to be a stl::list with the push_back and and push_front. Vector won't cut it as you wont be able to push_front. So i 'll create a tree with my replacement using stl::list! So concentrating on looking at the code that uses sql_list and remove that to use stl:list :)

So a quick ack-grep gives:

redbrain@silix:~/workspace/drizzle/drizzle-replace-list/drizzled$ ack-grep 'SQL_LIST' *.{cc,h}

sql_delete.cc 38: SQL_LIST *order, ha_rows limit, uint64_t options, 870: error= mysql_delete(session, table_list, (COND*) 0, (SQL_LIST*) 0,


sql_parse.cc 2492:bool add_to_list(Session *session, SQL_LIST &list,Item *item,bool asc)


sql_update.cc 1004: SQL_LIST update;


sql_yacc.cc 12752: (SQL_LIST*) sql_memdup((char*) &select->order_list,


handler.h 1275: SQL_LIST *order, ha_rows rows, uint64_t options,


sql_base.h 58:bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);


sql_lex.h 456: SQL_LIST table_list; 457: SQL_LIST group_list; /* GROUP BY clause. */ 480: SQL_LIST order_list; /* ORDER clause */ 481: SQL_LIST *gorder_list; 1297: SQL_LIST proc_list, auxiliary_table_list, save_list;


sql_list.h 20:#ifndef DRIZZLED_SQL_LIST_H 21:#define DRIZZLED_SQL_LIST_H 69:} SQL_LIST; 623:#endif // DRIZZLED_SQL_LIST_H


table_list.h 91: List of tables local to a subquery (used by SQL_LIST). Considers

==

Lets start working with drizzled/sql_update.cc ...... more later

===

redbrain@omicron:~/workspace/drizzle/drizzle-replace-list-new$ ack-grep 'SQL_LIST' drizzled/ drizzled/item/sum.cc 2956: SQL_LIST *order_list, String *separator_arg)

drizzled/item/sum.h 1012: SQL_LIST *is_order, String *is_separator);

drizzled/sql_list.h 20:#ifndef DRIZZLED_SQL_LIST_H 21:#define DRIZZLED_SQL_LIST_H 69:} SQL_LIST; 623:#endif // DRIZZLED_SQL_LIST_H

drizzled/handler.h 1271: SQL_LIST *order, ha_rows rows, uint64_t options,

drizzled/sql_base.h 58:bool add_to_list(Session *session, SQL_LIST &list,Item *group,bool asc);

drizzled/sql_parse.cc 2219:bool add_to_list(Session *session, SQL_LIST &list,Item *item,bool asc)

drizzled/table_list.h 91: List of tables local to a subquery (used by SQL_LIST). Considers

drizzled/sql_delete.cc 38: SQL_LIST *order, ha_rows limit, uint64_t options, 866: error= mysql_delete(session, table_list, (COND*) 0, (SQL_LIST*) 0,

drizzled/sql_lex.h 454: SQL_LIST table_list; 455: SQL_LIST group_list; /* GROUP BY clause. */ 478: SQL_LIST order_list; /* ORDER clause */ 479: SQL_LIST *gorder_list; 1294: SQL_LIST auxiliary_table_list, save_list;

drizzled/sql_update.cc 1003: SQL_LIST update;


Looking at sum.{cc,h}

This leads into constructor

Item_func_group_concat:: Item_func_group_concat(Name_resolution_context *context_arg,

                      bool distinct_arg, List<Item> *select_list,
                      SQL_LIST *order_list, String *separator_arg)

So its a class that this relys on SQL_LIST

So where is this Class used

drizzled/item/sum.cc 2801: Item_func_group_concat *item_func= (Item_func_group_concat*)arg; 2835: Item_func_group_concat* grp_item= (Item_func_group_concat*) arg; 2877: Item_func_group_concat *item) 2945: Constructor of Item_func_group_concat. 2953:Item_func_group_concat:: 2954:Item_func_group_concat(Name_resolution_context *context_arg, 3006:Item_func_group_concat::Item_func_group_concat(Session *session, 3007: Item_func_group_concat *item) 3032:void Item_func_group_concat::cleanup() 3082:Item *Item_func_group_concat::copy_or_same(Session* session) 3084: return new (session->mem_root) Item_func_group_concat(session, this); 3088:void Item_func_group_concat::clear() 3103:bool Item_func_group_concat::add() 3151:Item_func_group_concat::fix_fields(Session *session, Item **ref) 3214:bool Item_func_group_concat::setup(Session *session) 3323:void Item_func_group_concat::make_unique() 3333:String* Item_func_group_concat::val_str(String* ) 3346: Item_func_group_concat::cleanup(). 3357:void Item_func_group_concat::print(String *str, enum_query_type query_type) 3388:Item_func_group_concat::~Item_func_group_concat()

drizzled/item/sum.h 966:class Item_func_group_concat : public Item_sum 978: @see Item_func_group_concat::setup 979: @see Item_func_group_concat::add 980: @see Item_func_group_concat::clear 1000: Item_func_group_concat *original; 1007: Item_func_group_concat *group_concat_item); 1010: Item_func_group_concat(Name_resolution_context *context_arg, 1014: Item_func_group_concat(Session *session, Item_func_group_concat *item); 1015: ~Item_func_group_concat();

drizzled/sql_select.cc 14227: We check order_item->fixed because Item_func_group_concat can put

drizzled/field.h 528: friend class Item_func_group_concat;

I have so far replaced the constructor for Item_func_group_concat(Name_resolution_context *context_arg,

                      bool distinct_arg, List<Item> *select_list,
                      SQL_LIST *order_list, String *separator_arg)

from SQL_LIST -> std::list<unsigned char*>

Now going step my step through where it is used in sum.{cc,h}

Site generously hosted by SoftLayer Technologies