#At file:///home/acorreia/workspace.sun/repository.mysql.new/bzrwork/wl-2775/mysql-next-mr-rpl-merge.crash-safe.2775/ based on revid:alfranio.correia@stripped
3016 Alfranio Correia 2010-08-24
Introduced templates to simplify the rpl_info_handler class.
modified:
sql/rpl_info_handler.cc
sql/rpl_info_handler.h
sql/rpl_mi.cc
=== modified file 'sql/rpl_info_handler.cc'
--- a/sql/rpl_info_handler.cc 2010-07-27 19:26:54 +0000
+++ b/sql/rpl_info_handler.cc 2010-08-24 08:39:26 +0000
@@ -45,118 +45,3 @@ void Rpl_info_handler::set_sync_period(u
{
sync_period= period;
}
-
-bool Rpl_info_handler::set_info(const char *value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_set_info(cursor, value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::set_info(ulong const value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_set_info(cursor, value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::set_info(int const value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_set_info(cursor, value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::set_info(float const value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_set_info(cursor, value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::set_info(const Server_ids *value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_set_info(cursor, value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::get_info(char *value, const size_t size,
- const char *default_value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_get_info(cursor, value, size, default_value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::get_info(ulong *value,
- ulong const default_value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_get_info(cursor, value, default_value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::get_info(int *value,
- int const default_value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_get_info(cursor, value, default_value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::get_info(float *value,
- float const default_value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_get_info(cursor, value, default_value)))
- cursor++;
-
- return(prv_error);
-}
-
-bool Rpl_info_handler::get_info(Server_ids *value,
- const Server_ids *default_value)
-{
- if (cursor >= ninfo || prv_error)
- return TRUE;
-
- if (!(prv_error= do_get_info(cursor, value, default_value)))
- cursor++;
-
- return(prv_error);
-}
=== modified file 'sql/rpl_info_handler.h'
--- a/sql/rpl_info_handler.h 2010-06-26 19:13:27 +0000
+++ b/sql/rpl_info_handler.h 2010-08-24 08:39:26 +0000
@@ -122,7 +122,7 @@ public:
}
/**
- Sets the value of a string field to @c value.
+ Sets the value of a field to @c value.
Any call must be done in the right order which
is defined by the caller that wants to persist
the information.
@@ -132,55 +132,44 @@ public:
@retval FALSE No error
@retval TRUE Failure
*/
- bool set_info(const char *value);
- /**
- Sets the value of an ulong field to @c value.
- Any call must be done in the right order which
- is defined by the caller that wants to persist
- the information.
+ template <class TypeHandler>
+ bool set_info(TypeHandler const value)
+ {
+ if (cursor >= ninfo || prv_error)
+ return TRUE;
- @param[in] value Value to be set.
+ if (!(prv_error= do_set_info(cursor, value)))
+ cursor++;
- @retval FALSE No error
- @retval TRUE Failure
- */
- bool set_info(ulong const value);
- /**
- Sets the value of an integer field to @c value.
- Any call must be done in the right order which
- is defined by the caller that wants to persist
- the information.
-
- @param[in] value Value to be set.
+ return(prv_error);
+ }
- @retval FALSE No error
- @retval TRUE Failure
- */
- bool set_info(int const value);
/**
- Sets the value of a float field to @c value.
+ Returns the value of a field.
Any call must be done in the right order which
- is defined by the caller that wants to persist
+ is defined by the caller that wants to return
the information.
@param[in] value Value to be set.
+ @param[in] default_value Returns a default value
+ if the field is empty.
@retval FALSE No error
@retval TRUE Failure
*/
- bool set_info(float const value);
- /**
- Sets the value of a Server_ids field to @c value.
- Any call must be done in the right order which
- is defined by the caller that wants to persist
- the information.
+ template <class TypeHandlerPointer, class TypeHandler>
+ bool get_info(TypeHandlerPointer value,
+ TypeHandler const default_value)
+ {
+ if (cursor >= ninfo || prv_error)
+ return TRUE;
- @param[in] value Value to be set.
+ if (!(prv_error= do_get_info(cursor, value, default_value)))
+ cursor++;
+
+ return(prv_error);
+ }
- @retval FALSE No error
- @retval TRUE Failure
- */
- bool set_info(const Server_ids *value);
/**
Returns the value of a string field.
Any call must be done in the right order which
@@ -197,52 +186,17 @@ public:
@retval TRUE Failure
*/
bool get_info(char *value, const size_t size,
- const char *default_value);
- /**
- Returns the value of an ulong field.
- Any call must be done in the right order which
- is defined by the caller that wants to return
- the information.
-
- @param[in] value Value to be set.
- @param[in] default_value Returns a default value
- if the field is empty.
-
- @retval FALSE No error
- @retval TRUE Failure
- */
- bool get_info(ulong *value,
- ulong const default_value);
- /**
- Returns the value of an integer field.
- Any call must be done in the right order which
- is defined by the caller that wants to return
- the information.
-
- @param[in] value Value to be set.
- @param[in] default_value Returns a default value
- if the field is empty.
-
- @retval FALSE No error
- @retval TRUE Failure
- */
- bool get_info(int *value,
- int const default_value);
- /**
- Returns the value of a float field.
- Any call must be done in the right order which
- is defined by the caller that wants to return
- the information.
+ const char *default_value)
+ {
+ if (cursor >= ninfo || prv_error)
+ return TRUE;
- @param[in] value Value to be set.
- @param[in] default_value Returns a default value
- if the field is empty.
+ if (!(prv_error= do_get_info(cursor, value, size, default_value)))
+ cursor++;
- @retval FALSE No error
- @retval TRUE Failure
- */
- bool get_info(float *value,
- float const default_value);
+ return(prv_error);
+ }
+
/**
Returns the value of a Server_id field.
Any call must be done in the right order which
@@ -257,7 +211,16 @@ public:
@retval TRUE Failure
*/
bool get_info(Server_ids *value,
- const Server_ids *default_value);
+ const Server_ids *default_value)
+ {
+ if (cursor >= ninfo || prv_error)
+ return TRUE;
+
+ if (!(prv_error= do_get_info(cursor, value, default_value)))
+ cursor++;
+
+ return(prv_error);
+ }
/**
Returns the number of fields handled by this handler.
=== modified file 'sql/rpl_mi.cc'
--- a/sql/rpl_mi.cc 2010-08-05 17:45:25 +0000
+++ b/sql/rpl_mi.cc 2010-08-24 08:39:26 +0000
@@ -387,7 +387,7 @@ bool Master_info::read_info(Rpl_info_han
*/
if (lines >= LINE_FOR_REPLICATE_IGNORE_SERVER_IDS)
{
- if (from->get_info(ignore_server_ids, NULL))
+ if (from->get_info(ignore_server_ids, (Server_ids *) NULL))
DBUG_RETURN(TRUE);
}
Attachment: [text/bzr-bundle] bzr/alfranio.correia@oracle.com-20100824083926-lm60c6w6pefsj4zi.bundle
| Thread |
|---|
| • bzr commit into mysql-next-mr-rpl-merge branch (alfranio.correia:3016) | Alfranio Correia | 24 Aug |