sqldata/sqlmysqlapi.cpp
// Fetch next portion of data to allocate buffers
Fetch next portion of data to allocate buffers
Fetch next portion of data to allocate buffers
int SqlMysqlApi::Fetch(int *rows_fetched, size_t *time_spent) 
{
	MYSQL_ROW row = NULL;
	int fetched = 0;
	size_t start = Os::GetTickCount();
	for(int i = 0; i < _cursor_allocated_rows; i++)
	{
		row =  _mysql_fetch_row(_cursor_result);
		if(row == NULL)
			break;
		unsigned long *lengths = (unsigned long*)_mysql_fetch_lengths(_cursor_result);
		for(int k = 0; k < _cursor_cols_count; k++)
		{
			if(row[k] == NULL)
			{
				_cursor_cols[k].ind[i] = (size_t)-1;
				continue;
			}
			else
				_cursor_cols[k].ind[i] = (size_t)lengths[k];
			char *data = NULL;
			if(_cursor_cols[k]._data != NULL)
				data = _cursor_cols[k]._data + _cursor_cols[k]._fetch_len * i;
			bool copy = true;
			if(row[k] != NULL && _cursor_cols[k]._native_dt == MYSQL_TYPE_DATE)
			{
				if(strcmp(row[k], "0000-00-00") == 0)
				{
					_cursor_cols[k].ind[i] = (size_t)-1;
					copy = false;
				}
			}
			else
			if(row[k] != NULL && _cursor_cols[k]._native_dt == MYSQL_TYPE_DATETIME)
			{
				if(strcmp(row[k], "0000-00-00 00:00:00") == 0)
				{
					_cursor_cols[k].ind[i] = (size_t)-1;
					copy = false;
				}
			}
			if(data != NULL && copy == true)
				memcpy(data, row[k], lengths[k]);
		}
		fetched++;
	}
	if(rows_fetched != NULL)
		*rows_fetched = fetched;
	if(time_spent != NULL)
		*time_spent = GetTickCount() - start;
	return 0;
}
int SqlMysqlApi :: Fetch ( int * rows_fetched , size_t * time_spent ) { MYSQL_ROW row = NULL ; int fetched = 0 ; size_t start = Os :: GetTickCount ( ) ; for ( int i = 0 ; i < _cursor_allocated_rows ; i ++ ) { row = _mysql_fetch_row ( _cursor_result ) ; if ( row == NULL ) break ; unsigned long * lengths = ( unsigned long * ) _mysql_fetch_lengths ( _cursor_result ) ; for ( int k = 0 ; k < _cursor_cols_count ; k ++ ) { if ( row [ k ] == NULL ) { _cursor_cols [ k ] . ind [ i ] = ( size_t ) -1 ; continue ; } else _cursor_cols [ k ] . ind [ i ] = ( size_t ) lengths [ k ] ; char * data = NULL ; if ( _cursor_cols [ k ] . _data != NULL ) data = _cursor_cols [ k ] . _data + _cursor_cols [ k ] . _fetch_len * i ; bool copy = true ; if ( row [ k ] != NULL && _cursor_cols [ k ] . _native_dt == MYSQL_TYPE_DATE ) { if ( strcmp ( row [ k ] , " " ) == 0 ) { _cursor_cols [ k ] . ind [ i ] = ( size_t ) -1 ; copy = false ; } } else if ( row [ k ] != NULL && _cursor_cols [ k ] . _native_dt == MYSQL_TYPE_DATETIME ) { if ( strcmp ( row [ k ] , " " ) == 0 ) { _cursor_cols [ k ] . ind [ i ] = ( size_t ) -1 ; copy = false ; } } if ( data != NULL && copy == true ) memcpy ( data , row [ k ] , lengths [ k ] ) ; } fetched ++ ; } if ( rows_fetched != NULL ) * rows_fetched = fetched ; if ( time_spent != NULL ) * time_spent = GetTickCount ( ) - start ; return 0 ; }
Fetch next portion of data to allocate buffers
Fetch next portion of data to allocate buffers
// Fill the buffer // Fetch the next row // Copy column values and set indicators // Check for NULL value // Column data // Check for zero date 0000-00-00 // Change to NULL // Check for zero datetime 0000-00-00 00:00:00 // Change to NULL // Copy data (LONGBLOB and LONGTEXT are not copied if they transferred as LOBs to the target)