Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
this.sql = sql;
this.returnsResultSet = returnsResultSet(sql);
this.parameterCount = SqlTokenizer.placeholderCount(sql);
this.parameterMetaData = new ParameterMetaDataView(this, parameterCount);

Check warning on line 60 in libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlPreparedStatement.java

View workflow job for this annotation

GitHub Actions / Build & Test (Java 25)

possible 'this' escape before subclass is fully initialized

Check warning on line 60 in libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlPreparedStatement.java

View workflow job for this annotation

GitHub Actions / Build & Test (Java 26)

possible 'this' escape before subclass is fully initialized

Check warning on line 60 in libsql-jdbc/src/main/java/com/github/magnusp/libsql/jdbc/LibsqlPreparedStatement.java

View workflow job for this annotation

GitHub Actions / Xerial Control (reference probe)

possible 'this' escape before subclass is fully initialized
}

private void setParam(int parameterIndex, Value value) throws SQLException {
Expand Down Expand Up @@ -100,7 +100,7 @@
throw new SQLException("Query returns results");
}
execute();
return (int) updateCount;
return snapshotUpdateCount();
}

private static boolean returnsResultSet(String sql) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,18 @@ protected void assignResultSet(
@Override
public int executeUpdate(String sql) throws SQLException {
execute(sql);
return (int) updateCount;
return snapshotUpdateCount();
}

/**
* Reads the update count under {@link #stateLock}, the lock every write to the field holds.
* The execute paths that return a count use this instead of reading the field directly, so the
* value they hand back has the same happens-before edge as {@link #getUpdateCount()}.
*/
protected int snapshotUpdateCount() {
synchronized (stateLock) {
return (int) updateCount;
}
}

@Override
Expand Down
Loading