Source
******************************************************************************************************************/
/*
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
typedef struct
{
unsigned char initialized;
zbx_vector_ptr_t dbinserts;
}
zbx_sql_writer_t;
static zbx_sql_writer_t writer;
typedef void (*vc_str2value_func_t)(zbx_history_value_t *value, zbx_db_row_t row);
/* history table data */
typedef struct
{
/* table name */
const char *name;
/* field list */
const char *fields;
/* string to value converter function, used to convert string value of DB row */
/* to the value of appropriate type */
vc_str2value_func_t rtov;
}
zbx_vc_history_table_t;
/* row to value converters for all value types */
static void row2value_str(zbx_history_value_t *value, zbx_db_row_t row)
{
value->str = zbx_strdup(NULL, row[0]);
}
static void row2value_dbl(zbx_history_value_t *value, zbx_db_row_t row)
{
value->dbl = atof(row[0]);
}
static void row2value_ui64(zbx_history_value_t *value, zbx_db_row_t row)
{
ZBX_STR2UINT64(value->ui64, row[0]);
}