Skip to content

Commit ad88ee1

Browse files
author
Dave Cramer
committed
changed some commented out messages to use the Driver.debug and fixed first to read the underlying data into rowbuffer
1 parent 3f85760 commit ad88ee1

File tree

1 file changed

+59
-5
lines changed

1 file changed

+59
-5
lines changed

src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
6262
protected org.postgresql.jdbc2.Statement statement;
6363

6464
private StringBuffer sbuf = null;
65+
protected byte[][] rowBuffer=null;
66+
protected String sqlQuery=null;
6567

6668
/*
6769
* Create a new ResultSet - Note that we create ResultSets to
@@ -110,12 +112,17 @@ public ResultSet(Connection conn, Field[] fields, Vector tuples, String status,
110112
*/
111113
public boolean next() throws SQLException
112114
{
113-
if (rows == null)
114-
throw new PSQLException("postgresql.con.closed");
115+
if (rows == null)
116+
throw new PSQLException("postgresql.con.closed");
117+
115118

116119
if (++current_row >= rows.size())
117120
return false;
121+
118122
this_row = (byte [][])rows.elementAt(current_row);
123+
124+
rowBuffer=new byte[this_row.length][];
125+
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
119126
return true;
120127
}
121128

@@ -640,6 +647,35 @@ public InputStream getBinaryStream(String columnName) throws SQLException
640647
return getBinaryStream(findColumn(columnName));
641648
}
642649

650+
public java.net.URL getURL(int columnIndex) throws SQLException
651+
{
652+
return null;
653+
}
654+
655+
public java.net.URL getURL(String columnName) throws SQLException
656+
{
657+
return null;
658+
659+
}
660+
661+
public void updateRef(int colIndex,java.sql.Ref ref) throws SQLException {
662+
663+
}
664+
public void updateRef(String colName,java.sql.Ref ref) throws SQLException {
665+
}
666+
public void updateBlob(int colIndex,java.sql.Blob blob) throws SQLException {
667+
}
668+
public void updateBlob(String colName,java.sql.Blob blob) throws SQLException {
669+
}
670+
public void updateClob(int colIndex,java.sql.Clob clob) throws SQLException {
671+
}
672+
public void updateClob(String colName,java.sql.Clob clob) throws SQLException {
673+
}
674+
public void updateArray(int colIndex,java.sql.Array array) throws SQLException {
675+
}
676+
public void updateArray(String colName,java.sql.Array array) throws SQLException {
677+
}
678+
643679
/*
644680
* The first warning reported by calls on this ResultSet is
645681
* returned. Subsequent ResultSet warnings will be chained
@@ -896,8 +932,13 @@ public boolean first() throws SQLException
896932
{
897933
if (rows.size() <= 0)
898934
return false;
935+
899936
current_row = 0;
900937
this_row = (byte [][])rows.elementAt(current_row);
938+
939+
rowBuffer=new byte[this_row.length][];
940+
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
941+
901942
return true;
902943
}
903944

@@ -1137,8 +1178,13 @@ public boolean last() throws SQLException
11371178
final int rows_size = rows.size();
11381179
if (rows_size <= 0)
11391180
return false;
1181+
11401182
current_row = rows_size - 1;
11411183
this_row = (byte [][])rows.elementAt(current_row);
1184+
1185+
rowBuffer=new byte[this_row.length][];
1186+
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
1187+
11421188
return true;
11431189
}
11441190

@@ -1159,6 +1205,7 @@ public boolean previous() throws SQLException
11591205
if (--current_row < 0)
11601206
return false;
11611207
this_row = (byte [][])rows.elementAt(current_row);
1208+
System.arraycopy(this_row,0,rowBuffer,0,this_row.length);
11621209
return true;
11631210
}
11641211

@@ -1598,7 +1645,7 @@ public static Time toTime(String s) throws SQLException
15981645
/**
15991646
* Parse a string and return a timestamp representing its value.
16001647
*
1601-
* The driver is set to return ISO date formated strings. We modify this
1648+
* The driver is set to return ISO date formated strings. We modify this
16021649
* string from the ISO format to a format that Java can understand. Java
16031650
* expects timezone info as 'GMT+09:00' where as ISO gives '+09'.
16041651
* Java also expects fractional seconds to 3 places where postgres
@@ -1625,6 +1672,7 @@ public static Timestamp toTimestamp(String s, ResultSet resultSet)
16251672
synchronized (resultSet)
16261673
{
16271674
SimpleDateFormat df = null;
1675+
if ( org.postgresql.Driver.logDebug ) org.postgresql.Driver.debug("the data from the DB is "+s);
16281676

16291677
// If first time, create the buffer, otherwise clear it.
16301678
if (resultSet.sbuf == null)
@@ -1693,7 +1741,7 @@ public static Timestamp toTimestamp(String s, ResultSet resultSet)
16931741
}
16941742
else if (slen == 19)
16951743
{
1696-
// No tz or fractional second info.
1744+
// No tz or fractional second info.
16971745
// I'm not sure if it is
16981746
// possible to have a string in this format, as pg
16991747
// should give us tz qualified timestamps back, but it was
@@ -1702,7 +1750,7 @@ else if (slen == 19)
17021750
}
17031751
else
17041752
{
1705-
// We must just have a date. This case is
1753+
// We must just have a date. This case is
17061754
// needed if this method is called on a date
17071755
// column
17081756
df = new SimpleDateFormat("yyyy-MM-dd");
@@ -1711,6 +1759,8 @@ else if (slen == 19)
17111759
try
17121760
{
17131761
// All that's left is to parse the string and return the ts.
1762+
if ( org.postgresql.Driver.logDebug ) org.postgresql.Driver.debug( "" + df.parse(resultSet.sbuf.toString()).getTime() );
1763+
17141764
return new Timestamp(df.parse(resultSet.sbuf.toString()).getTime());
17151765
}
17161766
catch (ParseException e)
@@ -1719,5 +1769,9 @@ else if (slen == 19)
17191769
}
17201770
}
17211771
}
1772+
1773+
public void setSQLQuery(String sqlQuery) {
1774+
this.sqlQuery=sqlQuery;
1775+
}
17221776
}
17231777

0 commit comments

Comments
 (0)