Subject: [pgjdbc/pgjdbc] issue #3955: The value of backend_xmin has different transaction behaviors in JDBC and PSQL

From: "frlzk (@frlzk)" <[email-masked]>
Date: Wed, 11 Mar 2026 12:34:08 +0000

**Describe the issue**
Use jdbc backend_xmin has value. 
Use psql backend_xmin not have value.

**Driver Version?** 
42.6.0
**Java Version?**
17
**OS Version?**
ubuntu 24
**PostgreSQL Version?**
15
**To Reproduce**

Use jdbc
```
import java.sql.*;
public class AdvisoryLockExample {
    public static void main(String[] args) {
        String url = "jdbc:postgresql://127.0.0.1:5432/testdb";
        String user = "testuser";
        String password = "123456";
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection(url, user, password);

            conn.setAutoCommit(false);
            System.out.println("Transaction started (auto-commit disabled).");

            stmt = conn.createStatement();
            
            rs = stmt.executeQuery("SELECT '888888 '");
            if (rs.next()) {
                String info = rs.getString(1);
                System.out.println("info: " + info);
            }
            rs.close();
            
            System.out.println("Transaction left open (idle in transaction).");
            System.out.println("Press Enter to commit and exit...");
            System.in.read();
            
            conn.commit();
            System.out.println("Transaction committed.");

        } catch (SQLException | java.io.IOException e) {
            e.printStackTrace();
            if (conn != null) {
                try {
                    conn.rollback();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
            }
        } finally {
            if (rs != null) try { rs.close(); } catch (SQLException ignored) {}
            if (stmt != null) try { stmt.close(); } catch (SQLException ignored) {}
            if (conn != null) try { conn.close(); } catch (SQLException ignored) {}
        }
    }
}
```
```
SELECT * FROM pg_stat_activity WHERE query like '%8888%' \gx
```

Use psql
```
BEGIN;
SELECT '888888';
```
```
SELECT * FROM pg_stat_activity WHERE query like '%8888%' \gx
```
**Expected behaviour**
When use jdbc the backend_xmin is null

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Mon, 20 Apr 2026 13:52:28 +0000

Interesting, thanks for the report

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Mon, 20 Apr 2026 13:54:45 +0000

I just tried this with psql
```
backend_xmin     | 1612181
```

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Mon, 20 Apr 2026 15:24:12 +0000

I'm unable to recreate this