[#5960] Diagnose missing and excess ResultSet.wasNull() calls

This commit is contained in:
lukaseder 2018-01-25 10:01:11 +01:00
parent 70354dbb22
commit c089ae8dcd

View File

@ -51,6 +51,7 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.RowId;
import java.sql.SQLException;
import java.sql.SQLType;
import java.sql.SQLXML;
import java.sql.Statement;
import java.sql.Time;
@ -627,6 +628,18 @@ final class DiagnosticsResultSet extends DefaultResultSet {
read(super.findColumn(columnLabel));
}
private final DefaultDiagnosticsContext ctx() {
DefaultDiagnosticsContext ctx = new DefaultDiagnosticsContext(sql);
ctx.resultSet = super.getDelegate();
ctx.resultSetFetchedColumns = read.cardinality();
ctx.resultSetActualColumns = columns;
ctx.resultSetFetchedRows = current;
ctx.resultSetActualRows = current + 1;
return ctx;
}
// ------------------------------------------------------------------------
// XXX Navigational methods
// ------------------------------------------------------------------------
@ -699,6 +712,30 @@ final class DiagnosticsResultSet extends DefaultResultSet {
return success;
}
@Override
public boolean isBeforeFirst() throws SQLException {
checkPrimitive();
return super.isBeforeFirst();
}
@Override
public boolean isAfterLast() throws SQLException {
checkPrimitive();
return super.isAfterLast();
}
@Override
public boolean isFirst() throws SQLException {
checkPrimitive();
return super.isFirst();
}
@Override
public boolean isLast() throws SQLException {
checkPrimitive();
return super.isLast();
}
@Override
public final void close() throws SQLException {
checkPrimitive();
@ -720,15 +757,583 @@ final class DiagnosticsResultSet extends DefaultResultSet {
super.close();
}
private final DefaultDiagnosticsContext ctx() {
DefaultDiagnosticsContext ctx = new DefaultDiagnosticsContext(sql);
// ------------------------------------------------------------------------
// XXX Other methods
// ------------------------------------------------------------------------
ctx.resultSet = super.getDelegate();
ctx.resultSetFetchedColumns = read.cardinality();
ctx.resultSetActualColumns = columns;
ctx.resultSetFetchedRows = current;
ctx.resultSetActualRows = current + 1;
@Override
public void setFetchDirection(int direction) throws SQLException {
checkPrimitive();
super.setFetchDirection(direction);
}
return ctx;
@Override
public void setFetchSize(int rows) throws SQLException {
checkPrimitive();
super.setFetchSize(rows);
}
@Override
public boolean rowUpdated() throws SQLException {
checkPrimitive();
return super.rowUpdated();
}
@Override
public boolean rowInserted() throws SQLException {
checkPrimitive();
return super.rowInserted();
}
@Override
public boolean rowDeleted() throws SQLException {
checkPrimitive();
return super.rowDeleted();
}
@Override
public void updateNull(int columnIndex) throws SQLException {
checkPrimitive();
super.updateNull(columnIndex);
}
@Override
public void updateBoolean(int columnIndex, boolean x) throws SQLException {
checkPrimitive();
super.updateBoolean(columnIndex, x);
}
@Override
public void updateByte(int columnIndex, byte x) throws SQLException {
checkPrimitive();
super.updateByte(columnIndex, x);
}
@Override
public void updateShort(int columnIndex, short x) throws SQLException {
checkPrimitive();
super.updateShort(columnIndex, x);
}
@Override
public void updateInt(int columnIndex, int x) throws SQLException {
checkPrimitive();
super.updateInt(columnIndex, x);
}
@Override
public void updateLong(int columnIndex, long x) throws SQLException {
checkPrimitive();
super.updateLong(columnIndex, x);
}
@Override
public void updateFloat(int columnIndex, float x) throws SQLException {
checkPrimitive();
super.updateFloat(columnIndex, x);
}
@Override
public void updateDouble(int columnIndex, double x) throws SQLException {
checkPrimitive();
super.updateDouble(columnIndex, x);
}
@Override
public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
checkPrimitive();
super.updateBigDecimal(columnIndex, x);
}
@Override
public void updateString(int columnIndex, String x) throws SQLException {
checkPrimitive();
super.updateString(columnIndex, x);
}
@Override
public void updateBytes(int columnIndex, byte[] x) throws SQLException {
checkPrimitive();
super.updateBytes(columnIndex, x);
}
@Override
public void updateDate(int columnIndex, Date x) throws SQLException {
checkPrimitive();
super.updateDate(columnIndex, x);
}
@Override
public void updateTime(int columnIndex, Time x) throws SQLException {
checkPrimitive();
super.updateTime(columnIndex, x);
}
@Override
public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException {
checkPrimitive();
super.updateTimestamp(columnIndex, x);
}
@Override
public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
checkPrimitive();
super.updateAsciiStream(columnIndex, x, length);
}
@Override
public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException {
checkPrimitive();
super.updateBinaryStream(columnIndex, x, length);
}
@Override
public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException {
checkPrimitive();
super.updateCharacterStream(columnIndex, x, length);
}
@Override
public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException {
checkPrimitive();
super.updateObject(columnIndex, x, scaleOrLength);
}
@Override
public void updateObject(int columnIndex, Object x) throws SQLException {
checkPrimitive();
super.updateObject(columnIndex, x);
}
@Override
public void updateNull(String columnLabel) throws SQLException {
checkPrimitive();
super.updateNull(columnLabel);
}
@Override
public void updateBoolean(String columnLabel, boolean x) throws SQLException {
checkPrimitive();
super.updateBoolean(columnLabel, x);
}
@Override
public void updateByte(String columnLabel, byte x) throws SQLException {
checkPrimitive();
super.updateByte(columnLabel, x);
}
@Override
public void updateShort(String columnLabel, short x) throws SQLException {
checkPrimitive();
super.updateShort(columnLabel, x);
}
@Override
public void updateInt(String columnLabel, int x) throws SQLException {
checkPrimitive();
super.updateInt(columnLabel, x);
}
@Override
public void updateLong(String columnLabel, long x) throws SQLException {
checkPrimitive();
super.updateLong(columnLabel, x);
}
@Override
public void updateFloat(String columnLabel, float x) throws SQLException {
checkPrimitive();
super.updateFloat(columnLabel, x);
}
@Override
public void updateDouble(String columnLabel, double x) throws SQLException {
checkPrimitive();
super.updateDouble(columnLabel, x);
}
@Override
public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
checkPrimitive();
super.updateBigDecimal(columnLabel, x);
}
@Override
public void updateString(String columnLabel, String x) throws SQLException {
checkPrimitive();
super.updateString(columnLabel, x);
}
@Override
public void updateBytes(String columnLabel, byte[] x) throws SQLException {
checkPrimitive();
super.updateBytes(columnLabel, x);
}
@Override
public void updateDate(String columnLabel, Date x) throws SQLException {
checkPrimitive();
super.updateDate(columnLabel, x);
}
@Override
public void updateTime(String columnLabel, Time x) throws SQLException {
checkPrimitive();
super.updateTime(columnLabel, x);
}
@Override
public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException {
checkPrimitive();
super.updateTimestamp(columnLabel, x);
}
@Override
public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
checkPrimitive();
super.updateAsciiStream(columnLabel, x, length);
}
@Override
public void updateBinaryStream(String columnLabel, InputStream x, int length) throws SQLException {
checkPrimitive();
super.updateBinaryStream(columnLabel, x, length);
}
@Override
public void updateCharacterStream(String columnLabel, Reader reader, int length) throws SQLException {
checkPrimitive();
super.updateCharacterStream(columnLabel, reader, length);
}
@Override
public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException {
checkPrimitive();
super.updateObject(columnLabel, x, scaleOrLength);
}
@Override
public void updateObject(String columnLabel, Object x) throws SQLException {
checkPrimitive();
super.updateObject(columnLabel, x);
}
@Override
public void insertRow() throws SQLException {
checkPrimitive();
super.insertRow();
}
@Override
public void updateRow() throws SQLException {
checkPrimitive();
super.updateRow();
}
@Override
public void deleteRow() throws SQLException {
checkPrimitive();
super.deleteRow();
}
@Override
public void refreshRow() throws SQLException {
checkPrimitive();
super.refreshRow();
}
@Override
public void updateRef(int columnIndex, Ref x) throws SQLException {
checkPrimitive();
super.updateRef(columnIndex, x);
}
@Override
public void updateRef(String columnLabel, Ref x) throws SQLException {
checkPrimitive();
super.updateRef(columnLabel, x);
}
@Override
public void updateBlob(int columnIndex, Blob x) throws SQLException {
checkPrimitive();
super.updateBlob(columnIndex, x);
}
@Override
public void updateBlob(String columnLabel, Blob x) throws SQLException {
checkPrimitive();
super.updateBlob(columnLabel, x);
}
@Override
public void updateClob(int columnIndex, Clob x) throws SQLException {
checkPrimitive();
super.updateClob(columnIndex, x);
}
@Override
public void updateClob(String columnLabel, Clob x) throws SQLException {
checkPrimitive();
super.updateClob(columnLabel, x);
}
@Override
public void updateArray(int columnIndex, Array x) throws SQLException {
checkPrimitive();
super.updateArray(columnIndex, x);
}
@Override
public void updateArray(String columnLabel, Array x) throws SQLException {
checkPrimitive();
super.updateArray(columnLabel, x);
}
@Override
public void updateRowId(int columnIndex, RowId x) throws SQLException {
checkPrimitive();
super.updateRowId(columnIndex, x);
}
@Override
public void updateRowId(String columnLabel, RowId x) throws SQLException {
checkPrimitive();
super.updateRowId(columnLabel, x);
}
@Override
public boolean isClosed() throws SQLException {
checkPrimitive();
return super.isClosed();
}
@Override
public void updateNString(int columnIndex, String nString) throws SQLException {
checkPrimitive();
super.updateNString(columnIndex, nString);
}
@Override
public void updateNString(String columnLabel, String nString) throws SQLException {
checkPrimitive();
super.updateNString(columnLabel, nString);
}
@Override
public void updateNClob(int columnIndex, NClob nClob) throws SQLException {
checkPrimitive();
super.updateNClob(columnIndex, nClob);
}
@Override
public void updateNClob(String columnLabel, NClob nClob) throws SQLException {
checkPrimitive();
super.updateNClob(columnLabel, nClob);
}
@Override
public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException {
checkPrimitive();
super.updateSQLXML(columnIndex, xmlObject);
}
@Override
public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException {
checkPrimitive();
super.updateSQLXML(columnLabel, xmlObject);
}
@Override
public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
checkPrimitive();
super.updateNCharacterStream(columnIndex, x, length);
}
@Override
public void updateNCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
checkPrimitive();
super.updateNCharacterStream(columnLabel, reader, length);
}
@Override
public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
checkPrimitive();
super.updateAsciiStream(columnIndex, x, length);
}
@Override
public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
checkPrimitive();
super.updateBinaryStream(columnIndex, x, length);
}
@Override
public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
checkPrimitive();
super.updateCharacterStream(columnIndex, x, length);
}
@Override
public void updateAsciiStream(String columnLabel, InputStream x, long length) throws SQLException {
checkPrimitive();
super.updateAsciiStream(columnLabel, x, length);
}
@Override
public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
checkPrimitive();
super.updateBinaryStream(columnLabel, x, length);
}
@Override
public void updateCharacterStream(String columnLabel, Reader reader, long length) throws SQLException {
checkPrimitive();
super.updateCharacterStream(columnLabel, reader, length);
}
@Override
public void updateBlob(int columnIndex, InputStream inputStream, long length) throws SQLException {
checkPrimitive();
super.updateBlob(columnIndex, inputStream, length);
}
@Override
public void updateBlob(String columnLabel, InputStream inputStream, long length) throws SQLException {
checkPrimitive();
super.updateBlob(columnLabel, inputStream, length);
}
@Override
public void updateClob(int columnIndex, Reader reader, long length) throws SQLException {
checkPrimitive();
super.updateClob(columnIndex, reader, length);
}
@Override
public void updateClob(String columnLabel, Reader reader, long length) throws SQLException {
checkPrimitive();
super.updateClob(columnLabel, reader, length);
}
@Override
public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException {
checkPrimitive();
super.updateNClob(columnIndex, reader, length);
}
@Override
public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException {
checkPrimitive();
super.updateNClob(columnLabel, reader, length);
}
@Override
public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
checkPrimitive();
super.updateNCharacterStream(columnIndex, x);
}
@Override
public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException {
checkPrimitive();
super.updateNCharacterStream(columnLabel, reader);
}
@Override
public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
checkPrimitive();
super.updateAsciiStream(columnIndex, x);
}
@Override
public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException {
checkPrimitive();
super.updateBinaryStream(columnIndex, x);
}
@Override
public void updateCharacterStream(int columnIndex, Reader x) throws SQLException {
checkPrimitive();
super.updateCharacterStream(columnIndex, x);
}
@Override
public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
checkPrimitive();
super.updateAsciiStream(columnLabel, x);
}
@Override
public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException {
checkPrimitive();
super.updateBinaryStream(columnLabel, x);
}
@Override
public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException {
checkPrimitive();
super.updateCharacterStream(columnLabel, reader);
}
@Override
public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException {
checkPrimitive();
super.updateBlob(columnIndex, inputStream);
}
@Override
public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException {
checkPrimitive();
super.updateBlob(columnLabel, inputStream);
}
@Override
public void updateClob(int columnIndex, Reader reader) throws SQLException {
checkPrimitive();
super.updateClob(columnIndex, reader);
}
@Override
public void updateClob(String columnLabel, Reader reader) throws SQLException {
checkPrimitive();
super.updateClob(columnLabel, reader);
}
@Override
public void updateNClob(int columnIndex, Reader reader) throws SQLException {
checkPrimitive();
super.updateNClob(columnIndex, reader);
}
@Override
public void updateNClob(String columnLabel, Reader reader) throws SQLException {
checkPrimitive();
super.updateNClob(columnLabel, reader);
}
@Override
public void updateObject(int columnIndex, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException {
checkPrimitive();
super.updateObject(columnIndex, x, targetSqlType, scaleOrLength);
}
@Override
public void updateObject(String columnLabel, Object x, SQLType targetSqlType, int scaleOrLength) throws SQLException {
checkPrimitive();
super.updateObject(columnLabel, x, targetSqlType, scaleOrLength);
}
@Override
public void updateObject(int columnIndex, Object x, SQLType targetSqlType) throws SQLException {
checkPrimitive();
super.updateObject(columnIndex, x, targetSqlType);
}
@Override
public void updateObject(String columnLabel, Object x, SQLType targetSqlType) throws SQLException {
checkPrimitive();
super.updateObject(columnLabel, x, targetSqlType);
}
}