Re: [PATCHES] Re: [JDBC] [PATCH] Cleanup of JDBC character encoding

2001-07-19 Thread Anders Bengtsson

On Sun, 15 Jul 2001, Bruce Momjian wrote:

 I am having trouble applying this patch to the current CVS tree.  The
 majority of changes fail to apply.  Can you give me a patch against
 current CVS or can someone manually merge the changes into CVS and send
 me a patch?  Thanks.

Here's a patch against the current CVS. The changes from the previous
patch are mostly related to the changed interface for PG_Stream.

/Anders
_
A n d e r s  B e n g t s s o n   [EMAIL PROTECTED]
Stockholm, Sweden


Index: src/interfaces/jdbc/Implementation
===
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/Implementation,v
retrieving revision 1.2
diff -c -r1.2 Implementation
*** src/interfaces/jdbc/Implementation  2001/01/18 14:50:14 1.2
--- src/interfaces/jdbc/Implementation  2001/07/19 14:17:49
***
*** 151,156 
--- 151,157 
  MemoryPool  Interface for managing MemoryPools. Not used (yet).
  ObjectPool  Interface for an Object Pool
  SimpleObjectPool Class that implements ObjectPool and used by BytePoolDim#
+ EncodingCharacter encoding logic, mainly for Connection and PG_Stream.
  
  Package org.postgresql.fastpath
  ---
Index: src/interfaces/jdbc/org/postgresql/Connection.java
===
RCS file: 
/home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v

retrieving revision 1.18
diff -c -r1.18 Connection.java
*** src/interfaces/jdbc/org/postgresql/Connection.java  2001/07/15 04:21:26 1.18
--- src/interfaces/jdbc/org/postgresql/Connection.java  2001/07/19 14:17:52
***
*** 8,13 
--- 8,14 
  import org.postgresql.fastpath.*;
  import org.postgresql.largeobject.*;
  import org.postgresql.util.*;
+ import org.postgresql.core.Encoding;
  
  /**
   * $Id: Connection.java,v 1.18 2001/07/15 04:21:26 momjian Exp $
***
*** 33,43 
  
/**
 *  The encoding to use for this connection.
-*  If bnull/b, the encoding has not been specified by the
-*  user, and the default encoding for the platform should be
-*  used.
 */
!   private String encoding;
  
public boolean CONNECTION_OK = true;
public boolean CONNECTION_BAD = false;
--- 34,41 
  
/**
 *  The encoding to use for this connection.
 */
!   private Encoding encoding = Encoding.defaultEncoding();
  
public boolean CONNECTION_OK = true;
public boolean CONNECTION_BAD = false;
***
*** 162,168 
// The most common one to be thrown here is:
// User authentication failed
//
! throw new SQLException(pg_stream.ReceiveString(getEncoding()));
  
  case 'R':
// Get the type of request
--- 160,166 
// The most common one to be thrown here is:
// User authentication failed
//
! throw new SQLException(pg_stream.ReceiveString(encoding));
  
  case 'R':
// Get the type of request
***
*** 232,238 
break;
case 'E':
case 'N':
!throw new SQLException(pg_stream.ReceiveString(getEncoding()));
  default:
throw new PSQLException(postgresql.con.setup);
}
--- 230,236 
break;
case 'E':
case 'N':
!throw new SQLException(pg_stream.ReceiveString(encoding));
  default:
throw new PSQLException(postgresql.con.setup);
}
***
*** 244,354 
   break;
case 'E':
case 'N':
!throw new SQLException(pg_stream.ReceiveString(getEncoding()));
  default:
throw new PSQLException(postgresql.con.setup);
}
  
-   // Originally we issued a SHOW DATESTYLE statement to find the databases 
default
-   // datestyle. However, this caused some problems with timestamps, so in 6.5, 
we
-   // went the way of ODBC, and set the connection to ISO.
-   //
-   // This may cause some clients to break when they assume anything other than 
ISO,
-   // but then - they should be using the proper methods ;-)
-   //
-   // We also ask the DB for certain properties (i.e. DatabaseEncoding at this 
time)
-   //
firstWarning = null;
  
!   java.sql.ResultSet initrset = ExecSQL(set datestyle to 'ISO';  +
! select case when pg_encoding_to_char(1) = 'SQL_ASCII' then 'UNKNOWN' else 
getdatabaseencoding() end);
  
!   String dbEncoding = null;
!   //retrieve DB properties
!   if(initrset.next()) {
! 
! //handle DatabaseEncoding
! 

Re: [JDBC] Connection.setCatalog()

2001-07-19 Thread jason

[[[ Original Message from Tom Lane [EMAIL PROTECTED] ]]]

 Peter Eisentraut [EMAIL PROTECTED] writes:
  Tom Lane writes:
  Peter E. has previously commented that Postgres databases correspond
  most closely to the SQL concept of catalog cluster, not catalog.
 
  I most certainly did not.  According to my interpretation:
 
 I sit corrected.  If you want to define catalog == database, okay with
 me.
 
   regards, tom lane

Great, here is a context diff of CVS for implementing the get/setCatalog methods in 
Connection - note: I've updated setCatalog(String catalog) from my previous diff so it 
checks whether it is already connected to the specified catalog.

Thanks,

Jason Davies

[EMAIL PROTECTED]
 Connection.diff


---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html