#include "dbupgrade.h"
#include "zbxnum.h"
#include "zbxalgo.h"
#include "zbxdb.h"
#include "zbxdbhigh.h"
#include "zbxdbschema.h"
#include "zbxstr.h"
#ifndef HAVE_SQLITE3
static int DBpatch_4050001(void)
{
return DBdrop_foreign_key("items", 1);
}
static int DBpatch_4050002(void)
{
return DBdrop_index("items", "items_1");
}
static int DBpatch_4050003(void)
{
const zbx_db_field_t field = {"key_", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("items", &field, NULL);
}
static int DBpatch_4050004(void)
{
#ifdef HAVE_MYSQL
return DBcreate_index("items", "items_1", "hostid,key_(1021)", 0);
#else
return DBcreate_index("items", "items_1", "hostid,key_", 0);
#endif
}
static int DBpatch_4050005(void)
{
const zbx_db_field_t field = {"hostid", NULL, "hosts", "hostid", 0, 0, 0, ZBX_FK_CASCADE_DELETE};
return DBadd_foreign_key("items", 1, &field);
}
static int DBpatch_4050006(void)
{
const zbx_db_field_t field = {"key_", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("item_discovery", &field, NULL);
}
static int DBpatch_4050007(void)
{
const zbx_db_field_t field = {"key_", "", NULL, NULL, 2048, ZBX_TYPE_CHAR, ZBX_NOTNULL, 0};
return DBmodify_field_type("dchecks", &field, NULL);
}
static int DBpatch_4050011(void)
{
#if defined(HAVE_IBM_DB2) || defined(HAVE_POSTGRESQL)
const char *cast_value_str = "bigint";
#elif defined(HAVE_MYSQL)
const char *cast_value_str = "unsigned";
#endif
if (ZBX_DB_OK > zbx_db_execute(
"update profiles"
" set value_id=CAST(value_str as %s),"
" value_str='',"
" type=1"
" where type=3"
" and (idx='web.latest.filter.groupids' or idx='web.latest.filter.hostids')", cast_value_str))