diff options
Diffstat (limited to 'sql/rpl_utility.h')
-rw-r--r-- | sql/rpl_utility.h | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index eac3d14dfc6..4fd38022da0 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -217,7 +217,7 @@ public: WL#3915) or needs to advance the pointer for the fields in the raw data from the master to a specific column. */ - uint32 calc_field_size(uint col, uchar *master_data); + uint32 calc_field_size(uint col, uchar *master_data) const; /** Decide if the table definition is compatible with a table. @@ -258,4 +258,44 @@ struct RPL_TABLE_LIST table_def m_tabledef; }; + +/* Anonymous namespace for template functions/classes */ +namespace { + + /* + Smart pointer that will automatically call my_afree (a macro) when + the pointer goes out of scope. This is used so that I do not have + to remember to call my_afree() before each return. There is no + overhead associated with this, since all functions are inline. + + I (Matz) would prefer to use the free function as a template + parameter, but that is not possible when the "function" is a + macro. + */ + template <class Obj> + class auto_afree_ptr + { + Obj* m_ptr; + public: + auto_afree_ptr(Obj* ptr) : m_ptr(ptr) { } + ~auto_afree_ptr() { if (m_ptr) my_afree(m_ptr); } + void assign(Obj* ptr) { + /* Only to be called if it hasn't been given a value before. */ + DBUG_ASSERT(m_ptr == NULL); + m_ptr= ptr; + } + Obj* get() { return m_ptr; } + }; + +} + +#define DBUG_PRINT_BITSET(N,FRM,BS) \ + do { \ + char buf[256]; \ + for (uint i = 0 ; i < (BS)->n_bits ; ++i) \ + buf[i] = bitmap_is_set((BS), i) ? '1' : '0'; \ + buf[(BS)->n_bits] = '\0'; \ + DBUG_PRINT((N), ((FRM), buf)); \ + } while (0) + #endif /* RPL_UTILITY_H */ |