SQL queries Zabbix components create/use must adhere to the following guidelines.
Server SQL statements:
"select hostid,host from hosts where hostid=" ZBX_FS_UI64 " and status=%d;"
"update hosts set host='%s',ip='%s',useip=%d where hostid=" ZBX_FS_UI64 ";"
Wrong:
if (ZBX_DB_OK > zbx_db_execute("delete from item_rtdata"
" where exists ("
" select 1 from items i where"
" item_rtdata.itemid=i.itemid and i.flags=2"
")"))
Right:
if (ZBX_DB_OK > zbx_db_execute("delete from item_rtdata"
" where exists ("
"select null from items i where item_rtdata.itemid=i.itemid and i.flags=2"
")"))
All SQL parts in a multi-line query should have tree style