Source
zbx_db_add_condition_alloc(&sql, &sql_alloc, &sql_offset, td->table->recid, updateids.values, updateids.values_num);
/*
** 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/>.
**/
/*
* The configuration sync is split into 4 parts for each table:
* 1) proxyconfig_prepare_rows()
* Renames rename_field to '#'||rename_field for all rows to be updated. It's done to avoid
* possible conflicts when two field values used in unique index are swapped.
* Resets reset_field to null for all rows to be deleted or updated. It's done to avoid
* possible foreign key violation when rows in self referencing table are updated or deleted.
* The changed fields are marked as updated, so during update processing the correct values
* will be assigned to them.
*
* 2) proxyconfig_delete_rows()
* Deletes all existing rows within scope that are not present in received table data. The scope
* is limited to received hosts when partial updates are done.
*
* 3) proxyconfig_insert_rows()
* Inserts new rows that were not present in database.
*
* 4) proxyconfig_update_rows()
* Update changed fields.
*
* When processing related tables (for example drules, dchecks) the prepare and delete operations are
* done from child tables to master tables. The insert and update operations are done from master
* tables to child tables. This is done to avoid child rows being removed with cascaded deletes and
* have parent rows updated/inserted when updating/inserting child rows.
*
*/
typedef struct
{
const zbx_db_field_t *field;
}
zbx_const_field_ptr_t;
ZBX_VECTOR_DECL(const_field, zbx_const_field_ptr_t)
ZBX_VECTOR_IMPL(const_field, zbx_const_field_ptr_t)
/*
* 128 bit flags to support update flags for host_invetory table which has more that 64 columns
*/
typedef struct
{
zbx_uint64_t blocks[128 / 64];
}
zbx_flags128_t;
static void zbx_flags128_set(zbx_flags128_t *flags, int bit)
{
flags->blocks[bit >> 6] |= (__UINT64_C(1) << (bit & 0x3f));
}
static void zbx_flags128_clear(zbx_flags128_t *flags, int bit)
{
flags->blocks[bit >> 6] &= ~(__UINT64_C(1) << (bit & 0x3f));
}
static void zbx_flags128_init(zbx_flags128_t *flags)
{
memset(flags->blocks, 0, sizeof(zbx_uint64_t) * (128 / 64));
}
static int zbx_flags128_isset(zbx_flags128_t *flags, int bit)
{