Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit56de09b

Browse files
authored
Merge pull request#4311 from katzyn/check
Fix ConditionInConstantSet usage from other sessions
2 parentscdd1d06 +35f7028 commit56de09b

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

‎h2/src/docsrc/html/changelog.html‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,18 @@ <h1>Change Log</h1>
2121

2222
<h2>Next Version (unreleased)</h2>
2323
<ul>
24-
<li>nothing here yet</li>
24+
<li>Issue #4302: org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Check constraint invalid
25+
</li>
26+
<li>Issue #4286: [2.4.240] SHUTDOWN COMPACT failure
27+
</li>
28+
<li>Issue #4293: Data Race in org.h2.mvstore.tx.TransactionStore.registerTransaction
29+
</li>
30+
<li>Issue #4299: READ_COMMITTED isolation level sometimes doesn't see uncommitted changes from the same transaction 2.4.240
31+
</li>
32+
<li>Issue #4048: Assertion error in shrinkStoreIfPossible
33+
</li>
34+
<li>Issue #4304: DROP SCHEMA &amp; DROP ALL OBJECTS is broken if a materialized view is present in the schema
35+
</li>
2536
</ul>
2637

2738
<h2>Version 2.4.240 (2025-09-22)</h2>

‎h2/src/main/org/h2/expression/condition/ConditionInConstantSet.java‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
importjava.util.List;
1010
importjava.util.TreeSet;
1111

12+
importorg.h2.engine.Database;
1213
importorg.h2.engine.SessionLocal;
1314
importorg.h2.expression.Expression;
1415
importorg.h2.expression.ExpressionColumn;
@@ -53,7 +54,17 @@ public final class ConditionInConstantSet extends ConditionIn {
5354
ConditionInConstantSet(SessionLocalsession,Expressionleft,booleannot,booleanwhenOperand,
5455
ArrayList<Expression>valueList) {
5556
super(left,not,whenOperand,valueList);
56-
this.valueSet =newTreeSet<>(session);
57+
/*
58+
* We can't hold a reference to the session, because expression can be
59+
* used by other sessions (in CHECK constraints, for example).
60+
*
61+
* Because we cast all expressions to the same data type before
62+
* searching in the map, the lookup in the map itself shouldn't depend
63+
* on session-level settings, so it should be safe to use a database
64+
* here.
65+
*/
66+
Databasedb =session.getDatabase();
67+
this.valueSet =newTreeSet<>((o1,o2) ->o1.compareTo(o2,db,db.getCompareMode()));
5768
TypeInfotype =left.getType();
5869
for (Expressionexpression :valueList) {
5970
type =TypeInfo.getHigherType(type,expression.getType());

‎h2/src/test/org/h2/test/db/TestTriggersConstraints.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public void test() throws Exception {
6060
testTriggerAsJavascript();
6161
testTriggers();
6262
testConstraints();
63+
testCheckConstraints();
6364
testCheckConstraintErrorMessage();
6465
testMultiPartForeignKeys();
6566
testConcurrent();
@@ -567,6 +568,19 @@ private void testConstraints() throws SQLException {
567568
conn.close();
568569
}
569570

571+
privatevoidtestCheckConstraints()throwsSQLException {
572+
Connectionconn =getConnection("trigger");
573+
Statementstat =conn.createStatement();
574+
stat.execute("DROP TABLE IF EXISTS TEST");
575+
stat.execute("CREATE TABLE TEST(ID BIGINT PRIMARY KEY, A INT, B INT, CHECK (B IN (2, 3, 5)))");
576+
ConnectionotherConnection =getConnection("trigger");
577+
conn.close();
578+
stat =otherConnection.createStatement();
579+
stat.execute("INSERT INTO TEST VALUES (2, 3, 2)");
580+
stat.execute("DROP TABLE TEST");
581+
otherConnection.close();
582+
}
583+
570584
privatevoidtestCheckConstraintErrorMessage()throwsSQLException {
571585
Connectionconn =getConnection("trigger");
572586
Statementstat =conn.createStatement();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp