From girgen@palle.girgensohn.se  Sat Jun  2 19:44:25 2001
Return-Path: <girgen@palle.girgensohn.se>
Received: from palle.girgensohn.se (c213.89.165.253.cm-upc.chello.se [213.89.165.253])
	by hub.freebsd.org (Postfix) with ESMTP id 9AB3D37B42C
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  2 Jun 2001 19:44:24 -0700 (PDT)
	(envelope-from girgen@palle.girgensohn.se)
Received: (from girgen@localhost)
	by palle.girgensohn.se (8.11.3/8.11.3) id f532iMa32271;
	Sun, 3 Jun 2001 04:44:22 +0200 (CEST)
	(envelope-from girgen)
Message-Id: <200106030244.f532iMa32271@palle.girgensohn.se>
Date: Sun, 3 Jun 2001 04:44:22 +0200 (CEST)
From: girgen@partitur.se
Reply-To: girgen@partitur.se
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: databases/postgresql7 update for Java character encoding
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         27846
>Category:       ports
>Synopsis:       databases/postgresql7 update for Java character encoding
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 02 19:50:00 PDT 2001
>Closed-Date:    Mon Jun 4 04:54:03 PDT 2001
>Last-Modified:  Mon Jun 04 04:54:21 PDT 2001
>Originator:     Palle Girgensohn
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
Partitur
>Environment:
System: FreeBSD palle.girgensohn.se 4.3-STABLE FreeBSD 4.3-STABLE #0: Sat May 19 03:59:57 CEST 2001 girgen@palle.girgensohn.se:/usr/obj/usr/src/sys/STORDATAN i386


	
>Description:
With version 7.1, the JDBC implementation started checking the
postgres server for character encoding, but this only worked well when
multibyte encoding was activated when postgres was built. Without
multibyte, the server will always anser SQL_ASCII, and this would set
the JVM to use seven-bit ascii, and put '?' for all eight-bit
(e.g. latin1) characters.

	
>How-To-Repeat:
	
>Fix:
This is a patch from the postgres' CVS repository. bump revision and
cvs add the patch file. As a bonus, add support for Korean, KOI8_R,
encoding.

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/databases/postgresql7/Makefile,v
retrieving revision 1.84
diff -u -u -r1.84 Makefile
--- Makefile	2001/06/01 06:04:48	1.84
+++ Makefile	2001/06/03 02:08:03
@@ -7,6 +7,7 @@
 
 PORTNAME=	postgresql
 PORTVERSION=	7.1.2
+PORTREVISION=	2
 CATEGORIES=	databases
 MASTER_SITES=	ftp://ftp.iodynamics.com/pub/mirror/postgresql/%SUBDIR%/ \
 		ftp://ftp.postgresql.org/pub/%SUBDIR%/ \
--- /dev/null	Sun Jun  3 04:26:51 2001
+++ files/patch-jdbc-Connection	Sun Jun  3 03:56:23 2001
@@ -0,0 +1,51 @@
+===================================================================
+RCS file: /home/projects/pgsql/cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/Connection.java,v
+retrieving revision 1.14
+retrieving revision 1.16
+diff -u -r1.14 -r1.16
+--- src/interfaces/jdbc/org/postgresql/Connection.java	2001/01/31 08:26:01	1.14
++++ src/interfaces/jdbc/org/postgresql/Connection.java	2001/06/01 20:57:58	1.16
+@@ -10,7 +10,7 @@
+ import org.postgresql.util.*;
+ 
+ /**
+- * $Id: Connection.java,v 1.14 2001/01/31 08:26:01 peter Exp $
++ * $Id: Connection.java,v 1.16 2001/06/01 20:57:58 momjian Exp $
+  *
+  * This abstract class is used by org.postgresql.Driver to open either the JDBC1 or
+  * JDBC2 versions of the Connection class.
+@@ -267,7 +267,8 @@
+       //
+       firstWarning = null;
+ 
+-      java.sql.ResultSet initrset = ExecSQL("set datestyle to 'ISO'; select getdatabaseencoding()");
++      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
+@@ -307,9 +308,23 @@
+         } else if (dbEncoding.equals("EUC_TW")) {
+           dbEncoding = "EUC_TW";
+         } else if (dbEncoding.equals("KOI8")) {
+-          dbEncoding = "KOI8_R";
++	  // try first if KOI8_U is present, it's a superset of KOI8_R
++	    try {
++        	dbEncoding = "KOI8_U";
++		"test".getBytes(dbEncoding);
++	    }
++	    catch(UnsupportedEncodingException uee) {
++	    // well, KOI8_U is still not in standard JDK, falling back to KOI8_R :(
++        	dbEncoding = "KOI8_R";
++	    }
++
+         } else if (dbEncoding.equals("WIN")) {
+           dbEncoding = "Cp1252";
++        } else if (dbEncoding.equals("UNKNOWN")) {
++          //This isn't a multibyte database so we don't have an encoding to use
++          //We leave dbEncoding null which will cause the default encoding for the
++          //JVM to be used
++          dbEncoding = null;
+         } else {
+           dbEncoding = null;
+         }
>Release-Note:
>Audit-Trail:

From: Palle Girgensohn <girgen@partitur.se>
To: freebsd-gnats-submit@FreeBSD.org, girgen@partitur.se
Cc:  
Subject: Re: ports/27846: databases/postgresql7 update for Java character 
 encoding
Date: Sun, 03 Jun 2001 13:38:49 +0200

 PORTREVISION should of course be 1, not 2. Sorry about that.
 
 /Palle
State-Changed-From-To: open->closed 
State-Changed-By: jeh 
State-Changed-When: Mon Jun 4 04:54:03 PDT 2001 
State-Changed-Why:  
Committed Thanks 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27846 
>Unformatted:
