Commit b0b699dc authored by Sergey Petrunya's avatar Sergey Petrunya

Debugging aid: Add T* List<T>::elem(int n) which returns N-th element in the list.

- There was List<N>::nth_element() but it didn't work because linker removed it. 
- Now, removal by linker is prevented for important values of T, and function is renamed. 
parent 5611c0e2
...@@ -330,11 +330,12 @@ class base_list :public Sql_alloc ...@@ -330,11 +330,12 @@ class base_list :public Sql_alloc
friend class error_list; friend class error_list;
friend class error_list_iterator; friend class error_list_iterator;
#ifndef DBUG_OFF
/* /*
Debugging help: return N-th element in the list, or NULL if the list has Debugging help: return N-th element in the list, or NULL if the list has
less than N elements. less than N elements.
*/ */
inline void *nth_element(int n) void *elem(int n)
{ {
list_node *node= first; list_node *node= first;
void *data= NULL; void *data= NULL;
...@@ -350,6 +351,8 @@ class base_list :public Sql_alloc ...@@ -350,6 +351,8 @@ class base_list :public Sql_alloc
} }
return data; return data;
} }
#endif
#ifdef LIST_EXTRA_DEBUG #ifdef LIST_EXTRA_DEBUG
/* /*
Check list invariants and print results into trace. Invariants are: Check list invariants and print results into trace. Invariants are:
...@@ -528,7 +531,9 @@ template <class T> class List :public base_list ...@@ -528,7 +531,9 @@ template <class T> class List :public base_list
} }
empty(); empty();
} }
inline T *nth_element(int n) { return (T*)base_list::nth_element(n); } #ifndef DBUG_OFF
T *elem(int n) { return (T*)base_list::elem(n); }
#endif
}; };
......
...@@ -409,6 +409,15 @@ void print_sjm(SJ_MATERIALIZATION_INFO *sjm) ...@@ -409,6 +409,15 @@ void print_sjm(SJ_MATERIALIZATION_INFO *sjm)
} }
/* purecov: end */ /* purecov: end */
/*
Debugging help: force List<...>::elem function not be removed as unused.
*/
Item* (List<Item>:: *dbug_list_item_elem_ptr)(int)= &List<Item>::elem;
Item_equal* (List<Item_equal>:: *dbug_list_item_equal_elem_ptr)(int)=
&List<Item_equal>::elem;
TABLE_LIST* (List<TABLE_LIST>:: *dbug_list_table_list_elem_ptr)(int) =
&List<TABLE_LIST>::elem;
#endif #endif
typedef struct st_debug_lock typedef struct st_debug_lock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment