You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "sandynz (via GitHub)" <gi...@apache.org> on 2023/02/10 08:57:34 UTC

[GitHub] [shardingsphere] sandynz opened a new issue, #24107: Support order by MySQL VARBINARY primary key

sandynz opened a new issue, #24107:
URL: https://github.com/apache/shardingsphere/issues/24107

   ## Feature Request
   
   ### Is your feature request related to a problem?
   Yes
   
   ### Describe the feature you would like.
   MySQL is used, table primary key is VARBINARY type, it could be ordered in MySQL, but failed in ShardingSphere proxy and JDBC driver.
   The reason is VARBINARY column value type is byte array, it doesn't implement Comparable interface.
   
   Exception example:
   ```
   org.apache.shardingsphere.sharding.exception.data.NotImplementComparableValueException: Order by value must implements Comparable.
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.lambda$getOrderValues$0(OrderByValue.java:113)
   	at org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions.checkState(ShardingSpherePreconditions.java:41)
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.getOrderValues(OrderByValue.java:113)
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByValue.next(OrderByValue.java:105)
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByStreamMergedResult.orderResultSetsToQueue(OrderByStreamMergedResult.java:57)
   	at org.apache.shardingsphere.sharding.merge.dql.orderby.OrderByStreamMergedResult.<init>(OrderByStreamMergedResult.java:50)
   	at org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger.build(ShardingDQLResultMerger.java:100)
   	at org.apache.shardingsphere.sharding.merge.dql.ShardingDQLResultMerger.merge(ShardingDQLResultMerger.java:71)
   	at org.apache.shardingsphere.infra.merge.MergeEngine.executeMerge(MergeEngine.java:81)
   	at org.apache.shardingsphere.infra.merge.MergeEngine.merge(MergeEngine.java:71)
   ```
   
   Example table schema:
   ```
   CREATE TABLE `t_order` (
     `order_id` varbinary(64) NOT NULL,
     `user_id` int(11) NOT NULL,
     `status` varchar(255) DEFAULT NULL,
     PRIMARY KEY (`order_id`)
   ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
   ```
   
   Example query SQL:
   ```
   mysql> select * from t_order order by order_id limit 3;
   ERROR 20024 (44000): Order by value must implements Comparable.
   ```
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org