Skip to content

Commit 2232172

Browse files
author
Barry Lind
committed
JDBC checkin fixing the following bugs:
Fixed support in the driver for notifications (added PGConnection.getNotifications()) - problem reported by Benjamin.Feinstein@guardent.com Worked around server problems with int8/int2 and constants; quote values when they are intended to bind to an int8/int2 column - reported by many Fixed bug in the Array interface with string parsing not handling escaped characters correctly - reported by devajx@yahoo.com Added workaround to support 'infinity' and '-infinity' for dates - reported bydmitry@openratings.com Fixed some performance issues with setBlob - reported by d.wall@computer.org Added support for using new prepared statements functionality in 7.3 (added PGStatement.setUseServerPrepare() and isUseServerPrepare() methods) Modified Files: jdbc/org/postgresql/PGConnection.java jdbc/org/postgresql/PGStatement.java jdbc/org/postgresql/core/QueryExecutor.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java jdbc/org/postgresql/jdbc2/Array.java Added Files: jdbc/org/postgresql/PGNotification.java jdbc/org/postgresql/core/Notification.java
1 parent 97ac103 commit 2232172

File tree

10 files changed

+243
-40
lines changed

10 files changed

+243
-40
lines changed

src/interfaces/jdbc/org/postgresql/PGConnection.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.postgresql.fastpath.Fastpath;
88
import org.postgresql.largeobject.LargeObjectManager;
99

10-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.1 2002/07/23 03:59:55 barry Exp $
10+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGConnection.java,v 1.2 2002/09/02 03:07:36 barry Exp $
1111
* This interface defines PostgreSQL extentions to the java.sql.Connection interface.
1212
* Any java.sql.Connection object returned by the driver will also implement this
1313
* interface
@@ -68,5 +68,14 @@ public interface PGConnection
6868
*/
6969
public Object getObject(String type, String value) throws SQLException;
7070

71+
72+
/*
73+
* This method returns any notifications that have been received
74+
* since the last call to this method.
75+
* Returns null if there have been no notifications.
76+
*/
77+
public PGNotification[] getNotifications();
78+
79+
7180
}
7281

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.postgresql;
2+
3+
4+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGNotification.java,v 1.1 2002/09/02 03:07:36 barry Exp $
5+
* This interface defines PostgreSQL extention for Notifications
6+
*/
7+
public interface PGNotification
8+
{
9+
/*
10+
* Returns name of this notification
11+
*/
12+
public String getName();
13+
14+
/*
15+
* Returns the process id of the backend process making this notification
16+
*/
17+
public int getPID();
18+
19+
}
20+

src/interfaces/jdbc/org/postgresql/PGStatement.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import java.sql.*;
55

6-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.3 2002/07/23 03:59:55 barry Exp $
6+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.4 2002/09/02 03:07:36 barry Exp $
77
* This interface defines PostgreSQL extentions to the java.sql.Statement interface.
88
* Any java.sql.Statement object returned by the driver will also implement this
99
* interface
@@ -18,4 +18,8 @@ public interface PGStatement
1818
*/
1919
public long getLastOID() throws SQLException;
2020

21+
public void setUseServerPrepare(boolean flag);
22+
23+
public boolean isUseServerPrepare();
24+
2125
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.postgresql.core;
2+
3+
4+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/core/Attic/Notification.java,v 1.1 2002/09/02 03:07:36 barry Exp $
5+
* This is the implementation of the PGNotification interface
6+
*/
7+
public class Notification implements org.postgresql.PGNotification
8+
{
9+
public Notification(String p_name, int p_pid) {
10+
m_name = p_name;
11+
m_pid = p_pid;
12+
}
13+
14+
/*
15+
* Returns name of this notification
16+
*/
17+
public String getName() {
18+
return m_name;
19+
}
20+
21+
/*
22+
* Returns the process id of the backend process making this notification
23+
*/
24+
public int getPID() {
25+
return m_pid;
26+
}
27+
28+
private String m_name;
29+
private int m_pid;
30+
31+
}
32+

src/interfaces/jdbc/org/postgresql/core/QueryExecutor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* <p>The lifetime of a QueryExecutor object is from sending the query
1414
* until the response has been received from the backend.
1515
*
16-
* $Id: QueryExecutor.java,v 1.14 2002/08/23 20:45:49 barry Exp $
16+
* $Id: QueryExecutor.java,v 1.15 2002/09/02 03:07:36 barry Exp $
1717
*/
1818

1919
public class QueryExecutor
@@ -75,6 +75,7 @@ public java.sql.ResultSet execute() throws SQLException
7575
case 'A': // Asynchronous Notify
7676
int pid = pg_stream.ReceiveInteger(4);
7777
String msg = pg_stream.ReceiveString(connection.getEncoding());
78+
connection.addNotification(new org.postgresql.core.Notification(msg, pid));
7879
break;
7980
case 'B': // Binary Data Transfer
8081
receiveTuple(true);

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
import java.sql.*;
77
import java.util.*;
88
import org.postgresql.Driver;
9+
import org.postgresql.PGNotification;
910
import org.postgresql.PG_Stream;
1011
import org.postgresql.core.*;
1112
import org.postgresql.fastpath.Fastpath;
1213
import org.postgresql.largeobject.LargeObjectManager;
1314
import org.postgresql.util.*;
1415

1516

16-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.6 2002/09/01 23:56:13 davec Exp $
17+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.7 2002/09/02 03:07:36 barry Exp $
1718
* This class defines methods of the jdbc1 specification. This class is
1819
* extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2
1920
* methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection
@@ -34,6 +35,8 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec
3435
protected int pid;
3536
protected int ckey;
3637

38+
private Vector m_notifications;
39+
3740
/*
3841
The encoding to use for this connection.
3942
*/
@@ -1309,7 +1312,22 @@ public int getSQLType(String pgTypeName)
13091312
Types.TIMESTAMP, Types.TIMESTAMP, Types.TIMESTAMP
13101313
};
13111314

1312-
1315+
//Methods to support postgres notifications
1316+
public void addNotification(org.postgresql.PGNotification p_notification) {
1317+
if (m_notifications == null)
1318+
m_notifications = new Vector();
1319+
m_notifications.addElement(p_notification);
1320+
}
1321+
1322+
public PGNotification[] getNotifications() {
1323+
PGNotification[] l_return = null;
1324+
if (m_notifications != null) {
1325+
l_return = new PGNotification[m_notifications.size()];
1326+
m_notifications.copyInto(l_return);
1327+
}
1328+
m_notifications = null;
1329+
return l_return;
1330+
}
13131331
}
13141332

13151333

src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1ResultSet.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.postgresql.util.PGbytea;
1414
import org.postgresql.util.PSQLException;
1515

16-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.4 2002/08/16 17:51:38 barry Exp $
16+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1ResultSet.java,v 1.5 2002/09/02 03:07:36 barry Exp $
1717
* This class defines methods of the jdbc1 specification. This class is
1818
* extended by org.postgresql.jdbc2.AbstractJdbc2ResultSet which adds the jdbc2
1919
* methods. The real ResultSet class (for jdbc1) is org.postgresql.jdbc1.Jdbc1ResultSet
@@ -934,6 +934,15 @@ else if (slen == 19)
934934
}
935935
else
936936
{
937+
if (slen == 8 && s.equals("infinity"))
938+
//java doesn't have a concept of postgres's infinity
939+
//so set to an arbitrary future date
940+
s = "9999-01-01";
941+
if (slen == 9 && s.equals("-infinity"))
942+
//java doesn't have a concept of postgres's infinity
943+
//so set to an arbitrary old date
944+
s = "0001-01-01";
945+
937946
// We must just have a date. This case is
938947
// needed if this method is called on a date
939948
// column

0 commit comments

Comments
 (0)