Bug #33032 | Incorrect result with UNION and user-defined variables | ||
---|---|---|---|
Submitted: | 6 Dec 2007 10:06 | Modified: | 7 Dec 2007 15:35 |
Reporter: | Rinat Nasibullin | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S3 (Non-critical) |
Version: | 5.0.45-community-nt | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[6 Dec 2007 10:06]
Rinat Nasibullin
[6 Dec 2007 10:10]
Rinat Nasibullin
Related bug http://bugs.mysql.com/31255
[6 Dec 2007 11:08]
Sveta Smirnova
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://dev.mysql.com/doc/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php You will get same result if you issue instead of first SELECT: set @father_id=1; SELECT p.id, p.from_marriage_id, name, @father_id := m.man_id AS father_id FROM person p LEFT JOIN marriage m ON (p.from_marriage_id = m.id) WHERE p.id = @father_id;
[7 Dec 2007 15:35]
Rinat Nasibullin
Ok, it isn't UNION problem, just user-defined variables. mysql> SET @father_id := 1; Query OK, 0 rows affected (0.00 sec) mysql> SELECT @father_id; +------------+ | @father_id | +------------+ | 1 | +------------+ 1 row in set (0.00 sec) mysql> SELECT p.id, p.from_marriage_id, name, -> @father_id2 := m.man_id AS father_id -> FROM person p LEFT JOIN marriage m ON (p.from_marriage_id = m.id) -> WHERE p.id = @father_id; +----+------------------+------+-----------+ | id | from_marriage_id | name | father_id | +----+------------------+------+-----------+ | 1 | 3 | J | 6 | +----+------------------+------+-----------+ 1 row in set (0.00 sec) mysql> SELECT p.id, p.from_marriage_id, name, -> @father_id := m.man_id AS father_id -> FROM person p LEFT JOIN marriage m ON (p.from_marriage_id = m.id) -> WHERE p.id = @father_id; +----+------------------+------+-----------+ | id | from_marriage_id | name | father_id | +----+------------------+------+-----------+ | 1 | 3 | J | 6 | | 6 | 1 | F | 11 | | 11 | NULL | A | NULL | +----+------------------+------+-----------+ 3 rows in set (0.00 sec) Is last query correct?