Permalink
Browse files

refactor: remove unused PgPreparedStatement.adjustIndex (#1253)

  • Loading branch information...
vlsi committed Jul 16, 2018
1 parent 5898cdf commit 178eecc90643b36c8c5cd423ff311b26733384f2
@@ -156,6 +156,8 @@ public boolean executeWithFlags(int flags) throws SQLException {
}
/**
* {@inheritDoc}
*
* <p>Before executing a stored procedure call you must explicitly call registerOutParameter to
* register the java.sql.Type of each out parameter.</p>
*
@@ -169,7 +171,8 @@ public boolean executeWithFlags(int flags) throws SQLException {
* Decimal use the version of registerOutParameter that accepts a scale value
* @throws SQLException if a database-access error occurs.
*/
public void registerOutParameter(int parameterIndex, int sqlType, boolean setPreparedParameters)
@Override
public void registerOutParameter(int parameterIndex, int sqlType)
throws SQLException {
checkClosed();
switch (sqlType) {
@@ -191,6 +194,9 @@ public void registerOutParameter(int parameterIndex, int sqlType, boolean setPre
case Types.LONGVARBINARY:
sqlType = Types.BINARY;
break;
case Types.BOOLEAN:
sqlType = Types.BIT;
break;
default:
break;
}
@@ -202,9 +208,7 @@ public void registerOutParameter(int parameterIndex, int sqlType, boolean setPre
}
checkIndex(parameterIndex, false);
if (setPreparedParameters) {
preparedParameters.registerOutParameter(parameterIndex, sqlType);
}
preparedParameters.registerOutParameter(parameterIndex, sqlType);
// functionReturnType contains the user supplied value to check
// testReturn contains a modified version to make it easier to
// check the getXXX methods..
@@ -220,24 +224,6 @@ public void registerOutParameter(int parameterIndex, int sqlType, boolean setPre
returnTypeSet = true;
}
/**
* <p>You must also specify the scale for numeric/decimal types.</p>
*
* <p>Note: When reading the value of an out parameter, you must use the getXXX method whose Java
* type XXX corresponds to the parameter's registered SQL type.</p>
*
* @param parameterIndex the first parameter is 1, the second is 2,...
* @param sqlType use either java.sql.Type.NUMERIC or java.sql.Type.DECIMAL
* @param scale a value greater than or equal to zero representing the desired number of digits to
* the right of the decimal point
* @param setPreparedParameters set prepared parameters
* @throws SQLException if a database-access error occurs.
*/
public void registerOutParameter(int parameterIndex, int sqlType, int scale,
boolean setPreparedParameters) throws SQLException {
registerOutParameter(parameterIndex, sqlType, setPreparedParameters); // ignore for now..
}
public boolean wasNull() throws SQLException {
if (lastIndex == 0) {
throw new PSQLException(GT.tr("wasNull cannot be call before fetching a result."),
@@ -917,19 +903,6 @@ public Timestamp getTimestamp(String parameterName, Calendar cal) throws SQLExce
throw Driver.notImplemented(this.getClass(), "getURL(String)");
}
public void registerOutParameter(int parameterIndex, int sqlType) throws SQLException {
// if this isn't 8.1 or we are using protocol version 2 then we don't
// register the parameter
switch (sqlType) {
case Types.BOOLEAN:
sqlType = Types.BIT;
break;
default:
}
registerOutParameter(parameterIndex, sqlType, !adjustIndex);
}
public void registerOutParameter(int parameterIndex, int sqlType, int scale) throws SQLException {
// ignore scale for now
registerOutParameter(parameterIndex, sqlType);
@@ -71,13 +71,6 @@
protected final CachedQuery preparedQuery; // Query fragments for prepared statement.
protected final ParameterList preparedParameters; // Parameter values for prepared statement.
/**
* Used to differentiate between new function call logic and old function call logic. Will be set
* to true if the server is &lt; 8.1 or if we are using v2 protocol. There is an exception to this
* where we are using v3, and the call does not have an out parameter before the call.
*/
protected boolean adjustIndex = false;
private TimeZone defaultTimeZone;
PgPreparedStatement(PgConnection connection, String sql, int rsType, int rsConcurrency,
@@ -243,9 +236,6 @@ public void setNull(int parameterIndex, int sqlType) throws SQLException {
// Bad Types value.
throw new PSQLException(GT.tr("Unknown Types value."), PSQLState.INVALID_PARAMETER_TYPE);
}
if (adjustIndex) {
parameterIndex--;
}
preparedParameters.setNull(parameterIndex, oid);
}
@@ -331,9 +321,6 @@ protected void setString(int parameterIndex, String x, int oid) throws SQLExcept
// if the passed string is null, then set this column to null
checkClosed();
if (x == null) {
if (adjustIndex) {
parameterIndex--;
}
preparedParameters.setNull(parameterIndex, oid);
} else {
bindString(parameterIndex, x, oid);
@@ -989,16 +976,10 @@ public String toString() {
* @throws SQLException if something goes wrong
*/
protected void bindLiteral(int paramIndex, String s, int oid) throws SQLException {
if (adjustIndex) {
paramIndex--;
}
preparedParameters.setLiteralParameter(paramIndex, s, oid);
}
protected void bindBytes(int paramIndex, byte[] b, int oid) throws SQLException {
if (adjustIndex) {
paramIndex--;
}
preparedParameters.setBinaryParameter(paramIndex, b, oid);
}
@@ -1012,9 +993,6 @@ protected void bindBytes(int paramIndex, byte[] b, int oid) throws SQLException
* @throws SQLException if something goes wrong
*/
private void bindString(int paramIndex, String s, int oid) throws SQLException {
if (adjustIndex) {
paramIndex--;
}
preparedParameters.setStringParameter(paramIndex, s, oid);
}
@@ -1233,7 +1211,6 @@ public void setClob(int i, Clob x) throws SQLException {
}
public void setNull(int parameterIndex, int t, String typeName) throws SQLException {
if (typeName == null) {
setNull(parameterIndex, t);
return;
@@ -1242,15 +1219,9 @@ public void setNull(int parameterIndex, int t, String typeName) throws SQLExcept
checkClosed();
TypeInfo typeInfo = connection.getTypeInfo();
int oid = typeInfo.getPGType(typeName);
if (adjustIndex) {
parameterIndex--;
}
preparedParameters.setNull(parameterIndex, oid);
}
public void setRef(int i, Ref x) throws SQLException {

0 comments on commit 178eecc

Please sign in to comment.