ExportXMLWordPrintable

    • Type: Incident report
    • Resolution: Unresolved
    • Priority: Trivial
    • None
    • Affects Version/s: 8.0.0
    • Component/s: API (A), Frontend (F)
    • None

      Zabbix 8.0.0, frontend API, PostgreSQL.

      trigger.get with a host filter and sortfield "lastchange" returns:

      {"code": -32500, "message": "Application error.", "data": "Database error occurred."}

      PostgreSQL reports:

      ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list

      The host filter joins functions on triggerid. The primary key of functions is functionid, so the API builds SELECT DISTINCT. Sorting by lastchange adds ORDER BY trigger_rtdata.lastchange and does not put that column in the select list.

      In 7.0 and 7.4 lastchange is still a column of triggers, and that column is included in the select list when DISTINCT is used. The same request succeeds there.

      The same code is present on release/8.0 and master.

      Steps to reproduce:

      1. Zabbix server 8.0.0 with PostgreSQL.
      2. A monitored host with at least one enabled trigger in PROBLEM state.
      3. Call trigger.get:
        {
            "jsonrpc": "2.0",
            "method": "trigger.get",
            "id": 1,
            "params": {
                "host": "example-host",
                "output": ["triggerid"],
                "filter": {"value": 1, "status": 0},
                "sortfield": "lastchange",
                "sortorder": "DESC",
                "skipDependent": true,
                "monitored": true
            }
        }
        

      Result:
      API error "Database error occurred." PostgreSQL: for SELECT DISTINCT, ORDER BY expressions must appear in select list.

      Expected:
      The trigger ids for that host, sorted by lastchange descending.

      Component: Frontend (API)

            Assignee:
            Zabbix Support Team
            Reporter:
            Michal Laga
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: