const zbx_db_field_t field = {"default_theme", "blue-theme", NULL, NULL, 128, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
#include "dbupgrade.h"
#include "zbxdbhigh.h"
#include "zbxsysinfo.h"
#include "zbxparam.h"
#ifndef HAVE_SQLITE3
static int DBpatch_2050000(void)
{
const zbx_db_field_t field = {"agent", "Zabbix", NULL, NULL, 255, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBset_default("httptest", &field);
}
static int DBpatch_2050001(void)
{
zbx_db_result_t result;
zbx_db_row_t row;
char *oid = NULL;
size_t oid_alloc = 0;
int ret = FAIL, rc;
if (NULL == (result = zbx_db_select("select itemid,snmp_oid from items where flags=1 and type in (1,4,6)")))
return FAIL;
while (NULL != (row = zbx_db_fetch(result)))
{
char *param, *oid_esc;
size_t oid_offset = 0;
param = zbx_strdup(NULL, row[1]);
zbx_snprintf_alloc(&oid, &oid_alloc, &oid_offset, "discovery[{#SNMPVALUE},%s]", param);
if (FAIL == zbx_quote_key_param(¶m, 0))
{
zabbix_log(LOG_LEVEL_WARNING, "cannot convert SNMP discovery OID \"%s\":"
" OID contains invalid character(s)", row[1]);
rc = ZBX_DB_OK;
}
else if (255 < oid_offset && 255 < zbx_strlen_utf8(oid))
{
zabbix_log(LOG_LEVEL_WARNING, "cannot convert SNMP discovery OID \"%s\":"
" resulting OID is too long", row[1]);
rc = ZBX_DB_OK;
}
else
{
oid_esc = zbx_db_dyn_escape_string(oid);
rc = zbx_db_execute("update items set snmp_oid='%s' where itemid=%s", oid_esc, row[0]);
zbx_free(oid_esc);
}
zbx_free(param);
if (ZBX_DB_OK > rc)
goto out;
}
ret = SUCCEED;
out:
zbx_db_free_result(result);
zbx_free(oid);
return ret;
}
static int DBpatch_2050002(void)
{