diff options
Diffstat (limited to 'src/interfaces/jdbc/org/postgresql/jdbc1')
3 files changed, 45 insertions, 17 deletions
diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java index 45160ba34f..bf4ee76bd7 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java @@ -14,7 +14,7 @@ import org.postgresql.largeobject.LargeObjectManager; import org.postgresql.util.*; -/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.8 2002/09/06 21:23:05 momjian Exp $ +/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Connection.java,v 1.9 2002/09/11 05:38:44 barry Exp $ * This class defines methods of the jdbc1 specification. This class is * extended by org.postgresql.jdbc2.AbstractJdbc2Connection which adds the jdbc2 * methods. The real Connection class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Connection @@ -982,21 +982,32 @@ public abstract class AbstractJdbc1Connection implements org.postgresql.PGConnec */ public int getTransactionIsolation() throws SQLException { - clearWarnings(); - ExecSQL("show transaction isolation level"); - - SQLWarning warning = getWarnings(); - if (warning != null) - { - String message = warning.getMessage(); + String sql = "show transaction isolation level"; + String level = null; + if (haveMinimumServerVersion("7.3")) { + ResultSet rs = ExecSQL(sql); + if (rs.next()) { + level = rs.getString(1); + } + rs.close(); + } else { clearWarnings(); - if (message.indexOf("READ COMMITTED") != -1) + ExecSQL(sql); + SQLWarning warning = getWarnings(); + if (warning != null) + { + level = warning.getMessage(); + } + clearWarnings(); + } + if (level != null) { + if (level.indexOf("READ COMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_COMMITTED; - else if (message.indexOf("READ UNCOMMITTED") != -1) + else if (level.indexOf("READ UNCOMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; - else if (message.indexOf("REPEATABLE READ") != -1) + else if (level.indexOf("REPEATABLE READ") != -1) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; - else if (message.indexOf("SERIALIZABLE") != -1) + else if (level.indexOf("SERIALIZABLE") != -1) return java.sql.Connection.TRANSACTION_SERIALIZABLE; } return java.sql.Connection.TRANSACTION_READ_COMMITTED; diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java index 59958e592d..cdf6e8073e 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java @@ -27,19 +27,28 @@ public abstract class AbstractJdbc1DatabaseMetaData protected static final int iInt2Oid = 21; // OID for int2 protected static final int iInt4Oid = 23; // OID for int4 protected static final int VARHDRSZ = 4; // length for int4 - protected static int NAME_SIZE = 64; // length for name datatype + protected static int NAME_SIZE = 63; // length for name datatype public AbstractJdbc1DatabaseMetaData(AbstractJdbc1Connection conn) { this.connection = conn; + String sql; try { if (connection.haveMinimumServerVersion("7.3")) { - NAME_SIZE = 64; + sql = "SELECT t.typlen FROM pg_catalog.pg_type t, pg_catalog.pg_namespace n WHERE t.typnamespace=n.oid AND t.typname='name' AND n.nspname='pg_catalog'"; + NAME_SIZE = 63; } else { - NAME_SIZE = 32; + sql = "SELECT typlen FROM pg_type WHERE typname='name'"; + NAME_SIZE = 31; } + ResultSet rs = connection.createStatement().executeQuery(sql); + if (rs.next()) { + NAME_SIZE = rs.getInt("typlen") - 1; + } + rs.close(); } catch (SQLException l_se) { - //leave value at default + // depending on the error the NAME_SIZE value will + // be the original or the value set before the query. } } diff --git a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java index 672d0eefc7..e7e5d85d22 100644 --- a/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java +++ b/src/interfaces/jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java @@ -8,7 +8,7 @@ import java.util.Vector; import org.postgresql.largeobject.*; import org.postgresql.util.*; -/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.8 2002/09/08 00:15:29 barry Exp $ +/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.9 2002/09/11 05:38:44 barry Exp $ * This class defines methods of the jdbc1 specification. This class is * extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2 * methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement @@ -170,6 +170,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme { String l_sql = replaceProcessing(p_sql); m_sqlFragments = new String[] {l_sql}; + m_binds = new Object[0]; //If we have already created a server prepared statement, we need //to deallocate the existing one if (m_statementName != null) { @@ -213,6 +214,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme { String l_sql = replaceProcessing(p_sql); m_sqlFragments = new String[] {l_sql}; + m_binds = new Object[0]; //If we have already created a server prepared statement, we need //to deallocate the existing one if (m_statementName != null) { @@ -1775,6 +1777,12 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme */ private String modifyJdbcCall(String p_sql) throws SQLException { + //Check that this is actually a call which should start with a { + //if not do nothing and treat this as a standard prepared sql + if (!p_sql.trim().startsWith("{")) { + return p_sql; + } + // syntax checking is not complete only a few basics :( originalSql = p_sql; // save for error msgs.. String l_sql = p_sql; |
