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

   opengauss version: 7.0
   python version: 3.7
   
   SQL
   ```sql
   CREATE TABLE t4(id BIGINT PRIMARY KEY, v1 int, v2 int, v3 varchar(255));
   insert into t4 values(1, 2, 3, 'abc');
   insert into t4 values(2, 2, 3, 'abc');
   insert into t4 values(3, 2, 3, 'abc');
   ```
   And when I tried to select data from t4, using this:
   ```python
   result = cursor.execute(
               sql.Composed(
                   [ sql.SQL("select v1 from t4 order by %s::int limit %s")]),
               (2, 10),
               prepare=False,
               binary=False)
   ```
   
   I got this:
   
   ```
   psycopg.errors.SystemError: Unknown exception.
   More details: java.lang.ClassCastException: class java.lang.Short cannot be 
cast to class java.lang.Integer (java.lang.Short and java.lang.Integer are in 
module java.base of loader 'bootstrap')
   ```
   It seems it interpret the parameter whose initial type is `int2` as `short`, 
and then put it as Short object. 
   
   I modified this part:
   ```
   --- 
a/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2BinaryProtocolValue.java
   +++ 
b/db-protocol/postgresql/src/main/java/org/apache/shardingsphere/db/protocol/postgresql/packet/command/query/extended/bind/protocol/PostgreSQLInt2BinaryProtocolValue.java
   @@ -31,7 +31,7 @@ public final class PostgreSQLInt2BinaryProtocolValue 
implements PostgreSQLBinary
        
        @Override
        public Object read(final PostgreSQLPacketPayload payload, final int 
parameterValueLength) {
   -        return payload.getByteBuf().readShort();
   +        return payload.readInt2();
        }
   ``` 
   For the reason that ByteBuf does not have `readInt2()`, I think 
`payload.readInt2()` and `payload.gerByteBuf().readInt2()` are equivalent but I 
am not sure about it. I do not know if this is a valid modification and whether 
this is the root cause of this error
   
   
   


-- 
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-unsubscr...@shardingsphere.apache.org.apache.org

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

Reply via email to