Source
void zbx_append_trigger_diff(zbx_vector_ptr_t *trigger_diff, zbx_uint64_t triggerid, unsigned char priority,
/*
** Zabbix
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** 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 General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
/******************************************************************************
* *
* Purpose: save the trigger changes to database *
* *
* Parameters: trigger_diff - [IN] the trigger changeset *
* *
******************************************************************************/
void zbx_db_save_trigger_changes(const zbx_vector_ptr_t *trigger_diff)
{
int i;
char *sql = NULL;
size_t sql_alloc = 0, sql_offset = 0;
const zbx_trigger_diff_t *diff;
zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __func__);
zbx_db_begin_multiple_update(&sql, &sql_alloc, &sql_offset);
for (i = 0; i < trigger_diff->values_num; i++)
{
char delim = ' ';
diff = (const zbx_trigger_diff_t *)trigger_diff->values[i];
if (0 == (diff->flags & ZBX_FLAGS_TRIGGER_DIFF_UPDATE))
continue;
zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, "update triggers set");
if (0 != (diff->flags & ZBX_FLAGS_TRIGGER_DIFF_UPDATE_LASTCHANGE))
{
zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "%clastchange=%d", delim, diff->lastchange);
delim = ',';
}
if (0 != (diff->flags & ZBX_FLAGS_TRIGGER_DIFF_UPDATE_VALUE))
{
zbx_snprintf_alloc(&sql, &sql_alloc, &sql_offset, "%cvalue=%d", delim, diff->value);
delim = ',';