zabbix-agent2/src/libs/zbxdbhigh/proxy.c
/******************************************************************************
 *                                                                            *
 * Function: remember_record                                                  *
 *                                                                            *
 * Purpose: A record is stored as a sequence of fields and flag bytes for     *
 *          handling NULL values. A field is stored as a null-terminated      *
 *          string to preserve field boundaries. If a field value can be NULL *
 *          a flag byte is inserted after the field to distinguish between    *
 *          empty string and NULL value. The flag byte can be '\1'            *
 *          (not NULL value) or '\2' (NULL value).                            *
 *                                                                            *
 * Examples of representation:                                                *
 *          \0\2    - the field can be NULL and it is NULL                    *
 *          \0\1    - the field can be NULL but is empty string               *
 *          abc\0\1 - the field can be NULL but is a string "abc"             *
 *          \0      - the field can not be NULL and is empty string           *
 *          abc\0   - the field can not be NULL and is a string "abc"         *
 *                                                                            *
 ******************************************************************************/
remember_record

Purpose: A record is stored as a sequence of fields and flag bytes for
handling NULL values. A field is stored as a null-terminated
string to preserve field boundaries. If a field value can be NULL
a flag byte is inserted after the field to distinguish between
empty string and NULL value. The flag byte can be '\1'
(not NULL value) or '\2' (NULL value).
remember_record Purpose : A record is stored as a sequence of fields and flag bytes for handling NULL values . A field is stored as a null - terminated string to preserve field boundaries . If a field value can be NULL a flag byte is inserted after the field to distinguish between empty string and NULL value . The flag byte can be ' \ 1 ' ( not NULL value ) or ' \ 2 ' ( NULL value ) .
static void	remember_record(const ZBX_FIELD **fields, int fields_count, char **recs, size_t *recs_alloc,
		size_t *recs_offset, DB_ROW row)
{
	int	f;
	for (f = 0; f < fields_count; f++)
	{
		if (0 != (fields[f]->flags & ZBX_NOTNULL))
		{
			zbx_strcpy_alloc(recs, recs_alloc, recs_offset, row[f]);
			*recs_offset += sizeof(char);
		}
		else if (SUCCEED != DBis_null(row[f]))
		{
			zbx_strcpy_alloc(recs, recs_alloc, recs_offset, row[f]);
			*recs_offset += sizeof(char);
			zbx_chrcpy_alloc(recs, recs_alloc, recs_offset, '\1');
		}
		else
		{
			zbx_strcpy_alloc(recs, recs_alloc, recs_offset, "");
			*recs_offset += sizeof(char);
			zbx_chrcpy_alloc(recs, recs_alloc, recs_offset, '\2');
		}
	}
}
static void remember_record ( const ZBX_FIELD * * fields , int fields_count , char * * recs , size_t * recs_alloc , size_t * recs_offset , DB_ROW row ) { int f ; for ( f = 0 ; f < fields_count ; f ++ ) { if ( 0 != ( fields [ f ] -> flags & ZBX_NOTNULL ) ) { zbx_strcpy_alloc ( recs , recs_alloc , recs_offset , row [ f ] ) ; * recs_offset += sizeof ( char ) ; } else if ( SUCCEED != DBis_null ( row [ f ] ) ) { zbx_strcpy_alloc ( recs , recs_alloc , recs_offset , row [ f ] ) ; * recs_offset += sizeof ( char ) ; zbx_chrcpy_alloc ( recs , recs_alloc , recs_offset , ' \1 ' ) ; } else { zbx_strcpy_alloc ( recs , recs_alloc , recs_offset , " " ) ; * recs_offset += sizeof ( char ) ; zbx_chrcpy_alloc ( recs , recs_alloc , recs_offset , ' \2 ' ) ; } } }
Function: remember_record                                                  
                                                                            
 Purpose: A record is stored as a sequence of fields and flag bytes for     
          handling NULL values.
Function : remember_record Purpose : A record is stored as a sequence of fields and flag bytes for handling NULL values .