mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Indent jdbc case labels using pgjindent.
This commit is contained in:
parent
6c8120d68c
commit
09634eafe1
@ -291,7 +291,6 @@ public class ImageViewer implements ItemListener
|
|||||||
|
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
|
||||||
// Now the real import stuff
|
// Now the real import stuff
|
||||||
if (name != null && dir != null)
|
if (name != null && dir != null)
|
||||||
{
|
{
|
||||||
|
@ -214,21 +214,21 @@ public class Unicode
|
|||||||
{
|
{
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case CREATE:
|
case CREATE:
|
||||||
log("Exception creating database", sqle);
|
log("Exception creating database", sqle);
|
||||||
break;
|
break;
|
||||||
case INSERT:
|
case INSERT:
|
||||||
log("Exception inserting block " + blockNum, sqle);
|
log("Exception inserting block " + blockNum, sqle);
|
||||||
break;
|
break;
|
||||||
case SELECT:
|
case SELECT:
|
||||||
log("Exception selecting block " + blockNum, sqle);
|
log("Exception selecting block " + blockNum, sqle);
|
||||||
break;
|
break;
|
||||||
case LIKE:
|
case LIKE:
|
||||||
log("Exception doing LIKE on block " + blockNum, sqle);
|
log("Exception doing LIKE on block " + blockNum, sqle);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log("Exception", sqle);
|
log("Exception", sqle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ClassNotFoundException cnfe)
|
catch (ClassNotFoundException cnfe)
|
||||||
|
@ -6,7 +6,7 @@ import java.text.*;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* $Id: basic.java,v 1.9 2001/11/19 22:43:13 momjian Exp $
|
* $Id: basic.java,v 1.10 2001/11/19 23:16:44 momjian Exp $
|
||||||
*
|
*
|
||||||
* This example tests the basic components of the JDBC driver, and shows
|
* This example tests the basic components of the JDBC driver, and shows
|
||||||
* how even the simplest of queries can be implemented.
|
* how even the simplest of queries can be implemented.
|
||||||
@ -137,6 +137,7 @@ public class basic
|
|||||||
// Now run the query again, showing a more efficient way of getting the
|
// Now run the query again, showing a more efficient way of getting the
|
||||||
// result if you don't know what column number a value is in
|
// result if you don't know what column number a value is in
|
||||||
|
|
||||||
|
|
||||||
System.out.println("performing another query");
|
System.out.println("performing another query");
|
||||||
rs = st.executeQuery("select * from basic where b>1");
|
rs = st.executeQuery("select * from basic where b>1");
|
||||||
if (rs != null)
|
if (rs != null)
|
||||||
@ -163,6 +164,7 @@ public class basic
|
|||||||
|
|
||||||
// Now test maxrows by setting it to 3 rows
|
// Now test maxrows by setting it to 3 rows
|
||||||
|
|
||||||
|
|
||||||
st.setMaxRows(3);
|
st.setMaxRows(3);
|
||||||
System.out.println("performing a query limited to " + st.getMaxRows());
|
System.out.println("performing a query limited to " + st.getMaxRows());
|
||||||
rs = st.executeQuery("select a, b from basic");
|
rs = st.executeQuery("select a, b from basic");
|
||||||
|
@ -61,7 +61,6 @@ public class blobtest
|
|||||||
System.out.println("Now closing the connection");
|
System.out.println("Now closing the connection");
|
||||||
s.close();
|
s.close();
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -171,7 +170,6 @@ public class blobtest
|
|||||||
lobj.unlink(oid);
|
lobj.unlink(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
// This tests the Blob interface of the JDBC 2.0 specification
|
// This tests the Blob interface of the JDBC 2.0 specification
|
||||||
public void jdbc2api(int oid) throws SQLException, IOException
|
public void jdbc2api(int oid) throws SQLException, IOException
|
||||||
{
|
{
|
||||||
@ -218,8 +216,6 @@ public class blobtest
|
|||||||
db.setAutoCommit(false);
|
db.setAutoCommit(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//=======================================================================
|
|
||||||
|
|
||||||
public static void instructions()
|
public static void instructions()
|
||||||
{
|
{
|
||||||
System.err.println("java example.blobtest jdbc-url user password [debug]");
|
System.err.println("java example.blobtest jdbc-url user password [debug]");
|
||||||
|
@ -9,7 +9,7 @@ import org.omg.CosNaming.*;
|
|||||||
*
|
*
|
||||||
* It has no GUI, just a text frontend to keep it simple.
|
* It has no GUI, just a text frontend to keep it simple.
|
||||||
*
|
*
|
||||||
* $Id: StockClient.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
|
* $Id: StockClient.java,v 1.4 2001/11/19 23:16:45 momjian Exp $
|
||||||
*/
|
*/
|
||||||
public class StockClient
|
public class StockClient
|
||||||
{
|
{
|
||||||
@ -116,29 +116,29 @@ public class StockClient
|
|||||||
int i = getMenu("Main", 5);
|
int i = getMenu("Main", 5);
|
||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
run = false;
|
run = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
displayItem();
|
displayItem();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
bookOut();
|
bookOut();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
bookIn();
|
bookIn();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
order(0);
|
order(0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
displayAll();
|
displayAll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import java.text.*;
|
|||||||
*
|
*
|
||||||
* To use this example, you need a database to be in existence. This example
|
* To use this example, you need a database to be in existence. This example
|
||||||
* will create a table called datestyle.
|
* will create a table called datestyle.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class datestyle
|
public class datestyle
|
||||||
@ -105,7 +104,6 @@ public class datestyle
|
|||||||
ps.setDate(1, standard);
|
ps.setDate(1, standard);
|
||||||
ps.executeUpdate();
|
ps.executeUpdate();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -218,7 +218,6 @@ public class metadata
|
|||||||
{
|
{
|
||||||
if (line.startsWith("\\d"))
|
if (line.startsWith("\\d"))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (line.startsWith("\\d "))
|
if (line.startsWith("\\d "))
|
||||||
{
|
{
|
||||||
// Display details about a table
|
// Display details about a table
|
||||||
|
@ -50,7 +50,7 @@ public class psql
|
|||||||
// Now the main loop.
|
// Now the main loop.
|
||||||
int tt = 0, lineno = 1;
|
int tt = 0, lineno = 1;
|
||||||
while (tt != StreamTokenizer.TT_EOF && ! done)
|
while (tt != StreamTokenizer.TT_EOF && ! done)
|
||||||
{ // done added by CWJ to permit \q command
|
{
|
||||||
System.out.print("[" + lineno + "] ");
|
System.out.print("[" + lineno + "] ");
|
||||||
System.out.flush();
|
System.out.flush();
|
||||||
|
|
||||||
@ -72,7 +72,6 @@ public class psql
|
|||||||
System.out.println("Now closing the connection");
|
System.out.println("Now closing the connection");
|
||||||
st.close();
|
st.close();
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -53,7 +53,6 @@ public class threadsafe
|
|||||||
System.out.println("Now closing the connection");
|
System.out.println("Now closing the connection");
|
||||||
st.close();
|
st.close();
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -108,7 +107,6 @@ public class threadsafe
|
|||||||
System.out.println("Waiting for threads to run");
|
System.out.println("Waiting for threads to run");
|
||||||
while (thread1.isAlive() || thread2.isAlive() || thread3.isAlive())
|
while (thread1.isAlive() || thread2.isAlive() || thread3.isAlive())
|
||||||
thread0.yield();
|
thread0.yield();
|
||||||
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -11,7 +11,7 @@ import org.postgresql.util.*;
|
|||||||
import org.postgresql.core.*;
|
import org.postgresql.core.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: Connection.java,v 1.36 2001/11/19 22:33:37 momjian Exp $
|
* $Id: Connection.java,v 1.37 2001/11/19 23:16:45 momjian Exp $
|
||||||
*
|
*
|
||||||
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
|
* This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
|
||||||
* JDBC2 versions of the Connection class.
|
* JDBC2 versions of the Connection class.
|
||||||
@ -115,7 +115,7 @@ public abstract class Connection
|
|||||||
this_url = url;
|
this_url = url;
|
||||||
PG_DATABASE = database;
|
PG_DATABASE = database;
|
||||||
PG_USER = info.getProperty("user");
|
PG_USER = info.getProperty("user");
|
||||||
PG_PASSWORD = info.getProperty("password","");
|
PG_PASSWORD = info.getProperty("password", "");
|
||||||
PG_PORT = port;
|
PG_PORT = port;
|
||||||
PG_HOST = host;
|
PG_HOST = host;
|
||||||
PG_STATUS = CONNECTION_BAD;
|
PG_STATUS = CONNECTION_BAD;
|
||||||
@ -168,88 +168,88 @@ public abstract class Connection
|
|||||||
int beresp = pg_stream.ReceiveChar();
|
int beresp = pg_stream.ReceiveChar();
|
||||||
switch (beresp)
|
switch (beresp)
|
||||||
{
|
{
|
||||||
case 'E':
|
case 'E':
|
||||||
// An error occured, so pass the error message to the
|
// An error occured, so pass the error message to the
|
||||||
// user.
|
// user.
|
||||||
//
|
//
|
||||||
// The most common one to be thrown here is:
|
// The most common one to be thrown here is:
|
||||||
// "User authentication failed"
|
// "User authentication failed"
|
||||||
//
|
//
|
||||||
throw new SQLException(pg_stream.ReceiveString(encoding));
|
throw new SQLException(pg_stream.ReceiveString(encoding));
|
||||||
|
|
||||||
case 'R':
|
case 'R':
|
||||||
// Get the type of request
|
// Get the type of request
|
||||||
areq = pg_stream.ReceiveIntegerR(4);
|
areq = pg_stream.ReceiveIntegerR(4);
|
||||||
|
|
||||||
// Get the crypt password salt if there is one
|
// Get the crypt password salt if there is one
|
||||||
if (areq == AUTH_REQ_CRYPT)
|
if (areq == AUTH_REQ_CRYPT)
|
||||||
{
|
{
|
||||||
byte[] rst = new byte[2];
|
byte[] rst = new byte[2];
|
||||||
rst[0] = (byte)pg_stream.ReceiveChar();
|
rst[0] = (byte)pg_stream.ReceiveChar();
|
||||||
rst[1] = (byte)pg_stream.ReceiveChar();
|
rst[1] = (byte)pg_stream.ReceiveChar();
|
||||||
salt = new String(rst, 0, 2);
|
salt = new String(rst, 0, 2);
|
||||||
DriverManager.println("Crypt salt=" + salt);
|
DriverManager.println("Crypt salt=" + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Or get the md5 password salt if there is one
|
// Or get the md5 password salt if there is one
|
||||||
if (areq == AUTH_REQ_MD5)
|
if (areq == AUTH_REQ_MD5)
|
||||||
{
|
{
|
||||||
byte[] rst = new byte[4];
|
byte[] rst = new byte[4];
|
||||||
rst[0] = (byte)pg_stream.ReceiveChar();
|
rst[0] = (byte)pg_stream.ReceiveChar();
|
||||||
rst[1] = (byte)pg_stream.ReceiveChar();
|
rst[1] = (byte)pg_stream.ReceiveChar();
|
||||||
rst[2] = (byte)pg_stream.ReceiveChar();
|
rst[2] = (byte)pg_stream.ReceiveChar();
|
||||||
rst[3] = (byte)pg_stream.ReceiveChar();
|
rst[3] = (byte)pg_stream.ReceiveChar();
|
||||||
salt = new String(rst, 0, 4);
|
salt = new String(rst, 0, 4);
|
||||||
DriverManager.println("MD5 salt=" + salt);
|
DriverManager.println("MD5 salt=" + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now send the auth packet
|
// now send the auth packet
|
||||||
switch (areq)
|
switch (areq)
|
||||||
{
|
{
|
||||||
case AUTH_REQ_OK:
|
case AUTH_REQ_OK:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AUTH_REQ_KRB4:
|
|
||||||
DriverManager.println("postgresql: KRB4");
|
|
||||||
throw new PSQLException("postgresql.con.kerb4");
|
|
||||||
|
|
||||||
case AUTH_REQ_KRB5:
|
case AUTH_REQ_KRB4:
|
||||||
DriverManager.println("postgresql: KRB5");
|
DriverManager.println("postgresql: KRB4");
|
||||||
throw new PSQLException("postgresql.con.kerb5");
|
throw new PSQLException("postgresql.con.kerb4");
|
||||||
|
|
||||||
case AUTH_REQ_PASSWORD:
|
case AUTH_REQ_KRB5:
|
||||||
DriverManager.println("postgresql: PASSWORD");
|
DriverManager.println("postgresql: KRB5");
|
||||||
pg_stream.SendInteger(5 + PG_PASSWORD.length(), 4);
|
throw new PSQLException("postgresql.con.kerb5");
|
||||||
pg_stream.Send(PG_PASSWORD.getBytes());
|
|
||||||
pg_stream.SendInteger(0, 1);
|
|
||||||
pg_stream.flush();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case AUTH_REQ_CRYPT:
|
case AUTH_REQ_PASSWORD:
|
||||||
DriverManager.println("postgresql: CRYPT");
|
DriverManager.println("postgresql: PASSWORD");
|
||||||
String crypted = UnixCrypt.crypt(salt, PG_PASSWORD);
|
pg_stream.SendInteger(5 + PG_PASSWORD.length(), 4);
|
||||||
pg_stream.SendInteger(5 + crypted.length(), 4);
|
pg_stream.Send(PG_PASSWORD.getBytes());
|
||||||
pg_stream.Send(crypted.getBytes());
|
pg_stream.SendInteger(0, 1);
|
||||||
pg_stream.SendInteger(0, 1);
|
pg_stream.flush();
|
||||||
pg_stream.flush();
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case AUTH_REQ_MD5:
|
case AUTH_REQ_CRYPT:
|
||||||
DriverManager.println("postgresql: MD5");
|
DriverManager.println("postgresql: CRYPT");
|
||||||
byte[] digest = MD5Digest.encode(PG_USER, PG_PASSWORD, salt);
|
String crypted = UnixCrypt.crypt(salt, PG_PASSWORD);
|
||||||
pg_stream.SendInteger(5 + digest.length, 4);
|
pg_stream.SendInteger(5 + crypted.length(), 4);
|
||||||
pg_stream.Send(digest);
|
pg_stream.Send(crypted.getBytes());
|
||||||
pg_stream.SendInteger(0, 1);
|
pg_stream.SendInteger(0, 1);
|
||||||
pg_stream.flush();
|
pg_stream.flush();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUTH_REQ_MD5:
|
||||||
|
DriverManager.println("postgresql: MD5");
|
||||||
|
byte[] digest = MD5Digest.encode(PG_USER, PG_PASSWORD, salt);
|
||||||
|
pg_stream.SendInteger(5 + digest.length, 4);
|
||||||
|
pg_stream.Send(digest);
|
||||||
|
pg_stream.SendInteger(0, 1);
|
||||||
|
pg_stream.flush();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new PSQLException("postgresql.con.auth", new Integer(areq));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.auth", new Integer(areq));
|
throw new PSQLException("postgresql.con.authfail");
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new PSQLException("postgresql.con.authfail");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (areq != AUTH_REQ_OK);
|
while (areq != AUTH_REQ_OK);
|
||||||
@ -265,28 +265,28 @@ public abstract class Connection
|
|||||||
int beresp = pg_stream.ReceiveChar();
|
int beresp = pg_stream.ReceiveChar();
|
||||||
switch (beresp)
|
switch (beresp)
|
||||||
{
|
{
|
||||||
case 'K':
|
case 'K':
|
||||||
pid = pg_stream.ReceiveInteger(4);
|
pid = pg_stream.ReceiveInteger(4);
|
||||||
ckey = pg_stream.ReceiveInteger(4);
|
ckey = pg_stream.ReceiveInteger(4);
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'N':
|
case 'N':
|
||||||
throw new SQLException(pg_stream.ReceiveString(encoding));
|
throw new SQLException(pg_stream.ReceiveString(encoding));
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.setup");
|
throw new PSQLException("postgresql.con.setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Expect ReadyForQuery packet
|
// Expect ReadyForQuery packet
|
||||||
beresp = pg_stream.ReceiveChar();
|
beresp = pg_stream.ReceiveChar();
|
||||||
switch (beresp)
|
switch (beresp)
|
||||||
{
|
{
|
||||||
case 'Z':
|
case 'Z':
|
||||||
break;
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
case 'N':
|
case 'N':
|
||||||
throw new SQLException(pg_stream.ReceiveString(encoding));
|
throw new SQLException(pg_stream.ReceiveString(encoding));
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.setup");
|
throw new PSQLException("postgresql.con.setup");
|
||||||
}
|
}
|
||||||
|
|
||||||
firstWarning = null;
|
firstWarning = null;
|
||||||
@ -958,15 +958,15 @@ public abstract class Connection
|
|||||||
isolationLevelSQL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ";
|
isolationLevelSQL = "SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL ";
|
||||||
switch (isolationLevel)
|
switch (isolationLevel)
|
||||||
{
|
{
|
||||||
case java.sql.Connection.TRANSACTION_READ_COMMITTED:
|
case java.sql.Connection.TRANSACTION_READ_COMMITTED:
|
||||||
isolationLevelSQL += "READ COMMITTED";
|
isolationLevelSQL += "READ COMMITTED";
|
||||||
break;
|
break;
|
||||||
case java.sql.Connection.TRANSACTION_SERIALIZABLE:
|
case java.sql.Connection.TRANSACTION_SERIALIZABLE:
|
||||||
isolationLevelSQL += "SERIALIZABLE";
|
isolationLevelSQL += "SERIALIZABLE";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.isolevel",
|
throw new PSQLException("postgresql.con.isolevel",
|
||||||
new Integer(isolationLevel));
|
new Integer(isolationLevel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExecSQL(isolationLevelSQL);
|
ExecSQL(isolationLevelSQL);
|
||||||
@ -993,16 +993,16 @@ public abstract class Connection
|
|||||||
|
|
||||||
switch (isolationLevel)
|
switch (isolationLevel)
|
||||||
{
|
{
|
||||||
case java.sql.Connection.TRANSACTION_READ_COMMITTED:
|
case java.sql.Connection.TRANSACTION_READ_COMMITTED:
|
||||||
sb.append(" READ COMMITTED");
|
sb.append(" READ COMMITTED");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case java.sql.Connection.TRANSACTION_SERIALIZABLE:
|
case java.sql.Connection.TRANSACTION_SERIALIZABLE:
|
||||||
sb.append(" SERIALIZABLE");
|
sb.append(" SERIALIZABLE");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.isolevel", new Integer(isolationLevel));
|
throw new PSQLException("postgresql.con.isolevel", new Integer(isolationLevel));
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
@ -1166,6 +1166,5 @@ public abstract class Connection
|
|||||||
}
|
}
|
||||||
return pgType;
|
return pgType;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import org.postgresql.core.*;
|
|||||||
import org.postgresql.util.*;
|
import org.postgresql.util.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: PG_Stream.java,v 1.15 2001/11/19 22:33:37 momjian Exp $
|
* $Id: PG_Stream.java,v 1.16 2001/11/19 23:16:45 momjian Exp $
|
||||||
*
|
*
|
||||||
* This class is used by Connection & PGlobj for communicating with the
|
* This class is used by Connection & PGlobj for communicating with the
|
||||||
* backend.
|
* backend.
|
||||||
@ -371,5 +371,4 @@ public class PG_Stream
|
|||||||
pg_input.close();
|
pg_input.close();
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
|
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* $Id: PostgresqlDataSource.java,v 1.4 2001/11/19 22:33:37 momjian Exp $
|
* $Id: PostgresqlDataSource.java,v 1.5 2001/11/19 23:16:45 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -133,38 +133,32 @@ public class PostgresqlDataSource
|
|||||||
*/
|
*/
|
||||||
private int _loginTimeout;
|
private int _loginTimeout;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds the user's account name.
|
* Holds the user's account name.
|
||||||
*/
|
*/
|
||||||
private String _user;
|
private String _user;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds the database password.
|
* Holds the database password.
|
||||||
*/
|
*/
|
||||||
private String _password;
|
private String _password;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds the name of the particular database on the server.
|
* Holds the name of the particular database on the server.
|
||||||
*/
|
*/
|
||||||
private String _databaseName;
|
private String _databaseName;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description of this datasource.
|
* Description of this datasource.
|
||||||
*/
|
*/
|
||||||
private String _description = "PostgreSQL DataSource";
|
private String _description = "PostgreSQL DataSource";
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds the database server name. If null, this is
|
* Holds the database server name. If null, this is
|
||||||
* assumed to be the localhost.
|
* assumed to be the localhost.
|
||||||
*/
|
*/
|
||||||
private String _serverName;
|
private String _serverName;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds the port number where a server is listening.
|
* Holds the port number where a server is listening.
|
||||||
* The default value will open a connection with an
|
* The default value will open a connection with an
|
||||||
@ -172,7 +166,6 @@ public class PostgresqlDataSource
|
|||||||
*/
|
*/
|
||||||
private int _portNumber = DEFAULT_PORT;
|
private int _portNumber = DEFAULT_PORT;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The default port number. Since we open the connection
|
* The default port number. Since we open the connection
|
||||||
* without specifying the port if it's the default one,
|
* without specifying the port if it's the default one,
|
||||||
@ -180,7 +173,6 @@ public class PostgresqlDataSource
|
|||||||
*/
|
*/
|
||||||
private static final int DEFAULT_PORT = 0;
|
private static final int DEFAULT_PORT = 0;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Holds the log writer to which all messages should be
|
* Holds the log writer to which all messages should be
|
||||||
* printed. The default writer is obtained from the driver
|
* printed. The default writer is obtained from the driver
|
||||||
@ -189,7 +181,6 @@ public class PostgresqlDataSource
|
|||||||
*/
|
*/
|
||||||
private transient PrintWriter _logWriter;
|
private transient PrintWriter _logWriter;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Each datasource maintains it's own driver, in case of
|
* Each datasource maintains it's own driver, in case of
|
||||||
* driver-specific setup (e.g. pools, log writer).
|
* driver-specific setup (e.g. pools, log writer).
|
||||||
@ -197,9 +188,6 @@ public class PostgresqlDataSource
|
|||||||
// FIXME
|
// FIXME
|
||||||
// private transient postgresql.Driver _driver;
|
// private transient postgresql.Driver _driver;
|
||||||
private transient org.postgresql.Driver _driver;
|
private transient org.postgresql.Driver _driver;
|
||||||
//---------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PostgresqlDataSource()
|
public PostgresqlDataSource()
|
||||||
{
|
{
|
||||||
@ -233,12 +221,10 @@ public class PostgresqlDataSource
|
|||||||
// FIXME
|
// FIXME
|
||||||
// _driver = new postgresql.Driver();
|
// _driver = new postgresql.Driver();
|
||||||
_driver = new org.postgresql.Driver();
|
_driver = new org.postgresql.Driver();
|
||||||
//-----------
|
|
||||||
|
|
||||||
//FIXME
|
//FIXME
|
||||||
// _driver.setLogWriter( _logWriter );
|
// _driver.setLogWriter( _logWriter );
|
||||||
// Method seems to be unavailable. Just commented it out.
|
// Method seems to be unavailable. Just commented it out.
|
||||||
//----------
|
|
||||||
}
|
}
|
||||||
catch ( SQLException except )
|
catch ( SQLException except )
|
||||||
{
|
{
|
||||||
@ -282,7 +268,6 @@ public class PostgresqlDataSource
|
|||||||
// if ( ! ( conn instanceof postgresql.jdbc2.Connection ) ) {
|
// if ( ! ( conn instanceof postgresql.jdbc2.Connection ) ) {
|
||||||
if ( ! ( conn instanceof org.postgresql.jdbc2.Connection ) )
|
if ( ! ( conn instanceof org.postgresql.jdbc2.Connection ) )
|
||||||
{
|
{
|
||||||
//--------
|
|
||||||
if ( _logWriter != null )
|
if ( _logWriter != null )
|
||||||
_logWriter.println( "DataSource: JDBC 1 connections not supported" );
|
_logWriter.println( "DataSource: JDBC 1 connections not supported" );
|
||||||
throw new PSQLException( "postgresql.ds.onlyjdbc2" );
|
throw new PSQLException( "postgresql.ds.onlyjdbc2" );
|
||||||
@ -317,7 +302,6 @@ public class PostgresqlDataSource
|
|||||||
// FIXME
|
// FIXME
|
||||||
// _driver.setLogWriter( writer );
|
// _driver.setLogWriter( writer );
|
||||||
// Method seems to be unavailable. Commented it out.
|
// Method seems to be unavailable. Commented it out.
|
||||||
//----------
|
|
||||||
_logWriter = writer;
|
_logWriter = writer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -617,7 +601,5 @@ public class PostgresqlDataSource
|
|||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,50 +269,50 @@ public abstract class Statement
|
|||||||
char c = sql.charAt(i);
|
char c = sql.charAt(i);
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case IN_SQLCODE:
|
case IN_SQLCODE:
|
||||||
if (c == '\'') // start of a string?
|
if (c == '\'') // start of a string?
|
||||||
state = IN_STRING;
|
state = IN_STRING;
|
||||||
else if (c == '{') // start of an escape code?
|
else if (c == '{') // start of an escape code?
|
||||||
if (i + 1 < len)
|
if (i + 1 < len)
|
||||||
{
|
|
||||||
char next = sql.charAt(i + 1);
|
|
||||||
if (next == 'd')
|
|
||||||
{
|
{
|
||||||
state = ESC_TIMEDATE;
|
char next = sql.charAt(i + 1);
|
||||||
i++;
|
if (next == 'd')
|
||||||
break;
|
{
|
||||||
|
state = ESC_TIMEDATE;
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (next == 't')
|
||||||
|
{
|
||||||
|
state = ESC_TIMEDATE;
|
||||||
|
i += (i + 2 < len && sql.charAt(i + 2) == 's') ? 2 : 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (next == 't')
|
|
||||||
{
|
|
||||||
state = ESC_TIMEDATE;
|
|
||||||
i += (i + 2 < len && sql.charAt(i + 2) == 's') ? 2 : 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newsql.append(c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IN_STRING:
|
|
||||||
if (c == '\'') // end of string?
|
|
||||||
state = IN_SQLCODE;
|
|
||||||
else if (c == '\\') // a backslash?
|
|
||||||
state = BACKSLASH;
|
|
||||||
|
|
||||||
newsql.append(c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BACKSLASH:
|
|
||||||
state = IN_STRING;
|
|
||||||
|
|
||||||
newsql.append(c);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ESC_TIMEDATE:
|
|
||||||
if (c == '}')
|
|
||||||
state = IN_SQLCODE; // end of escape code.
|
|
||||||
else
|
|
||||||
newsql.append(c);
|
newsql.append(c);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IN_STRING:
|
||||||
|
if (c == '\'') // end of string?
|
||||||
|
state = IN_SQLCODE;
|
||||||
|
else if (c == '\\') // a backslash?
|
||||||
|
state = BACKSLASH;
|
||||||
|
|
||||||
|
newsql.append(c);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BACKSLASH:
|
||||||
|
state = IN_STRING;
|
||||||
|
|
||||||
|
newsql.append(c);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ESC_TIMEDATE:
|
||||||
|
if (c == '}')
|
||||||
|
state = IN_SQLCODE; // end of escape code.
|
||||||
|
else
|
||||||
|
newsql.append(c);
|
||||||
|
break;
|
||||||
} // end switch
|
} // end switch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ package org.postgresql.core;
|
|||||||
*/
|
*/
|
||||||
public class BytePoolDim1
|
public class BytePoolDim1
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The maximum size of the array we manage.
|
* The maximum size of the array we manage.
|
||||||
*/
|
*/
|
||||||
@ -47,26 +46,26 @@ public class BytePoolDim1
|
|||||||
// for now until the bug can be removed
|
// for now until the bug can be removed
|
||||||
return new byte[size];
|
return new byte[size];
|
||||||
/*
|
/*
|
||||||
// Don't pool if >maxsize
|
// Don't pool if >maxsize
|
||||||
if (size > maxsize){
|
if (size > maxsize){
|
||||||
return new byte[size];
|
return new byte[size];
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectPool not_usel = notusemap[size];
|
ObjectPool not_usel = notusemap[size];
|
||||||
ObjectPool in_usel = inusemap[size];
|
ObjectPool in_usel = inusemap[size];
|
||||||
byte b[] = null;
|
byte b[] = null;
|
||||||
|
|
||||||
// Fetch from the unused pool if available otherwise allocate a new
|
// Fetch from the unused pool if available otherwise allocate a new
|
||||||
// now array
|
// now array
|
||||||
if (!not_usel.isEmpty()) {
|
if (!not_usel.isEmpty()) {
|
||||||
Object o = not_usel.remove();
|
Object o = not_usel.remove();
|
||||||
b = (byte[]) o;
|
b = (byte[]) o;
|
||||||
} else
|
} else
|
||||||
b = new byte[size];
|
b = new byte[size];
|
||||||
in_usel.add(b);
|
in_usel.add(b);
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -20,22 +20,22 @@ public class BytePoolDim2
|
|||||||
// For now until the bug can be removed
|
// For now until the bug can be removed
|
||||||
return new byte[size][0];
|
return new byte[size][0];
|
||||||
/*
|
/*
|
||||||
if (size > maxsize){
|
if (size > maxsize){
|
||||||
return new byte[size][0];
|
return new byte[size][0];
|
||||||
}
|
}
|
||||||
ObjectPool not_usel = notusemap[size];
|
ObjectPool not_usel = notusemap[size];
|
||||||
ObjectPool in_usel = inusemap[size];
|
ObjectPool in_usel = inusemap[size];
|
||||||
|
|
||||||
byte b[][] = null;
|
byte b[][] = null;
|
||||||
|
|
||||||
if (!not_usel.isEmpty()) {
|
if (!not_usel.isEmpty()) {
|
||||||
Object o = not_usel.remove();
|
Object o = not_usel.remove();
|
||||||
b = (byte[][]) o;
|
b = (byte[][]) o;
|
||||||
} else
|
} else
|
||||||
b = new byte[size][0];
|
b = new byte[size][0];
|
||||||
in_usel.add(b);
|
in_usel.add(b);
|
||||||
return b;
|
return b;
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release(byte[][] b)
|
public void release(byte[][] b)
|
||||||
|
@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
|
|||||||
* <p>The lifetime of a QueryExecutor object is from sending the query
|
* <p>The lifetime of a QueryExecutor object is from sending the query
|
||||||
* until the response has been received from the backend.
|
* until the response has been received from the backend.
|
||||||
*
|
*
|
||||||
* $Id: QueryExecutor.java,v 1.4 2001/11/19 22:33:37 momjian Exp $
|
* $Id: QueryExecutor.java,v 1.5 2001/11/19 23:16:45 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class QueryExecutor
|
public class QueryExecutor
|
||||||
@ -69,53 +69,53 @@ public class QueryExecutor
|
|||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
case 'A': // Asynchronous Notify
|
case 'A': // Asynchronous Notify
|
||||||
int pid = pg_stream.ReceiveInteger(4);
|
int pid = pg_stream.ReceiveInteger(4);
|
||||||
String msg = pg_stream.ReceiveString(connection.getEncoding());
|
String msg = pg_stream.ReceiveString(connection.getEncoding());
|
||||||
break;
|
break;
|
||||||
case 'B': // Binary Data Transfer
|
case 'B': // Binary Data Transfer
|
||||||
receiveTuple(true);
|
receiveTuple(true);
|
||||||
break;
|
break;
|
||||||
case 'C': // Command Status
|
case 'C': // Command Status
|
||||||
receiveCommandStatus();
|
receiveCommandStatus();
|
||||||
|
|
||||||
if (fields != null)
|
if (fields != null)
|
||||||
hfr = true;
|
hfr = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sendQuery(" ");
|
sendQuery(" ");
|
||||||
fqp++;
|
fqp++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'D': // Text Data Transfer
|
case 'D': // Text Data Transfer
|
||||||
receiveTuple(false);
|
receiveTuple(false);
|
||||||
break;
|
break;
|
||||||
case 'E': // Error Message
|
case 'E': // Error Message
|
||||||
throw new SQLException(pg_stream.ReceiveString(connection.getEncoding()));
|
throw new SQLException(pg_stream.ReceiveString(connection.getEncoding()));
|
||||||
case 'I': // Empty Query
|
case 'I': // Empty Query
|
||||||
int t = pg_stream.ReceiveChar();
|
int t = pg_stream.ReceiveChar();
|
||||||
if (t != 0)
|
if (t != 0)
|
||||||
throw new PSQLException("postgresql.con.garbled");
|
throw new PSQLException("postgresql.con.garbled");
|
||||||
|
|
||||||
if (fqp > 0)
|
if (fqp > 0)
|
||||||
fqp--;
|
fqp--;
|
||||||
if (fqp == 0)
|
if (fqp == 0)
|
||||||
hfr = true;
|
hfr = true;
|
||||||
break;
|
break;
|
||||||
case 'N': // Error Notification
|
case 'N': // Error Notification
|
||||||
connection.addWarning(pg_stream.ReceiveString(connection.getEncoding()));
|
connection.addWarning(pg_stream.ReceiveString(connection.getEncoding()));
|
||||||
break;
|
break;
|
||||||
case 'P': // Portal Name
|
case 'P': // Portal Name
|
||||||
String pname = pg_stream.ReceiveString(connection.getEncoding());
|
String pname = pg_stream.ReceiveString(connection.getEncoding());
|
||||||
break;
|
break;
|
||||||
case 'T': // MetaData Field Description
|
case 'T': // MetaData Field Description
|
||||||
receiveFields();
|
receiveFields();
|
||||||
break;
|
break;
|
||||||
case 'Z': // backend ready for query, ignore for now :-)
|
case 'Z': // backend ready for query, ignore for now :-)
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.type",
|
throw new PSQLException("postgresql.con.type",
|
||||||
new Character((char) c));
|
new Character((char) c));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid, binaryCursor);
|
return connection.getResultSet(connection, statement, fields, tuples, status, update_count, insert_oid, binaryCursor);
|
||||||
@ -162,7 +162,6 @@ public class QueryExecutor
|
|||||||
*/
|
*/
|
||||||
private void receiveCommandStatus() throws SQLException
|
private void receiveCommandStatus() throws SQLException
|
||||||
{
|
{
|
||||||
|
|
||||||
status = pg_stream.ReceiveString(connection.getEncoding());
|
status = pg_stream.ReceiveString(connection.getEncoding());
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -61,7 +61,6 @@ public class Fastpath
|
|||||||
// added Oct 7 1998 to give us thread safety
|
// added Oct 7 1998 to give us thread safety
|
||||||
synchronized (stream)
|
synchronized (stream)
|
||||||
{
|
{
|
||||||
|
|
||||||
// send the function call
|
// send the function call
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -105,52 +104,52 @@ public class Fastpath
|
|||||||
//DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
|
//DriverManager.println("ReceiveChar() = "+in+" '"+((char)in)+"'");
|
||||||
switch (in)
|
switch (in)
|
||||||
{
|
{
|
||||||
case 'V':
|
case 'V':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// Function returned properly
|
// Function returned properly
|
||||||
//
|
//
|
||||||
case 'G':
|
case 'G':
|
||||||
int sz = stream.ReceiveIntegerR(4);
|
int sz = stream.ReceiveIntegerR(4);
|
||||||
//DriverManager.println("G: size="+sz); //debug
|
//DriverManager.println("G: size="+sz); //debug
|
||||||
|
|
||||||
// Return an Integer if
|
// Return an Integer if
|
||||||
if (resulttype)
|
if (resulttype)
|
||||||
result = new Integer(stream.ReceiveIntegerR(sz));
|
result = new Integer(stream.ReceiveIntegerR(sz));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
byte buf[] = new byte[sz];
|
byte buf[] = new byte[sz];
|
||||||
stream.Receive(buf, 0, sz);
|
stream.Receive(buf, 0, sz);
|
||||||
result = buf;
|
result = buf;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// Error message returned
|
// Error message returned
|
||||||
case 'E':
|
case 'E':
|
||||||
throw new PSQLException("postgresql.fp.error", stream.ReceiveString(conn.getEncoding()));
|
throw new PSQLException("postgresql.fp.error", stream.ReceiveString(conn.getEncoding()));
|
||||||
|
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// Notice from backend
|
// Notice from backend
|
||||||
case 'N':
|
case 'N':
|
||||||
conn.addWarning(stream.ReceiveString(conn.getEncoding()));
|
conn.addWarning(stream.ReceiveString(conn.getEncoding()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// End of results
|
// End of results
|
||||||
//
|
//
|
||||||
// Here we simply return res, which would contain the result
|
// Here we simply return res, which would contain the result
|
||||||
// processed earlier. If no result, this already contains null
|
// processed earlier. If no result, this already contains null
|
||||||
case '0':
|
case '0':
|
||||||
//DriverManager.println("returning "+result);
|
//DriverManager.println("returning "+result);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
case 'Z':
|
case 'Z':
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.fp.protocol", new Character((char)in));
|
throw new PSQLException("postgresql.fp.protocol", new Character((char)in));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,5 +148,4 @@ public class PGpath extends PGobject implements Serializable, Cloneable
|
|||||||
{
|
{
|
||||||
open = true;
|
open = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import org.postgresql.util.PSQLException;
|
|||||||
/*
|
/*
|
||||||
* This class provides information about the database as a whole.
|
* This class provides information about the database as a whole.
|
||||||
*
|
*
|
||||||
* $Id: DatabaseMetaData.java,v 1.39 2001/11/19 22:33:38 momjian Exp $
|
* $Id: DatabaseMetaData.java,v 1.40 2001/11/19 23:16:45 momjian Exp $
|
||||||
*
|
*
|
||||||
* <p>Many of the methods here return lists of information in ResultSets. You
|
* <p>Many of the methods here return lists of information in ResultSets. You
|
||||||
* can use the normal ResultSet methods such as getString and getInt to
|
* can use the normal ResultSet methods such as getString and getInt to
|
||||||
@ -1731,20 +1731,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
String relKind;
|
String relKind;
|
||||||
switch (r.getBytes(3)[0])
|
switch (r.getBytes(3)[0])
|
||||||
{
|
{
|
||||||
case (byte) 'r':
|
case (byte) 'r':
|
||||||
relKind = "TABLE";
|
relKind = "TABLE";
|
||||||
break;
|
break;
|
||||||
case (byte) 'i':
|
case (byte) 'i':
|
||||||
relKind = "INDEX";
|
relKind = "INDEX";
|
||||||
break;
|
break;
|
||||||
case (byte) 'S':
|
case (byte) 'S':
|
||||||
relKind = "SEQUENCE";
|
relKind = "SEQUENCE";
|
||||||
break;
|
break;
|
||||||
case (byte) 'v':
|
case (byte) 'v':
|
||||||
relKind = "VIEW";
|
relKind = "VIEW";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
relKind = null;
|
relKind = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple[0] = null; // Catalog name
|
tuple[0] = null; // Catalog name
|
||||||
@ -2012,17 +2012,17 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
|
|
||||||
tuple[7] = null; // Buffer length
|
tuple[7] = null; // Buffer length
|
||||||
// Decimal digits = scale
|
// Decimal digits = scale
|
||||||
// From the source (see e.g. backend/utils/adt/numeric.c,
|
// From the source (see e.g. backend/utils/adt/numeric.c,
|
||||||
// function numeric()) the scale and precision can be calculated
|
// function numeric()) the scale and precision can be calculated
|
||||||
// from the typmod value.
|
// from the typmod value.
|
||||||
if (typname.equals("numeric") || typname.equals("decimal"))
|
if (typname.equals("numeric") || typname.equals("decimal"))
|
||||||
{
|
{
|
||||||
int attypmod = r.getInt(8);
|
int attypmod = r.getInt(8);
|
||||||
tuple[8] =
|
tuple[8] =
|
||||||
Integer.toString((attypmod - VARHDRSZ) & 0xffff).getBytes();
|
Integer.toString((attypmod - VARHDRSZ) & 0xffff).getBytes();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tuple[8] = "0".getBytes();
|
tuple[8] = "0".getBytes();
|
||||||
|
|
||||||
tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
|
tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
|
||||||
tuple[10] = Integer.toString(nullFlag.equals("f") ?
|
tuple[10] = Integer.toString(nullFlag.equals("f") ?
|
||||||
@ -2262,7 +2262,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
"a.attnum as KEY_SEQ," +
|
"a.attnum as KEY_SEQ," +
|
||||||
"ic.relname as PK_NAME " +
|
"ic.relname as PK_NAME " +
|
||||||
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
|
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
|
||||||
" WHERE bc.relkind = 'r' " + // -- not indices
|
" WHERE bc.relkind = 'r' " + // -- not indices
|
||||||
" and upper(bc.relname) = upper('" + table + "')" +
|
" and upper(bc.relname) = upper('" + table + "')" +
|
||||||
" and i.indrelid = bc.oid" +
|
" and i.indrelid = bc.oid" +
|
||||||
" and i.indexrelid = ic.oid" +
|
" and i.indexrelid = ic.oid" +
|
||||||
@ -2274,115 +2274,135 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
|
|
||||||
private java.sql.ResultSet getImportedExportedKeys(String catalog, String schema, String primaryTable, String foreignTable) throws SQLException
|
private java.sql.ResultSet getImportedExportedKeys(String catalog, String schema, String primaryTable, String foreignTable) throws SQLException
|
||||||
{
|
{
|
||||||
Field f[]=new Field[14];
|
Field f[] = new Field[14];
|
||||||
|
|
||||||
f[0]=new Field(connection, "PKTABLE_CAT", iVarcharOid, 32);
|
f[0] = new Field(connection, "PKTABLE_CAT", iVarcharOid, 32);
|
||||||
f[1]=new Field(connection, "PKTABLE_SCHEM", iVarcharOid, 32);
|
f[1] = new Field(connection, "PKTABLE_SCHEM", iVarcharOid, 32);
|
||||||
f[2]=new Field(connection, "PKTABLE_NAME", iVarcharOid, 32);
|
f[2] = new Field(connection, "PKTABLE_NAME", iVarcharOid, 32);
|
||||||
f[3]=new Field(connection, "PKCOLUMN_NAME", iVarcharOid, 32);
|
f[3] = new Field(connection, "PKCOLUMN_NAME", iVarcharOid, 32);
|
||||||
f[4]=new Field(connection, "FKTABLE_CAT", iVarcharOid, 32);
|
f[4] = new Field(connection, "FKTABLE_CAT", iVarcharOid, 32);
|
||||||
f[5]=new Field(connection, "FKTABLE_SCHEM", iVarcharOid, 32);
|
f[5] = new Field(connection, "FKTABLE_SCHEM", iVarcharOid, 32);
|
||||||
f[6]=new Field(connection, "FKTABLE_NAME", iVarcharOid, 32);
|
f[6] = new Field(connection, "FKTABLE_NAME", iVarcharOid, 32);
|
||||||
f[7]=new Field(connection, "FKCOLUMN_NAME", iVarcharOid, 32);
|
f[7] = new Field(connection, "FKCOLUMN_NAME", iVarcharOid, 32);
|
||||||
f[8]=new Field(connection, "KEY_SEQ", iInt2Oid, 2);
|
f[8] = new Field(connection, "KEY_SEQ", iInt2Oid, 2);
|
||||||
f[9]=new Field(connection, "UPDATE_RULE", iInt2Oid, 2);
|
f[9] = new Field(connection, "UPDATE_RULE", iInt2Oid, 2);
|
||||||
f[10]=new Field(connection, "DELETE_RULE", iInt2Oid, 2);
|
f[10] = new Field(connection, "DELETE_RULE", iInt2Oid, 2);
|
||||||
f[11]=new Field(connection, "FK_NAME", iVarcharOid, 32);
|
f[11] = new Field(connection, "FK_NAME", iVarcharOid, 32);
|
||||||
f[12]=new Field(connection, "PK_NAME", iVarcharOid, 32);
|
f[12] = new Field(connection, "PK_NAME", iVarcharOid, 32);
|
||||||
f[13]=new Field(connection, "DEFERRABILITY", iInt2Oid, 2);
|
f[13] = new Field(connection, "DEFERRABILITY", iInt2Oid, 2);
|
||||||
|
|
||||||
java.sql.ResultSet rs = connection.ExecSQL("SELECT c.relname,c2.relname,"
|
java.sql.ResultSet rs = connection.ExecSQL("SELECT c.relname,c2.relname,"
|
||||||
+ "t.tgconstrname,ic.relname,"
|
+ "t.tgconstrname,ic.relname,"
|
||||||
+ "t.tgdeferrable,t.tginitdeferred,"
|
+ "t.tgdeferrable,t.tginitdeferred,"
|
||||||
+ "t.tgnargs,t.tgargs,p.proname "
|
+ "t.tgnargs,t.tgargs,p.proname "
|
||||||
+ "FROM pg_trigger t,pg_class c,pg_class c2,"
|
+ "FROM pg_trigger t,pg_class c,pg_class c2,"
|
||||||
+ "pg_class ic,pg_proc p, pg_index i "
|
+ "pg_class ic,pg_proc p, pg_index i "
|
||||||
+ "WHERE t.tgrelid=c.oid AND t.tgconstrrelid=c2.oid "
|
+ "WHERE t.tgrelid=c.oid AND t.tgconstrrelid=c2.oid "
|
||||||
+ "AND t.tgfoid=p.oid AND tgisconstraint "
|
+ "AND t.tgfoid=p.oid AND tgisconstraint "
|
||||||
+ ((primaryTable!=null) ? "AND c2.relname='"+primaryTable+"' " : "")
|
+ ((primaryTable != null) ? "AND c2.relname='" + primaryTable + "' " : "")
|
||||||
+ ((foreignTable!=null) ? "AND c.relname='"+foreignTable+"' " : "")
|
+ ((foreignTable != null) ? "AND c.relname='" + foreignTable + "' " : "")
|
||||||
+ "AND i.indrelid=c.oid "
|
+ "AND i.indrelid=c.oid "
|
||||||
+ "AND i.indexrelid=ic.oid AND i.indisprimary "
|
+ "AND i.indexrelid=ic.oid AND i.indisprimary "
|
||||||
+ "ORDER BY c.relname,c2.relname"
|
+ "ORDER BY c.relname,c2.relname"
|
||||||
);
|
);
|
||||||
Vector tuples = new Vector();
|
Vector tuples = new Vector();
|
||||||
short seq=0;
|
short seq = 0;
|
||||||
if (rs.next()) {
|
if (rs.next())
|
||||||
boolean hasMore;
|
{
|
||||||
do {
|
boolean hasMore;
|
||||||
byte tuple[][]=new byte[14][0];
|
do
|
||||||
for (int k = 0;k < 14;k++)
|
{
|
||||||
tuple[k] = null;
|
byte tuple[][] = new byte[14][0];
|
||||||
|
for (int k = 0;k < 14;k++)
|
||||||
|
tuple[k] = null;
|
||||||
|
|
||||||
String fKeyName=rs.getString(3);
|
String fKeyName = rs.getString(3);
|
||||||
boolean foundRule=false;
|
boolean foundRule = false;
|
||||||
do {
|
do
|
||||||
String proname=rs.getString(9);
|
{
|
||||||
if (proname!=null && proname.startsWith("RI_FKey_")) {
|
String proname = rs.getString(9);
|
||||||
int col=-1;
|
if (proname != null && proname.startsWith("RI_FKey_"))
|
||||||
if (proname.endsWith("_upd")) col=9; // UPDATE_RULE
|
{
|
||||||
else if (proname.endsWith("_del")) col=10; // DELETE_RULE
|
int col = -1;
|
||||||
if (col>-1) {
|
if (proname.endsWith("_upd"))
|
||||||
String rule=proname.substring(8, proname.length()-4);
|
col = 9; // UPDATE_RULE
|
||||||
int action=importedKeyNoAction;
|
else if (proname.endsWith("_del"))
|
||||||
if ("cascade".equals(rule)) action=importedKeyCascade;
|
col = 10; // DELETE_RULE
|
||||||
else if ("setnull".equals(rule)) action=importedKeySetNull;
|
if (col > -1)
|
||||||
else if ("setdefault".equals(rule)) action=importedKeySetDefault;
|
{
|
||||||
tuple[col]=Integer.toString(action).getBytes();
|
String rule = proname.substring(8, proname.length() - 4);
|
||||||
foundRule=true;
|
int action = importedKeyNoAction;
|
||||||
|
if ("cascade".equals(rule))
|
||||||
|
action = importedKeyCascade;
|
||||||
|
else if ("setnull".equals(rule))
|
||||||
|
action = importedKeySetNull;
|
||||||
|
else if ("setdefault".equals(rule))
|
||||||
|
action = importedKeySetDefault;
|
||||||
|
tuple[col] = Integer.toString(action).getBytes();
|
||||||
|
foundRule = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ((hasMore=rs.next()) && fKeyName.equals(rs.getString(3)));
|
while ((hasMore = rs.next()) && fKeyName.equals(rs.getString(3)));
|
||||||
|
|
||||||
if (foundRule) {
|
if (foundRule)
|
||||||
tuple[2]=rs.getBytes(2); //PKTABLE_NAME
|
{
|
||||||
tuple[6]=rs.getBytes(1); //FKTABLE_NAME
|
tuple[2] = rs.getBytes(2); //PKTABLE_NAME
|
||||||
|
tuple[6] = rs.getBytes(1); //FKTABLE_NAME
|
||||||
|
|
||||||
// Parse the tgargs data
|
// Parse the tgargs data
|
||||||
StringBuffer fkeyColumns=new StringBuffer();
|
StringBuffer fkeyColumns = new StringBuffer();
|
||||||
StringBuffer pkeyColumns=new StringBuffer();
|
StringBuffer pkeyColumns = new StringBuffer();
|
||||||
int numColumns=(rs.getInt(7) >> 1) - 2;
|
int numColumns = (rs.getInt(7) >> 1) - 2;
|
||||||
String s=rs.getString(8);
|
String s = rs.getString(8);
|
||||||
int pos=s.lastIndexOf("\\000");
|
int pos = s.lastIndexOf("\\000");
|
||||||
for(int c=0;c<numColumns;c++) {
|
for (int c = 0;c < numColumns;c++)
|
||||||
if (pos>-1) {
|
{
|
||||||
int pos2=s.lastIndexOf("\\000", pos-1);
|
if (pos > -1)
|
||||||
if (pos2>-1) {
|
{
|
||||||
if (fkeyColumns.length()>0) fkeyColumns.insert(0, ',');
|
int pos2 = s.lastIndexOf("\\000", pos - 1);
|
||||||
fkeyColumns.insert(0, s.substring(pos2+4, pos)); //FKCOLUMN_NAME
|
if (pos2 > -1)
|
||||||
pos=s.lastIndexOf("\\000", pos2-1);
|
{
|
||||||
if (pos>-1) {
|
if (fkeyColumns.length() > 0)
|
||||||
if (pkeyColumns.length()>0) pkeyColumns.insert(0, ',');
|
fkeyColumns.insert(0, ',');
|
||||||
pkeyColumns.insert(0, s.substring(pos+4, pos2)); //PKCOLUMN_NAME
|
fkeyColumns.insert(0, s.substring(pos2 + 4, pos)); //FKCOLUMN_NAME
|
||||||
|
pos = s.lastIndexOf("\\000", pos2 - 1);
|
||||||
|
if (pos > -1)
|
||||||
|
{
|
||||||
|
if (pkeyColumns.length() > 0)
|
||||||
|
pkeyColumns.insert(0, ',');
|
||||||
|
pkeyColumns.insert(0, s.substring(pos + 4, pos2)); //PKCOLUMN_NAME
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
tuple[7] = fkeyColumns.toString().getBytes(); //FKCOLUMN_NAME
|
||||||
|
tuple[3] = pkeyColumns.toString().getBytes(); //PKCOLUMN_NAME
|
||||||
|
|
||||||
|
tuple[8] = Integer.toString(seq++).getBytes(); //KEY_SEQ
|
||||||
|
tuple[11] = fKeyName.getBytes(); //FK_NAME
|
||||||
|
tuple[12] = rs.getBytes(4); //PK_NAME
|
||||||
|
|
||||||
|
// DEFERRABILITY
|
||||||
|
int deferrability = importedKeyNotDeferrable;
|
||||||
|
boolean deferrable = rs.getBoolean(5);
|
||||||
|
boolean initiallyDeferred = rs.getBoolean(6);
|
||||||
|
if (deferrable)
|
||||||
|
{
|
||||||
|
if (initiallyDeferred)
|
||||||
|
deferrability = importedKeyInitiallyDeferred;
|
||||||
|
else
|
||||||
|
deferrability = importedKeyInitiallyImmediate;
|
||||||
|
}
|
||||||
|
tuple[13] = Integer.toString(deferrability).getBytes();
|
||||||
|
|
||||||
|
tuples.addElement(tuple);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tuple[7]=fkeyColumns.toString().getBytes(); //FKCOLUMN_NAME
|
while (hasMore);
|
||||||
tuple[3]=pkeyColumns.toString().getBytes(); //PKCOLUMN_NAME
|
}
|
||||||
|
|
||||||
tuple[8]=Integer.toString(seq++).getBytes(); //KEY_SEQ
|
return new ResultSet(connection, f, tuples, "OK", 1);
|
||||||
tuple[11]=fKeyName.getBytes(); //FK_NAME
|
|
||||||
tuple[12]=rs.getBytes(4); //PK_NAME
|
|
||||||
|
|
||||||
// DEFERRABILITY
|
|
||||||
int deferrability=importedKeyNotDeferrable;
|
|
||||||
boolean deferrable=rs.getBoolean(5);
|
|
||||||
boolean initiallyDeferred=rs.getBoolean(6);
|
|
||||||
if (deferrable) {
|
|
||||||
if (initiallyDeferred)
|
|
||||||
deferrability=importedKeyInitiallyDeferred;
|
|
||||||
else
|
|
||||||
deferrability=importedKeyInitiallyImmediate;
|
|
||||||
}
|
|
||||||
tuple[13]=Integer.toString(deferrability).getBytes();
|
|
||||||
|
|
||||||
tuples.addElement(tuple);
|
|
||||||
}
|
|
||||||
} while (hasMore);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResultSet(connection, f, tuples, "OK", 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2496,7 +2516,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
|
public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
|
||||||
{
|
{
|
||||||
return getImportedExportedKeys(catalog, schema, table, null);
|
return getImportedExportedKeys(catalog, schema, table, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2557,7 +2577,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
|
public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
|
||||||
{
|
{
|
||||||
return getImportedExportedKeys(primaryCatalog, primarySchema, primaryTable, foreignTable);
|
return getImportedExportedKeys(primaryCatalog, primarySchema, primaryTable, foreignTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -617,53 +617,53 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
|
|||||||
}
|
}
|
||||||
switch (targetSqlType)
|
switch (targetSqlType)
|
||||||
{
|
{
|
||||||
case Types.TINYINT:
|
case Types.TINYINT:
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
case Types.DECIMAL:
|
case Types.DECIMAL:
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
if (x instanceof Boolean)
|
if (x instanceof Boolean)
|
||||||
set(parameterIndex, ((Boolean)x).booleanValue() ? "1" : "0");
|
set(parameterIndex, ((Boolean)x).booleanValue() ? "1" : "0");
|
||||||
else
|
else
|
||||||
set(parameterIndex, x.toString());
|
set(parameterIndex, x.toString());
|
||||||
break;
|
break;
|
||||||
case Types.CHAR:
|
case Types.CHAR:
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
case Types.LONGVARCHAR:
|
case Types.LONGVARCHAR:
|
||||||
setString(parameterIndex, x.toString());
|
setString(parameterIndex, x.toString());
|
||||||
break;
|
break;
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
setDate(parameterIndex, (java.sql.Date)x);
|
setDate(parameterIndex, (java.sql.Date)x);
|
||||||
break;
|
break;
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
setTime(parameterIndex, (Time)x);
|
setTime(parameterIndex, (Time)x);
|
||||||
break;
|
break;
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
setTimestamp(parameterIndex, (Timestamp)x);
|
setTimestamp(parameterIndex, (Timestamp)x);
|
||||||
break;
|
break;
|
||||||
case Types.BIT:
|
case Types.BIT:
|
||||||
if (x instanceof Boolean)
|
if (x instanceof Boolean)
|
||||||
{
|
{
|
||||||
set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
|
set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
throw new PSQLException("postgresql.prep.type");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Types.BINARY:
|
||||||
|
case Types.VARBINARY:
|
||||||
|
setObject(parameterIndex, x);
|
||||||
|
break;
|
||||||
|
case Types.OTHER:
|
||||||
|
setString(parameterIndex, ((PGobject)x).getValue());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw new PSQLException("postgresql.prep.type");
|
throw new PSQLException("postgresql.prep.type");
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Types.BINARY:
|
|
||||||
case Types.VARBINARY:
|
|
||||||
setObject(parameterIndex, x);
|
|
||||||
break;
|
|
||||||
case Types.OTHER:
|
|
||||||
setString(parameterIndex, ((PGobject)x).getValue());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new PSQLException("postgresql.prep.type");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -394,40 +394,40 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
wasNullFlag = (this_row[columnIndex - 1] == null);
|
wasNullFlag = (this_row[columnIndex - 1] == null);
|
||||||
if (!wasNullFlag)
|
if (!wasNullFlag)
|
||||||
{
|
{
|
||||||
if (binaryCursor)
|
if (binaryCursor)
|
||||||
{
|
|
||||||
//If the data is already binary then just return it
|
|
||||||
return this_row[columnIndex - 1];
|
|
||||||
}
|
|
||||||
else if (connection.haveMinimumCompatibleVersion("7.2"))
|
|
||||||
{
|
|
||||||
//Version 7.2 supports the bytea datatype for byte arrays
|
|
||||||
if (fields[columnIndex - 1].getPGType().equals("bytea"))
|
|
||||||
{
|
{
|
||||||
return PGbytea.toBytes(getString(columnIndex));
|
//If the data is already binary then just return it
|
||||||
|
return this_row[columnIndex - 1];
|
||||||
|
}
|
||||||
|
else if (connection.haveMinimumCompatibleVersion("7.2"))
|
||||||
|
{
|
||||||
|
//Version 7.2 supports the bytea datatype for byte arrays
|
||||||
|
if (fields[columnIndex - 1].getPGType().equals("bytea"))
|
||||||
|
{
|
||||||
|
return PGbytea.toBytes(getString(columnIndex));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this_row[columnIndex - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return this_row[columnIndex - 1];
|
//Version 7.1 and earlier supports LargeObjects for byte arrays
|
||||||
|
// Handle OID's as BLOBS
|
||||||
|
if ( fields[columnIndex - 1].getOID() == 26)
|
||||||
|
{
|
||||||
|
LargeObjectManager lom = connection.getLargeObjectAPI();
|
||||||
|
LargeObject lob = lom.open(getInt(columnIndex));
|
||||||
|
byte buf[] = lob.read(lob.size());
|
||||||
|
lob.close();
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this_row[columnIndex - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Version 7.1 and earlier supports LargeObjects for byte arrays
|
|
||||||
// Handle OID's as BLOBS
|
|
||||||
if ( fields[columnIndex - 1].getOID() == 26)
|
|
||||||
{
|
|
||||||
LargeObjectManager lom = connection.getLargeObjectAPI();
|
|
||||||
LargeObject lob = lom.open(getInt(columnIndex));
|
|
||||||
byte buf[] = lob.read(lob.size());
|
|
||||||
lob.close();
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this_row[columnIndex - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -447,10 +447,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
return null;
|
return null;
|
||||||
// length == 10: SQL Date
|
// length == 10: SQL Date
|
||||||
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
|
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
|
||||||
try {
|
try
|
||||||
return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0,10));
|
{
|
||||||
} catch (NumberFormatException e) {
|
return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10));
|
||||||
throw new PSQLException("postgresql.res.baddate", s);
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
throw new PSQLException("postgresql.res.baddate", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,43 +929,43 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
switch (field.getSQLType())
|
switch (field.getSQLType())
|
||||||
{
|
{
|
||||||
case Types.BIT:
|
case Types.BIT:
|
||||||
return new Boolean(getBoolean(columnIndex));
|
return new Boolean(getBoolean(columnIndex));
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
return new Integer(getInt(columnIndex));
|
return new Integer(getInt(columnIndex));
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return new Integer(getInt(columnIndex));
|
return new Integer(getInt(columnIndex));
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
return new Long(getLong(columnIndex));
|
return new Long(getLong(columnIndex));
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
return getBigDecimal(columnIndex, ((field.getMod() - 4) & 0xffff));
|
return getBigDecimal(columnIndex, ((field.getMod() - 4) & 0xffff));
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
return new Float(getFloat(columnIndex));
|
return new Float(getFloat(columnIndex));
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return new Double(getDouble(columnIndex));
|
return new Double(getDouble(columnIndex));
|
||||||
case Types.CHAR:
|
case Types.CHAR:
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return getString(columnIndex);
|
|
||||||
case Types.DATE:
|
|
||||||
return getDate(columnIndex);
|
|
||||||
case Types.TIME:
|
|
||||||
return getTime(columnIndex);
|
|
||||||
case Types.TIMESTAMP:
|
|
||||||
return getTimestamp(columnIndex);
|
|
||||||
case Types.BINARY:
|
|
||||||
case Types.VARBINARY:
|
|
||||||
return getBytes(columnIndex);
|
|
||||||
default:
|
|
||||||
String type = field.getPGType();
|
|
||||||
// if the backend doesn't know the type then coerce to String
|
|
||||||
if (type.equals("unknown"))
|
|
||||||
{
|
|
||||||
return getString(columnIndex);
|
return getString(columnIndex);
|
||||||
}
|
case Types.DATE:
|
||||||
else
|
return getDate(columnIndex);
|
||||||
{
|
case Types.TIME:
|
||||||
return connection.getObject(field.getPGType(), getString(columnIndex));
|
return getTime(columnIndex);
|
||||||
}
|
case Types.TIMESTAMP:
|
||||||
|
return getTimestamp(columnIndex);
|
||||||
|
case Types.BINARY:
|
||||||
|
case Types.VARBINARY:
|
||||||
|
return getBytes(columnIndex);
|
||||||
|
default:
|
||||||
|
String type = field.getPGType();
|
||||||
|
// if the backend doesn't know the type then coerce to String
|
||||||
|
if (type.equals("unknown"))
|
||||||
|
{
|
||||||
|
return getString(columnIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return connection.getObject(field.getPGType(), getString(columnIndex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,17 +78,17 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,10 +112,10 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
// for further expansion.
|
// for further expansion.
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.OTHER:
|
case Types.OTHER:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,18 +167,18 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return true;
|
return true;
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
return false; // I don't know about these?
|
return false; // I don't know about these?
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,26 +294,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
return 5;
|
return 5;
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return 10;
|
return 10;
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
return 8;
|
return 8;
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
Field f = getField(column);
|
Field f = getField(column);
|
||||||
if (f != null)
|
if (f != null)
|
||||||
return ((0xFFFF0000)&f.getMod()) >> 16;
|
return ((0xFFFF0000)&f.getMod()) >> 16;
|
||||||
else
|
else
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,26 +331,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
return 8;
|
return 8;
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
Field f = getField(column);
|
Field f = getField(column);
|
||||||
if (f != null)
|
if (f != null)
|
||||||
return (((0x0000FFFF)&f.getMod()) - 4);
|
return (((0x0000FFFF)&f.getMod()) - 4);
|
||||||
else
|
else
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,64 +115,64 @@ public class Array implements java.sql.Array
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
switch ( getBaseType() )
|
switch ( getBaseType() )
|
||||||
{
|
{
|
||||||
case Types.BIT:
|
case Types.BIT:
|
||||||
retVal = new boolean[ count ];
|
retVal = new boolean[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((boolean[])retVal)[i++] = ResultSet.toBoolean( arrayContents[(int)index++] );
|
((boolean[])retVal)[i++] = ResultSet.toBoolean( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
retVal = new int[ count ];
|
retVal = new int[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((int[])retVal)[i++] = ResultSet.toInt( arrayContents[(int)index++] );
|
((int[])retVal)[i++] = ResultSet.toInt( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
retVal = new long[ count ];
|
retVal = new long[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((long[])retVal)[i++] = ResultSet.toLong( arrayContents[(int)index++] );
|
((long[])retVal)[i++] = ResultSet.toLong( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
retVal = new BigDecimal[ count ];
|
retVal = new BigDecimal[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((BigDecimal[])retVal)[i] = ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
|
((BigDecimal[])retVal)[i] = ResultSet.toBigDecimal( arrayContents[(int)index++], 0 );
|
||||||
break;
|
break;
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
retVal = new float[ count ];
|
retVal = new float[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((float[])retVal)[i++] = ResultSet.toFloat( arrayContents[(int)index++] );
|
((float[])retVal)[i++] = ResultSet.toFloat( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
retVal = new double[ count ];
|
retVal = new double[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((double[])retVal)[i++] = ResultSet.toDouble( arrayContents[(int)index++] );
|
((double[])retVal)[i++] = ResultSet.toDouble( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.CHAR:
|
case Types.CHAR:
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
retVal = new String[ count ];
|
retVal = new String[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((String[])retVal)[i++] = arrayContents[(int)index++];
|
((String[])retVal)[i++] = arrayContents[(int)index++];
|
||||||
break;
|
break;
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
retVal = new java.sql.Date[ count ];
|
retVal = new java.sql.Date[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((java.sql.Date[])retVal)[i++] = ResultSet.toDate( arrayContents[(int)index++] );
|
((java.sql.Date[])retVal)[i++] = ResultSet.toDate( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
retVal = new java.sql.Time[ count ];
|
retVal = new java.sql.Time[ count ];
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((java.sql.Time[])retVal)[i++] = ResultSet.toTime( arrayContents[(int)index++] );
|
((java.sql.Time[])retVal)[i++] = ResultSet.toTime( arrayContents[(int)index++] );
|
||||||
break;
|
break;
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
retVal = new Timestamp[ count ];
|
retVal = new Timestamp[ count ];
|
||||||
StringBuffer sbuf = null;
|
StringBuffer sbuf = null;
|
||||||
for ( ; count > 0; count-- )
|
for ( ; count > 0; count-- )
|
||||||
((java.sql.Timestamp[])retVal)[i++] = ResultSet.toTimestamp( arrayContents[(int)index], rs );
|
((java.sql.Timestamp[])retVal)[i++] = ResultSet.toTimestamp( arrayContents[(int)index], rs );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Other datatypes not currently supported. If you are really using other types ask
|
// Other datatypes not currently supported. If you are really using other types ask
|
||||||
// yourself if an array of non-trivial data types is really good database design.
|
// yourself if an array of non-trivial data types is really good database design.
|
||||||
default:
|
default:
|
||||||
throw org.postgresql.Driver.notImplemented();
|
throw org.postgresql.Driver.notImplemented();
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
@ -213,126 +213,126 @@ public class Array implements java.sql.Array
|
|||||||
fields[0] = new Field(conn, "INDEX", conn.getOID("int2"), 2);
|
fields[0] = new Field(conn, "INDEX", conn.getOID("int2"), 2);
|
||||||
switch ( getBaseType() )
|
switch ( getBaseType() )
|
||||||
{
|
{
|
||||||
case Types.BIT:
|
case Types.BIT:
|
||||||
boolean[] booleanArray = (boolean[]) array;
|
boolean[] booleanArray = (boolean[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("bool"), 1);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("bool"), 1);
|
||||||
for ( int i = 0; i < booleanArray.length; i++ )
|
for ( int i = 0; i < booleanArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( (booleanArray[i] ? "YES" : "NO") ); // Value
|
tuple[1] = conn.getEncoding().encode( (booleanArray[i] ? "YES" : "NO") ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("int2"), 2);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("int2"), 2);
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
int[] intArray = (int[]) array;
|
int[] intArray = (int[]) array;
|
||||||
if ( fields[1] == null )
|
if ( fields[1] == null )
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("int4"), 4);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("int4"), 4);
|
||||||
for ( int i = 0; i < intArray.length; i++ )
|
for ( int i = 0; i < intArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( Integer.toString(intArray[i]) ); // Value
|
tuple[1] = conn.getEncoding().encode( Integer.toString(intArray[i]) ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
long[] longArray = (long[]) array;
|
long[] longArray = (long[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("int8"), 8);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("int8"), 8);
|
||||||
for ( int i = 0; i < longArray.length; i++ )
|
for ( int i = 0; i < longArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( Long.toString(longArray[i]) ); // Value
|
tuple[1] = conn.getEncoding().encode( Long.toString(longArray[i]) ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
BigDecimal[] bdArray = (BigDecimal[]) array;
|
BigDecimal[] bdArray = (BigDecimal[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("numeric"), -1);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("numeric"), -1);
|
||||||
for ( int i = 0; i < bdArray.length; i++ )
|
for ( int i = 0; i < bdArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( bdArray[i].toString() ); // Value
|
tuple[1] = conn.getEncoding().encode( bdArray[i].toString() ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
float[] floatArray = (float[]) array;
|
float[] floatArray = (float[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("float4"), 4);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("float4"), 4);
|
||||||
for ( int i = 0; i < floatArray.length; i++ )
|
for ( int i = 0; i < floatArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( Float.toString(floatArray[i]) ); // Value
|
tuple[1] = conn.getEncoding().encode( Float.toString(floatArray[i]) ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
double[] doubleArray = (double[]) array;
|
double[] doubleArray = (double[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("float8"), 8);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("float8"), 8);
|
||||||
for ( int i = 0; i < doubleArray.length; i++ )
|
for ( int i = 0; i < doubleArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( Double.toString(doubleArray[i]) ); // Value
|
tuple[1] = conn.getEncoding().encode( Double.toString(doubleArray[i]) ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.CHAR:
|
case Types.CHAR:
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("char"), 1);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("char"), 1);
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
String[] strArray = (String[]) array;
|
String[] strArray = (String[]) array;
|
||||||
if ( fields[1] == null )
|
if ( fields[1] == null )
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("varchar"), -1);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("varchar"), -1);
|
||||||
for ( int i = 0; i < strArray.length; i++ )
|
for ( int i = 0; i < strArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( strArray[i] ); // Value
|
tuple[1] = conn.getEncoding().encode( strArray[i] ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
java.sql.Date[] dateArray = (java.sql.Date[]) array;
|
java.sql.Date[] dateArray = (java.sql.Date[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("date"), 4);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("date"), 4);
|
||||||
for ( int i = 0; i < dateArray.length; i++ )
|
for ( int i = 0; i < dateArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( dateArray[i].toString() ); // Value
|
tuple[1] = conn.getEncoding().encode( dateArray[i].toString() ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
java.sql.Time[] timeArray = (java.sql.Time[]) array;
|
java.sql.Time[] timeArray = (java.sql.Time[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("time"), 8);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("time"), 8);
|
||||||
for ( int i = 0; i < timeArray.length; i++ )
|
for ( int i = 0; i < timeArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( timeArray[i].toString() ); // Value
|
tuple[1] = conn.getEncoding().encode( timeArray[i].toString() ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
java.sql.Timestamp[] timestampArray = (java.sql.Timestamp[]) array;
|
java.sql.Timestamp[] timestampArray = (java.sql.Timestamp[]) array;
|
||||||
fields[1] = new Field(conn, "VALUE", conn.getOID("timestamp"), 8);
|
fields[1] = new Field(conn, "VALUE", conn.getOID("timestamp"), 8);
|
||||||
for ( int i = 0; i < timestampArray.length; i++ )
|
for ( int i = 0; i < timestampArray.length; i++ )
|
||||||
{
|
{
|
||||||
byte[][] tuple = new byte[2][0];
|
byte[][] tuple = new byte[2][0];
|
||||||
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
tuple[0] = conn.getEncoding().encode( Integer.toString((int)index + i) ); // Index
|
||||||
tuple[1] = conn.getEncoding().encode( timestampArray[i].toString() ); // Value
|
tuple[1] = conn.getEncoding().encode( timestampArray[i].toString() ); // Value
|
||||||
rows.addElement(tuple);
|
rows.addElement(tuple);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Other datatypes not currently supported. If you are really using other types ask
|
// Other datatypes not currently supported. If you are really using other types ask
|
||||||
// yourself if an array of non-trivial data types is really good database design.
|
// yourself if an array of non-trivial data types is really good database design.
|
||||||
default:
|
default:
|
||||||
throw org.postgresql.Driver.notImplemented();
|
throw org.postgresql.Driver.notImplemented();
|
||||||
}
|
}
|
||||||
return new ResultSet((org.postgresql.jdbc2.Connection)conn, fields, rows, "OK", 1 );
|
return new ResultSet((org.postgresql.jdbc2.Connection)conn, fields, rows, "OK", 1 );
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import org.postgresql.util.PSQLException;
|
|||||||
/*
|
/*
|
||||||
* This class provides information about the database as a whole.
|
* This class provides information about the database as a whole.
|
||||||
*
|
*
|
||||||
* $Id: DatabaseMetaData.java,v 1.46 2001/11/19 22:33:39 momjian Exp $
|
* $Id: DatabaseMetaData.java,v 1.47 2001/11/19 23:16:46 momjian Exp $
|
||||||
*
|
*
|
||||||
* <p>Many of the methods here return lists of information in ResultSets. You
|
* <p>Many of the methods here return lists of information in ResultSets. You
|
||||||
* can use the normal ResultSet methods such as getString and getInt to
|
* can use the normal ResultSet methods such as getString and getInt to
|
||||||
@ -88,7 +88,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public String getURL() throws SQLException
|
public String getURL() throws SQLException
|
||||||
{
|
{
|
||||||
String url = connection.getURL();
|
String url = connection.getURL();
|
||||||
Driver.debug("getURL "+url);
|
Driver.debug("getURL " + url);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public String getUserName() throws SQLException
|
public String getUserName() throws SQLException
|
||||||
{
|
{
|
||||||
String userName = connection.getUserName();
|
String userName = connection.getUserName();
|
||||||
Driver.debug("getUserName "+ userName);
|
Driver.debug("getUserName " + userName);
|
||||||
return userName;
|
return userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public boolean isReadOnly() throws SQLException
|
public boolean isReadOnly() throws SQLException
|
||||||
{
|
{
|
||||||
boolean isReadOnly = connection.isReadOnly();
|
boolean isReadOnly = connection.isReadOnly();
|
||||||
Driver.debug("isReadOnly " +isReadOnly);
|
Driver.debug("isReadOnly " + isReadOnly);
|
||||||
return isReadOnly;
|
return isReadOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +164,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public boolean nullsAreSortedAtEnd() throws SQLException
|
public boolean nullsAreSortedAtEnd() throws SQLException
|
||||||
{
|
{
|
||||||
boolean nullsAreSortedAtEnd = ! connection.haveMinimumServerVersion("7.2");
|
boolean nullsAreSortedAtEnd = ! connection.haveMinimumServerVersion("7.2");
|
||||||
Driver.debug("nullsAreSortedAtEnd "+nullsAreSortedAtEnd);
|
Driver.debug("nullsAreSortedAtEnd " + nullsAreSortedAtEnd);
|
||||||
return nullsAreSortedAtEnd;
|
return nullsAreSortedAtEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,7 +209,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* What is the version string of this JDBC driver? Again, this is
|
* What is the version string of this JDBC driver? Again, this is
|
||||||
* static.
|
* static.
|
||||||
*
|
*
|
||||||
* @return the JDBC driver name.
|
* @return the JDBC driver name.
|
||||||
@ -218,7 +218,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public String getDriverVersion() throws SQLException
|
public String getDriverVersion() throws SQLException
|
||||||
{
|
{
|
||||||
String driverVersion = connection.this_driver.getVersion();
|
String driverVersion = connection.this_driver.getVersion();
|
||||||
Driver.debug("getDriverVersion "+driverVersion);
|
Driver.debug("getDriverVersion " + driverVersion);
|
||||||
return driverVersion;
|
return driverVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public int getDriverMajorVersion()
|
public int getDriverMajorVersion()
|
||||||
{
|
{
|
||||||
int majorVersion = connection.this_driver.getMajorVersion();
|
int majorVersion = connection.this_driver.getMajorVersion();
|
||||||
Driver.debug("getMajorVersion " +majorVersion);
|
Driver.debug("getMajorVersion " + majorVersion);
|
||||||
return majorVersion;
|
return majorVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,12 +242,12 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public int getDriverMinorVersion()
|
public int getDriverMinorVersion()
|
||||||
{
|
{
|
||||||
int minorVersion = connection.this_driver.getMinorVersion();
|
int minorVersion = connection.this_driver.getMinorVersion();
|
||||||
Driver.debug("getMinorVersion " +minorVersion);
|
Driver.debug("getMinorVersion " + minorVersion);
|
||||||
return minorVersion;
|
return minorVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does the database store tables in a local file? No - it
|
* Does the database store tables in a local file? No - it
|
||||||
* stores them in a file on the server.
|
* stores them in a file on the server.
|
||||||
*
|
*
|
||||||
* @return true if so
|
* @return true if so
|
||||||
@ -298,7 +298,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public boolean storesUpperCaseIdentifiers() throws SQLException
|
public boolean storesUpperCaseIdentifiers() throws SQLException
|
||||||
{
|
{
|
||||||
Driver.debug("storesUpperCaseIdentifiers "+false);
|
Driver.debug("storesUpperCaseIdentifiers " + false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -622,13 +622,13 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
public boolean supportsGroupByUnrelated() throws SQLException
|
public boolean supportsGroupByUnrelated() throws SQLException
|
||||||
{
|
{
|
||||||
boolean supportsGroupByUnrelated = connection.haveMinimumServerVersion("6.4");
|
boolean supportsGroupByUnrelated = connection.haveMinimumServerVersion("6.4");
|
||||||
Driver.debug("supportsGroupByUnrelated "+ supportsGroupByUnrelated);
|
Driver.debug("supportsGroupByUnrelated " + supportsGroupByUnrelated);
|
||||||
return supportsGroupByUnrelated;
|
return supportsGroupByUnrelated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can a "GROUP BY" clause add columns not in the SELECT provided
|
* Can a "GROUP BY" clause add columns not in the SELECT provided
|
||||||
* it specifies all the columns in the SELECT? Does anyone actually
|
* it specifies all the columns in the SELECT? Does anyone actually
|
||||||
* understand what they mean here?
|
* understand what they mean here?
|
||||||
*
|
*
|
||||||
* (I think this is a subset of the previous function. -- petere)
|
* (I think this is a subset of the previous function. -- petere)
|
||||||
@ -686,7 +686,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can columns be defined as non-nullable. A JDBC Compliant driver
|
* Can columns be defined as non-nullable. A JDBC Compliant driver
|
||||||
* always returns true.
|
* always returns true.
|
||||||
*
|
*
|
||||||
* <p>This changed from false to true in v6.2 of the driver, as this
|
* <p>This changed from false to true in v6.2 of the driver, as this
|
||||||
@ -715,12 +715,12 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public boolean supportsMinimumSQLGrammar() throws SQLException
|
public boolean supportsMinimumSQLGrammar() throws SQLException
|
||||||
{
|
{
|
||||||
Driver.debug("supportsMinimumSQLGrammar TRUE");
|
Driver.debug("supportsMinimumSQLGrammar TRUE");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Does this driver support the Core ODBC SQL grammar. We need
|
* Does this driver support the Core ODBC SQL grammar. We need
|
||||||
* SQL-92 conformance for this.
|
* SQL-92 conformance for this.
|
||||||
*
|
*
|
||||||
* @return true if so
|
* @return true if so
|
||||||
@ -910,7 +910,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Can a schema name be used in a data manipulation statement? Nope.
|
* Can a schema name be used in a data manipulation statement? Nope.
|
||||||
*
|
*
|
||||||
* @return true if so
|
* @return true if so
|
||||||
* @exception SQLException if a database access error occurs
|
* @exception SQLException if a database access error occurs
|
||||||
@ -1831,20 +1831,20 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
String relKind;
|
String relKind;
|
||||||
switch (r.getBytes(3)[0])
|
switch (r.getBytes(3)[0])
|
||||||
{
|
{
|
||||||
case (byte) 'r':
|
case (byte) 'r':
|
||||||
relKind = "TABLE";
|
relKind = "TABLE";
|
||||||
break;
|
break;
|
||||||
case (byte) 'i':
|
case (byte) 'i':
|
||||||
relKind = "INDEX";
|
relKind = "INDEX";
|
||||||
break;
|
break;
|
||||||
case (byte) 'S':
|
case (byte) 'S':
|
||||||
relKind = "SEQUENCE";
|
relKind = "SEQUENCE";
|
||||||
break;
|
break;
|
||||||
case (byte) 'v':
|
case (byte) 'v':
|
||||||
relKind = "VIEW";
|
relKind = "VIEW";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
relKind = null;
|
relKind = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
tuple[0] = null; // Catalog name
|
tuple[0] = null; // Catalog name
|
||||||
@ -2243,29 +2243,30 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
Vector v = new Vector();
|
Vector v = new Vector();
|
||||||
|
|
||||||
if (tableNamePattern == null)
|
if (tableNamePattern == null)
|
||||||
tableNamePattern = "%";
|
tableNamePattern = "%";
|
||||||
|
|
||||||
f[0] = new Field(connection,"TABLE_CAT",iVarcharOid,32);
|
f[0] = new Field(connection, "TABLE_CAT", iVarcharOid, 32);
|
||||||
f[1] = new Field(connection,"TABLE_SCHEM",iVarcharOid,32);
|
f[1] = new Field(connection, "TABLE_SCHEM", iVarcharOid, 32);
|
||||||
f[2] = new Field(connection,"TABLE_NAME",iVarcharOid,32);
|
f[2] = new Field(connection, "TABLE_NAME", iVarcharOid, 32);
|
||||||
f[3] = new Field(connection,"COLUMN_NAME",iVarcharOid,32);
|
f[3] = new Field(connection, "COLUMN_NAME", iVarcharOid, 32);
|
||||||
f[4] = new Field(connection,"GRANTOR",iVarcharOid,32);
|
f[4] = new Field(connection, "GRANTOR", iVarcharOid, 32);
|
||||||
f[5] = new Field(connection,"GRANTEE",iVarcharOid,32);
|
f[5] = new Field(connection, "GRANTEE", iVarcharOid, 32);
|
||||||
f[6] = new Field(connection,"PRIVILEGE",iVarcharOid,32);
|
f[6] = new Field(connection, "PRIVILEGE", iVarcharOid, 32);
|
||||||
f[7] = new Field(connection,"IS_GRANTABLE",iVarcharOid,32);
|
f[7] = new Field(connection, "IS_GRANTABLE", iVarcharOid, 32);
|
||||||
|
|
||||||
// This is taken direct from the psql source
|
// This is taken direct from the psql source
|
||||||
java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '"+tableNamePattern.toLowerCase()+"' ORDER BY relname");
|
java.sql.ResultSet r = connection.ExecSQL("SELECT relname, relacl FROM pg_class, pg_user WHERE ( relkind = 'r' OR relkind = 'i') and relname !~ '^pg_' and relname !~ '^xin[vx][0-9]+' and usesysid = relowner and relname like '" + tableNamePattern.toLowerCase() + "' ORDER BY relname");
|
||||||
while (r.next()) {
|
while (r.next())
|
||||||
byte[][] tuple = new byte[8][0];
|
{
|
||||||
tuple[0] = tuple[1]= "".getBytes();
|
byte[][] tuple = new byte[8][0];
|
||||||
DriverManager.println("relname=\""+r.getString(1)+"\" relacl=\""+r.getString(2)+"\"");
|
tuple[0] = tuple[1] = "".getBytes();
|
||||||
|
DriverManager.println("relname=\"" + r.getString(1) + "\" relacl=\"" + r.getString(2) + "\"");
|
||||||
|
|
||||||
// For now, don't add to the result as relacl needs to be processed.
|
// For now, don't add to the result as relacl needs to be processed.
|
||||||
//v.addElement(tuple);
|
//v.addElement(tuple);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResultSet(connection,f,v,"OK",1);
|
return new ResultSet(connection, f, v, "OK", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2389,7 +2390,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
"a.attnum as KEY_SEQ," +
|
"a.attnum as KEY_SEQ," +
|
||||||
"ic.relname as PK_NAME " +
|
"ic.relname as PK_NAME " +
|
||||||
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
|
" FROM pg_class bc, pg_class ic, pg_index i, pg_attribute a" +
|
||||||
" WHERE bc.relkind = 'r' " + // -- not indices
|
" WHERE bc.relkind = 'r' " + // -- not indices
|
||||||
" and upper(bc.relname) = upper('" + table + "')" +
|
" and upper(bc.relname) = upper('" + table + "')" +
|
||||||
" and i.indrelid = bc.oid" +
|
" and i.indrelid = bc.oid" +
|
||||||
" and i.indexrelid = ic.oid" +
|
" and i.indexrelid = ic.oid" +
|
||||||
@ -2401,112 +2402,132 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
|
|
||||||
private java.sql.ResultSet getImportedExportedKeys(String catalog, String schema, String primaryTable, String foreignTable) throws SQLException
|
private java.sql.ResultSet getImportedExportedKeys(String catalog, String schema, String primaryTable, String foreignTable) throws SQLException
|
||||||
{
|
{
|
||||||
Field f[]=new Field[14];
|
Field f[] = new Field[14];
|
||||||
|
|
||||||
f[0]=new Field(connection, "PKTABLE_CAT", iVarcharOid, 32);
|
f[0] = new Field(connection, "PKTABLE_CAT", iVarcharOid, 32);
|
||||||
f[1]=new Field(connection, "PKTABLE_SCHEM", iVarcharOid, 32);
|
f[1] = new Field(connection, "PKTABLE_SCHEM", iVarcharOid, 32);
|
||||||
f[2]=new Field(connection, "PKTABLE_NAME", iVarcharOid, 32);
|
f[2] = new Field(connection, "PKTABLE_NAME", iVarcharOid, 32);
|
||||||
f[3]=new Field(connection, "PKCOLUMN_NAME", iVarcharOid, 32);
|
f[3] = new Field(connection, "PKCOLUMN_NAME", iVarcharOid, 32);
|
||||||
f[4]=new Field(connection, "FKTABLE_CAT", iVarcharOid, 32);
|
f[4] = new Field(connection, "FKTABLE_CAT", iVarcharOid, 32);
|
||||||
f[5]=new Field(connection, "FKTABLE_SCHEM", iVarcharOid, 32);
|
f[5] = new Field(connection, "FKTABLE_SCHEM", iVarcharOid, 32);
|
||||||
f[6]=new Field(connection, "FKTABLE_NAME", iVarcharOid, 32);
|
f[6] = new Field(connection, "FKTABLE_NAME", iVarcharOid, 32);
|
||||||
f[7]=new Field(connection, "FKCOLUMN_NAME", iVarcharOid, 32);
|
f[7] = new Field(connection, "FKCOLUMN_NAME", iVarcharOid, 32);
|
||||||
f[8]=new Field(connection, "KEY_SEQ", iInt2Oid, 2);
|
f[8] = new Field(connection, "KEY_SEQ", iInt2Oid, 2);
|
||||||
f[9]=new Field(connection, "UPDATE_RULE", iInt2Oid, 2);
|
f[9] = new Field(connection, "UPDATE_RULE", iInt2Oid, 2);
|
||||||
f[10]=new Field(connection, "DELETE_RULE", iInt2Oid, 2);
|
f[10] = new Field(connection, "DELETE_RULE", iInt2Oid, 2);
|
||||||
f[11]=new Field(connection, "FK_NAME", iVarcharOid, 32);
|
f[11] = new Field(connection, "FK_NAME", iVarcharOid, 32);
|
||||||
f[12]=new Field(connection, "PK_NAME", iVarcharOid, 32);
|
f[12] = new Field(connection, "PK_NAME", iVarcharOid, 32);
|
||||||
f[13]=new Field(connection, "DEFERRABILITY", iInt2Oid, 2);
|
f[13] = new Field(connection, "DEFERRABILITY", iInt2Oid, 2);
|
||||||
|
|
||||||
java.sql.ResultSet rs = connection.ExecSQL("SELECT c.relname,c2.relname,"
|
java.sql.ResultSet rs = connection.ExecSQL("SELECT c.relname,c2.relname,"
|
||||||
+ "t.tgconstrname,ic.relname,"
|
+ "t.tgconstrname,ic.relname,"
|
||||||
+ "t.tgdeferrable,t.tginitdeferred,"
|
+ "t.tgdeferrable,t.tginitdeferred,"
|
||||||
+ "t.tgnargs,t.tgargs,p.proname "
|
+ "t.tgnargs,t.tgargs,p.proname "
|
||||||
+ "FROM pg_trigger t,pg_class c,pg_class c2,"
|
+ "FROM pg_trigger t,pg_class c,pg_class c2,"
|
||||||
+ "pg_class ic,pg_proc p, pg_index i "
|
+ "pg_class ic,pg_proc p, pg_index i "
|
||||||
+ "WHERE t.tgrelid=c.oid AND t.tgconstrrelid=c2.oid "
|
+ "WHERE t.tgrelid=c.oid AND t.tgconstrrelid=c2.oid "
|
||||||
+ "AND t.tgfoid=p.oid AND tgisconstraint "
|
+ "AND t.tgfoid=p.oid AND tgisconstraint "
|
||||||
+ ((primaryTable!=null) ? "AND c2.relname='"+primaryTable+"' " : "")
|
+ ((primaryTable != null) ? "AND c2.relname='" + primaryTable + "' " : "")
|
||||||
+ ((foreignTable!=null) ? "AND c.relname='"+foreignTable+"' " : "")
|
+ ((foreignTable != null) ? "AND c.relname='" + foreignTable + "' " : "")
|
||||||
+ "AND i.indrelid=c.oid "
|
+ "AND i.indrelid=c.oid "
|
||||||
+ "AND i.indexrelid=ic.oid AND i.indisprimary "
|
+ "AND i.indexrelid=ic.oid AND i.indisprimary "
|
||||||
+ "ORDER BY c.relname,c2.relname"
|
+ "ORDER BY c.relname,c2.relname"
|
||||||
);
|
);
|
||||||
Vector tuples = new Vector();
|
Vector tuples = new Vector();
|
||||||
short seq=0;
|
short seq = 0;
|
||||||
if (rs.next()) {
|
if (rs.next())
|
||||||
boolean hasMore;
|
{
|
||||||
do {
|
boolean hasMore;
|
||||||
byte tuple[][]=new byte[14][0];
|
do
|
||||||
for (int k = 0;k < 14;k++)
|
{
|
||||||
tuple[k] = null;
|
byte tuple[][] = new byte[14][0];
|
||||||
|
for (int k = 0;k < 14;k++)
|
||||||
|
tuple[k] = null;
|
||||||
|
|
||||||
String fKeyName=rs.getString(3);
|
String fKeyName = rs.getString(3);
|
||||||
boolean foundRule=false;
|
boolean foundRule = false;
|
||||||
do {
|
do
|
||||||
String proname=rs.getString(9);
|
{
|
||||||
if (proname!=null && proname.startsWith("RI_FKey_")) {
|
String proname = rs.getString(9);
|
||||||
int col=-1;
|
if (proname != null && proname.startsWith("RI_FKey_"))
|
||||||
if (proname.endsWith("_upd")) col=9; // UPDATE_RULE
|
{
|
||||||
else if (proname.endsWith("_del")) col=10; // DELETE_RULE
|
int col = -1;
|
||||||
if (col>-1) {
|
if (proname.endsWith("_upd"))
|
||||||
String rule=proname.substring(8, proname.length()-4);
|
col = 9; // UPDATE_RULE
|
||||||
int action=importedKeyNoAction;
|
else if (proname.endsWith("_del"))
|
||||||
if ("cascade".equals(rule)) action=importedKeyCascade;
|
col = 10; // DELETE_RULE
|
||||||
else if ("setnull".equals(rule)) action=importedKeySetNull;
|
if (col > -1)
|
||||||
else if ("setdefault".equals(rule)) action=importedKeySetDefault;
|
{
|
||||||
tuple[col]=Integer.toString(action).getBytes();
|
String rule = proname.substring(8, proname.length() - 4);
|
||||||
foundRule=true;
|
int action = importedKeyNoAction;
|
||||||
}
|
if ("cascade".equals(rule))
|
||||||
}
|
action = importedKeyCascade;
|
||||||
} while ((hasMore=rs.next()) && fKeyName.equals(rs.getString(3)));
|
else if ("setnull".equals(rule))
|
||||||
|
action = importedKeySetNull;
|
||||||
if (foundRule) {
|
else if ("setdefault".equals(rule))
|
||||||
tuple[2]=rs.getBytes(2); //PKTABLE_NAME
|
action = importedKeySetDefault;
|
||||||
tuple[6]=rs.getBytes(1); //FKTABLE_NAME
|
tuple[col] = Integer.toString(action).getBytes();
|
||||||
|
foundRule = true;
|
||||||
// Parse the tgargs data
|
}
|
||||||
StringBuffer fkeyColumns=new StringBuffer();
|
|
||||||
StringBuffer pkeyColumns=new StringBuffer();
|
|
||||||
int numColumns=(rs.getInt(7) >> 1) - 2;
|
|
||||||
String s=rs.getString(8);
|
|
||||||
int pos=s.lastIndexOf("\\000");
|
|
||||||
for(int c=0;c<numColumns;c++) {
|
|
||||||
if (pos>-1) {
|
|
||||||
int pos2=s.lastIndexOf("\\000", pos-1);
|
|
||||||
if (pos2>-1) {
|
|
||||||
if (fkeyColumns.length()>0) fkeyColumns.insert(0, ',');
|
|
||||||
fkeyColumns.insert(0, s.substring(pos2+4, pos)); //FKCOLUMN_NAME
|
|
||||||
pos=s.lastIndexOf("\\000", pos2-1);
|
|
||||||
if (pos>-1) {
|
|
||||||
if (pkeyColumns.length()>0) pkeyColumns.insert(0, ',');
|
|
||||||
pkeyColumns.insert(0, s.substring(pos+4, pos2)); //PKCOLUMN_NAME
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
while ((hasMore = rs.next()) && fKeyName.equals(rs.getString(3)));
|
||||||
|
|
||||||
|
if (foundRule)
|
||||||
|
{
|
||||||
|
tuple[2] = rs.getBytes(2); //PKTABLE_NAME
|
||||||
|
tuple[6] = rs.getBytes(1); //FKTABLE_NAME
|
||||||
|
|
||||||
|
// Parse the tgargs data
|
||||||
|
StringBuffer fkeyColumns = new StringBuffer();
|
||||||
|
StringBuffer pkeyColumns = new StringBuffer();
|
||||||
|
int numColumns = (rs.getInt(7) >> 1) - 2;
|
||||||
|
String s = rs.getString(8);
|
||||||
|
int pos = s.lastIndexOf("\\000");
|
||||||
|
for (int c = 0;c < numColumns;c++)
|
||||||
|
{
|
||||||
|
if (pos > -1)
|
||||||
|
{
|
||||||
|
int pos2 = s.lastIndexOf("\\000", pos - 1);
|
||||||
|
if (pos2 > -1)
|
||||||
|
{
|
||||||
|
if (fkeyColumns.length() > 0)
|
||||||
|
fkeyColumns.insert(0, ',');
|
||||||
|
fkeyColumns.insert(0, s.substring(pos2 + 4, pos)); //FKCOLUMN_NAME
|
||||||
|
pos = s.lastIndexOf("\\000", pos2 - 1);
|
||||||
|
if (pos > -1)
|
||||||
|
{
|
||||||
|
if (pkeyColumns.length() > 0)
|
||||||
|
pkeyColumns.insert(0, ',');
|
||||||
|
pkeyColumns.insert(0, s.substring(pos + 4, pos2)); //PKCOLUMN_NAME
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tuple[7] = fkeyColumns.toString().getBytes(); //FKCOLUMN_NAME
|
||||||
|
tuple[3] = pkeyColumns.toString().getBytes(); //PKCOLUMN_NAME
|
||||||
|
|
||||||
|
tuple[8] = Integer.toString(seq++).getBytes(); //KEY_SEQ
|
||||||
|
tuple[11] = fKeyName.getBytes(); //FK_NAME
|
||||||
|
tuple[12] = rs.getBytes(4); //PK_NAME
|
||||||
|
|
||||||
|
// DEFERRABILITY
|
||||||
|
int deferrability = importedKeyNotDeferrable;
|
||||||
|
boolean deferrable = rs.getBoolean(5);
|
||||||
|
boolean initiallyDeferred = rs.getBoolean(6);
|
||||||
|
if (deferrable)
|
||||||
|
{
|
||||||
|
if (initiallyDeferred)
|
||||||
|
deferrability = importedKeyInitiallyDeferred;
|
||||||
|
else
|
||||||
|
deferrability = importedKeyInitiallyImmediate;
|
||||||
|
}
|
||||||
|
tuple[13] = Integer.toString(deferrability).getBytes();
|
||||||
|
|
||||||
|
tuples.addElement(tuple);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tuple[7]=fkeyColumns.toString().getBytes(); //FKCOLUMN_NAME
|
while (hasMore);
|
||||||
tuple[3]=pkeyColumns.toString().getBytes(); //PKCOLUMN_NAME
|
|
||||||
|
|
||||||
tuple[8]=Integer.toString(seq++).getBytes(); //KEY_SEQ
|
|
||||||
tuple[11]=fKeyName.getBytes(); //FK_NAME
|
|
||||||
tuple[12]=rs.getBytes(4); //PK_NAME
|
|
||||||
|
|
||||||
// DEFERRABILITY
|
|
||||||
int deferrability=importedKeyNotDeferrable;
|
|
||||||
boolean deferrable=rs.getBoolean(5);
|
|
||||||
boolean initiallyDeferred=rs.getBoolean(6);
|
|
||||||
if (deferrable) {
|
|
||||||
if (initiallyDeferred)
|
|
||||||
deferrability=importedKeyInitiallyDeferred;
|
|
||||||
else
|
|
||||||
deferrability=importedKeyInitiallyImmediate;
|
|
||||||
}
|
|
||||||
tuple[13]=Integer.toString(deferrability).getBytes();
|
|
||||||
|
|
||||||
tuples.addElement(tuple);
|
|
||||||
}
|
|
||||||
} while (hasMore);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResultSet(connection, f, tuples, "OK", 1);
|
return new ResultSet(connection, f, tuples, "OK", 1);
|
||||||
@ -2565,7 +2586,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public java.sql.ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException
|
public java.sql.ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException
|
||||||
{
|
{
|
||||||
return getImportedExportedKeys(catalog, schema, null, table);
|
return getImportedExportedKeys(catalog, schema, null, table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2623,7 +2644,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
|
public java.sql.ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException
|
||||||
{
|
{
|
||||||
return getImportedExportedKeys(catalog, schema, table, null);
|
return getImportedExportedKeys(catalog, schema, table, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2684,7 +2705,7 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
|
public java.sql.ResultSet getCrossReference(String primaryCatalog, String primarySchema, String primaryTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException
|
||||||
{
|
{
|
||||||
return getImportedExportedKeys(primaryCatalog, primarySchema, primaryTable, foreignTable);
|
return getImportedExportedKeys(primaryCatalog, primarySchema, primaryTable, foreignTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -652,53 +652,53 @@ public class PreparedStatement extends Statement implements java.sql.PreparedSta
|
|||||||
}
|
}
|
||||||
switch (targetSqlType)
|
switch (targetSqlType)
|
||||||
{
|
{
|
||||||
case Types.TINYINT:
|
case Types.TINYINT:
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
case Types.DECIMAL:
|
case Types.DECIMAL:
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
if (x instanceof Boolean)
|
if (x instanceof Boolean)
|
||||||
set(parameterIndex, ((Boolean)x).booleanValue() ? "1" : "0");
|
set(parameterIndex, ((Boolean)x).booleanValue() ? "1" : "0");
|
||||||
else
|
else
|
||||||
set(parameterIndex, x.toString());
|
set(parameterIndex, x.toString());
|
||||||
break;
|
break;
|
||||||
case Types.CHAR:
|
case Types.CHAR:
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
case Types.LONGVARCHAR:
|
case Types.LONGVARCHAR:
|
||||||
setString(parameterIndex, x.toString());
|
setString(parameterIndex, x.toString());
|
||||||
break;
|
break;
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
setDate(parameterIndex, (java.sql.Date)x);
|
setDate(parameterIndex, (java.sql.Date)x);
|
||||||
break;
|
break;
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
setTime(parameterIndex, (Time)x);
|
setTime(parameterIndex, (Time)x);
|
||||||
break;
|
break;
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
setTimestamp(parameterIndex, (Timestamp)x);
|
setTimestamp(parameterIndex, (Timestamp)x);
|
||||||
break;
|
break;
|
||||||
case Types.BIT:
|
case Types.BIT:
|
||||||
if (x instanceof Boolean)
|
if (x instanceof Boolean)
|
||||||
{
|
{
|
||||||
set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
|
set(parameterIndex, ((Boolean)x).booleanValue() ? "TRUE" : "FALSE");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
throw new PSQLException("postgresql.prep.type");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Types.BINARY:
|
||||||
|
case Types.VARBINARY:
|
||||||
|
setObject(parameterIndex, x);
|
||||||
|
break;
|
||||||
|
case Types.OTHER:
|
||||||
|
setString(parameterIndex, ((PGobject)x).getValue());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw new PSQLException("postgresql.prep.type");
|
throw new PSQLException("postgresql.prep.type");
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Types.BINARY:
|
|
||||||
case Types.VARBINARY:
|
|
||||||
setObject(parameterIndex, x);
|
|
||||||
break;
|
|
||||||
case Types.OTHER:
|
|
||||||
setString(parameterIndex, ((PGobject)x).getValue());
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new PSQLException("postgresql.prep.type");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,40 +321,40 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
wasNullFlag = (this_row[columnIndex - 1] == null);
|
wasNullFlag = (this_row[columnIndex - 1] == null);
|
||||||
if (!wasNullFlag)
|
if (!wasNullFlag)
|
||||||
{
|
{
|
||||||
if (binaryCursor)
|
if (binaryCursor)
|
||||||
{
|
|
||||||
//If the data is already binary then just return it
|
|
||||||
return this_row[columnIndex - 1];
|
|
||||||
}
|
|
||||||
else if (connection.haveMinimumCompatibleVersion("7.2"))
|
|
||||||
{
|
|
||||||
//Version 7.2 supports the bytea datatype for byte arrays
|
|
||||||
if (fields[columnIndex - 1].getPGType().equals("bytea"))
|
|
||||||
{
|
{
|
||||||
return PGbytea.toBytes(getString(columnIndex));
|
//If the data is already binary then just return it
|
||||||
|
return this_row[columnIndex - 1];
|
||||||
|
}
|
||||||
|
else if (connection.haveMinimumCompatibleVersion("7.2"))
|
||||||
|
{
|
||||||
|
//Version 7.2 supports the bytea datatype for byte arrays
|
||||||
|
if (fields[columnIndex - 1].getPGType().equals("bytea"))
|
||||||
|
{
|
||||||
|
return PGbytea.toBytes(getString(columnIndex));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this_row[columnIndex - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return this_row[columnIndex - 1];
|
//Version 7.1 and earlier supports LargeObjects for byte arrays
|
||||||
|
// Handle OID's as BLOBS
|
||||||
|
if ( fields[columnIndex - 1].getOID() == 26)
|
||||||
|
{
|
||||||
|
LargeObjectManager lom = connection.getLargeObjectAPI();
|
||||||
|
LargeObject lob = lom.open(getInt(columnIndex));
|
||||||
|
byte buf[] = lob.read(lob.size());
|
||||||
|
lob.close();
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return this_row[columnIndex - 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Version 7.1 and earlier supports LargeObjects for byte arrays
|
|
||||||
// Handle OID's as BLOBS
|
|
||||||
if ( fields[columnIndex - 1].getOID() == 26)
|
|
||||||
{
|
|
||||||
LargeObjectManager lom = connection.getLargeObjectAPI();
|
|
||||||
LargeObject lob = lom.open(getInt(columnIndex));
|
|
||||||
byte buf[] = lob.read(lob.size());
|
|
||||||
lob.close();
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this_row[columnIndex - 1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -742,44 +742,44 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
switch (field.getSQLType())
|
switch (field.getSQLType())
|
||||||
{
|
{
|
||||||
case Types.BIT:
|
case Types.BIT:
|
||||||
return new Boolean(getBoolean(columnIndex));
|
return new Boolean(getBoolean(columnIndex));
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
return new Integer(getInt(columnIndex));
|
return new Integer(getInt(columnIndex));
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return new Integer(getInt(columnIndex));
|
return new Integer(getInt(columnIndex));
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
return new Long(getLong(columnIndex));
|
return new Long(getLong(columnIndex));
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
return getBigDecimal
|
return getBigDecimal
|
||||||
(columnIndex, (field.getMod() == -1) ? -1 : ((field.getMod() - 4) & 0xffff));
|
(columnIndex, (field.getMod() == -1) ? -1 : ((field.getMod() - 4) & 0xffff));
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
return new Float(getFloat(columnIndex));
|
return new Float(getFloat(columnIndex));
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return new Double(getDouble(columnIndex));
|
return new Double(getDouble(columnIndex));
|
||||||
case Types.CHAR:
|
case Types.CHAR:
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return getString(columnIndex);
|
|
||||||
case Types.DATE:
|
|
||||||
return getDate(columnIndex);
|
|
||||||
case Types.TIME:
|
|
||||||
return getTime(columnIndex);
|
|
||||||
case Types.TIMESTAMP:
|
|
||||||
return getTimestamp(columnIndex);
|
|
||||||
case Types.BINARY:
|
|
||||||
case Types.VARBINARY:
|
|
||||||
return getBytes(columnIndex);
|
|
||||||
default:
|
|
||||||
String type = field.getPGType();
|
|
||||||
// if the backend doesn't know the type then coerce to String
|
|
||||||
if (type.equals("unknown"))
|
|
||||||
{
|
|
||||||
return getString(columnIndex);
|
return getString(columnIndex);
|
||||||
}
|
case Types.DATE:
|
||||||
else
|
return getDate(columnIndex);
|
||||||
{
|
case Types.TIME:
|
||||||
return connection.getObject(field.getPGType(), getString(columnIndex));
|
return getTime(columnIndex);
|
||||||
}
|
case Types.TIMESTAMP:
|
||||||
|
return getTimestamp(columnIndex);
|
||||||
|
case Types.BINARY:
|
||||||
|
case Types.VARBINARY:
|
||||||
|
return getBytes(columnIndex);
|
||||||
|
default:
|
||||||
|
String type = field.getPGType();
|
||||||
|
// if the backend doesn't know the type then coerce to String
|
||||||
|
if (type.equals("unknown"))
|
||||||
|
{
|
||||||
|
return getString(columnIndex);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return connection.getObject(field.getPGType(), getString(columnIndex));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1082,7 +1082,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
|
|
||||||
if (current_row < 0 || current_row >= rows_size)
|
if (current_row < 0 || current_row >= rows_size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return current_row + 1;
|
return current_row + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1565,10 +1565,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
return null;
|
return null;
|
||||||
// length == 10: SQL Date
|
// length == 10: SQL Date
|
||||||
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
|
// length > 10: SQL Timestamp, assumes PGDATESTYLE=ISO
|
||||||
try {
|
try
|
||||||
return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0,10));
|
{
|
||||||
} catch (NumberFormatException e) {
|
return java.sql.Date.valueOf((s.length() == 10) ? s : s.substring(0, 10));
|
||||||
throw new PSQLException("postgresql.res.baddate", s);
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
throw new PSQLException("postgresql.res.baddate", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1578,10 +1581,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
return null; // SQL NULL
|
return null; // SQL NULL
|
||||||
// length == 8: SQL Time
|
// length == 8: SQL Time
|
||||||
// length > 8: SQL Timestamp
|
// length > 8: SQL Timestamp
|
||||||
try {
|
try
|
||||||
return java.sql.Time.valueOf((s.length() == 8) ? s : s.substring(11,19));
|
{
|
||||||
} catch (NumberFormatException e) {
|
return java.sql.Time.valueOf((s.length() == 8) ? s : s.substring(11, 19));
|
||||||
throw new PSQLException("postgresql.res.badtime",s);
|
}
|
||||||
|
catch (NumberFormatException e)
|
||||||
|
{
|
||||||
|
throw new PSQLException("postgresql.res.badtime", s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1628,7 +1634,7 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
char sub = resultSet.sbuf.charAt(resultSet.sbuf.length() - 3);
|
char sub = resultSet.sbuf.charAt(resultSet.sbuf.length() - 3);
|
||||||
if (sub == '+' || sub == '-')
|
if (sub == '+' || sub == '-')
|
||||||
{
|
{
|
||||||
//we have found timezone info of format +/-HH
|
//we have found timezone info of format +/-HH
|
||||||
|
|
||||||
resultSet.sbuf.setLength(resultSet.sbuf.length() - 3);
|
resultSet.sbuf.setLength(resultSet.sbuf.length() - 3);
|
||||||
if (subsecond)
|
if (subsecond)
|
||||||
@ -1639,22 +1645,28 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
|
|||||||
{
|
{
|
||||||
resultSet.sbuf.append("GMT").append(s.substring(s.length() - 3)).append(":00");
|
resultSet.sbuf.append("GMT").append(s.substring(s.length() - 3)).append(":00");
|
||||||
}
|
}
|
||||||
} else if (sub == ':') {
|
}
|
||||||
//we may have found timezone info of format +/-HH:MM, or there is no
|
else if (sub == ':')
|
||||||
//timezone info at all and this is the : preceding the seconds
|
{
|
||||||
char sub2 = resultSet.sbuf.charAt(resultSet.sbuf.length()-5);
|
//we may have found timezone info of format +/-HH:MM, or there is no
|
||||||
if (sub2 == '+' || sub2 == '-')
|
//timezone info at all and this is the : preceding the seconds
|
||||||
|
char sub2 = resultSet.sbuf.charAt(resultSet.sbuf.length() - 5);
|
||||||
|
if (sub2 == '+' || sub2 == '-')
|
||||||
{
|
{
|
||||||
//we have found timezone info of format +/-HH:MM
|
//we have found timezone info of format +/-HH:MM
|
||||||
resultSet.sbuf.setLength(resultSet.sbuf.length()-5);
|
resultSet.sbuf.setLength(resultSet.sbuf.length() - 5);
|
||||||
if (subsecond)
|
if (subsecond)
|
||||||
{
|
{
|
||||||
resultSet.sbuf.append('0').append("GMT").append(s.substring(s.length()-5));
|
resultSet.sbuf.append('0').append("GMT").append(s.substring(s.length() - 5));
|
||||||
} else {
|
|
||||||
resultSet.sbuf.append("GMT").append(s.substring(s.length()-5));
|
|
||||||
}
|
}
|
||||||
} else if (subsecond) {
|
else
|
||||||
resultSet.sbuf.append('0');
|
{
|
||||||
|
resultSet.sbuf.append("GMT").append(s.substring(s.length() - 5));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (subsecond)
|
||||||
|
{
|
||||||
|
resultSet.sbuf.append('0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (subsecond)
|
else if (subsecond)
|
||||||
|
@ -73,17 +73,17 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,10 +107,10 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
// for further expansion.
|
// for further expansion.
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.OTHER:
|
case Types.OTHER:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,18 +162,18 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return true;
|
return true;
|
||||||
case Types.DATE:
|
case Types.DATE:
|
||||||
case Types.TIME:
|
case Types.TIME:
|
||||||
case Types.TIMESTAMP:
|
case Types.TIMESTAMP:
|
||||||
return false; // I don't know about these?
|
return false; // I don't know about these?
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,26 +289,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
return 5;
|
return 5;
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return 10;
|
return 10;
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
return 8;
|
return 8;
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
Field f = getField(column);
|
Field f = getField(column);
|
||||||
if (f != null)
|
if (f != null)
|
||||||
return ((0xFFFF0000)&f.getMod()) >> 16;
|
return ((0xFFFF0000)&f.getMod()) >> 16;
|
||||||
else
|
else
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -326,26 +326,26 @@ public class ResultSetMetaData implements java.sql.ResultSetMetaData
|
|||||||
|
|
||||||
switch (sql_type)
|
switch (sql_type)
|
||||||
{
|
{
|
||||||
case Types.SMALLINT:
|
case Types.SMALLINT:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.REAL:
|
case Types.REAL:
|
||||||
return 8;
|
return 8;
|
||||||
case Types.FLOAT:
|
case Types.FLOAT:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.DOUBLE:
|
case Types.DOUBLE:
|
||||||
return 16;
|
return 16;
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return 0;
|
return 0;
|
||||||
case Types.NUMERIC:
|
case Types.NUMERIC:
|
||||||
Field f = getField(column);
|
Field f = getField(column);
|
||||||
if (f != null)
|
if (f != null)
|
||||||
return (((0x0000FFFF)&f.getMod()) - 4);
|
return (((0x0000FFFF)&f.getMod()) - 4);
|
||||||
else
|
else
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import java.sql.*;
|
|||||||
import org.postgresql.largeobject.*;
|
import org.postgresql.largeobject.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: BlobTest.java,v 1.4 2001/11/19 22:33:39 momjian Exp $
|
* $Id: BlobTest.java,v 1.5 2001/11/19 23:16:46 momjian Exp $
|
||||||
*
|
*
|
||||||
* Some simple tests based on problems reported by users. Hopefully these will
|
* Some simple tests based on problems reported by users. Hopefully these will
|
||||||
* help prevent previous problems from re-occuring ;-)
|
* help prevent previous problems from re-occuring ;-)
|
||||||
@ -108,36 +108,36 @@ public class BlobTest extends TestCase
|
|||||||
|
|
||||||
switch (method)
|
switch (method)
|
||||||
{
|
{
|
||||||
case LOOP:
|
case LOOP:
|
||||||
buf = new byte[2048];
|
buf = new byte[2048];
|
||||||
t = 0;
|
t = 0;
|
||||||
while ((s = fis.read(buf, 0, buf.length)) > 0)
|
while ((s = fis.read(buf, 0, buf.length)) > 0)
|
||||||
{
|
{
|
||||||
t += s;
|
t += s;
|
||||||
blob.write(buf, 0, s);
|
blob.write(buf, 0, s);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NATIVE_STREAM:
|
case NATIVE_STREAM:
|
||||||
os = blob.getOutputStream();
|
os = blob.getOutputStream();
|
||||||
s = fis.read();
|
|
||||||
while (s > -1)
|
|
||||||
{
|
|
||||||
os.write(s);
|
|
||||||
s = fis.read();
|
s = fis.read();
|
||||||
}
|
while (s > -1)
|
||||||
os.close();
|
{
|
||||||
break;
|
os.write(s);
|
||||||
|
s = fis.read();
|
||||||
|
}
|
||||||
|
os.close();
|
||||||
|
break;
|
||||||
|
|
||||||
case JDBC_STREAM:
|
case JDBC_STREAM:
|
||||||
File f = new File(file);
|
File f = new File(file);
|
||||||
PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testblob", "?"));
|
PreparedStatement ps = con.prepareStatement(JDBC2Tests.insertSQL("testblob", "?"));
|
||||||
ps.setBinaryStream(1, fis, (int) f.length());
|
ps.setBinaryStream(1, fis, (int) f.length());
|
||||||
ps.execute();
|
ps.execute();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assertTrue("Unknown method in uploadFile", false);
|
assertTrue("Unknown method in uploadFile", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
blob.close();
|
blob.close();
|
||||||
|
@ -21,7 +21,7 @@ public class ResultSetTest extends TestCase
|
|||||||
{
|
{
|
||||||
con = JDBC2Tests.openDB();
|
con = JDBC2Tests.openDB();
|
||||||
Statement stmt = con.createStatement();
|
Statement stmt = con.createStatement();
|
||||||
|
|
||||||
JDBC2Tests.createTable(con, "testrs", "id integer");
|
JDBC2Tests.createTable(con, "testrs", "id integer");
|
||||||
|
|
||||||
stmt.executeUpdate("INSERT INTO testrs VALUES (1)");
|
stmt.executeUpdate("INSERT INTO testrs VALUES (1)");
|
||||||
@ -44,23 +44,23 @@ public class ResultSetTest extends TestCase
|
|||||||
{
|
{
|
||||||
Statement stmt = con.createStatement();
|
Statement stmt = con.createStatement();
|
||||||
ResultSet rs = stmt.executeQuery("SELECT * FROM testrs");
|
ResultSet rs = stmt.executeQuery("SELECT * FROM testrs");
|
||||||
|
|
||||||
assertTrue(rs.absolute(-1));
|
assertTrue(rs.absolute( -1));
|
||||||
assertEquals(6, rs.getRow());
|
assertEquals(6, rs.getRow());
|
||||||
|
|
||||||
assertTrue(rs.absolute(1));
|
assertTrue(rs.absolute(1));
|
||||||
assertEquals(1, rs.getRow());
|
assertEquals(1, rs.getRow());
|
||||||
|
|
||||||
assertTrue(!rs.absolute(-10));
|
assertTrue(!rs.absolute( -10));
|
||||||
assertEquals(0, rs.getRow());
|
assertEquals(0, rs.getRow());
|
||||||
assertTrue(rs.next());
|
assertTrue(rs.next());
|
||||||
assertEquals(1, rs.getRow());
|
assertEquals(1, rs.getRow());
|
||||||
|
|
||||||
assertTrue(!rs.absolute(10));
|
assertTrue(!rs.absolute(10));
|
||||||
assertEquals(0, rs.getRow());
|
assertEquals(0, rs.getRow());
|
||||||
assertTrue(rs.previous());
|
assertTrue(rs.previous());
|
||||||
assertEquals(6, rs.getRow());
|
assertEquals(6, rs.getRow());
|
||||||
|
|
||||||
stmt.close();
|
stmt.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@ public class PGtokenizer
|
|||||||
|
|
||||||
// Don't forget the last token ;-)
|
// Don't forget the last token ;-)
|
||||||
|
|
||||||
|
|
||||||
if (s < string.length())
|
if (s < string.length())
|
||||||
tokens.addElement(string.substring(s));
|
tokens.addElement(string.substring(s));
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
|
* Copyright 1999 (C) Exoffice Technologies Inc. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* $Id: XADataSourceImpl.java,v 1.3 2001/11/19 22:33:39 momjian Exp $
|
* $Id: XADataSourceImpl.java,v 1.4 2001/11/19 23:16:46 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@ -379,6 +379,7 @@ public abstract class XADataSourceImpl
|
|||||||
// Look for all connections inside a transaction that
|
// Look for all connections inside a transaction that
|
||||||
// should have timed out by now.
|
// should have timed out by now.
|
||||||
|
|
||||||
|
|
||||||
timeout = System.currentTimeMillis();
|
timeout = System.currentTimeMillis();
|
||||||
enum = _txConnections.elements();
|
enum = _txConnections.elements();
|
||||||
while ( enum.hasMoreElements() )
|
while ( enum.hasMoreElements() )
|
||||||
|
@ -16,7 +16,7 @@ fi
|
|||||||
|
|
||||||
for FILE
|
for FILE
|
||||||
do
|
do
|
||||||
astyle --style=java -b -p -j < "$FILE" >/tmp/$$ 2>/tmp/$$a
|
astyle --style=java -b -p -j -S < "$FILE" >/tmp/$$ 2>/tmp/$$a
|
||||||
if [ "$?" -ne 0 -o -s /tmp/$$a ]
|
if [ "$?" -ne 0 -o -s /tmp/$$a ]
|
||||||
then echo "$FILE"
|
then echo "$FILE"
|
||||||
cat /tmp/$$a
|
cat /tmp/$$a
|
||||||
|
Loading…
x
Reference in New Issue
Block a user