Skip to content

Commit

Permalink
fix group commit case
Browse files Browse the repository at this point in the history
  • Loading branch information
eldenmoon committed Jun 21, 2024
1 parent 03c640b commit 95666dd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -41,5 +41,5 @@
5 e \N
6 f 40
7 e -1
8 NULL -1
8 \N -1

Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(?, ?, ?, ?)")) {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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"
}

0 comments on commit 95666dd

Please sign in to comment.