Source
int zbx_db_delete_template_elements(zbx_uint64_t hostid, const char *hostname, zbx_vector_uint64_t *del_templateids,
/*
** 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.
**/
typedef enum
{
SYSMAP_ELEMENT_TYPE_HOST = 0,
SYSMAP_ELEMENT_TYPE_MAP,
SYSMAP_ELEMENT_TYPE_TRIGGER,
SYSMAP_ELEMENT_TYPE_HOST_GROUP,
SYSMAP_ELEMENT_TYPE_IMAGE
}
zbx_sysmap_element_types_t;
typedef struct
{
zbx_uint64_t id;
char *name;
}
zbx_id_name_pair_t;
static zbx_hash_t zbx_ids_names_hash_func(const void *data)
{
const zbx_id_name_pair_t *id_name_pair_entry = (const zbx_id_name_pair_t *)data;
return ZBX_DEFAULT_UINT64_HASH_ALGO(&(id_name_pair_entry->id), sizeof(id_name_pair_entry->id),
ZBX_DEFAULT_HASH_SEED);
}
static int zbx_ids_names_compare_func(const void *d1, const void *d2)
{
const zbx_id_name_pair_t *id_name_pair_entry_1 = (const zbx_id_name_pair_t *)d1;
const zbx_id_name_pair_t *id_name_pair_entry_2 = (const zbx_id_name_pair_t *)d2;
ZBX_RETURN_IF_NOT_EQUAL(id_name_pair_entry_1->id, id_name_pair_entry_2->id);
return 0;
}
/******************************************************************************
* *
* Parameters: sql - [IN] sql statement *
* ids - [OUT] sorted list of selected uint64 values *
* names - [OUT] list of names of the requested resource, order *
* matches the order of ids list *
* *
* Return value: SUCCEED - query for selecting ids and names SUCCEEDED *
* FAIL - otherwise *
* *
******************************************************************************/
static int DBselect_ids_names(const char *sql, zbx_vector_uint64_t *ids, zbx_vector_str_t *names)
{
int i, ret = FAIL;
DB_RESULT result;
DB_ROW row;
zbx_uint64_t id;
zbx_hashset_t ids_names;
if (NULL == (result = DBselect("%s", sql)))