mirror of
https://github.com/postgres/postgres.git
synced 2025-05-23 00:02:38 -04:00
fixed problem connecting to server with client_min_messages set to debug. The code was not expecting to receive notice messages during the connection handshake.
This commit is contained in:
parent
ef9db25a7e
commit
e25c93c7eb
@ -4,6 +4,7 @@ import java.io.*;
|
|||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import org.postgresql.Driver;
|
||||||
import org.postgresql.Field;
|
import org.postgresql.Field;
|
||||||
import org.postgresql.fastpath.*;
|
import org.postgresql.fastpath.*;
|
||||||
import org.postgresql.largeobject.*;
|
import org.postgresql.largeobject.*;
|
||||||
@ -11,7 +12,7 @@ import org.postgresql.util.*;
|
|||||||
import org.postgresql.core.*;
|
import org.postgresql.core.*;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: Connection.java,v 1.45 2002/03/26 05:52:48 barry Exp $
|
* $Id: Connection.java,v 1.46 2002/05/14 03:00:35 barry 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.
|
||||||
@ -30,7 +31,7 @@ public abstract class Connection
|
|||||||
private String compatible;
|
private String compatible;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The encoding to use for this connection.
|
The encoding to use for this connection.
|
||||||
*/
|
*/
|
||||||
private Encoding encoding = Encoding.defaultEncoding();
|
private Encoding encoding = Encoding.defaultEncoding();
|
||||||
|
|
||||||
@ -209,7 +210,6 @@ public abstract class Connection
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@ -217,7 +217,7 @@ public abstract class Connection
|
|||||||
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);
|
Driver.debug("Crypt salt=" + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Or get the md5 password salt if there is one
|
// Or get the md5 password salt if there is one
|
||||||
@ -229,7 +229,7 @@ public abstract class Connection
|
|||||||
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);
|
Driver.debug("MD5 salt=" + salt);
|
||||||
}
|
}
|
||||||
|
|
||||||
// now send the auth packet
|
// now send the auth packet
|
||||||
@ -239,15 +239,15 @@ public abstract class Connection
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AUTH_REQ_KRB4:
|
case AUTH_REQ_KRB4:
|
||||||
DriverManager.println("postgresql: KRB4");
|
Driver.debug("postgresql: KRB4");
|
||||||
throw new PSQLException("postgresql.con.kerb4");
|
throw new PSQLException("postgresql.con.kerb4");
|
||||||
|
|
||||||
case AUTH_REQ_KRB5:
|
case AUTH_REQ_KRB5:
|
||||||
DriverManager.println("postgresql: KRB5");
|
Driver.debug("postgresql: KRB5");
|
||||||
throw new PSQLException("postgresql.con.kerb5");
|
throw new PSQLException("postgresql.con.kerb5");
|
||||||
|
|
||||||
case AUTH_REQ_PASSWORD:
|
case AUTH_REQ_PASSWORD:
|
||||||
DriverManager.println("postgresql: PASSWORD");
|
Driver.debug("postgresql: PASSWORD");
|
||||||
pg_stream.SendInteger(5 + password.length(), 4);
|
pg_stream.SendInteger(5 + password.length(), 4);
|
||||||
pg_stream.Send(password.getBytes());
|
pg_stream.Send(password.getBytes());
|
||||||
pg_stream.SendInteger(0, 1);
|
pg_stream.SendInteger(0, 1);
|
||||||
@ -255,7 +255,7 @@ public abstract class Connection
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AUTH_REQ_CRYPT:
|
case AUTH_REQ_CRYPT:
|
||||||
DriverManager.println("postgresql: CRYPT");
|
Driver.debug("postgresql: CRYPT");
|
||||||
String crypted = UnixCrypt.crypt(salt, password);
|
String crypted = UnixCrypt.crypt(salt, password);
|
||||||
pg_stream.SendInteger(5 + crypted.length(), 4);
|
pg_stream.SendInteger(5 + crypted.length(), 4);
|
||||||
pg_stream.Send(crypted.getBytes());
|
pg_stream.Send(crypted.getBytes());
|
||||||
@ -264,7 +264,7 @@ public abstract class Connection
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AUTH_REQ_MD5:
|
case AUTH_REQ_MD5:
|
||||||
DriverManager.println("postgresql: MD5");
|
Driver.debug("postgresql: MD5");
|
||||||
byte[] digest = MD5Digest.encode(PG_USER, password, salt);
|
byte[] digest = MD5Digest.encode(PG_USER, password, salt);
|
||||||
pg_stream.SendInteger(5 + digest.length, 4);
|
pg_stream.SendInteger(5 + digest.length, 4);
|
||||||
pg_stream.Send(digest);
|
pg_stream.Send(digest);
|
||||||
@ -291,7 +291,9 @@ public abstract class Connection
|
|||||||
|
|
||||||
|
|
||||||
// As of protocol version 2.0, we should now receive the cancellation key and the pid
|
// As of protocol version 2.0, we should now receive the cancellation key and the pid
|
||||||
int beresp = pg_stream.ReceiveChar();
|
int beresp;
|
||||||
|
do {
|
||||||
|
beresp = pg_stream.ReceiveChar();
|
||||||
switch (beresp)
|
switch (beresp)
|
||||||
{
|
{
|
||||||
case 'K':
|
case 'K':
|
||||||
@ -306,19 +308,24 @@ public abstract class Connection
|
|||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.setup");
|
throw new PSQLException("postgresql.con.setup");
|
||||||
}
|
}
|
||||||
|
} while (beresp == 'N');
|
||||||
|
|
||||||
// Expect ReadyForQuery packet
|
// Expect ReadyForQuery packet
|
||||||
|
do {
|
||||||
beresp = pg_stream.ReceiveChar();
|
beresp = pg_stream.ReceiveChar();
|
||||||
switch (beresp)
|
switch (beresp)
|
||||||
{
|
{
|
||||||
case 'Z':
|
case 'Z':
|
||||||
break;
|
break;
|
||||||
|
case 'N':
|
||||||
|
addWarning(pg_stream.ReceiveString(encoding));
|
||||||
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
|
throw new PSQLException("postgresql.con.backend", pg_stream.ReceiveString(encoding));
|
||||||
default:
|
default:
|
||||||
throw new PSQLException("postgresql.con.setup");
|
throw new PSQLException("postgresql.con.setup");
|
||||||
}
|
}
|
||||||
|
} while (beresp == 'N');
|
||||||
// "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
|
// "pg_encoding_to_char(1)" will return 'EUC_JP' for a backend compiled with multibyte,
|
||||||
// otherwise it's hardcoded to 'SQL_ASCII'.
|
// otherwise it's hardcoded to 'SQL_ASCII'.
|
||||||
// If the backend doesn't know about multibyte we can't assume anything about the encoding
|
// If the backend doesn't know about multibyte we can't assume anything about the encoding
|
||||||
@ -368,8 +375,6 @@ public abstract class Connection
|
|||||||
*/
|
*/
|
||||||
public void addWarning(String msg)
|
public void addWarning(String msg)
|
||||||
{
|
{
|
||||||
DriverManager.println(msg);
|
|
||||||
|
|
||||||
// Add the warning to the chain
|
// Add the warning to the chain
|
||||||
if (firstWarning != null)
|
if (firstWarning != null)
|
||||||
firstWarning.setNextWarning(new SQLWarning(msg));
|
firstWarning.setNextWarning(new SQLWarning(msg));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user