Ticket #33145: postgresql90.diff

File postgresql90.diff, 19.8 KB (added by mail_ben_schmidt@…, 12 years ago)
  • Portfile

    diff -Naur /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/databases/postgresql90/Portfile ./Portfile
    old new  
    66
    77name                    postgresql90
    88version                 9.0.6
     9revision                2
    910
    1011categories              databases
    1112platforms               darwin
     
    3839patchfiles              src_pl_plpython_Makefile.patch
    3940
    4041set libdir              ${prefix}/lib/${name}
     42
     43if {[variant_isset icu]} {
     44    pre-configure {
     45        system "${prefix}/bin/autoreconf263 ${worksrcpath}"
     46    }
     47}
     48
    4149configure.args  --sysconfdir=${prefix}/etc/${name} \
    4250                                --bindir=${libdir}/bin \
    4351                                --libdir=${libdir} \
     
    127135        configure.env-append            TCLSH=${prefix}/bin/tclsh
    128136}
    129137
     138variant icu description {use ICU for locale-aware text functionality} {
     139        depends_lib-append              port:icu
     140        depends_build-append            port:autoconf263
     141        patchfiles-append               pg906_icu_2012-02-15.patch
     142        configure.args-append           --with-icu
     143}
     144
     145default_variants +icu
     146
    130147post-install {
    131148    ui_msg "\nTo use the postgresql server, install the ${name}-server port"
    132149}
  • files/pg906_icu_2012-02-15.patch

    diff -Naur /opt/local/var/macports/sources/rsync.macports.org/release/tarballs/ports/databases/postgresql90/files/pg906_icu_2012-02-15.patch ./files/pg906_icu_2012-02-15.patch
    old new  
     1diff -Naur postgresql-9.0.6-orig/configure.in postgresql-9.0.6/configure.in
     2--- configure.in        2012-02-03 11:56:32.000000000 +1100
     3+++ configure.in        2012-02-03 12:02:54.000000000 +1100
     4@@ -678,6 +678,16 @@
     5 
     6 
     7 #
     8+# ICU
     9+#
     10+AC_MSG_CHECKING([whether to build with ICU support])
     11+PGAC_ARG_BOOL(with, icu, no, [  --with-icu              build with ICU support],
     12+              [AC_DEFINE([USE_ICU], 1, [Define to build with ICU support. (--with-icu)])])
     13+AC_MSG_RESULT([$with_icu])
     14+AC_SUBST(with_icu)
     15+
     16+
     17+#
     18 # Readline
     19 #
     20 PGAC_ARG_BOOL(with, readline, yes,
     21@@ -936,6 +946,31 @@
     22   fi
     23 fi
     24 
     25+if test "$with_icu" = yes ; then
     26+  AC_CHECK_LIB(icui18n, ucol_open_48, [], [
     27+    AC_CHECK_LIB(icui18n, ucol_open_44, [], [
     28+       AC_CHECK_LIB(icui18n, ucol_open_43, [], [
     29+          AC_CHECK_LIB(icui18n, ucol_open_3_8, [], [
     30+             AC_CHECK_LIB(icui18n, ucol_open_3_6, [], [
     31+                AC_CHECK_LIB(icui18n, ucol_open_3_4, [], [AC_MSG_ERROR([library 'icui18n' is required for ICU])])
     32+             ])
     33+          ])
     34+       ])
     35+    ])
     36+  ])
     37+  AC_CHECK_LIB(icuuc, ucnv_fromUChars_48, [], [
     38+    AC_CHECK_LIB(icuuc, ucnv_fromUChars_44, [], [
     39+       AC_CHECK_LIB(icuuc, ucnv_fromUChars_43, [], [
     40+          AC_CHECK_LIB(icuuc, ucnv_fromUChars_3_8, [], [
     41+             AC_CHECK_LIB(icuuc, ucnv_fromUChars_3_6, [], [
     42+                AC_CHECK_LIB(icuuc, ucnv_fromUChars_3_4, [], [AC_MSG_ERROR([library 'icuuc' is required for ICU])])
     43+             ])
     44+          ])
     45+       ])
     46+    ])
     47+  ])
     48+fi
     49+
     50 if test "$with_pam" = yes ; then
     51   AC_CHECK_LIB(pam,    pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])])
     52 fi
     53@@ -1042,6 +1077,10 @@
     54   AC_CHECK_FUNCS([ERR_set_mark])
     55 fi
     56 
     57+if test "$with_icu" = yes ; then
     58+  AC_CHECK_HEADER(unicode/utypes.h, [], [AC_MSG_ERROR([header file <unicode/utypes.h> is required for ICU])])
     59+fi
     60+
     61 if test "$with_pam" = yes ; then
     62   AC_CHECK_HEADERS(security/pam_appl.h, [],
     63                    [AC_CHECK_HEADERS(pam/pam_appl.h, [],
     64diff -Naur postgresql-9.0.6-orig/src/backend/utils/adt/formatting.c postgresql-9.0.6/src/backend/utils/adt/formatting.c
     65--- src/backend/utils/adt/formatting.c  2012-02-03 11:56:34.000000000 +1100
     66+++ src/backend/utils/adt/formatting.c  2012-02-03 12:02:54.000000000 +1100
     67@@ -91,6 +91,12 @@
     68 #include "utils/numeric.h"
     69 #include "utils/pg_locale.h"
     70 
     71+#ifdef USE_ICU
     72+#include <unicode/utypes.h>   /* Basic ICU data types */
     73+#include <unicode/ucnv.h>     /* C   Converter API    */
     74+#include <unicode/ustring.h>
     75+#endif /* USE_ICU */
     76+
     77 /* ----------
     78  * Routines type
     79  * ----------
     80@@ -941,6 +947,12 @@
     81 } NUMProc;
     82 
     83 
     84+#ifdef USE_ICU
     85+static UConverter *conv = NULL;
     86+#define STACKBUFLEN            1024 / sizeof(UChar)
     87+#endif   /* USE_ICU */
     88+
     89+
     90 /* ----------
     91  * Functions
     92  * ----------
     93@@ -1477,6 +1489,83 @@
     94        if (!buff)
     95                return NULL;
     96 
     97+#ifdef USE_ICU
     98+       /* use ICU only when max encoding length > one */
     99+       if (pg_database_encoding_max_length() > 1)
     100+       {
     101+               UChar       sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN];
     102+               UChar      *source, *dest;
     103+               int                     buflen;
     104+               size_t          result_size, usize;
     105+               UErrorCode  status = U_ZERO_ERROR;
     106+
     107+               if (conv == NULL)
     108+               {
     109+                       conv = ucnv_open(NULL, &status);
     110+                       if (U_FAILURE(status))
     111+                       {
     112+                               ereport(ERROR,
     113+                                               (errcode(status),
     114+                                                errmsg("ICU error: oracle_compat.c, could not get converter for \"%s\"", ucnv_getDefaultName())));
     115+                       }
     116+               }
     117+
     118+               if (nbytes >= STACKBUFLEN / sizeof(UChar))
     119+               {
     120+                       buflen = (nbytes + 1) * sizeof(UChar);
     121+                       source = palloc(buflen);
     122+                       dest = palloc(buflen);
     123+               }
     124+               else
     125+               {
     126+                       buflen = STACKBUFLEN;
     127+                       source = sourcebuf;
     128+                       dest = destbuf;
     129+               }
     130+               // convert to UTF-16
     131+               ucnv_toUChars(conv, source, buflen, buff, nbytes, &status);
     132+               if (U_FAILURE(status))
     133+               {
     134+                       ereport(ERROR,
     135+                                               (errcode(status),
     136+                                                errmsg("ICU error: Could not convert string")));
     137+               }
     138+               
     139+               // run desired function
     140+               buflen = u_strToLower(dest, buflen, source, -1, NULL, &status);
     141+               if (U_FAILURE(status))
     142+               {
     143+                       ereport(ERROR,
     144+                                               (errcode(status),
     145+                                                errmsg("ICU error: Could not modify case")));
     146+               }
     147+
     148+               // and convert modified utf-16 string back to text
     149+               result_size = UCNV_GET_MAX_BYTES_FOR_STRING(buflen, ucnv_getMaxCharSize(conv));
     150+               result = palloc(result_size);
     151+
     152+               usize = ucnv_fromUChars(conv, result, result_size,
     153+                                                                dest, buflen, &status);
     154+
     155+               if (U_FAILURE(status))
     156+               {
     157+                       /* Invalid multibyte character encountered ... shouldn't happen */
     158+                       ereport(ERROR,
     159+                                       (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
     160+                                        errmsg("ICU: invalid multibyte character for locale")));
     161+               }
     162+
     163+               Assert(usize <= (size_t) (buflen * sizeof(UChar)));
     164+
     165+               if (nbytes >= STACKBUFLEN / sizeof(UChar))
     166+               {
     167+                       pfree(source);
     168+                       pfree(dest);
     169+               }
     170+               return result;
     171+       }
     172+       else
     173+#else
     174 #ifdef USE_WIDE_UPPER_LOWER
     175        if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
     176        {
     177@@ -1507,6 +1596,7 @@
     178        }
     179        else
     180 #endif   /* USE_WIDE_UPPER_LOWER */
     181+#endif   /* USE_ICU */
     182        {
     183                char       *p;
     184 
     185@@ -1533,6 +1623,83 @@
     186        if (!buff)
     187                return NULL;
     188 
     189+#ifdef USE_ICU
     190+       /* use ICU only when max encoding length > one */
     191+       if (pg_database_encoding_max_length() > 1)
     192+       {
     193+               UChar       sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN];
     194+               UChar      *source, *dest;
     195+               int                     buflen;
     196+               size_t          result_size, usize;
     197+               UErrorCode  status = U_ZERO_ERROR;
     198+
     199+               if (conv == NULL)
     200+               {
     201+                       conv = ucnv_open(NULL, &status);
     202+                       if (U_FAILURE(status))
     203+                       {
     204+                               ereport(ERROR,
     205+                                               (errcode(status),
     206+                                                errmsg("ICU error: oracle_compat.c, could not get converter for \"%s\"", ucnv_getDefaultName())));
     207+                       }
     208+               }
     209+
     210+               if (nbytes >= STACKBUFLEN / sizeof(UChar))
     211+               {
     212+                       buflen = (nbytes + 1) * sizeof(UChar);
     213+                       source = palloc(buflen);
     214+                       dest = palloc(buflen);
     215+               }
     216+               else
     217+               {
     218+                       buflen = STACKBUFLEN;
     219+                       source = sourcebuf;
     220+                       dest = destbuf;
     221+               }
     222+               // convert to UTF-16
     223+               ucnv_toUChars(conv, source, buflen, buff, nbytes, &status);
     224+               if (U_FAILURE(status))
     225+               {
     226+                       ereport(ERROR,
     227+                                               (errcode(status),
     228+                                                errmsg("ICU error: Could not convert string")));
     229+               }
     230+               
     231+               // run desired function
     232+               buflen = u_strToUpper(dest, buflen, source, -1, NULL, &status);
     233+               if (U_FAILURE(status))
     234+               {
     235+                       ereport(ERROR,
     236+                                               (errcode(status),
     237+                                                errmsg("ICU error: Could not modify case")));
     238+               }
     239+
     240+               // and convert modified utf-16 string back to text
     241+               result_size = UCNV_GET_MAX_BYTES_FOR_STRING(buflen, ucnv_getMaxCharSize(conv));
     242+               result = palloc(result_size);
     243+
     244+               usize = ucnv_fromUChars(conv, result, result_size,
     245+                                                                dest, buflen, &status);
     246+
     247+               if (U_FAILURE(status))
     248+               {
     249+                       /* Invalid multibyte character encountered ... shouldn't happen */
     250+                       ereport(ERROR,
     251+                                       (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
     252+                                        errmsg("ICU: invalid multibyte character for locale")));
     253+               }
     254+
     255+               Assert(usize <= (size_t) (buflen * sizeof(UChar)));
     256+
     257+               if (nbytes >= STACKBUFLEN / sizeof(UChar))
     258+               {
     259+                       pfree(source);
     260+                       pfree(dest);
     261+               }
     262+               return result;
     263+       }
     264+       else
     265+#else
     266 #ifdef USE_WIDE_UPPER_LOWER
     267        if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
     268        {
     269@@ -1563,6 +1730,7 @@
     270        }
     271        else
     272 #endif   /* USE_WIDE_UPPER_LOWER */
     273+#endif /* USE_ICU */
     274        {
     275                char       *p;
     276 
     277@@ -1590,6 +1758,83 @@
     278        if (!buff)
     279                return NULL;
     280 
     281+#ifdef USE_ICU
     282+       /* use ICU only when max encoding length > one */
     283+       if (pg_database_encoding_max_length() > 1)
     284+       {
     285+               UChar       sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN];
     286+               UChar      *source, *dest;
     287+               int                     buflen;
     288+               size_t          result_size, usize;
     289+               UErrorCode  status = U_ZERO_ERROR;
     290+
     291+               if (conv == NULL)
     292+               {
     293+                       conv = ucnv_open(NULL, &status);
     294+                       if (U_FAILURE(status))
     295+                       {
     296+                               ereport(ERROR,
     297+                                               (errcode(status),
     298+                                                errmsg("ICU error: oracle_compat.c, could not get converter for \"%s\"", ucnv_getDefaultName())));
     299+                       }
     300+               }
     301+
     302+               if (nbytes >= STACKBUFLEN / sizeof(UChar))
     303+               {
     304+                       buflen = (nbytes + 1) * sizeof(UChar);
     305+                       source = palloc(buflen);
     306+                       dest = palloc(buflen);
     307+               }
     308+               else
     309+               {
     310+                       buflen = STACKBUFLEN;
     311+                       source = sourcebuf;
     312+                       dest = destbuf;
     313+               }
     314+               // convert to UTF-16
     315+               ucnv_toUChars(conv, source, buflen, buff, nbytes, &status);
     316+               if (U_FAILURE(status))
     317+               {
     318+                       ereport(ERROR,
     319+                                               (errcode(status),
     320+                                                errmsg("ICU error: Could not convert string")));
     321+               }
     322+               
     323+               // run desired function
     324+               buflen = u_strToTitle(dest, buflen, source, -1, NULL, NULL, &status);
     325+               if (U_FAILURE(status))
     326+               {
     327+                       ereport(ERROR,
     328+                                               (errcode(status),
     329+                                                errmsg("ICU error: Could not modify case")));
     330+               }
     331+
     332+               // and convert modified utf-16 string back to text
     333+               result_size = UCNV_GET_MAX_BYTES_FOR_STRING(buflen, ucnv_getMaxCharSize(conv));
     334+               result = palloc(result_size);
     335+
     336+               usize = ucnv_fromUChars(conv, result, result_size,
     337+                                                                dest, buflen, &status);
     338+
     339+               if (U_FAILURE(status))
     340+               {
     341+                       /* Invalid multibyte character encountered ... shouldn't happen */
     342+                       ereport(ERROR,
     343+                                       (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE),
     344+                                        errmsg("ICU: invalid multibyte character for locale")));
     345+               }
     346+
     347+               Assert(usize <= (size_t) (buflen * sizeof(UChar)));
     348+
     349+               if (nbytes >= STACKBUFLEN / sizeof(UChar))
     350+               {
     351+                       pfree(source);
     352+                       pfree(dest);
     353+               }
     354+               return result;
     355+       }
     356+       else
     357+#else
     358 #ifdef USE_WIDE_UPPER_LOWER
     359        if (pg_database_encoding_max_length() > 1 && !lc_ctype_is_c())
     360        {
     361@@ -1626,6 +1871,7 @@
     362        }
     363        else
     364 #endif   /* USE_WIDE_UPPER_LOWER */
     365+#endif /* USE_ICU */
     366        {
     367                char       *p;
     368 
     369diff -Naur postgresql-9.0.6-orig/src/backend/utils/adt/varlena.c postgresql-9.0.6/src/backend/utils/adt/varlena.c
     370--- src/backend/utils/adt/varlena.c     2012-02-03 11:56:34.000000000 +1100
     371+++ src/backend/utils/adt/varlena.c     2012-02-03 12:02:54.000000000 +1100
     372@@ -28,6 +28,15 @@
     373 #include "utils/lsyscache.h"
     374 #include "utils/pg_locale.h"
     375 
     376+#ifdef USE_ICU
     377+#include <unicode/utypes.h>   /* Basic ICU data types */
     378+#include <unicode/ucnv.h>     /* C   Converter API    */
     379+#include <unicode/ucol.h>
     380+#include <unicode/uloc.h>
     381+#include "unicode/uiter.h"
     382+#define USTACKBUFLEN           STACKBUFLEN / sizeof(UChar)
     383+#endif /* USE_ICU */
     384+
     385 
     386 /* GUC variable */
     387 int                    bytea_output = BYTEA_OUTPUT_HEX;
     388@@ -1287,6 +1296,134 @@
     389        {
     390 #define STACKBUFLEN            1024
     391 
     392+#ifdef USE_ICU
     393+
     394+               if (pg_database_encoding_max_length() > 1)
     395+               {
     396+                       static UCollator * collator = NULL;
     397+                       UErrorCode  status = U_ZERO_ERROR;
     398+
     399+                       /* We keep a static collator "forever", since it is hard
     400+                        * coded into the database cluster at initdb time
     401+                        * anyway. Create it first time we get here. */
     402+                       if (collator == NULL)
     403+                       {
     404+                               /* Expect LC_COLLATE to be set to something that ICU
     405+                                * will understand. This is quite probable, since ICU
     406+                                * does a lot of heuristics with this argument. I'd
     407+                                * rather set this in xlog.c, but it seems ICU forgets
     408+                                * it??? */
     409+                               uloc_setDefault(setlocale(LC_COLLATE, NULL), &status);
     410+                               if(U_FAILURE(status))
     411+                               {
     412+                                       ereport(WARNING,
     413+                                                       (errcode(status),
     414+                                                        errmsg("ICU Error: varlena.c, could not set default lc_collate")));
     415+                               }
     416+                               collator = ucol_open(NULL, &status);
     417+                               if (U_FAILURE(status))
     418+                               {
     419+                                       ereport(WARNING,
     420+                                                       (errcode(status),
     421+                                                        errmsg("ICU Error: varlena.c, could not open collator")));
     422+                               }
     423+                       }
     424+                       
     425+                       if (GetDatabaseEncoding() == PG_UTF8)
     426+                       {
     427+                               UCharIterator sIter, tIter;
     428+                               uiter_setUTF8(&sIter, arg1, len1);
     429+                               uiter_setUTF8(&tIter, arg2, len2);
     430+                               result = ucol_strcollIter(collator, &sIter, &tIter, &status);
     431+                               if (U_FAILURE(status))
     432+                               {
     433+                                       ereport(WARNING,
     434+                                                       (errcode(status),
     435+                                                        errmsg("ICU Error: varlena.c, could not collate")));
     436+                               }
     437+                       }
     438+                       else {
     439+                               /* We keep a static converter "forever".
     440+                                * Create it first time we get here. */
     441+                               static UConverter * conv = NULL;
     442+                               if (conv == NULL)
     443+                               {
     444+                                       conv = ucnv_open(NULL, &status);
     445+                                       if (U_FAILURE(status) || conv == NULL)
     446+                                       {
     447+                                               ereport(ERROR,
     448+                                                               (errcode(status),
     449+                                                                errmsg("ICU error: varlena.c, could not get converter for \"%s\"", ucnv_getDefaultName())));
     450+                                       }
     451+                               }
     452+
     453+                               UChar   a1buf[USTACKBUFLEN],
     454+                                               a2buf[USTACKBUFLEN];
     455+                               int             a1len = USTACKBUFLEN,
     456+                                               a2len = USTACKBUFLEN;   
     457+                               UChar   *a1p,
     458+                                               *a2p;
     459+                               if (len1 >= USTACKBUFLEN / sizeof(UChar))
     460+                               {
     461+                                       a1len = (len1 + 1) * sizeof(UChar);
     462+                                       a1p = (UChar *) palloc(a1len); 
     463+                               }
     464+                               else
     465+                                       a1p = a1buf;
     466+
     467+                               if (len2 >= USTACKBUFLEN / sizeof(UChar))
     468+                               {
     469+                                       a2len = (len2 + 1) * sizeof(UChar);
     470+                                       a2p = (UChar *) palloc(a2len);
     471+                               }
     472+                               else
     473+                                       a2p = a2buf;
     474+
     475+                               ucnv_toUChars(conv, a1p, a1len, arg1, len1, &status);
     476+                               if(U_FAILURE(status))
     477+                               {
     478+                                       ereport(WARNING,
     479+                                                       (errcode(status),
     480+                                                        errmsg("ICU Error: varlena.c, could not convert to UChars")));
     481+                               }
     482+                               ucnv_toUChars(conv, a2p, a2len, arg2, len2, &status);
     483+                               if(U_FAILURE(status))
     484+                               {
     485+                                       ereport(WARNING,
     486+                                                       (errcode(status),
     487+                                                        errmsg("ICU Error: varlena.c, could not convert to UChars")));
     488+                               }
     489+
     490+                               result = ucol_strcoll(collator, a1p, -1, a2p, -1);
     491+                               if(U_FAILURE(status))
     492+                               {
     493+                                       ereport(WARNING,
     494+                                                       (errcode(status),
     495+                                                        errmsg("ICU Error: varlena.c, could not collate")));
     496+                               }
     497+                               if (len1 * sizeof(UChar) >= USTACKBUFLEN)
     498+                                       pfree(a1p);
     499+                               if (len2 * sizeof(UChar) >= USTACKBUFLEN)
     500+                                       pfree(a2p);
     501+                       }
     502+                       /*
     503+                        * In some locales wcscoll() can claim that nonidentical strings
     504+                        * are equal.  Believing that this might be so also for ICU, and
     505+                        * believing that would be bad news for a number of
     506+                        * reasons, we follow Perl's lead and sort "equal" strings
     507+                        * according to strcmp (on the byte representation).
     508+                        */
     509+                       if (result == 0)
     510+                       {
     511+                               result = strncmp(arg1, arg2, Min(len1, len2));
     512+                               if ((result == 0) && (len1 != len2))
     513+                                       result = (len1 < len2) ? -1 : 1;
     514+                       }
     515+
     516+                       return result;
     517+               }
     518+#endif /* USE_ICU */
     519+
     520                char            a1buf[STACKBUFLEN];
     521                char            a2buf[STACKBUFLEN];
     522                char       *a1p,
     523diff -Naur postgresql-9.0.6-orig/src/backend/utils/mb/encnames.c postgresql-9.0.6/src/backend/utils/mb/encnames.c
     524--- src/backend/utils/mb/encnames.c     2012-02-03 11:56:34.000000000 +1100
     525+++ src/backend/utils/mb/encnames.c     2012-02-03 12:02:54.000000000 +1100
     526@@ -394,6 +394,118 @@
     527 };
     528 
     529 
     530+#ifdef USE_ICU
     531+/*
     532+ * Try to map most internal character encodings to the proper and
     533+ * preferred IANA string. Use this in mbutils.c to feed ICU info about
     534+ * the database's character encoding.
     535+ *
     536+ * Palle Girgensohn, 2005
     537+ */
     538+
     539+pg_enc2name pg_enc2iananame_tbl[] =
     540+{
     541+       {
     542+               "US-ASCII", PG_SQL_ASCII
     543+       },
     544+       {
     545+               "EUC-JP", PG_EUC_JP
     546+       },
     547+       {
     548+               "GB2312", PG_EUC_CN
     549+       },
     550+       {
     551+               "EUC-KR", PG_EUC_KR
     552+       },
     553+       {
     554+               "ISO-2022-CN", PG_EUC_TW
     555+       },
     556+       {
     557+               "KS_C_5601-1987", PG_JOHAB  /* either KS_C_5601-1987 or ISO-2022-KR ??? */
     558+       },
     559+       {
     560+               "UTF-8", PG_UTF8
     561+       },
     562+       {
     563+               "MULE_INTERNAL", PG_MULE_INTERNAL  /* is not for real */
     564+       },
     565+       {
     566+               "ISO-8859-1", PG_LATIN1
     567+       },
     568+       {
     569+               "ISO-8859-2", PG_LATIN2
     570+       },
     571+       {
     572+               "ISO-8859-3", PG_LATIN3
     573+       },
     574+       {
     575+               "ISO-8859-4", PG_LATIN4
     576+       },
     577+       {
     578+               "ISO-8859-9", PG_LATIN5
     579+       },
     580+       {
     581+               "ISO-8859-10", PG_LATIN6
     582+       },
     583+       {
     584+               "ISO-8859-13", PG_LATIN7
     585+       },
     586+       {
     587+               "ISO-8859-14", PG_LATIN8
     588+       },
     589+       {
     590+               "ISO-8859-15", PG_LATIN9
     591+       },
     592+       {
     593+               "ISO-8859-16", PG_LATIN10
     594+       },
     595+       {
     596+               "windows-1256", PG_WIN1256
     597+       },
     598+       {
     599+               "windows-874", PG_WIN874
     600+       },
     601+       {
     602+               "KOI8-R", PG_KOI8R
     603+       },
     604+       {
     605+               "windows-1251", PG_WIN1251
     606+       },
     607+       {
     608+               "ISO-8859-5", PG_ISO_8859_5
     609+       },
     610+       {
     611+               "ISO-8859-6", PG_ISO_8859_6
     612+       },
     613+       {
     614+               "ISO-8859-7", PG_ISO_8859_7
     615+       },
     616+       {
     617+               "ISO-8859-8", PG_ISO_8859_8
     618+       },
     619+       {
     620+               "windows-1250", PG_WIN1250
     621+       },
     622+       {
     623+               "Shift_JIS", PG_SJIS
     624+       },
     625+       {
     626+               "Big5", PG_BIG5
     627+       },
     628+       {
     629+               "GBK", PG_GBK
     630+       },
     631+       {
     632+               "cp949", PG_UHC
     633+       },
     634+       {
     635+               "GB18030", PG_GB18030
     636+       }
     637+};
     638+#endif /* USE_ICU */
     639+
     640+
     641+
     642 /* ----------
     643  * Encoding checks, for error returns -1 else encoding id
     644  * ----------
     645diff -Naur postgresql-9.0.6-orig/src/backend/utils/mb/mbutils.c postgresql-9.0.6/src/backend/utils/mb/mbutils.c
     646--- src/backend/utils/mb/mbutils.c      2012-02-03 11:56:34.000000000 +1100
     647+++ src/backend/utils/mb/mbutils.c      2012-02-03 12:02:54.000000000 +1100
     648@@ -15,6 +15,9 @@
     649 #include "utils/memutils.h"
     650 #include "utils/pg_locale.h"
     651 #include "utils/syscache.h"
     652+#ifdef USE_ICU
     653+#include <unicode/ucnv.h>
     654+#endif /* USE_ICU */
     655 
     656 /*
     657  * When converting strings between different encodings, we assume that space
     658@@ -908,6 +911,9 @@
     659 
     660        DatabaseEncoding = &pg_enc2name_tbl[encoding];
     661        Assert(DatabaseEncoding->encoding == encoding);
     662+#ifdef USE_ICU
     663+       ucnv_setDefaultName((&pg_enc2iananame_tbl[encoding])->name);
     664+#endif
     665 }
     666 
     667 /*
     668diff -Naur postgresql-9.0.6-orig/src/include/mb/pg_wchar.h postgresql-9.0.6/src/include/mb/pg_wchar.h
     669--- src/include/mb/pg_wchar.h   2012-02-03 11:56:34.000000000 +1100
     670+++ src/include/mb/pg_wchar.h   2012-02-03 12:02:54.000000000 +1100
     671@@ -263,6 +263,9 @@
     672 } pg_enc2name;
     673 
     674 extern pg_enc2name pg_enc2name_tbl[];
     675+#ifdef USE_ICU
     676+extern pg_enc2name pg_enc2iananame_tbl[];
     677+#endif
     678 
     679 /*
     680  * Encoding names for gettext
     681diff -Naur postgresql-9.0.6-orig/src/include/pg_config.h.in postgresql-9.0.6/src/include/pg_config.h.in
     682--- src/include/pg_config.h.in  2012-02-03 11:56:34.000000000 +1100
     683+++ src/include/pg_config.h.in  2012-02-03 12:02:54.000000000 +1100
     684@@ -290,6 +290,12 @@
     685 /* Define to 1 if you have the `eay32' library (-leay32). */
     686 #undef HAVE_LIBEAY32
     687 
     688+/* Define to 1 if you have the `icui18n' library (-licui18n). */
     689+#undef HAVE_LIBICUI18N
     690+
     691+/* Define to 1 if you have the `icuuc' library (-licuuc). */
     692+#undef HAVE_LIBICUUC
     693+
     694 /* Define to 1 if you have the `ldap' library (-lldap). */
     695 #undef HAVE_LIBLDAP
     696 
     697@@ -747,6 +753,9 @@
     698 /* Define to 1 to build with Bonjour support. (--with-bonjour) */
     699 #undef USE_BONJOUR
     700 
     701+/* Define to build with ICU support. (--with-icu) */
     702+#undef USE_ICU
     703+
     704 /* Define to 1 if you want float4 values to be passed by value.
     705    (--enable-float4-byval) */
     706 #undef USE_FLOAT4_BYVAL