Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-18423

Inconsistent behaviour with Oracle DB compared with other databases when using zbx_db_is_null() check

XMLWordPrintable

    • Sprint 68 (Sep 2020), Sprint 69 (Oct 2020), Sprint 70 (Nov 2020), Sprint 71 (Dec 2020)
    • 0.25

      With non Oracle DB macro expansion with empty string value will succeed but with Oracle DB will fail.

      In most cases zbx_db_is_null() is used for checking various IDs where the value of type zbx_uint64_t can't be an empty string. However there are multiple places where this check is used for values that could be empty strings and not equal to NULL.

      src/libs/zbxserver/expression.c:


      1)

      Observed:
      With MySQL if a discovered host has no DNS macros {DISCOVERY.DEVICE.DNS} expansion will succeed (same with {HOST.METADATA}) and the replaced value would be an empty string. However with Oracle DB in the same scenario macros expansion will fail.

      Expected:
      Identical behaviour with all DBa - no need to fail macro expansion if field is empty (like dservices.dns) or has no data and is NULL (like drules.proxy_hostid). Those are normal situation.

      DBget_dhost_value_by_event()

      • tables: drule, dservices
      -       if (NULL != (row = DBfetch(result)) && SUCCEED != DBis_null(row[0]))
      +       if (NULL != (row = DBfetch(result)))
              {
      -               *replace_to = zbx_strdup(*replace_to, row[0]);
      +               *replace_to = zbx_strdup(*replace_to, ZBX_NULL2STR(row[0]));
      

      get_autoreg_value_by_event()

      • table: autoreg_host
      -               if (SUCCEED == DBis_null(row[0]))
      -               {
      -                       zbx_free(*replace_to);
      -               }
      -               else
      -                       *replace_to = zbx_strdup(*replace_to, row[0]);
      -
      +               *replace_to = zbx_strdup(*replace_to, ZBX_NULL2STR(row[0]));
      

      2)

      DBget_drule_value_by_event()

      • table: drule
        • field: name

      For macro expansion only name field is used. It cannot be NULL and without manually changing DB it also cannot be empty. No need for DBis_null() check.

      -       if (NULL != (row = DBfetch(result)) && SUCCEED != DBis_null(row[0]))
      +       if (NULL != (row = DBfetch(result)))
      

            viktors.tjarve Viktors Tjarve
            viktors.tjarve Viktors Tjarve
            Team A
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: