Source
/*
** Zabbix
** Copyright (C) 2001-2023 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: get events and flags that indicate what was filled in *
* ZBX_DB_EVENT structure *
* *
* Parameters: eventids - [IN] requested event ids *
* events - [OUT] the array of events *
* *
* Comments: use 'zbx_db_free_event' function to release allocated memory *
* *
******************************************************************************/
void zbx_db_get_events_by_eventids(zbx_vector_uint64_t *eventids, zbx_vector_ptr_t *events)
{
DB_RESULT result;
DB_ROW row;
char *sql = NULL;
size_t sql_alloc = 0, sql_offset = 0;
zbx_vector_uint64_t tagged_eventids, triggerids;
int i, index;
zbx_vector_uint64_create(&tagged_eventids);
zbx_vector_uint64_create(&triggerids);
zbx_vector_uint64_sort(eventids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
zbx_vector_uint64_uniq(eventids, ZBX_DEFAULT_UINT64_COMPARE_FUNC);
/* read event data */
zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset,
"select eventid,source,object,objectid,clock,value,acknowledged,ns,name,severity"
" from events"
" where");
zbx_db_add_condition_alloc(&sql, &sql_alloc, &sql_offset, "eventid", eventids->values, eventids->values_num);
zbx_strcpy_alloc(&sql, &sql_alloc, &sql_offset, " order by eventid");
result = zbx_db_select("%s", sql);
while (NULL != (row = zbx_db_fetch(result)))
{