Project

General

Profile

Actions

Bug #1181

closed

Host searching returns duplicates (or-ed facts)

Added by Tim Speetjens over 12 years ago. Updated over 12 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Search
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

When filtering hosts, based on facts or-ed criteria return duplicates:

Affected:
facts.operatingsystemrelease = 5.3 or facts.operatingsystemrelease = 5.4
facts.clientversion = 0.25.5 or facts.hardwaremodel = <model>

Correct:
model = "Model 1" or model = "Model 2"

Actions #1

Updated by Ohad Levy over 12 years ago

  • Category set to Search
  • Assignee set to Amos Benari
  • Target version deleted (0.4)
Actions #2

Updated by Tim Speetjens over 12 years ago

A quick look in dev mode reveals the following SQL (mysql):

SELECT `hosts`.* FROM `hosts`
INNER JOIN `fact_values` fact_values_730703 ON (hosts.id = fact_values_730703.host_id)
INNER JOIN `fact_names` fact_names_730703 ON (fact_names_730703.id = fact_values_730703.fact_name_id)
INNER JOIN `fact_values` fact_values_804546 ON (hosts.id = fact_values_804546.host_id)
INNER JOIN `fact_names` fact_names_804546 ON (fact_names_804546.id = fact_values_804546.fact_name_id) WHERE ((fact_names_730703.`name` = 'operatingsystemrelease' AND fact_values_730703.`value` = BINARY '5.3') OR (fact_names_804546.`name` = 'operatingsystemrelease' AND fact_values_804546.`value` = BINARY '5.4')) ORDER BY `hosts`.`name` ASC LIMIT 0, 20

This should be:

SELECT `hosts`.* FROM `hosts`
INNER JOIN `fact_values` fact_values_730703 ON (hosts.id = fact_values_730703.host_id)
INNER JOIN `fact_names` fact_names_730703 ON (fact_names_730703.id = fact_values_730703.fact_name_id)
INNER JOIN `fact_values` fact_values_804546 ON (hosts.id = fact_values_804546.host_id)
INNER JOIN `fact_names` fact_names_804546 ON (fact_names_804546.id = fact_values_804546.fact_name_id)
WHERE
fact_names_730703.`name` = 'operatingsystemrelease'
AND
fact_names_804546.`name` = 'operatingsystemrelease'
AND
( fact_values_730703.`value` = BINARY '5.3' OR fact_values_804546.`value` = BINARY '5.4')

ORDER BY `hosts`.`name` ASC LIMIT 0, 20

This same principle applies for different fact names, as in the second example query.

Actions #3

Updated by Ohad Levy over 12 years ago

  • Target version set to 0.4
Actions #4

Updated by Ohad Levy over 12 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF