xy720 opened a new pull request, #36133: URL: https://github.com/apache/doris/pull/36133
## Proposed changes Now we still can not handle unsigned type in prepare statement. According to the docs of Mysql Binary Protocol [mysql docs](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query.html). The `param_type_and_flag` flag which indicate a type has 2 bytes. e.g. 1. For signed type: ``` +----------+------------------+---------------------+ | typecode | binary | type | +----------+------------------+---------------------+ | 1 | 0000000000000001 | MYSQL_TYPE_TINY | | 2 | 0000000000000010 | MYSQL_TYPE_SHORT | | 3 | 0000000000000011 | MYSQL_TYPE_LONG | | 8 | 0000000000001000 | MYSQL_TYPE_LONGLONG | +----------+------------------+---------------------+ ``` 2. For unsigned type:3. ``` +----------+------------------+---------------------+ | typecode | binary | type | +----------+------------------+---------------------+ | 1 | 1000000000000001 | MYSQL_TYPE_TINY | | 2 | 1000000000000010 | MYSQL_TYPE_SHORT | | 3 | 1000000000000011 | MYSQL_TYPE_LONG | | 8 | 1000000000001000 | MYSQL_TYPE_LONGLONG | +----------+------------------+---------------------+ ``` The MSB of the 2 bytes is reserved for unsigned flag. Now, when we encountered an unsigned long long in prepared statement, we will meet code 1000000000001000, which is 32776 in integer, then a NullPointerException will be thrown: ``` java.lang.NullPointerException: Cannot invoke "org.apache.doris.qe.StmtExecutor.getParsedStmt()" because "this.executor" is null at org.apache.doris.qe.MysqlConnectProcessor.handleExecute(MysqlConnectProcessor.java:208) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.qe.MysqlConnectProcessor.handleExecute(MysqlConnectProcessor.java:242) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.qe.MysqlConnectProcessor.dispatch(MysqlConnectProcessor.java:287) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.qe.MysqlConnectProcessor.processOnce(MysqlConnectProcessor.java:337) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.mysql.ReadListener.lambda$handleEvent$0(ReadListener.java:52) ~[doris-fe.jar:1.2-SNAPSHOT] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?] at java.lang.Thread.run(Thread.java:840) ~[?:?] ``` So this commit will handle the situation mentioned above. If an unsigned numeric type is encountered, we convert it by using larger data types. For example, we can use small int to represent unsigned tiny int (0-255), big int to represent unsigned ints (0-2 ^ 32-1), and so on. <!--Describe your changes.--> -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
