Skip to content

Commit

Permalink
#771 Fixed: CallableStatement.getXXX(String) could return value from …
Browse files Browse the repository at this point in the history
…wrong column

Removed protected method FBCallableStatement.findOutParameter(String)
  • Loading branch information
mrotteveel committed Oct 27, 2023
1 parent e8af4fb commit ab011ca
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 141 deletions.
7 changes: 7 additions & 0 deletions src/docs/asciidoc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,9 @@ The JDBC API specifies _"This `byte` array contains up to `length` consecutive b
+
The JDBC API does not specify what should happen if the requested position is beyond the end-of-blob.
The modified implementation returns an empty array, but given this is unspecified behaviour, we reserve the option to change this in the future to throw an exception instead.
* Fixed: `CallableStatement.getXXX(String)` could return value from wrong column (https://github.com/FirebirdSQL/jaybird/issues/771[#771])
+
This change was also backported to Jaybird 4.0.10 and Jaybird 5.0.3.
* `FBResultSetNotUpdatableException` now extends `SQLNonTransientException` instead of `FBSQLException`.
* Jaybird no longer throws any instances of `FBSQLException`.
Expand Down Expand Up @@ -1098,6 +1101,10 @@ there is no replacement
there is no replacement
** `getLoggerImplementation()`;
there is no replacement
* `FBCallableStatement`
** `findOutParameter(String)` (protected);
use `getAndAssertSingletonResultSet().findColumn(paramName)`;
carefully check if that is the correct usage (the method was removed because the old usage within Jaybird resulted in mapping the wrong column)

The following methods had their visibility reduced:

Expand Down
70 changes: 30 additions & 40 deletions src/main/org/firebirdsql/jdbc/FBCallableStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ public Object getObject(int parameterIndex) throws SQLException {

@Override
public Object getObject(String colName) throws SQLException {
return getObject(findOutParameter(colName));
return getAndAssertSingletonResultSet().getObject(colName);
}

/**
Expand All @@ -530,7 +530,7 @@ public Object getObject(int parameterIndex, Map<String, Class<?>> map) throws SQ
*/
@Override
public Object getObject(String colName, Map<String, Class<?>> map) throws SQLException {
return getObject(findOutParameter(colName), map);
return getAndAssertSingletonResultSet().getObject(colName, map);
}

@Override
Expand All @@ -540,7 +540,7 @@ public <T> T getObject(int parameterIndex, Class<T> type) throws SQLException {

@Override
public <T> T getObject(String parameterName, Class<T> type) throws SQLException {
return getObject(findOutParameter(parameterName), type);
return getAndAssertSingletonResultSet().getObject(parameterName, type);
}

@Override
Expand Down Expand Up @@ -590,107 +590,107 @@ public URL getURL(int parameterIndex) throws SQLException {

@Override
public String getString(String colName) throws SQLException {
return getString(findOutParameter(colName));
return getAndAssertSingletonResultSet().getString(colName);
}

@Override
public boolean getBoolean(String colName) throws SQLException {
return getBoolean(findOutParameter(colName));
return getAndAssertSingletonResultSet().getBoolean(colName);
}

@Override
public byte getByte(String colName) throws SQLException {
return getByte(findOutParameter(colName));
return getAndAssertSingletonResultSet().getByte(colName);
}

@Override
public short getShort(String colName) throws SQLException {
return getShort(findOutParameter(colName));
return getAndAssertSingletonResultSet().getShort(colName);
}

@Override
public int getInt(String colName) throws SQLException {
return getInt(findOutParameter(colName));
return getAndAssertSingletonResultSet().getInt(colName);
}

@Override
public long getLong(String colName) throws SQLException {
return getLong(findOutParameter(colName));
return getAndAssertSingletonResultSet().getLong(colName);
}

@Override
public float getFloat(String colName) throws SQLException {
return getFloat(findOutParameter(colName));
return getAndAssertSingletonResultSet().getFloat(colName);
}

@Override
public double getDouble(String colName) throws SQLException {
return getDouble(findOutParameter(colName));
return getAndAssertSingletonResultSet().getDouble(colName);
}

@Override
public byte[] getBytes(String colName) throws SQLException {
return getBytes(findOutParameter(colName));
return getAndAssertSingletonResultSet().getBytes(colName);
}

@Override
public Date getDate(String colName) throws SQLException {
return getDate(findOutParameter(colName));
return getAndAssertSingletonResultSet().getDate(colName);
}

@Override
public Time getTime(String colName) throws SQLException {
return getTime(findOutParameter(colName));
return getAndAssertSingletonResultSet().getTime(colName);
}

@Override
public Timestamp getTimestamp(String colName) throws SQLException {
return getTimestamp(findOutParameter(colName));
return getAndAssertSingletonResultSet().getTimestamp(colName);
}

@Override
public BigDecimal getBigDecimal(String colName) throws SQLException {
return getBigDecimal(findOutParameter(colName));
return getAndAssertSingletonResultSet().getBigDecimal(colName);
}

@Override
public Ref getRef(String colName) throws SQLException {
return getRef(findOutParameter(colName));
return getAndAssertSingletonResultSet().getRef(colName);
}

@Override
public Blob getBlob(String colName) throws SQLException {
return getBlob(findOutParameter(colName));
return getAndAssertSingletonResultSet().getBlob(colName);
}

@Override
public Clob getClob(String colName) throws SQLException {
return getClob(findOutParameter(colName));
return getAndAssertSingletonResultSet().getClob(colName);
}

@Override
public Array getArray(String colName) throws SQLException {
return getArray(findOutParameter(colName));
return getAndAssertSingletonResultSet().getArray(colName);
}

@Override
public Date getDate(String colName, Calendar cal) throws SQLException {
return getDate(findOutParameter(colName), cal);
return getAndAssertSingletonResultSet().getDate(colName, cal);
}

@Override
public Time getTime(String colName, Calendar cal) throws SQLException {
return getTime(findOutParameter(colName), cal);
return getAndAssertSingletonResultSet().getTime(colName, cal);
}

@Override
public Timestamp getTimestamp(String colName, Calendar cal) throws SQLException {
return getTimestamp(findOutParameter(colName), cal);
return getAndAssertSingletonResultSet().getTimestamp(colName, cal);
}

@Override
public URL getURL(String colName) throws SQLException {
return getURL(findOutParameter(colName));
return getAndAssertSingletonResultSet().getURL(colName);
}

@Override
Expand All @@ -700,7 +700,7 @@ public Reader getCharacterStream(int parameterIndex) throws SQLException {

@Override
public Reader getCharacterStream(String parameterName) throws SQLException {
return getCharacterStream(findOutParameter(parameterName));
return getAndAssertSingletonResultSet().getCharacterStream(parameterName);
}

/**
Expand All @@ -722,7 +722,7 @@ public Reader getNCharacterStream(int parameterIndex) throws SQLException {
*/
@Override
public Reader getNCharacterStream(String parameterName) throws SQLException {
return getNCharacterStream(findOutParameter(parameterName));
return getAndAssertSingletonResultSet().getNCharacterStream(parameterName);
}

/**
Expand All @@ -744,7 +744,7 @@ public String getNString(int parameterIndex) throws SQLException {
*/
@Override
public String getNString(String parameterName) throws SQLException {
return getNString(findOutParameter(parameterName));
return getAndAssertSingletonResultSet().getNString(parameterName);
}

@Override
Expand Down Expand Up @@ -1268,16 +1268,6 @@ private void setSelectabilityAutomatically(StoredProcedureMetaData storedProcMet
selectableProcedure = storedProcMetaData.isSelectable(procedureCall.getName());
}

/**
* Helper method to identify the right result set column for the give OUT parameter name.
*
* @param paramName
* Name of the OUT parameter
*/
protected int findOutParameter(String paramName) throws SQLException {
return getAndAssertSingletonResultSet().findColumn(paramName);
}

/**
* {@inheritDoc}
* <p>
Expand All @@ -1297,7 +1287,7 @@ public NClob getNClob(int parameterIndex) throws SQLException {
*/
@Override
public NClob getNClob(String parameterName) throws SQLException {
return getNClob(findOutParameter(parameterName));
return getAndAssertSingletonResultSet().getNClob(parameterName);
}

@Override
Expand All @@ -1307,7 +1297,7 @@ public RowId getRowId(int parameterIndex) throws SQLException {

@Override
public RowId getRowId(String parameterName) throws SQLException {
return getRowId(findOutParameter(parameterName));
return getAndAssertSingletonResultSet().getRowId(parameterName);
}

@Override
Expand All @@ -1317,7 +1307,7 @@ public SQLXML getSQLXML(int parameterIndex) throws SQLException {

@Override
public SQLXML getSQLXML(String parameterName) throws SQLException {
return getSQLXML(findOutParameter(parameterName));
return getAndAssertSingletonResultSet().getSQLXML(parameterName);
}

/**
Expand Down
Loading

0 comments on commit ab011ca

Please sign in to comment.