Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jun 2001 04:44:22 +0200 (CEST)
From:      girgen@partitur.se
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/27846: databases/postgresql7 update for Java character encoding
Message-ID:  <200106030244.f532iMa32271@palle.girgensohn.se>

next in thread | raw e-mail | index | archive | help

>Number:         27846
>Category:       ports
>Synopsis:       databases/postgresql7 update for Java character encoding
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Sat Jun 02 19:50:00 PDT 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200106030244.f532iMa32271>