? pgsql/.project ? pgsql/autom4te.cache ? pgsql/d.diff ? pgsql/dd.diff ? pgsql/ddd.diff ? pgsql/src/backend/utils/adt/varlena.orig.c Index: pgsql/configure.in =================================================================== RCS file: /projects/cvsroot/pgsql/configure.in,v retrieving revision 1.546.2.3 diff -u -r1.546.2.3 configure.in --- pgsql/configure.in 14 Mar 2008 03:23:22 -0000 1.546.2.3 +++ pgsql/configure.in 17 Mar 2008 15:22:53 -0000 @@ -19,7 +19,7 @@ AC_INIT([PostgreSQL], [8.3.1], [pgsql-bugs@postgresql.org]) -m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.59], [], [m4_fatal([Autoconf version 2.59 is required. +m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.61], [], [m4_fatal([Autoconf version 2.61 is required. Untested combinations of 'autoconf' and PostgreSQL versions are not recommended. You can remove the check from 'configure.in' but it is then your responsibility whether the result works or not.])]) @@ -547,6 +547,14 @@ AC_MSG_RESULT([$with_openssl]) AC_SUBST(with_openssl) +# +# ICU +# +AC_MSG_CHECKING([whether to build with ICU support]) +PGAC_ARG_BOOL(with, icu, no, [ --with-icu build with ICU support], + [AC_DEFINE([USE_ICU], 1, [Define to build with ICU support. (--with-icu)])]) +AC_MSG_RESULT([$with_icu]) +AC_SUBST(with_icu) # # Readline @@ -786,6 +794,19 @@ fi fi +if test "$with_icu" = yes ; then + AC_CHECK_LIB(icui18n, ucol_open_3_8, [], [ + AC_CHECK_LIB(icui18n, ucol_open_3_6, [], [ + AC_CHECK_LIB(icui18n, ucol_open_3_4, [], [AC_MSG_ERROR([library 'icui18n' is required for ICU])]) + ]) + ]) + AC_CHECK_LIB(icuuc, ucnv_fromUChars_3_8, [], [ + AC_CHECK_LIB(icuuc, ucnv_fromUChars_3_6, [], [ + AC_CHECK_LIB(icuuc, ucnv_fromUChars_3_4, [], [AC_MSG_ERROR([library 'icuuc' is required for ICU])]) + ]) + ]) +fi + if test "$with_pam" = yes ; then AC_CHECK_LIB(pam, pam_start, [], [AC_MSG_ERROR([library 'pam' is required for PAM])]) fi @@ -883,6 +904,10 @@ AC_CHECK_FUNCS([ERR_set_mark]) fi +if test "$with_icu" = yes ; then + AC_CHECK_HEADER(unicode/utypes.h, [], [AC_MSG_ERROR([header file is required for ICU])]) +fi + if test "$with_pam" = yes ; then AC_CHECK_HEADERS(security/pam_appl.h, [], [AC_CHECK_HEADERS(pam/pam_appl.h, [], Index: pgsql/src/backend/utils/adt/oracle_compat.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v retrieving revision 1.77 diff -u -r1.77 oracle_compat.c --- pgsql/src/backend/utils/adt/oracle_compat.c 1 Jan 2008 19:45:52 -0000 1.77 +++ pgsql/src/backend/utils/adt/oracle_compat.c 17 Mar 2008 15:22:54 -0000 @@ -32,6 +32,11 @@ #include "utils/pg_locale.h" #include "mb/pg_wchar.h" +#ifdef USE_ICU +#include /* Basic ICU data types */ +#include /* C Converter API */ +#include +#endif /* USE_ICU */ /* * If the system provides the needed functions for wide-character manipulation @@ -55,6 +60,48 @@ bool doltrim, bool dortrim); +#ifdef USE_ICU +static UConverter *conv = NULL; + +static text * +UChartotext(const UChar *str, int ncodes) +{ + text *result; + size_t nbytes, resultsize; + + UErrorCode status = U_ZERO_ERROR; + + /* Overflow paranoia */ + if (ncodes < 0 || + ncodes > (int) ((INT_MAX - VARHDRSZ) / sizeof(UChar)) - 1) + ereport(ERROR, + (errcode(ERRCODE_OUT_OF_MEMORY), + errmsg("ICU: out of memory"))); + + /* Make workspace large enough for result */ + resultsize = UCNV_GET_MAX_BYTES_FOR_STRING(ncodes, ucnv_getMaxCharSize(conv)); + result = (text *) palloc(resultsize + VARHDRSZ); + + nbytes = ucnv_fromUChars(conv, VARDATA(result), resultsize, + str, ncodes, &status); + + if (U_FAILURE(status)) + { + /* Invalid multibyte character encountered ... shouldn't happen */ + ereport(ERROR, + (errcode(ERRCODE_CHARACTER_NOT_IN_REPERTOIRE), + errmsg("ICU: invalid multibyte character for locale"))); + } + + Assert(nbytes <= (size_t) (ncodes * sizeof(UChar))); + + SET_VARSIZE(result, nbytes + VARHDRSZ); + + return result; +} + + +#else #ifdef USE_WIDE_UPPER_LOWER /* @@ -149,7 +196,7 @@ return result; } #endif /* USE_WIDE_UPPER_LOWER */ - +#endif /* USE_ICU */ /* * On Windows, the "Unicode" locales assume UTF16 not UTF8 encoding. @@ -262,6 +309,169 @@ #define wcstotext win32_wcstotext #endif /* WIN32 */ + +#ifdef USE_ICU +#define STACKBUFLEN 1024 / sizeof(UChar) +char * +wstring_upper(char *str) +{ + text *in_text, *out_text; + char *result; + UChar sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN]; + UChar *source, *dest; + int buflen, arglen, + nbytes = strlen(str); + UErrorCode status = U_ZERO_ERROR; + + if (conv == NULL) + { + conv = ucnv_open(NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: oracle_compat.c, could not get converter for \"%s\"", ucnv_getDefaultName()))); + } + } + + in_text = palloc(nbytes + VARHDRSZ); + memcpy(VARDATA(in_text), str, nbytes); + SET_VARSIZE(in_text, nbytes + VARHDRSZ); + + arglen = VARSIZE(in_text) - VARHDRSZ; + + if (arglen >= STACKBUFLEN / sizeof(UChar)) + { + buflen = (nbytes + 1) * sizeof(UChar); + source = palloc(buflen); + dest = palloc(buflen); + } + else + { + buflen = STACKBUFLEN; + source = sourcebuf; + dest = destbuf; + } + + // convert to UTF-16 + ucnv_toUChars(conv, source, buflen, VARDATA(in_text), nbytes, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not convert string"))); + } + + // run desired function + buflen = u_strToUpper(dest, buflen, source, -1, NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not modify case"))); + } + + // and convert modified utf-16 string back to text + out_text = UChartotext(dest, buflen); + + if (arglen >= STACKBUFLEN / sizeof(UChar)) + { + pfree(source); + pfree(dest); + } + + nbytes = VARSIZE(out_text) - VARHDRSZ; + result = palloc(nbytes + 1); + memcpy(result, VARDATA(out_text), nbytes); + + result[nbytes] = '\0'; + + pfree(in_text); + pfree(out_text); + + return result; +} + +char * +wstring_lower(char *str) +{ + text *in_text, *out_text; + char *result; + UChar sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN]; + UChar *source, *dest; + int buflen, arglen, + nbytes = strlen(str); + UErrorCode status = U_ZERO_ERROR; + + if (conv == NULL) + { + conv = ucnv_open(NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: oracle_compat.c, could not get converter for \"%s\"", ucnv_getDefaultName()))); + } + } + + in_text = palloc(nbytes + VARHDRSZ); + memcpy(VARDATA(in_text), str, nbytes); + SET_VARSIZE(in_text, nbytes + VARHDRSZ); + + arglen = VARSIZE(in_text) - VARHDRSZ; + + if (arglen >= STACKBUFLEN / sizeof(UChar)) + { + buflen = (nbytes + 1) * sizeof(UChar); + source = palloc(buflen); + dest = palloc(buflen); + } + else + { + buflen = STACKBUFLEN; + source = sourcebuf; + dest = destbuf; + } + + // convert to UTF-16 + ucnv_toUChars(conv, source, buflen, VARDATA(in_text), nbytes, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not convert string"))); + } + + // run desired function + buflen = u_strToLower(dest, buflen, source, -1, NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not modify case"))); + } + + // and convert modified utf-16 string back to text + out_text = UChartotext(dest, buflen); + + if (arglen >= STACKBUFLEN / sizeof(UChar)) + { + pfree(source); + pfree(dest); + } + + nbytes = VARSIZE(out_text) - VARHDRSZ; + result = palloc(nbytes + 1); + memcpy(result, VARDATA(out_text), nbytes); + + result[nbytes] = '\0'; + + pfree(in_text); + pfree(out_text); + + return result; +} +#else /* USE_ICU */ #ifdef USE_WIDE_UPPER_LOWER /* * string_upper and string_lower are used for correct multibyte upper/lower @@ -336,6 +546,7 @@ return result; } #endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_ICU */ /******************************************************************** * @@ -354,6 +565,71 @@ Datum lower(PG_FUNCTION_ARGS) { +#ifdef USE_ICU + /* use ICU only when max encoding length > one */ + if (pg_database_encoding_max_length() > 1) + { + text *string = PG_GETARG_TEXT_P(0); + text *result; + UChar sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN]; + UChar *source, *dest; + int buflen, + arglen = VARSIZE(string) - VARHDRSZ; + UErrorCode status = U_ZERO_ERROR; + + if (conv == NULL) + { + conv = ucnv_open(NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: oracle_compat.c, could not get converter for \"%s\"", ucnv_getDefaultName()))); + } + } + + if (arglen >= STACKBUFLEN / sizeof(UChar)) + { + buflen = (arglen + 1) * sizeof(UChar); + source = palloc(buflen); + dest = palloc(buflen); + } + else + { + buflen = STACKBUFLEN; + source = sourcebuf; + dest = destbuf; + } + // convert to UTF-16 + ucnv_toUChars(conv, source, buflen, VARDATA(string), arglen, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not convert string"))); + } + + // run desired function + buflen = u_strToLower(dest, buflen, source, -1, NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not modify case"))); + } + + // and convert modified utf-16 string back to text + result = UChartotext(dest, buflen); + + if (arglen >= STACKBUFLEN / sizeof(UChar)) + { + pfree(source); + pfree(dest); + } + PG_RETURN_TEXT_P(result); + } + else +#else #ifdef USE_WIDE_UPPER_LOWER /* @@ -381,6 +657,7 @@ } else #endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_ICU */ { text *string = PG_GETARG_TEXT_P_COPY(0); char *ptr; @@ -420,6 +697,71 @@ Datum upper(PG_FUNCTION_ARGS) { +#ifdef USE_ICU + /* use ICU only when max encoding length > one */ + if (pg_database_encoding_max_length() > 1) + { + text *string = PG_GETARG_TEXT_P(0); + text *result; + UChar sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN]; + UChar *source, *dest; + int32_t buflen, arglen; + + UErrorCode status = U_ZERO_ERROR; + + if (conv == NULL) + { + conv = ucnv_open(NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not get converter for \"%s\"", ucnv_getDefaultName()))); + } + } + arglen = VARSIZE(string) - VARHDRSZ; + if (arglen * sizeof(UChar) >= STACKBUFLEN) + { + buflen = (arglen + 1) * sizeof(UChar); + source = palloc(buflen); + dest = palloc(buflen); + } + else + { + buflen = STACKBUFLEN; + source = sourcebuf; + dest = destbuf; + } + // convert to UTF-16 + ucnv_toUChars(conv, source, buflen, VARDATA(string), arglen, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not convert string"))); + } + + // run desired function + buflen = u_strToUpper(dest, buflen, source, -1, NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not modify case"))); + } + + // and convert modified utf-16 string back to text + result = UChartotext(dest, buflen); + + if (arglen * sizeof(UChar) >= STACKBUFLEN) + { + pfree(source); + pfree(dest); + } + PG_RETURN_TEXT_P(result); + } + else +#else #ifdef USE_WIDE_UPPER_LOWER /* @@ -447,6 +789,7 @@ } else #endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_ICU */ { text *string = PG_GETARG_TEXT_P_COPY(0); char *ptr; @@ -489,6 +832,71 @@ Datum initcap(PG_FUNCTION_ARGS) { +#ifdef USE_ICU + /* use ICU only when max encoding length > one */ + if (pg_database_encoding_max_length() > 1) + { + text *string = PG_GETARG_TEXT_P(0); + text *result; + UChar sourcebuf[STACKBUFLEN], destbuf[STACKBUFLEN]; + UChar *source, *dest; + int32_t buflen, arglen; + + UErrorCode status = U_ZERO_ERROR; + + if (conv == NULL) + { + conv = ucnv_open(NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not get converter for \"%s\"", ucnv_getDefaultName()))); + } + } + arglen = VARSIZE(string) - VARHDRSZ; + if (arglen * sizeof(UChar) >= STACKBUFLEN) + { + buflen = (arglen + 1) * sizeof(UChar); + source = palloc(buflen); + dest = palloc(buflen); + } + else + { + buflen = STACKBUFLEN; + source = sourcebuf; + dest = destbuf; + } + // convert to UTF-16 + ucnv_toUChars(conv, source, buflen, VARDATA(string), arglen, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not convert string"))); + } + + // run desired function + buflen = u_strToTitle(dest, buflen, source, -1, NULL, NULL, &status); + if (U_FAILURE(status)) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: Could not modify case"))); + } + + // and convert modified utf-16 string back to text + result = UChartotext(dest, buflen); + + if (arglen * sizeof(UChar) >= STACKBUFLEN) + { + pfree(source); + pfree(dest); + } + PG_RETURN_TEXT_P(result); + } + else +#else #ifdef USE_WIDE_UPPER_LOWER /* @@ -523,6 +931,7 @@ } else #endif /* USE_WIDE_UPPER_LOWER */ +#endif /* USE_ICU */ { text *string = PG_GETARG_TEXT_P_COPY(0); int wasalnum = 0; Index: pgsql/src/backend/utils/adt/varlena.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/varlena.c,v retrieving revision 1.162.2.1 diff -u -r1.162.2.1 varlena.c --- pgsql/src/backend/utils/adt/varlena.c 13 Mar 2008 18:32:02 -0000 1.162.2.1 +++ pgsql/src/backend/utils/adt/varlena.c 17 Mar 2008 15:22:54 -0000 @@ -28,6 +28,14 @@ #include "utils/lsyscache.h" #include "utils/pg_locale.h" +#ifdef USE_ICU +#include /* Basic ICU data types */ +#include /* C Converter API */ +#include +#include +#include "unicode/uiter.h" +#define USTACKBUFLEN STACKBUFLEN / sizeof(UChar) +#endif /* USE_ICU */ typedef struct varlena unknown; @@ -935,6 +943,134 @@ { #define STACKBUFLEN 1024 +#ifdef USE_ICU + + if (pg_database_encoding_max_length() > 1) + { + static UCollator * collator = NULL; + UErrorCode status = U_ZERO_ERROR; + + /* We keep a static collator "forever", since it is hard + * coded into the database cluster at initdb time + * anyway. Create it first time we get here. */ + if (collator == NULL) + { + /* Expect LC_COLLATE to be set to something that ICU + * will understand. This is quite probable, since ICU + * does a lot of heuristics with this argument. I'd + * rather set this in xlog.c, but it seems ICU forgets + * it??? */ + uloc_setDefault(setlocale(LC_COLLATE, NULL), &status); + if(U_FAILURE(status)) + { + ereport(WARNING, + (errcode(status), + errmsg("ICU Error: varlena.c, could not set default lc_collate"))); + } + collator = ucol_open(NULL, &status); + if (U_FAILURE(status)) + { + ereport(WARNING, + (errcode(status), + errmsg("ICU Error: varlena.c, could not open collator"))); + } + } + + if (GetDatabaseEncoding() == PG_UTF8) + { + UCharIterator sIter, tIter; + uiter_setUTF8(&sIter, arg1, len1); + uiter_setUTF8(&tIter, arg2, len2); + result = ucol_strcollIter(collator, &sIter, &tIter, &status); + if (U_FAILURE(status)) + { + ereport(WARNING, + (errcode(status), + errmsg("ICU Error: varlena.c, could not collate"))); + } + } + else { + /* We keep a static converter "forever". + * Create it first time we get here. */ + static UConverter * conv = NULL; + if (conv == NULL) + { + conv = ucnv_open(NULL, &status); + if (U_FAILURE(status) || conv == NULL) + { + ereport(ERROR, + (errcode(status), + errmsg("ICU error: varlena.c, could not get converter for \"%s\"", ucnv_getDefaultName()))); + } + } + + UChar a1buf[USTACKBUFLEN], + a2buf[USTACKBUFLEN]; + int a1len = USTACKBUFLEN, + a2len = USTACKBUFLEN; + UChar *a1p, + *a2p; + if (len1 >= USTACKBUFLEN / sizeof(UChar)) + { + a1len = (len1 + 1) * sizeof(UChar); + a1p = (UChar *) palloc(a1len); + } + else + a1p = a1buf; + + if (len2 >= USTACKBUFLEN / sizeof(UChar)) + { + a2len = (len2 + 1) * sizeof(UChar); + a2p = (UChar *) palloc(a2len); + } + else + a2p = a2buf; + + ucnv_toUChars(conv, a1p, a1len, arg1, len1, &status); + if(U_FAILURE(status)) + { + ereport(WARNING, + (errcode(status), + errmsg("ICU Error: varlena.c, could not convert to UChars"))); + } + ucnv_toUChars(conv, a2p, a2len, arg2, len2, &status); + if(U_FAILURE(status)) + { + ereport(WARNING, + (errcode(status), + errmsg("ICU Error: varlena.c, could not convert to UChars"))); + } + + result = ucol_strcoll(collator, a1p, -1, a2p, -1); + if(U_FAILURE(status)) + { + ereport(WARNING, + (errcode(status), + errmsg("ICU Error: varlena.c, could not collate"))); + } + if (len1 * sizeof(UChar) >= USTACKBUFLEN) + pfree(a1p); + if (len2 * sizeof(UChar) >= USTACKBUFLEN) + pfree(a2p); + } + /* + * In some locales wcscoll() can claim that nonidentical strings + * are equal. Believing that this might be so also for ICU, and + * believing that would be bad news for a number of + * reasons, we follow Perl's lead and sort "equal" strings + * according to strcmp (on the byte representation). + */ + if (result == 0) + { + result = strncmp(arg1, arg2, Min(len1, len2)); + if ((result == 0) && (len1 != len2)) + result = (len1 < len2) ? -1 : 1; + } + + return result; + } +#endif /* USE_ICU */ + char a1buf[STACKBUFLEN]; char a2buf[STACKBUFLEN]; char *a1p, Index: pgsql/src/backend/utils/mb/encnames.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/mb/encnames.c,v retrieving revision 1.37 diff -u -r1.37 encnames.c --- pgsql/src/backend/utils/mb/encnames.c 15 Nov 2007 21:14:40 -0000 1.37 +++ pgsql/src/backend/utils/mb/encnames.c 17 Mar 2008 15:22:54 -0000 @@ -424,6 +424,118 @@ } }; +#ifdef USE_ICU +/* + * Try to map most internal character encodings to the proper and + * preferred IANA string. Use this in mbutils.c to feed ICU info about + * the database's character encoding. + * + * Palle Girgensohn, 2005 + */ + +pg_enc2name pg_enc2iananame_tbl[] = +{ + { + "US-ASCII", PG_SQL_ASCII + }, + { + "EUC-JP", PG_EUC_JP + }, + { + "GB2312", PG_EUC_CN + }, + { + "EUC-KR", PG_EUC_KR + }, + { + "ISO-2022-CN", PG_EUC_TW + }, + { + "KS_C_5601-1987", PG_JOHAB /* either KS_C_5601-1987 or ISO-2022-KR ??? */ + }, + { + "UTF-8", PG_UTF8 + }, + { + "MULE_INTERNAL", PG_MULE_INTERNAL /* is not for real */ + }, + { + "ISO-8859-1", PG_LATIN1 + }, + { + "ISO-8859-2", PG_LATIN2 + }, + { + "ISO-8859-3", PG_LATIN3 + }, + { + "ISO-8859-4", PG_LATIN4 + }, + { + "ISO-8859-9", PG_LATIN5 + }, + { + "ISO-8859-10", PG_LATIN6 + }, + { + "ISO-8859-13", PG_LATIN7 + }, + { + "ISO-8859-14", PG_LATIN8 + }, + { + "ISO-8859-15", PG_LATIN9 + }, + { + "ISO-8859-16", PG_LATIN10 + }, + { + "windows-1256", PG_WIN1256 + }, + { + "windows-874", PG_WIN874 + }, + { + "KOI8-R", PG_KOI8R + }, + { + "windows-1251", PG_WIN1251 + }, + { + "ISO-8859-5", PG_ISO_8859_5 + }, + { + "ISO-8859-6", PG_ISO_8859_6 + }, + { + "ISO-8859-7", PG_ISO_8859_7 + }, + { + "ISO-8859-8", PG_ISO_8859_8 + }, + { + "windows-1250", PG_WIN1250 + }, + { + "Shift_JIS", PG_SJIS + }, + { + "Big5", PG_BIG5 + }, + { + "GBK", PG_GBK + }, + { + "cp949", PG_UHC + }, + { + "GB18030", PG_GB18030 + } +}; +#endif /* USE_ICU */ + + + /* ---------- * Encoding checks, for error returns -1 else encoding id * ---------- Index: pgsql/src/backend/utils/mb/mbutils.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/utils/mb/mbutils.c,v retrieving revision 1.69 diff -u -r1.69 mbutils.c --- pgsql/src/backend/utils/mb/mbutils.c 9 Jan 2008 23:43:54 -0000 1.69 +++ pgsql/src/backend/utils/mb/mbutils.c 17 Mar 2008 15:22:54 -0000 @@ -14,6 +14,9 @@ #include "utils/builtins.h" #include "utils/memutils.h" #include "utils/syscache.h" +#ifdef USE_ICU +#include +#endif /* USE_ICU */ /* * When converting strings between different encodings, we assume that space @@ -697,6 +700,9 @@ DatabaseEncoding = &pg_enc2name_tbl[encoding]; Assert(DatabaseEncoding->encoding == encoding); +#ifdef USE_ICU + ucnv_setDefaultName((&pg_enc2iananame_tbl[encoding])->name); +#endif } void Index: pgsql/src/include/pg_config.h.in =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/pg_config.h.in,v retrieving revision 1.127 diff -u -r1.127 pg_config.h.in --- pgsql/src/include/pg_config.h.in 24 Jan 2008 06:23:32 -0000 1.127 +++ pgsql/src/include/pg_config.h.in 17 Mar 2008 15:22:54 -0000 @@ -247,6 +247,12 @@ /* Define to 1 if you have the `eay32' library (-leay32). */ #undef HAVE_LIBEAY32 +/* Define to 1 if you have the `icui18n' library (-licui18n). */ +#undef HAVE_LIBICUI18N + +/* Define to 1 if you have the `icuuc' library (-licuuc). */ +#undef HAVE_LIBICUUC + /* Define to 1 if you have the `ldap' library (-lldap). */ #undef HAVE_LIBLDAP @@ -662,6 +668,9 @@ /* Define to 1 to build with Bonjour support. (--with-bonjour) */ #undef USE_BONJOUR +/* Define to build with ICU support. (--with-icu) */ +#undef USE_ICU + /* Define to 1 if you want 64-bit integer timestamp and interval support. (--enable-integer-datetimes) */ #undef USE_INTEGER_DATETIMES Index: pgsql/src/include/mb/pg_wchar.h =================================================================== RCS file: /projects/cvsroot/pgsql/src/include/mb/pg_wchar.h,v retrieving revision 1.78 diff -u -r1.78 pg_wchar.h --- pgsql/src/include/mb/pg_wchar.h 1 Jan 2008 19:45:58 -0000 1.78 +++ pgsql/src/include/mb/pg_wchar.h 17 Mar 2008 15:22:55 -0000 @@ -259,6 +259,9 @@ } pg_enc2name; extern pg_enc2name pg_enc2name_tbl[]; +#ifdef USE_ICU +extern pg_enc2name pg_enc2iananame_tbl[]; +#endif /* * pg_wchar stuff