sqldata/sqlpgapi.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 SqlPgApi::Fetch(int *rows_fetched, size_t *time_spent) 
{
	int fetched = 0;
	size_t start = (time_spent != NULL) ? Os::GetTickCount() : 0;
	for(int i = 0; i < _cursor_allocated_rows; i++)
	{
		if(_cursor_rows_fetched >= _cursor_rows_count)
			break;
		for(int k = 0; k < _cursor_cols_count; k++)
		{
			int null = _PQgetisnull(_cursor_result, _cursor_rows_fetched, k);
			if(null == 1)
			{
				_cursor_cols[k].ind[i] = (size_t)-1;
				continue;
			}
			size_t len = (size_t)_PQgetlength(_cursor_result, _cursor_rows_fetched, k);			
			if(len > _cursor_cols[k]._fetch_len)
				len = _cursor_cols[k]._fetch_len;
			_cursor_cols[k].ind[i] = len;
			char *data = _PQgetvalue(_cursor_result, _cursor_rows_fetched, k);
			memcpy(_cursor_cols[k]._data + _cursor_cols[k]._fetch_len * i, data, len);
		}
		_cursor_rows_fetched++;
		fetched++;
	}
	if(rows_fetched != NULL)
		*rows_fetched = fetched;
	if(time_spent != NULL)
		*time_spent = GetTickCount() - start;
	return 0;
}
int SqlPgApi :: Fetch ( int * rows_fetched , size_t * time_spent ) { int fetched = 0 ; size_t start = ( time_spent != NULL ) ? Os :: GetTickCount ( ) : 0 ; for ( int i = 0 ; i < _cursor_allocated_rows ; i ++ ) { if ( _cursor_rows_fetched >= _cursor_rows_count ) break ; for ( int k = 0 ; k < _cursor_cols_count ; k ++ ) { int null = _PQgetisnull ( _cursor_result , _cursor_rows_fetched , k ) ; if ( null == 1 ) { _cursor_cols [ k ] . ind [ i ] = ( size_t ) -1 ; continue ; } size_t len = ( size_t ) _PQgetlength ( _cursor_result , _cursor_rows_fetched , k ) ; if ( len > _cursor_cols [ k ] . _fetch_len ) len = _cursor_cols [ k ] . _fetch_len ; _cursor_cols [ k ] . ind [ i ] = len ; char * data = _PQgetvalue ( _cursor_result , _cursor_rows_fetched , k ) ; memcpy ( _cursor_cols [ k ] . _data + _cursor_cols [ k ] . _fetch_len * i , data , len ) ; } _cursor_rows_fetched ++ ; 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 // Copy column values and set indicators // Check for NULL value // Get the actual data length in bytes // Get column data // Copy data