TeemIp / teemip-core-ip-mgmt

Core modules of TeemIP, a WEB based IP Address Management tool
https://www.teemip.net
GNU Affero General Public License v3.0
19 stars 12 forks source link

mysql_error = The used SELECT statements have a different number of columns #8

Closed annProg closed 2 years ago

annProg commented 4 years ago

The following oql:

SELECT IPv4Block UNION SELECT IPv6Subnet

will report error:

2020-09-12 21:30:32 | Error   | Exception during GetDisplay: Failed to issue SQL query: query = SELECT
 DISTINCT `IPv4Block_IPBlock`.`id` AS `IPv4Blockid`,
 CAST(CONCAT(COALESCE(`IPv4Block_IPBlock`.`name`, '')) AS CHAR) AS `IPv4Blockfriendlyname`,
 `IPv4Block_IPObject`.`finalclass` AS `IPv4Blockfinalclass`
 FROM 
   `ipblock` AS `IPv4Block_IPBlock`
   INNER JOIN 
      `ipobject` AS `IPv4Block_IPObject`
    ON `IPv4Block_IPBlock`.`id` = `IPv4Block_IPObject`.`id`
 WHERE COALESCE((`IPv4Block_IPBlock`.`finalclass` IN ('IPv4Block')), 1)

 UNION
 SELECT
 DISTINCT `IPv6Subnet`.`id` AS `IPv6Subnetid`,
 CAST(CONCAT(COALESCE(`IPv6Subnet`.`ip_comp`, '')) AS CHAR) AS `IPv6Subnetfriendlyname`,
 `IPv6Subnet_IPObject`.`finalclass` AS `IPv6Subnetfinalclass`,
 `IPv6Subnet`.`ip_text` AS `IPv6Subnetip_text`,
 `IPv6Subnet`.`ip_comp` AS `IPv6Subnetip_comp`
 FROM 
   `ipsubnetv6` AS `IPv6Subnet`
   INNER JOIN 
      `ipobject` AS `IPv6Subnet_IPObject`
    ON `IPv6Subnet`.`id` = `IPv6Subnet_IPObject`.`id`
 WHERE 1

ORDER BY `IPv4Blockfriendlyname` ASC
 LIMIT 0, 10, mysql_errno = 1222, mysql_error = The used SELECT statements have a different number of columns | IssueLog

while the following oql will run correctly

SELECT IPv6Block UNION SELECT IPv4Subnet

Is this a bug?

xtophe38 commented 3 years ago

Sorry for the delayed answer ! I brought the issue to Combodo's R&D team who confirmed that this was a bug.

I'll open a ticket to Combodo who will, hopefully, bring a correction in a future iTop's version. In the meantime, I leave the issue open.

xtophe38 commented 3 years ago

FYI, this bug should be fixed with new iTop 2.7.4 revision. Let's see.

xtophe38 commented 2 years ago

I confirm that that the bug is fixed since iTop 2.7.4 / TeemIp 2.7.1.