Commit 62da2fa0 authored by Barry Lind's avatar Barry Lind

Fixed DatabaseMetaData to correctly handle NAME size of 64

Fixed Statement to correctly DEALLOCATE any prepared statements

 Modified Files:
 	jdbc/org/postgresql/PGStatement.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
 	jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
parent 24507acc
...@@ -3,7 +3,7 @@ package org.postgresql; ...@@ -3,7 +3,7 @@ package org.postgresql;
import java.sql.*; import java.sql.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.5 2002/09/06 21:23:05 momjian Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Attic/PGStatement.java,v 1.6 2002/09/08 00:15:28 barry Exp $
* This interface defines PostgreSQL extentions to the java.sql.Statement interface. * This interface defines PostgreSQL extentions to the java.sql.Statement interface.
* Any java.sql.Statement object returned by the driver will also implement this * Any java.sql.Statement object returned by the driver will also implement this
* interface * interface
...@@ -18,7 +18,7 @@ public interface PGStatement ...@@ -18,7 +18,7 @@ public interface PGStatement
*/ */
public long getLastOID() throws SQLException; public long getLastOID() throws SQLException;
public void setUseServerPrepare(boolean flag); public void setUseServerPrepare(boolean flag) throws SQLException;
public boolean isUseServerPrepare(); public boolean isUseServerPrepare();
......
...@@ -8,7 +8,7 @@ import java.util.Vector; ...@@ -8,7 +8,7 @@ import java.util.Vector;
import org.postgresql.largeobject.*; import org.postgresql.largeobject.*;
import org.postgresql.util.*; import org.postgresql.util.*;
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.7 2002/09/06 21:23:06 momjian Exp $ /* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.8 2002/09/08 00:15:29 barry Exp $
* This class defines methods of the jdbc1 specification. This class is * This class defines methods of the jdbc1 specification. This class is
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
...@@ -111,8 +111,6 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -111,8 +111,6 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
m_sqlFragments = new String[v.size()]; m_sqlFragments = new String[v.size()];
m_binds = new String[v.size() - 1]; m_binds = new String[v.size() - 1];
m_bindTypes = new String[v.size() - 1]; m_bindTypes = new String[v.size() - 1];
//BJL why if binds is new???
clearParameters();
for (i = 0 ; i < m_sqlFragments.length; ++i) for (i = 0 ; i < m_sqlFragments.length; ++i)
m_sqlFragments[i] = (String)v.elementAt(i); m_sqlFragments[i] = (String)v.elementAt(i);
...@@ -131,6 +129,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -131,6 +129,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
String l_sql = replaceProcessing(p_sql); String l_sql = replaceProcessing(p_sql);
m_sqlFragments = new String[] {l_sql}; m_sqlFragments = new String[] {l_sql};
//If we have already created a server prepared statement, we need
//to deallocate the existing one
if (m_statementName != null) {
((AbstractJdbc1Connection)connection).ExecSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_origSqlFragments = null;
m_executeSqlFragments = null;
}
return executeQuery(); return executeQuery();
} }
...@@ -164,6 +170,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -164,6 +170,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
String l_sql = replaceProcessing(p_sql); String l_sql = replaceProcessing(p_sql);
m_sqlFragments = new String[] {l_sql}; m_sqlFragments = new String[] {l_sql};
//If we have already created a server prepared statement, we need
//to deallocate the existing one
if (m_statementName != null) {
((AbstractJdbc1Connection)connection).ExecSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_origSqlFragments = null;
m_executeSqlFragments = null;
}
return executeUpdate(); return executeUpdate();
} }
...@@ -199,6 +213,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -199,6 +213,14 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
{ {
String l_sql = replaceProcessing(p_sql); String l_sql = replaceProcessing(p_sql);
m_sqlFragments = new String[] {l_sql}; m_sqlFragments = new String[] {l_sql};
//If we have already created a server prepared statement, we need
//to deallocate the existing one
if (m_statementName != null) {
((AbstractJdbc1Connection)connection).ExecSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_origSqlFragments = null;
m_executeSqlFragments = null;
}
return execute(); return execute();
} }
...@@ -566,6 +588,11 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -566,6 +588,11 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
if (rs != null) if (rs != null)
rs.close(); rs.close();
// If using server prepared statements deallocate them
if (m_useServerPrepare && m_statementName != null) {
((AbstractJdbc1Connection)connection).ExecSQL("DEALLOCATE " + m_statementName);
}
// Disasociate it from us (For Garbage Collection) // Disasociate it from us (For Garbage Collection)
result = null; result = null;
} }
...@@ -1812,9 +1839,20 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme ...@@ -1812,9 +1839,20 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
public void setUseServerPrepare(boolean flag) public void setUseServerPrepare(boolean flag) throws SQLException {
{ //Server side prepared statements were introduced in 7.3
m_useServerPrepare = flag; if (connection.haveMinimumServerVersion("7.3")) {
//If turning server prepared statements off deallocate statement
//and reset statement name
if (m_useServerPrepare != flag && !flag)
((AbstractJdbc1Connection)connection).ExecSQL("DEALLOCATE " + m_statementName);
m_statementName = null;
m_useServerPrepare = flag;
} else {
//This is a pre 7.3 server so no op this method
//which means we will never turn on the flag to use server
//prepared statements and thus regular processing will continue
}
} }
public boolean isUseServerPrepare() public boolean isUseServerPrepare()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment