Skip to content

Add failing regression test for #4308 (CHECK + DEFAULT IDENTITY across connections)#4309

Closed
Daboni wants to merge 1 commit intoh2database:masterfrom
Daboni:fix/check-default-identity-regression
Closed

Add failing regression test for #4308 (CHECK + DEFAULT IDENTITY across connections)#4309
Daboni wants to merge 1 commit intoh2database:masterfrom
Daboni:fix/check-default-identity-regression

Conversation

@Daboni
Copy link

@Daboni Daboni commented Nov 24, 2025

This PR adds a failing regression test for issue #4308(Closed as duplicate). -> Fixes #4302

Summary

On H2 2.4.240, an INSERT that uses:

  • a CHECK (col IN (...)) constraint, and
  • DEFAULT on an IDENTITY primary key,
    fails only when executed across different connections/sessions.

The same SQL succeeds on:

  • H2 2.3.232, and
  • a single-connection workflow on 2.4.240.

Test

TestBug4308 (new)
reproduces the regression with plain JDBC using multiple connections.

The test is expected to fail on 2.4.240 and pass on 2.3.232.

Pass/Fail toggles observed

  • Works if the CREATE TABLE connection is kept open (single-session).
  • Works on H2 2.3.232.
  • Works if the CHECK constraint is removed.
  • Works if INSERT is executed on the same connection as CREATE TABLE.

Notes

  • The test avoids Java text blocks for Java 11 compatibility.
  • This PR intentionally makes CI red to capture the regression.
    A follow-up PR will provide a fix and turn CI green.

@Daboni
Copy link
Author

Daboni commented Nov 25, 2025

This PR adds a failing regression test for the duplicate issue #4302.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

org.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Check constraint invalid:

3 participants