MySQL Forums
Forum List  »  General

XOR returns true when OR returns false
Posted by: Andy Lanng
Date: August 15, 2016 02:45AM

I have a case where XOR returns true for a condition where OR returns false. This should never be the case.

The query looks odd because it is generated using Entity Framework in .Net.

The full explanation of the issue is a bit long for this post, but I'll summarize below (full post at http://stackoverflow.com/questions/38895765/mysql-or-operand-is-broken)

select *,
(SELECT `Project2`.`id`
FROM `ldz_from_rec` AS `Project2`
/* the next line returns results */
WHERE (`Distinct1`.`region` = `Project2`.`region`) XOR ((`Distinct1`.`region` IS NULL) AND (`Project2`.`region` IS NULL))
/* the next line does not return results */
/*WHERE (`Distinct1`.`region` = `Project2`.`region`) OR ((`Distinct1`.`region` IS NULL) AND (`Project2`.`region` IS NULL))*/
ORDER BY
`Project2`.`LDZ_Exit` ASC LIMIT 1) AS `id`
from (SELECT DISTINCT
`Extent1`.`region`
FROM `ldz_from_rec` AS `Extent1`) as `Distinct1` ;

The problem started when we upgrading a server to 5.7. We have another server running 5.6 which handles the query correctly.

I upgraded my .Net Entity Framework, but the query is the same.

I haven't got any response on other forums I have posted to, so I'm hoping that this is a known issue that I just can't find by myself.

Thanks ^_^

Options: ReplyQuote


Subject
Written By
Posted
XOR returns true when OR returns false
August 15, 2016 02:45AM


Sorry, you can't reply to this topic. It has been closed.
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.