Skip to content

Commit

Permalink
undo format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
davecramer committed Nov 1, 2012
1 parent 3481a55 commit cf433a1
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions org/postgresql/core/v3/SimpleParameterList.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
import java.util.Arrays;

import org.postgresql.core.*;
import org.postgresql.util.*;
import org.postgresql.util.PSQLException;
import org.postgresql.util.PSQLState;
import org.postgresql.util.StreamWrapper;
import org.postgresql.util.GT;
import org.postgresql.util.ByteConverter;


/**
* Parameter list for a single-statement V3 query.
Expand All @@ -41,18 +46,14 @@ class SimpleParameterList implements V3ParameterList {
public void registerOutParameter( int index, int sqlType ) throws SQLException
{
if (index < 1 || index > paramValues.length)
{
throw new PSQLException(GT.tr("The column index is out of range: {0}, number of columns: {1}.", new Object[]{new Integer(index), new Integer(paramValues.length)}), PSQLState.INVALID_PARAMETER_VALUE);
}

flags[index-1] |= OUT;
}

private void bind(int index, Object value, int oid, int binary) throws SQLException {
if (index < 1 || index > paramValues.length)
{
throw new PSQLException(GT.tr("The column index is out of range: {0}, number of columns: {1}.", new Object[]{new Integer(index), new Integer(paramValues.length)}), PSQLState.INVALID_PARAMETER_VALUE);
}

--index;

Expand All @@ -65,9 +66,7 @@ private void bind(int index, Object value, int oid, int binary) throws SQLExcept
// send this value, and we don't want to overwrite and require a
// reparse.
if (oid == Oid.UNSPECIFIED && paramTypes[index] != Oid.UNSPECIFIED && value == NULL_OBJECT)
{
return;
}

paramTypes[index] = oid;
}
Expand All @@ -88,9 +87,7 @@ public int getOutParameterCount()
}
// Every function has at least one output.
if (count == 0)
{
count = 1;
}
return count;

}
Expand Down Expand Up @@ -140,13 +137,9 @@ public void setNull(int index, int oid) throws SQLException {
public String toString(int index) {
--index;
if (paramValues[index] == null)
{
return "?";
}
else if (paramValues[index] == NULL_OBJECT)
{
return "NULL";
}

else if ( (flags[index]& BINARY) == BINARY )
{
Expand Down Expand Up @@ -193,9 +186,7 @@ else if ( (flags[index]& BINARY) == BINARY )
}

if (hasBackslash && !standardConformingStrings && supportsEStringSyntax)
{
p.append('E');
}

p.append('\'');
try
Expand All @@ -222,11 +213,9 @@ public void checkAllParametersSet() throws SQLException {
for (int i = 0; i < paramTypes.length; ++i)
{
if (direction(i) != OUT && paramValues[i] == null)
{
throw new PSQLException(GT.tr("No value specified for parameter {0}.", new Integer(i + 1)), PSQLState.INVALID_PARAMETER_VALUE);
}
}
}

public void convertFunctionOutParameters()
{
Expand Down Expand Up @@ -270,10 +259,8 @@ int getTypeOID(int index) {
boolean hasUnresolvedTypes() {
for (int i=0; i< paramTypes.length; i++) {
if (paramTypes[i] == Oid.UNSPECIFIED)
{
return true;
}
}
return false;
}

Expand Down Expand Up @@ -303,21 +290,15 @@ int getV3Length(int index) {

// Null?
if (paramValues[index] == NULL_OBJECT)
{
throw new IllegalArgumentException("can't getV3Length() on a null parameter");
}

// Directly encoded?
if (paramValues[index] instanceof byte[])
{
return ((byte[]) paramValues[index]).length;
}

// Binary-format bytea?
if (paramValues[index] instanceof StreamWrapper)
{
return ((StreamWrapper) paramValues[index]).getLength();
}

// Already encoded?
if (encoded[index] == null)
Expand All @@ -334,9 +315,7 @@ void writeV3Value(int index, PGStream pgStream) throws IOException {

// Null?
if (paramValues[index] == NULL_OBJECT)
{
throw new IllegalArgumentException("can't writeV3Value() on a null parameter");
}

// Directly encoded?
if (paramValues[index] instanceof byte[])
Expand All @@ -354,9 +333,7 @@ void writeV3Value(int index, PGStream pgStream) throws IOException {

// Encoded string.
if (encoded[index] == null)
{
encoded[index] = Utils.encodeUTF8((String) paramValues[index]);
}
pgStream.Send(encoded[index]);
}

Expand Down

0 comments on commit cf433a1

Please sign in to comment.