Skip to content

use user variables in [order by] with union got error #1453

@irene-coming

Description

@irene-coming
  • dble version:
    5.6.29-dble-9.9.9.9-78a278906811927e31ad0cdc0cc19c2379963992-20191012125722
  • preconditions :
drop table if exists sharding_2_t1;
drop table if exists schema2.sharding_3_t1;
create table sharding_2_t1(id int(4), B float(8,2)) ;
insert into sharding_2_t1 values(1,234.25),(2,67.29),(3,1.25),(12,1),(1,234.25) ;
create table schema2.sharding_3_t1(id int(4), B int(4)) ;
insert into schema2.sharding_3_t1 values (10, 1),(11, 2),(10,2) ;
  • configs:

schema.xml



rule.xml



server.xml



  • steps:
    step1. query with dble
mysql> set @id_a=2,@id_b=10;
Query OK, 0 rows affected (0.00 sec)

mysql> SELECT id FROM sharding_2_t1 WHERE id=@id_a AND B=67.29 order by @id_a;
+------+
| id   |
+------+
|    2 |
+------+
1 row in set (0.01 sec)
mysql> (SELECT id FROM sharding_2_t1 WHERE id=@id_a AND B=67.29) UNION (SELECT id FROM schema2.sharding_3_t1 WHERE id=@id_b AND B=2);
+------+
| id   |
+------+
|    2 |
|   10 |
+------+
2 rows in set (0.01 sec)
mysql> (SELECT id FROM sharding_2_t1 WHERE id=@id_a AND B=67.29) UNION (SELECT id FROM schema2.sharding_3_t1 WHERE id=@id_b AND B=2) order by @id_a;
ERROR 1003 (HY000): Union field merge error, field not found:@id_a

step2 query with dble

mysql> set @id_a=2,@id_b=10;                                                                                                                                                                    Query OK, 0 rows affected (0.01 sec)

mysql> (SELECT id FROM sharding_2_t1 WHERE id=@id_a AND B=67.29) UNION (SELECT id FROM schema2.sharding_3_t1 WHERE id=@id_b AND B=2) UNION (SELECT id FROM sharding_2_t1 WHERE id=@id_a+@id_b AND B=1) ;
+------+
| id   |
+------+
|    2 |
|   10 |
|   12 |
+------+
3 rows in set (0.03 sec)

mysql> (SELECT id FROM sharding_2_t1 WHERE id=@id_a AND B=67.29) UNION (SELECT id FROM schema2.sharding_3_t1 WHERE id=@id_b AND B=2) UNION (SELECT id FROM sharding_2_t1 WHERE id=@id_a+@id_b AND B=1) order by @id_a ;
  • expect result:
    1.step1 the last query success with resultset:
+------+
| id   |
+------+
|    2 |
|   10 |
+------+
2.step2 the last query success with resultset
+------+
| id   |
+------+
|    2 |
|   10 |
|   12 |
+------+
  • real result:
    1.step1 the last union query got error
    2.step2 the last union query got hang
  • supplements:
    1.

Metadata

Metadata

Assignees

Labels

autotest-addedthe case has append to autotestautotest-waitissue waits to be added to autotestresolveproblem has been fixed by developeruser-variablesproblems with user variables

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions