summaryrefslogtreecommitdiff
path: root/src/interfaces/jdbc/postgresql/jdbc1
diff options
context:
space:
mode:
authorPeter Mount <peter@retep.org.uk>1999-09-14 05:50:44 +0000
committerPeter Mount <peter@retep.org.uk>1999-09-14 05:50:44 +0000
commit24c82830cf8e7cc6d378c622ef1028937a4ee488 (patch)
tree7850bdf877e854d555422f705cc42830ddba9611 /src/interfaces/jdbc/postgresql/jdbc1
parent4197aaa8ae50410cce73fef871b6c5740b705f0c (diff)
Patches for 6.5.2
Diffstat (limited to 'src/interfaces/jdbc/postgresql/jdbc1')
-rw-r--r--src/interfaces/jdbc/postgresql/jdbc1/Connection.java35
-rw-r--r--src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java43
2 files changed, 50 insertions, 28 deletions
diff --git a/src/interfaces/jdbc/postgresql/jdbc1/Connection.java b/src/interfaces/jdbc/postgresql/jdbc1/Connection.java
index f7c88c579a2..7a83e6f114e 100644
--- a/src/interfaces/jdbc/postgresql/jdbc1/Connection.java
+++ b/src/interfaces/jdbc/postgresql/jdbc1/Connection.java
@@ -17,7 +17,7 @@ import postgresql.largeobject.*;
import postgresql.util.*;
/**
- * $Id: Connection.java,v 1.2 1999/05/18 23:17:21 peter Exp $
+ * $Id: Connection.java,v 1.3 1999/09/14 05:50:39 peter Exp $
*
* A Connection represents a session with a specific database. Within the
* context of a Connection, SQL statements are executed and results are
@@ -216,7 +216,7 @@ public class Connection extends postgresql.Connection implements java.sql.Connec
pg_stream = null;
}
}
-
+
/**
* Tests to see if a Connection is closed
*
@@ -311,9 +311,23 @@ public class Connection extends postgresql.Connection implements java.sql.Connec
*/
public void setTransactionIsolation(int level) throws SQLException
{
- throw postgresql.Driver.notImplemented();
+ String q = "SET TRANSACTION ISOLATION LEVEL";
+
+ switch(level) {
+
+ case java.sql.Connection.TRANSACTION_READ_COMMITTED:
+ ExecSQL(q + " READ COMMITTED");
+ return;
+
+ case java.sql.Connection.TRANSACTION_SERIALIZABLE:
+ ExecSQL(q + " SERIALIZABLE");
+ return;
+
+ default:
+ throw new PSQLException("postgresql.con.isolevel",new Integer(level));
+ }
}
-
+
/**
* Get this Connection's current transaction isolation mode.
*
@@ -322,9 +336,18 @@ public class Connection extends postgresql.Connection implements java.sql.Connec
*/
public int getTransactionIsolation() throws SQLException
{
- return java.sql.Connection.TRANSACTION_SERIALIZABLE;
+ ExecSQL("show xactisolevel");
+
+ SQLWarning w = getWarnings();
+ if (w != null) {
+ if (w.getMessage().indexOf("READ COMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_COMMITTED; else
+ if (w.getMessage().indexOf("READ UNCOMMITTED") != -1) return java.sql.Connection.TRANSACTION_READ_UNCOMMITTED; else
+ if (w.getMessage().indexOf("REPEATABLE READ") != -1) return java.sql.Connection.TRANSACTION_REPEATABLE_READ; else
+ if (w.getMessage().indexOf("SERIALIZABLE") != -1) return java.sql.Connection.TRANSACTION_SERIALIZABLE;
+ }
+ return java.sql.Connection.TRANSACTION_READ_COMMITTED;
}
-
+
/**
* The first warning reported by calls on this Connection is
* returned.
diff --git a/src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java b/src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java
index b7e90e8768a..84130f2cb46 100644
--- a/src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java
+++ b/src/interfaces/jdbc/postgresql/jdbc1/DatabaseMetaData.java
@@ -179,7 +179,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public String getDatabaseProductVersion() throws SQLException
{
- return ("6.4");
+ return ("6.5.2");
}
/**
@@ -1350,7 +1350,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public int getDefaultTransactionIsolation() throws SQLException
{
- return Connection.TRANSACTION_SERIALIZABLE;
+ return Connection.TRANSACTION_READ_COMMITTED;
}
/**
@@ -1368,7 +1368,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
/**
* Does the database support the given transaction isolation level?
- * We only support TRANSACTION_SERIALIZABLE
+ * We only support TRANSACTION_SERIALIZABLE and TRANSACTION_READ_COMMITTED
*
* @param level the values are defined in java.sql.Connection
* @return true if so
@@ -1377,10 +1377,11 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
*/
public boolean supportsTransactionIsolationLevel(int level) throws SQLException
{
- if (level == Connection.TRANSACTION_SERIALIZABLE)
- return true;
- else
- return false;
+ if (level == Connection.TRANSACTION_SERIALIZABLE ||
+ level == Connection.TRANSACTION_READ_COMMITTED)
+ return true;
+ else
+ return false;
}
/**
@@ -2151,21 +2152,19 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
public java.sql.ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException
{
return connection.createStatement().executeQuery("SELECT " +
- "'' as TABLE_CAT," +
- "'' AS TABLE_SCHEM," +
- "bc.relname AS TABLE_NAME," +
- "ic.relname AS COLUMN_NAME," +
- "'1' as KEY_SEQ,"+ // -- fake it as a String for now
- "t.typname as PK_NAME " +
- " FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t " +
- " WHERE bc.relkind = 'r' " + // -- not indices
- " and bc.relname ~ '"+table+"'" +
- " and i.indrelid = bc.oid" +
- " and i.indexrelid = ic.oid" +
- " and i.indkey[0] = a.attnum" +
- " and i.indproc = '0'::oid" +
- " and a.attrelid = bc.oid" +
- " ORDER BY TABLE_NAME, COLUMN_NAME;"
+ " '' as TABLE_CAT," +
+ " '' AS TABLE_SCHEM," +
+ " bc.relname AS TABLE_NAME," +
+ " a.attname AS COLUMN_NAME," +
+ " a.attnum as KEY_SEQ," +
+ " ic.relname as PK_NAME" +
+ " from pg_class bc, pg_class ic, pg_index i, pg_attribute a, pg_type t" +
+ " where bc.relkind = 'r'"+
+ " and upper(bc.relname) = upper('test')" +
+ " and i.indrelid = bc.oid" +
+ " and i.indexrelid = ic.oid and a.attrelid = ic.oid"+
+ " and i.indisprimary='t'"+
+ " order by table_name, pk_name,key_seq;"
);
}