mirror of
https://github.com/postgres/postgres.git
synced 2025-07-11 10:01:57 +03:00
From: Peter T Mount <patches@maidast.demon.co.uk>
[This is a repost - it supercedes the previous one. It fixes the patch so it doesn't bread aix port, plus there's a file missing out of the original post because difforig doesn't pick up new files. It's now attached. peter] This patch brings the JDBC driver up to the current protocol spec. Basically, the backend now tells the driver what authentication scheme to use. The patch also fixes a performance problem with large objects. In the buffer manager, each fastpath call was sending multiple Notifications to the backend (sometimes more data in the form of notifications were being sent than blob data!).
This commit is contained in:
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.32 1998/01/25 05:13:53 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.33 1998/02/02 13:16:31 scrappy Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -1532,6 +1532,7 @@ PrintBufferDescs()
|
|||||||
if (IsUnderPostmaster)
|
if (IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
SpinAcquire(BufMgrLock);
|
SpinAcquire(BufMgrLock);
|
||||||
|
#if 0
|
||||||
for (i = 0; i < NBuffers; ++i, ++buf)
|
for (i = 0; i < NBuffers; ++i, ++buf)
|
||||||
{
|
{
|
||||||
elog(NOTICE, "[%02d] (freeNext=%d, freePrev=%d, relname=%s, \
|
elog(NOTICE, "[%02d] (freeNext=%d, freePrev=%d, relname=%s, \
|
||||||
@ -1540,6 +1541,7 @@ blockNum=%d, flags=0x%x, refcount=%d %d)",
|
|||||||
buf->sb_relname, buf->tag.blockNum, buf->flags,
|
buf->sb_relname, buf->tag.blockNum, buf->flags,
|
||||||
buf->refcount, PrivateRefCount[i]);
|
buf->refcount, PrivateRefCount[i]);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
SpinRelease(BufMgrLock);
|
SpinRelease(BufMgrLock);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
# Makefile for Java JDBC interface
|
# Makefile for Java JDBC interface
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# IDENTIFICATION
|
||||||
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.4 1998/01/13 02:19:10 scrappy Exp $
|
# $Header: /cvsroot/pgsql/src/interfaces/jdbc/Attic/Makefile,v 1.5 1998/02/02 13:16:38 scrappy Exp $
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -33,8 +33,9 @@ all: postgresql.jar
|
|||||||
@echo
|
@echo
|
||||||
@echo Then either add -Djdbc.drivers=postgresql.Driver to the
|
@echo Then either add -Djdbc.drivers=postgresql.Driver to the
|
||||||
@echo commandline when running your application, or edit the
|
@echo commandline when running your application, or edit the
|
||||||
@echo "properties file (~/.hotjava/properties under unix), and"
|
@echo "properties file for your application (~/.hotjava/properties"
|
||||||
@echo add a line containing jdbc.drivers=postgresql.Driver
|
@echo "under unix for HotJava), and add a line containing"
|
||||||
|
@echo jdbc.drivers=postgresql.Driver
|
||||||
@echo
|
@echo
|
||||||
@echo More details are in the README file.
|
@echo More details are in the README file.
|
||||||
@echo ------------------------------------------------------------
|
@echo ------------------------------------------------------------
|
||||||
@ -76,8 +77,12 @@ OBJS= postgresql/CallableStatement.class \
|
|||||||
postgresql/util/PGobject.class \
|
postgresql/util/PGobject.class \
|
||||||
postgresql/util/PGtokenizer.class
|
postgresql/util/PGtokenizer.class
|
||||||
|
|
||||||
|
# If you have problems with the first line, try the second one.
|
||||||
|
# This is needed when compiling under Solaris, as the solaris sh doesn't
|
||||||
|
# recognise $( )
|
||||||
postgresql.jar: $(OBJS)
|
postgresql.jar: $(OBJS)
|
||||||
$(JAR) -c0vf $@ $$($(FIND) postgresql -name "*.class" -print)
|
$(JAR) -c0f $@ $$($(FIND) postgresql -name "*.class" -print)
|
||||||
|
# $(JAR) -c0f $@ `$(FIND) postgresql -name "*.class" -print`
|
||||||
|
|
||||||
# This rule removes any temporary and compiled files from the source tree.
|
# This rule removes any temporary and compiled files from the source tree.
|
||||||
clean:
|
clean:
|
||||||
|
@ -43,16 +43,16 @@ public class Connection implements java.sql.Connection
|
|||||||
public boolean CONNECTION_OK = true;
|
public boolean CONNECTION_OK = true;
|
||||||
public boolean CONNECTION_BAD = false;
|
public boolean CONNECTION_BAD = false;
|
||||||
|
|
||||||
private static final int STARTUP_LEN = 288; // Length of a startup packet
|
//private static final int STARTUP_LEN = 288; // Length of a startup packet
|
||||||
|
|
||||||
// These are defined in src/include/libpq/pqcomm.h
|
// These are defined in src/include/libpq/pqcomm.h
|
||||||
private int STARTUP_CODE = STARTUP_USER;
|
//private int STARTUP_CODE = STARTUP_USER;
|
||||||
private static final int STARTUP_USER = 7; // User auth
|
//private static final int STARTUP_USER = 7; // User auth
|
||||||
private static final int STARTUP_KRB4 = 10; // Kerberos 4 (unused)
|
//private static final int STARTUP_KRB4 = 10; // Kerberos 4 (unused)
|
||||||
private static final int STARTUP_KRB5 = 11; // Kerberos 5 (unused)
|
//private static final int STARTUP_KRB5 = 11; // Kerberos 5 (unused)
|
||||||
private static final int STARTUP_HBA = 12; // Host Based
|
//private static final int STARTUP_HBA = 12; // Host Based
|
||||||
private static final int STARTUP_NONE = 13; // Unauthenticated (unused)
|
//private static final int STARTUP_NONE = 13; // Unauthenticated (unused)
|
||||||
private static final int STARTUP_PASS = 14; // Password auth
|
//private static final int STARTUP_PASS = 14; // Password auth
|
||||||
|
|
||||||
private boolean autoCommit = true;
|
private boolean autoCommit = true;
|
||||||
private boolean readOnly = false;
|
private boolean readOnly = false;
|
||||||
@ -61,8 +61,25 @@ public class Connection implements java.sql.Connection
|
|||||||
private String this_url;
|
private String this_url;
|
||||||
private String cursor = null; // The positioned update cursor name
|
private String cursor = null; // The positioned update cursor name
|
||||||
|
|
||||||
// This is false for US, true for European date formats
|
// These are new for v6.3, they determine the current protocol versions
|
||||||
//protected boolean europeanDates = false;
|
// supported by this version of the driver. They are defined in
|
||||||
|
// src/include/libpq/pqcomm.h
|
||||||
|
protected static final int PG_PROTOCOL_LATEST_MAJOR = 1;
|
||||||
|
protected static final int PG_PROTOCOL_LATEST_MINOR = 0;
|
||||||
|
private static final int SM_DATABASE = 64;
|
||||||
|
private static final int SM_USER = 32;
|
||||||
|
private static final int SM_OPTIONS = 64;
|
||||||
|
private static final int SM_UNUSED = 64;
|
||||||
|
private static final int SM_TTY = 64;
|
||||||
|
|
||||||
|
private static final int AUTH_REQ_OK = 0;
|
||||||
|
private static final int AUTH_REQ_KRB4 = 1;
|
||||||
|
private static final int AUTH_REQ_KRB5 = 2;
|
||||||
|
private static final int AUTH_REQ_PASSWORD = 3;
|
||||||
|
private static final int AUTH_REQ_CRYPT = 4;
|
||||||
|
|
||||||
|
// New for 6.3, salt value for crypt authorisation
|
||||||
|
private String salt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the current date style of the backend
|
* This is the current date style of the backend
|
||||||
@ -120,7 +137,7 @@ public class Connection implements java.sql.Connection
|
|||||||
*/
|
*/
|
||||||
public Connection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException
|
public Connection(String host, int port, Properties info, String database, String url, Driver d) throws SQLException
|
||||||
{
|
{
|
||||||
int len = STARTUP_LEN; // Length of a startup packet
|
//int len = STARTUP_LEN; // Length of a startup packet
|
||||||
|
|
||||||
this_driver = d;
|
this_driver = d;
|
||||||
this_url = new String(url);
|
this_url = new String(url);
|
||||||
@ -131,6 +148,7 @@ public class Connection implements java.sql.Connection
|
|||||||
PG_HOST = new String(host);
|
PG_HOST = new String(host);
|
||||||
PG_STATUS = CONNECTION_BAD;
|
PG_STATUS = CONNECTION_BAD;
|
||||||
|
|
||||||
|
// Pre 6.3 code
|
||||||
// This handles the auth property. Any value begining with p enables
|
// This handles the auth property. Any value begining with p enables
|
||||||
// password authentication, while anything begining with i enables
|
// password authentication, while anything begining with i enables
|
||||||
// ident (RFC 1413) authentication. Any other values default to trust.
|
// ident (RFC 1413) authentication. Any other values default to trust.
|
||||||
@ -138,17 +156,17 @@ public class Connection implements java.sql.Connection
|
|||||||
// Also, the postgresql.auth system property can be used to change the
|
// Also, the postgresql.auth system property can be used to change the
|
||||||
// local default, if the auth property is not present.
|
// local default, if the auth property is not present.
|
||||||
//
|
//
|
||||||
String auth = info.getProperty("auth",System.getProperty("postgresql.auth","trust")).toLowerCase();
|
//String auth = info.getProperty("auth",System.getProperty("postgresql.auth","trust")).toLowerCase();
|
||||||
if(auth.startsWith("p")) {
|
//if(auth.startsWith("p")) {
|
||||||
// Password authentication
|
//// Password authentication
|
||||||
STARTUP_CODE=STARTUP_PASS;
|
//STARTUP_CODE=STARTUP_PASS;
|
||||||
} else if(auth.startsWith("i")) {
|
//} else if(auth.startsWith("i")) {
|
||||||
// Ident (RFC 1413) authentication
|
//// Ident (RFC 1413) authentication
|
||||||
STARTUP_CODE=STARTUP_HBA;
|
//STARTUP_CODE=STARTUP_HBA;
|
||||||
} else {
|
//} else {
|
||||||
// Anything else defaults to trust authentication
|
//// Anything else defaults to trust authentication
|
||||||
STARTUP_CODE=STARTUP_USER;
|
//STARTUP_CODE=STARTUP_USER;
|
||||||
}
|
//}
|
||||||
|
|
||||||
// Now make the initial connection
|
// Now make the initial connection
|
||||||
try
|
try
|
||||||
@ -161,21 +179,94 @@ public class Connection implements java.sql.Connection
|
|||||||
// Now we need to construct and send a startup packet
|
// Now we need to construct and send a startup packet
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
pg_stream.SendInteger(len, 4); len -= 4;
|
// Pre 6.3 code
|
||||||
pg_stream.SendInteger(STARTUP_CODE, 4); len -= 4;
|
//pg_stream.SendInteger(len, 4); len -= 4;
|
||||||
pg_stream.Send(database.getBytes(), 64); len -= 64;
|
//pg_stream.SendInteger(STARTUP_CODE, 4); len -= 4;
|
||||||
pg_stream.Send(PG_USER.getBytes(), len);
|
//pg_stream.Send(database.getBytes(), 64); len -= 64;
|
||||||
|
//pg_stream.Send(PG_USER.getBytes(), len);
|
||||||
|
//
|
||||||
|
//// Send the password packet if required
|
||||||
|
//if(STARTUP_CODE == STARTUP_PASS) {
|
||||||
|
//len=STARTUP_LEN;
|
||||||
|
//pg_stream.SendInteger(len, 4); len -= 4;
|
||||||
|
//pg_stream.SendInteger(STARTUP_PASS, 4); len -= 4;
|
||||||
|
//pg_stream.Send(PG_USER.getBytes(), PG_USER.length());
|
||||||
|
//len-=PG_USER.length();
|
||||||
|
//pg_stream.SendInteger(0,1); len -= 1;
|
||||||
|
//pg_stream.Send(PG_PASSWORD.getBytes(), len);
|
||||||
|
//}
|
||||||
|
|
||||||
// Send the password packet if required
|
// Ver 6.3 code
|
||||||
if(STARTUP_CODE == STARTUP_PASS) {
|
pg_stream.SendInteger(4+4+SM_DATABASE+SM_USER+SM_OPTIONS+SM_UNUSED+SM_TTY,4);
|
||||||
len=STARTUP_LEN;
|
pg_stream.SendInteger(PG_PROTOCOL_LATEST_MAJOR,2);
|
||||||
pg_stream.SendInteger(len, 4); len -= 4;
|
pg_stream.SendInteger(PG_PROTOCOL_LATEST_MINOR,2);
|
||||||
pg_stream.SendInteger(STARTUP_PASS, 4); len -= 4;
|
pg_stream.Send(database.getBytes(),SM_DATABASE);
|
||||||
pg_stream.Send(PG_USER.getBytes(), PG_USER.length());
|
pg_stream.Send(PG_USER.getBytes(),SM_USER+SM_OPTIONS+SM_UNUSED+SM_TTY);
|
||||||
len-=PG_USER.length();
|
// The last send includes the unused fields
|
||||||
pg_stream.SendInteger(0,1); len -= 1;
|
|
||||||
pg_stream.Send(PG_PASSWORD.getBytes(), len);
|
// Now get the response from the backend, either an error message
|
||||||
}
|
// or an authentication request
|
||||||
|
int areq = -1; // must have a value here
|
||||||
|
do {
|
||||||
|
int beresp = pg_stream.ReceiveChar();
|
||||||
|
switch(beresp)
|
||||||
|
{
|
||||||
|
case 'E':
|
||||||
|
throw new SQLException(pg_stream.ReceiveString(4096));
|
||||||
|
|
||||||
|
case 'R':
|
||||||
|
// Get the type of request
|
||||||
|
areq = pg_stream.ReceiveIntegerR(4);
|
||||||
|
|
||||||
|
// Get the password salt if there is one
|
||||||
|
if(areq == AUTH_REQ_CRYPT) {
|
||||||
|
byte[] rst = new byte[2];
|
||||||
|
rst[0] = (byte)pg_stream.ReceiveChar();
|
||||||
|
rst[1] = (byte)pg_stream.ReceiveChar();
|
||||||
|
salt = new String(rst,0,2);
|
||||||
|
DriverManager.println("Salt="+salt);
|
||||||
|
}
|
||||||
|
|
||||||
|
// now send the auth packet
|
||||||
|
switch(areq)
|
||||||
|
{
|
||||||
|
case AUTH_REQ_OK:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUTH_REQ_KRB4:
|
||||||
|
DriverManager.println("postgresql: KRB4");
|
||||||
|
throw new SQLException("Kerberos 4 not supported");
|
||||||
|
|
||||||
|
case AUTH_REQ_KRB5:
|
||||||
|
DriverManager.println("postgresql: KRB5");
|
||||||
|
throw new SQLException("Kerberos 5 not supported");
|
||||||
|
|
||||||
|
case AUTH_REQ_PASSWORD:
|
||||||
|
DriverManager.println("postgresql: PASSWORD");
|
||||||
|
pg_stream.SendInteger(5+PG_PASSWORD.length(),4);
|
||||||
|
pg_stream.Send(PG_PASSWORD.getBytes());
|
||||||
|
pg_stream.SendInteger(0,1);
|
||||||
|
//pg_stream.SendPacket(PG_PASSWORD.getBytes());
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AUTH_REQ_CRYPT:
|
||||||
|
DriverManager.println("postgresql: CRYPT");
|
||||||
|
String crypted = UnixCrypt.crypt(salt,PG_PASSWORD);
|
||||||
|
pg_stream.SendInteger(5+crypted.length(),4);
|
||||||
|
pg_stream.Send(crypted.getBytes());
|
||||||
|
pg_stream.SendInteger(0,1);
|
||||||
|
//pg_stream.SendPacket(UnixCrypt.crypt(salt,PG_PASSWORD).getBytes());
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new SQLException("Authentication type "+areq+" not supported");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new SQLException("error getting authentication request");
|
||||||
|
}
|
||||||
|
} while(areq != AUTH_REQ_OK);
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new SQLException("Connection failed: " + e.toString());
|
throw new SQLException("Connection failed: " + e.toString());
|
||||||
@ -671,14 +762,14 @@ public class Connection implements java.sql.Connection
|
|||||||
*/
|
*/
|
||||||
private Field[] ReceiveFields() throws SQLException
|
private Field[] ReceiveFields() throws SQLException
|
||||||
{
|
{
|
||||||
int nf = pg_stream.ReceiveInteger(2), i;
|
int nf = pg_stream.ReceiveIntegerR(2), i;
|
||||||
Field[] fields = new Field[nf];
|
Field[] fields = new Field[nf];
|
||||||
|
|
||||||
for (i = 0 ; i < nf ; ++i)
|
for (i = 0 ; i < nf ; ++i)
|
||||||
{
|
{
|
||||||
String typname = pg_stream.ReceiveString(8192);
|
String typname = pg_stream.ReceiveString(8192);
|
||||||
int typid = pg_stream.ReceiveInteger(4);
|
int typid = pg_stream.ReceiveIntegerR(4);
|
||||||
int typlen = pg_stream.ReceiveInteger(2);
|
int typlen = pg_stream.ReceiveIntegerR(2);
|
||||||
fields[i] = new Field(this, typname, typid, typlen);
|
fields[i] = new Field(this, typname, typid, typlen);
|
||||||
}
|
}
|
||||||
return fields;
|
return fields;
|
||||||
|
@ -1925,30 +1925,28 @@ public class DatabaseMetaData implements java.sql.DatabaseMetaData
|
|||||||
*/
|
*/
|
||||||
public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException
|
public java.sql.ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException
|
||||||
{
|
{
|
||||||
// XXX-Not Implemented as grant is broken
|
Field f[] = new Field[8];
|
||||||
return null;
|
Vector v = new Vector();
|
||||||
//Field f[] = new Field[8];
|
|
||||||
//Vector v = new Vector();
|
f[0] = new Field(connection,new String("TABLE_CAT"),iVarcharOid,32);
|
||||||
//
|
f[1] = new Field(connection,new String("TABLE_SCHEM"),iVarcharOid,32);
|
||||||
//f[0] = new Field(connection,new String("TABLE_CAT"),iVarcharOid,32);
|
f[2] = new Field(connection,new String("TABLE_NAME"),iVarcharOid,32);
|
||||||
//f[1] = new Field(connection,new String("TABLE_SCHEM"),iVarcharOid,32);
|
f[3] = new Field(connection,new String("COLUMN_NAME"),iVarcharOid,32);
|
||||||
//f[2] = new Field(connection,new String("TABLE_NAME"),iVarcharOid,32);
|
f[4] = new Field(connection,new String("GRANTOR"),iVarcharOid,32);
|
||||||
//f[3] = new Field(connection,new String("COLUMN_NAME"),iVarcharOid,32);
|
f[5] = new Field(connection,new String("GRANTEE"),iVarcharOid,32);
|
||||||
//f[4] = new Field(connection,new String("GRANTOR"),iVarcharOid,32);
|
f[6] = new Field(connection,new String("PRIVILEGE"),iVarcharOid,32);
|
||||||
//f[5] = new Field(connection,new String("GRANTEE"),iVarcharOid,32);
|
f[7] = new Field(connection,new String("IS_GRANTABLE"),iVarcharOid,32);
|
||||||
//f[6] = new Field(connection,new String("PRIVILEGE"),iVarcharOid,32);
|
|
||||||
//f[7] = new Field(connection,new String("IS_GRANTABLE"),iVarcharOid,32);
|
// This is taken direct from the psql source
|
||||||
//
|
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 ORDER BY relname");
|
||||||
//// This is taken direct from the psql source
|
while(r.next()) {
|
||||||
//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 ORDER BY relname");
|
byte[][] tuple = new byte[8][0];
|
||||||
//while(r.next()) {
|
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]= "default".getBytes();
|
//v.addElement(tuple);
|
||||||
//
|
}
|
||||||
//v.addElement(tuple);
|
|
||||||
//}
|
return new ResultSet(connection,f,v,"OK",1);
|
||||||
//
|
|
||||||
//return new ResultSet(connection,f,v,"OK",1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -76,6 +76,8 @@ public class PG_Stream
|
|||||||
* This is required when the backend uses the routines in the
|
* This is required when the backend uses the routines in the
|
||||||
* src/backend/libpq/pqcomprim.c module.
|
* src/backend/libpq/pqcomprim.c module.
|
||||||
*
|
*
|
||||||
|
* As time goes by, this should become obsolete.
|
||||||
|
*
|
||||||
* @param val the integer to be sent
|
* @param val the integer to be sent
|
||||||
* @param siz the length of the integer in bytes (size of structure)
|
* @param siz the length of the integer in bytes (size of structure)
|
||||||
* @exception IOException if an I/O error occurs
|
* @exception IOException if an I/O error occurs
|
||||||
@ -139,6 +141,17 @@ public class PG_Stream
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a packet, prefixed with the packet's length
|
||||||
|
* @param buf buffer to send
|
||||||
|
* @exception SQLException if an I/O Error returns
|
||||||
|
*/
|
||||||
|
public void SendPacket(byte[] buf) throws IOException
|
||||||
|
{
|
||||||
|
SendInteger(buf.length+4,4);
|
||||||
|
Send(buf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives a single character from the backend
|
* Receives a single character from the backend
|
||||||
*
|
*
|
||||||
@ -186,6 +199,33 @@ public class PG_Stream
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Receives an integer from the backend
|
||||||
|
*
|
||||||
|
* @param siz length of the integer in bytes
|
||||||
|
* @return the integer received from the backend
|
||||||
|
* @exception SQLException if an I/O error occurs
|
||||||
|
*/
|
||||||
|
public int ReceiveIntegerR(int siz) throws SQLException
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
for (int i = 0 ; i < siz ; i++)
|
||||||
|
{
|
||||||
|
int b = pg_input.read();
|
||||||
|
|
||||||
|
if (b < 0)
|
||||||
|
throw new IOException("EOF");
|
||||||
|
n = b | (n << 8);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SQLException("Error reading from backend: " + e.toString());
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Receives a null-terminated string from the backend. Maximum of
|
* Receives a null-terminated string from the backend. Maximum of
|
||||||
* maxsiz bytes - if we don't see a null, then we assume something
|
* maxsiz bytes - if we don't see a null, then we assume something
|
||||||
@ -253,7 +293,7 @@ public class PG_Stream
|
|||||||
answer[i] = null;
|
answer[i] = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int len = ReceiveInteger(4);
|
int len = ReceiveIntegerR(4);
|
||||||
if (!bin)
|
if (!bin)
|
||||||
len -= 4;
|
len -= 4;
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
|
@ -75,8 +75,10 @@ public class Fastpath
|
|||||||
stream.SendInteger(70,1);
|
stream.SendInteger(70,1);
|
||||||
stream.SendInteger(0,1);
|
stream.SendInteger(0,1);
|
||||||
|
|
||||||
stream.SendIntegerReverse(fnid,4);
|
//stream.SendIntegerReverse(fnid,4);
|
||||||
stream.SendIntegerReverse(args.length,4);
|
//stream.SendIntegerReverse(args.length,4);
|
||||||
|
stream.SendInteger(fnid,4);
|
||||||
|
stream.SendInteger(args.length,4);
|
||||||
|
|
||||||
for(int i=0;i<args.length;i++)
|
for(int i=0;i<args.length;i++)
|
||||||
args[i].send(stream);
|
args[i].send(stream);
|
||||||
@ -114,12 +116,12 @@ public class Fastpath
|
|||||||
// Function returned properly
|
// Function returned properly
|
||||||
//
|
//
|
||||||
case 'G':
|
case 'G':
|
||||||
int sz = stream.ReceiveInteger(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.ReceiveInteger(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);
|
||||||
|
@ -94,11 +94,11 @@ public class FastpathArg
|
|||||||
{
|
{
|
||||||
if(type) {
|
if(type) {
|
||||||
// argument is an integer
|
// argument is an integer
|
||||||
s.SendIntegerReverse(4,4); // size of an integer
|
s.SendInteger(4,4); // size of an integer
|
||||||
s.SendIntegerReverse(value,4); // integer value of argument
|
s.SendInteger(value,4); // integer value of argument
|
||||||
} else {
|
} else {
|
||||||
// argument is a byte array
|
// argument is a byte array
|
||||||
s.SendIntegerReverse(bytes.length,4); // size of array
|
s.SendInteger(bytes.length,4); // size of array
|
||||||
s.Send(bytes);
|
s.Send(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user