StarRocks / starrocks

The world's fastest open query engine for sub-second analytics both on and off the data lakehouse. With the flexibility to support nearly any scenario, StarRocks provides best-in-class performance for multi-dimensional analytics, real-time analytics, and ad-hoc queries. A Linux Foundation project.
https://starrocks.io
Apache License 2.0
8.89k stars 1.78k forks source link

prepare stmt exec failed after table schema change by java #44874

Open nextdreamblue opened 6 months ago

nextdreamblue commented 6 months ago

Steps to reproduce the behavior (Required)

  1. CREATE TABLE test1 ( k1 int(11) NULL COMMENT "", k2 int(11) NULL COMMENT "", k3 varchar(300) NULL COMMENT "", k4 varchar(30) NULL COMMENT "", k5 date NULL COMMENT "", new_column0 int(11) NULL DEFAULT "0" COMMENT "" ) ENGINE=OLAP UNIQUE KEY(k1, k2, k3) COMMENT "OLAP" DISTRIBUTED BY HASH(k1, k2, k3) BUCKETS 1 PROPERTIES ( "compression" = "LZ4", "fast_schema_evolution" = "true", "replicated_storage" = "true", "replication_num" = "1" );

  2. insert into test1 values(1,2,'a','b','2020-01-01');

  3. by java prepare stmt preparedStatement = connect.prepareStatement("select * from test1 where k2 = ? and k3 = ?"); preparedStatement.setString(1, "2"); preparedStatement.setString(2, "a"); stmt.execute("ALTER table test1 ADD COLUMN new_column0 INT default \"0\";"); stmt.execute("INSERT INTO test1 VALUES(2, 3, \"aa\", \"bb\", \"2030-01-02\", 1)"); preparedStatement.setString(1, "3"); preparedStatement.setString(2, "aa"); // 执行查询 resultSet = preparedStatement.executeQuery(); will get exception by java

    Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for length 5
    at com.mysql.cj.protocol.a.MergingColumnDefinitionFactory.createFromFields(MergingColumnDefinitionFactory.java:61)
    at com.mysql.cj.protocol.a.ColumnDefinitionReader.read(ColumnDefinitionReader.java:80)
    at com.mysql.cj.protocol.a.ColumnDefinitionReader.read(ColumnDefinitionReader.java:40)
    at com.mysql.cj.protocol.a.NativeProtocol.read(NativeProtocol.java:1585)
    at com.mysql.cj.protocol.a.BinaryResultsetReader.read(BinaryResultsetReader.java:70)
    at com.mysql.cj.protocol.a.BinaryResultsetReader.read(BinaryResultsetReader.java:50)
    at com.mysql.cj.protocol.a.NativeProtocol.read(NativeProtocol.java:1598)
    at com.mysql.cj.protocol.a.NativeProtocol.readAllResults(NativeProtocol.java:1652)
    at com.mysql.cj.ServerPreparedQuery.readExecuteResult(ServerPreparedQuery.java:389)
    at com.mysql.cj.ServerPreparedQuery.serverExecute(ServerPreparedQuery.java:208)
    at com.mysql.cj.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:635)
    at com.mysql.cj.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:418)
    ... 3 more

Expected behavior (Required)

exec pareparestmt success

Real behavior (Required)

failed

StarRocks version (Required)

github-actions[bot] commented 3 days ago

We have marked this issue as stale because it has been inactive for 6 months. If this issue is still relevant, removing the stale label or adding a comment will keep it active. Otherwise, we'll close it in 10 days to keep the issue queue tidy. Thank you for your contribution to StarRocks!