Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
10.0(EOL), 10.1(EOL)
Description
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARCHAR(40));
|
INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x');
|
SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01';
|
returns:
+-------------+
|
| a |
|
+-------------+
|
| 2001-01-01 |
|
| 2001-01-01x |
|
+-------------+
|
The second row is obviously wrong.
If I write WHERE the other way round:
SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01';
|
it works fine and correctly returns one row:
+------------+
|
| a |
|
+------------+
|
| 2001-01-01 |
|
+------------+
|
The same problem is repeatable with ENUM type:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a ENUM('2001-01-01','2001-01-01x'));
|
INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x');
|
SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01';
|
SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01';
|
Another example using ROW syntax:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARCHAR(20));
|
INSERT INTO t1 VALUES ('2001-01-01x'),('2001-01-01');
|
SELECT * FROM t1 WHERE (a,a)=('2001-01-01x',DATE'2001-01-01');
|
SELECT * FROM t1 WHERE (a,a)=(DATE'2001-01-01','2001-01-01x')
|
The first query correctly returns one row, the second query erroneously returns two rows.
Another example:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40));
|
INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x');
|
SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01';
|
returns:
+------------+-------------+
|
| a | b |
|
+------------+-------------+
|
| 2001-01-01 | 2001-01-01x |
|
+------------+-------------+
|
This is wrong. The expected result is empty set.
The same problem happens with ENUM:
DROP TABLE IF EXISTS t1;
|
CREATE TABLE t1 (a ENUM('2001-01-01','2001-01-01x'),b ENUM('2001-01-01','2001-01-01x'));
|
INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x');
|
SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01';
|
It erroneously returns one row. The expected result it to return no rows.
Attachments
Issue Links
- blocks
-
MDEV-8728 Fix a number of problems in equal field and equal expression propagation
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Description |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. |
Description |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. |
Description |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} Another example using ROW syntax: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(20)); INSERT INTO t1 VALUES ('2001-01-01x'),('2001-01-01'); SELECT * FROM t1 WHERE (a,a)=('2001-01-01x',DATE'2001-01-01'); SELECT * FROM t1 WHERE (a,a)=(DATE'2001-01-01','2001-01-01x') {code} The first query correctly returns one row, the second query erroneously returns two rows. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. |
Description |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} Another example using ROW syntax: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(20)); INSERT INTO t1 VALUES ('2001-01-01x'),('2001-01-01'); SELECT * FROM t1 WHERE (a,a)=('2001-01-01x',DATE'2001-01-01'); SELECT * FROM t1 WHERE (a,a)=(DATE'2001-01-01','2001-01-01x') {code} The first query correctly returns one row, the second query erroneously returns two rows. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} Another example using ROW syntax: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(20)); INSERT INTO t1 VALUES ('2001-01-01x'),('2001-01-01'); SELECT * FROM t1 WHERE (a,a)=('2001-01-01x',DATE'2001-01-01'); SELECT * FROM t1 WHERE (a,a)=(DATE'2001-01-01','2001-01-01x') {code} The first query correctly returns one row, the second query erroneously returns two rows. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. The same problem happens with ENUM: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a ENUM('2001-01-01','2001-01-01x'),b ENUM('2001-01-01','2001-01-01x')); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} It erroneously returns one row. The expected result it to return no rows. |
Description |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} Another example using ROW syntax: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(20)); INSERT INTO t1 VALUES ('2001-01-01x'),('2001-01-01'); SELECT * FROM t1 WHERE (a,a)=('2001-01-01x',DATE'2001-01-01'); SELECT * FROM t1 WHERE (a,a)=(DATE'2001-01-01','2001-01-01x') {code} The first query correctly returns one row, the second query erroneously returns two rows. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. The same problem happens with ENUM: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a ENUM('2001-01-01','2001-01-01x'),b ENUM('2001-01-01','2001-01-01x')); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} It erroneously returns one row. The expected result it to return no rows. |
{code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; {code} returns: {noformat} +-------------+ | a | +-------------+ | 2001-01-01 | | 2001-01-01x | +-------------+ {noformat} The second row is obviously wrong. If I write WHERE the other way round: {code} SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} it works fine and correctly returns one row: {noformat} +------------+ | a | +------------+ | 2001-01-01 | +------------+ {noformat} The same problem is repeatable with ENUM type: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a ENUM('2001-01-01','2001-01-01x')); INSERT INTO t1 VALUES ('2001-01-01'),('2001-01-01x'); SELECT * FROM t1 WHERE a=DATE'2001-01-01' AND a='2001-01-01'; SELECT * FROM t1 WHERE a='2001-01-01' AND a=DATE'2001-01-01'; {code} Another example using ROW syntax: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(20)); INSERT INTO t1 VALUES ('2001-01-01x'),('2001-01-01'); SELECT * FROM t1 WHERE (a,a)=('2001-01-01x',DATE'2001-01-01'); SELECT * FROM t1 WHERE (a,a)=(DATE'2001-01-01','2001-01-01x') {code} The first query correctly returns one row, the second query erroneously returns two rows. Another example: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a VARCHAR(40),b VARCHAR(40)); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} returns: {noformat} +------------+-------------+ | a | b | +------------+-------------+ | 2001-01-01 | 2001-01-01x | +------------+-------------+ {noformat} This is wrong. The expected result is empty set. The same problem happens with ENUM: {code} DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a ENUM('2001-01-01','2001-01-01x'),b ENUM('2001-01-01','2001-01-01x')); INSERT INTO t1 VALUES ('2001-01-01','2001-01-01x'); SELECT * FROM t1 WHERE a=b AND a=DATE'2001-01-01'; {code} It erroneously returns one row. The expected result it to return no rows. |
Fix Version/s | 10.1.7 [ 19604 ] | |
Fix Version/s | 10.1 [ 16100 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
Labels | upstream |
Labels | upstream | propagation upstream |
Workflow | MariaDB v3 [ 71253 ] | MariaDB v4 [ 149540 ] |