sqldata/sqldatacmd.cpp
// Callback function for row count validation task
Callback function for row count validation task
Callback function for row count validation task
void SqlDataCmd::CallbackValidationRowCount(SqlDataReply *reply)
{
	if(reply == NULL)
		return;
	if(reply->_cmd_subtype != SQLDATA_CMD_ALL_COMPLETE)
		_log.Log("\n  %s - ", reply->_s_name);
	if(reply->_cmd_subtype == SQLDATA_CMD_STARTED)
	{
		_log.Log("Started (%d of %d, session %d)", _validate_table_num, _total_tables, reply->session_id);
		_validate_table_num++;
	}
	else
	if(reply->_cmd_subtype == SQLDATA_CMD_COMPLETE)
	{
		std::string table_diff;
		if(reply->_s_rc == -1 || reply->_t_rc == -1)
			_log.Log("Failed");
		else
		if(reply->_s_int1 != reply->_t_int1)
		{
			char row_fmt[13];
			_log.Log("Not Equal");
			_tables_diff++;
			table_diff = reply->_s_name;
			table_diff += " (";
			table_diff += Str::IntToString(reply->_s_int1, row_fmt);
			table_diff += " rows in source, ";
			table_diff += Str::IntToString(reply->_t_int1, row_fmt);
			table_diff += " rows in target)";
			_tables_diff_list.push_back(table_diff);
		}
		else
		{
			_log.Log("Ok");
			_tables_equal++;
		}
		char time_fmt[21], s_time_fmt[21], t_time_fmt[21];
		Str::FormatTime(reply->_time_spent, time_fmt);
		Str::FormatTime(reply->_s_time_spent, s_time_fmt);
		Str::FormatTime(reply->_t_time_spent, t_time_fmt);
		_log.Log(" (%s, session %d)\n", time_fmt, reply->session_id);
		_log.Log("    Source: ");
		if(reply->_s_rc == -1)
		{
			if(reply->s_error == SQL_DBAPI_NOT_EXISTS_ERROR)
				_log.Log("Table does not exist");
			else
				_log.Log("Error");
		}
		else
			_log.Log("%d row%s", reply->_s_int1, SUFFIX(reply->_s_int1));
		_log.Log(" (%s)\n", s_time_fmt);
		_log.Log("    Target: ");
		if(reply->_t_rc == -1)
		{
			if(reply->t_error == SQL_DBAPI_NOT_EXISTS_ERROR)
				_log.Log("Table does not exist");
			else
				_log.Log("Error");
		}
		else
			_log.Log("%d row%s", reply->_t_int1, SUFFIX(reply->_t_int1));
		_log.Log(" (%s)", t_time_fmt);
	}
	else
	if(reply->_cmd_subtype == SQLDATA_CMD_ALL_COMPLETE)
	{
		if(_tables_diff == 0)
			_log.Log("\n\nThere are no row count differences.\n");
		else
		{
			_log.Log("\n\nRow count differences (%d table%s):\n\n", _tables_diff, SUFFIX(_tables_diff));
			int k = 1;
			for(std::list<std::string>::iterator i = _tables_diff_list.begin(); i != _tables_diff_list.end(); i++, k++)
				_log.Log("%5d. %s\n", k, i->c_str());
		}
		char time_fmt[21];
		Str::FormatTime(reply->_time_spent, time_fmt);
		_log.Log("\nSummary:\n\n");
		_log.Log("  Total number of tables:         %d\n", _total_tables);
		_log.Log("    With the same row count:      %d\n", _tables_equal);
		_log.Log("    With the different row count: %d\n", _tables_diff);
		_log.Log("  Total number of rows:           %d in source, %d in target\n", reply->_s_int1, reply->_t_int1);
		_log.Log("    Row count difference:         %d\n", abs(reply->_s_int1 - reply->_t_int1));
		_log.Log("  Validation time:                %s\n", time_fmt);
	}
}
void SqlDataCmd :: CallbackValidationRowCount ( SqlDataReply * reply ) { if ( reply == NULL ) return ; if ( reply -> _cmd_subtype != SQLDATA_CMD_ALL_COMPLETE ) _log . Log ( " \n " , reply -> _s_name ) ; if ( reply -> _cmd_subtype == SQLDATA_CMD_STARTED ) { _log . Log ( " " , _validate_table_num , _total_tables , reply -> session_id ) ; _validate_table_num ++ ; } else if ( reply -> _cmd_subtype == SQLDATA_CMD_COMPLETE ) { std :: string table_diff ; if ( reply -> _s_rc == -1 || reply -> _t_rc == -1 ) _log . Log ( " " ) ; else if ( reply -> _s_int1 != reply -> _t_int1 ) { char row_fmt [ 13 ] ; _log . Log ( " " ) ; _tables_diff ++ ; table_diff = reply -> _s_name ; table_diff += " " ; table_diff += Str :: IntToString ( reply -> _s_int1 , row_fmt ) ; table_diff += " " ; table_diff += Str :: IntToString ( reply -> _t_int1 , row_fmt ) ; table_diff += " " ; _tables_diff_list . push_back ( table_diff ) ; } else { _log . Log ( " " ) ; _tables_equal ++ ; } char time_fmt [ 21 ] , s_time_fmt [ 21 ] , t_time_fmt [ 21 ] ; Str :: FormatTime ( reply -> _time_spent , time_fmt ) ; Str :: FormatTime ( reply -> _s_time_spent , s_time_fmt ) ; Str :: FormatTime ( reply -> _t_time_spent , t_time_fmt ) ; _log . Log ( " \n " , time_fmt , reply -> session_id ) ; _log . Log ( " " ) ; if ( reply -> _s_rc == -1 ) { if ( reply -> s_error == SQL_DBAPI_NOT_EXISTS_ERROR ) _log . Log ( " " ) ; else _log . Log ( " " ) ; } else _log . Log ( " " , reply -> _s_int1 , SUFFIX ( reply -> _s_int1 ) ) ; _log . Log ( " \n " , s_time_fmt ) ; _log . Log ( " " ) ; if ( reply -> _t_rc == -1 ) { if ( reply -> t_error == SQL_DBAPI_NOT_EXISTS_ERROR ) _log . Log ( " " ) ; else _log . Log ( " " ) ; } else _log . Log ( " " , reply -> _t_int1 , SUFFIX ( reply -> _t_int1 ) ) ; _log . Log ( " " , t_time_fmt ) ; } else if ( reply -> _cmd_subtype == SQLDATA_CMD_ALL_COMPLETE ) { if ( _tables_diff == 0 ) _log . Log ( " \n \n \n " ) ; else { _log . Log ( " \n \n \n \n " , _tables_diff , SUFFIX ( _tables_diff ) ) ; int k = 1 ; for ( std :: list < std :: string > :: iterator i = _tables_diff_list . begin ( ) ; i != _tables_diff_list . end ( ) ; i ++ , k ++ ) _log . Log ( " \n " , k , i -> c_str ( ) ) ; } char time_fmt [ 21 ] ; Str :: FormatTime ( reply -> _time_spent , time_fmt ) ; _log . Log ( " \n \n \n " ) ; _log . Log ( " \n " , _total_tables ) ; _log . Log ( " \n " , _tables_equal ) ; _log . Log ( " \n " , _tables_diff ) ; _log . Log ( " \n " , reply -> _s_int1 , reply -> _t_int1 ) ; _log . Log ( " \n " , abs ( reply -> _s_int1 - reply -> _t_int1 ) ) ; _log . Log ( " \n " , time_fmt ) ; } }
Callback function for row count validation task
Callback function for row count validation task
// Object name // A single table validated // Operation result // There is a difference in row count // The same row count // Format time // All tables validated // Output table information including row count // Format validation time