From 95666dde0c05b10adcef0a3d8450291dc43e1f61 Mon Sep 17 00:00:00 2001 From: eldenmoon <15605149486@163.com> Date: Fri, 21 Jun 2024 11:44:46 +0800 Subject: [PATCH] fix group commit case --- .../insert_group_commit_with_prepare_stmt.out | 16 ++++++++-------- .../insert_group_commit_with_exception.groovy | 13 +++++++++++-- .../insert_group_commit_with_prepare_stmt.groovy | 8 +++----- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/regression-test/data/insert_p0/insert_group_commit_with_prepare_stmt.out b/regression-test/data/insert_p0/insert_group_commit_with_prepare_stmt.out index b13dfb13cff2db..5baa12fb3a1ebe 100644 --- a/regression-test/data/insert_p0/insert_group_commit_with_prepare_stmt.out +++ b/regression-test/data/insert_p0/insert_group_commit_with_prepare_stmt.out @@ -1,25 +1,25 @@ -- This file is automatically generated. You should know what you did if you want to edit this -- !sql -- 1 a 10 -2 NULL 20 +2 \N 20 3 c \N 4 d 40 5 e \N 6 f 40 -- !sql -- -2 NULL 20 +2 \N 20 3 c \N 4 d 40 5 e \N 6 f 40 7 e -1 -8 NULL -1 +8 \N -1 -- !sql -- 1 a 10 -2 NULL 20 -2 NULL 20 +2 \N 20 +2 \N 20 3 c \N 3 c \N 4 d 40 @@ -31,8 +31,8 @@ -- !sql -- 1 a -1 1 a 10 -2 NULL 20 -2 NULL 20 +2 \N 20 +2 \N 20 3 c \N 3 c \N 4 d 40 @@ -41,5 +41,5 @@ 5 e \N 6 f 40 7 e -1 -8 NULL -1 +8 \N -1 diff --git a/regression-test/suites/insert_p0/insert_group_commit_with_exception.groovy b/regression-test/suites/insert_p0/insert_group_commit_with_exception.groovy index 776714cfd63730..726065afa26ccc 100644 --- a/regression-test/suites/insert_p0/insert_group_commit_with_exception.groovy +++ b/regression-test/suites/insert_p0/insert_group_commit_with_exception.groovy @@ -22,7 +22,6 @@ import java.sql.PreparedStatement suite("insert_group_commit_with_exception", "nonConcurrent") { def table = "insert_group_commit_with_exception" - sql "set global enable_server_side_prepared_statement = false" def getRowCount = { expectedRowCount -> def retry = 0 while (retry < 30) { @@ -75,8 +74,10 @@ suite("insert_group_commit_with_exception", "nonConcurrent") { sql """ set enable_nereids_dml = true; """ sql """ set enable_nereids_planner=true; """ sql """ set enable_fallback_to_original_planner=false; """ + sql "set global enable_server_side_prepared_statement = true" } else { sql """ set enable_nereids_dml = false; """ + sql "set global enable_server_side_prepared_statement = false" } // insert into without column @@ -137,8 +138,10 @@ suite("insert_group_commit_with_exception", "nonConcurrent") { statement.execute("set enable_nereids_dml = true;"); statement.execute("set enable_nereids_planner=true;"); statement.execute("set enable_fallback_to_original_planner=false;"); + sql "set global enable_server_side_prepared_statement = true" } else { statement.execute("set enable_nereids_dml = false;"); + sql "set global enable_server_side_prepared_statement = false" } // without column try (PreparedStatement ps = connection.prepareStatement("insert into ${table} values(?, ?, ?, ?)")) { @@ -262,7 +265,13 @@ suite("insert_group_commit_with_exception", "nonConcurrent") { result = ps.executeBatch() assertTrue(false) } catch (Exception e) { - assertTrue(e.getMessage().contains("Column count doesn't match value count")) + logger.info("exception : " + e) + if (item == "legacy") { + assertTrue(e.getMessage().contains("Column count doesn't match value count")) + } + if (item == "nereids") { + assertTrue(e.getMessage().contains("insert into cols should be corresponding to the query output")) + } } } getRowCount(14) diff --git a/regression-test/suites/insert_p0/insert_group_commit_with_prepare_stmt.groovy b/regression-test/suites/insert_p0/insert_group_commit_with_prepare_stmt.groovy index d10856dff5f2e5..e686b752db573b 100644 --- a/regression-test/suites/insert_p0/insert_group_commit_with_prepare_stmt.groovy +++ b/regression-test/suites/insert_p0/insert_group_commit_with_prepare_stmt.groovy @@ -29,15 +29,13 @@ import java.util.ArrayList import java.util.List import java.util.concurrent.CopyOnWriteArrayList -suite("insert_group_commit_with_prepare_stmt", "nonConcurrent") { +suite("insert_group_commit_with_prepare_stmt") { def user = context.config.jdbcUser def password = context.config.jdbcPassword def realDb = "regression_test_insert_p0" def table = realDb + ".insert_group_commit_with_prepare_stmt" sql "CREATE DATABASE IF NOT EXISTS ${realDb}" - // group commit not supported in nereids - sql "set global enable_server_side_prepared_statement = false" def getRowCount = { expectedRowCount -> def retry = 0 while (retry < 30) { @@ -90,7 +88,8 @@ suite("insert_group_commit_with_prepare_stmt", "nonConcurrent") { } assertTrue(serverInfo.contains("'status':'PREPARE'")) assertTrue(serverInfo.contains("'label':'group_commit_")) - assertEquals(reuse_plan, serverInfo.contains("reuse_group_commit_plan")) + // TODO: currently if enable_server_side_prepared_statement = true, will not reuse plan + // assertEquals(reuse_plan, serverInfo.contains("reuse_group_commit_plan")) } else { // for batch insert ConnectionImpl connection = (ConnectionImpl) stmt.getConnection() @@ -267,5 +266,4 @@ suite("insert_group_commit_with_prepare_stmt", "nonConcurrent") { // try_sql("DROP TABLE ${table}") } } - sql "set global enable_server_side_prepared_statement = true" }