Bug #30526 Manual, Precedence of XOR
Submitted: 21 Aug 2007 2:21 Modified: 7 Sep 2007 2:09
Reporter: Marc ALFF Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: Paul DuBois CPU Architecture:Any

[21 Aug 2007 2:21] Marc ALFF
Description:
The following statement :

select TRUE OR TRUE XOR TRUE

does not return the same result between 4.1 and 5.0

In 4.1.24:
select TRUE OR TRUE XOR TRUE;
TRUE OR TRUE XOR TRUE
0

In 5.0.48:
select TRUE OR TRUE XOR TRUE;
TRUE OR TRUE XOR TRUE
1

The relative priority or the OR and XOR operators have changed in 5.0

How to repeat:
See description

Suggested fix:
Both 4.1 and 5.0 have been in production for too long,
it's too late to change the code behavior since this will introduce a non
compatible change in 5.0

Suggested fix:
Document this (so far undetected) regression in the manual,
and document the current priority of the XOR operator.
[21 Aug 2007 7:37] Sveta Smirnova
Thank you for the report.

Verified as described.
[4 Sep 2007 22:26] Marc ALFF
See the parser_precedence.test tests cases, for operator precedence.

In the 5.0 manual and above,
XOR should be in a line by itself, between OR and AND:
OR has a lesser precedence that XOR, which has a lesser precedence that AND

Also, note that listing "||" as the same precedence as "OR" is incorrect:
this might not be the case depending on SQL_MODE PIPE_AS_CONCAT
[7 Sep 2007 2:09] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Updated the precedence of XOR.

Also noted the change in precedence for || if PIPES_AS_CONCAT
is enabled.