OSDN Git Service

> > > > > - PostgreSQL requires to be compiled with --enable-multibyte
authorBruce Momjian <bruce@momjian.us>
Mon, 1 Oct 2001 15:33:31 +0000 (15:33 +0000)
committerBruce Momjian <bruce@momjian.us>
Mon, 1 Oct 2001 15:33:31 +0000 (15:33 +0000)
> > > > >   and --enable-unicode-convertion if it ought to work correctly
> > > > >   with Tcl/Tk >= 8.1 (client or server side).
> > > > >
> > > > > - PL/Tcl needs to be changed to use pg_do_encoding_conversion
> > > > >   if it runs on a Tcl version >= 8.1 .
> > >
> > > > I'll do pl/tcl part in the next version of patch. Using this approach we
> > > > can eliminate overhead for databases in UNICODE.
> > >
> > > Any progress on this?  I'd prefer to get rid of this --enable-pltcl-utf
> > > option before release.
> >
> > Done
> >
> > Next version removes --enable-pltcl-utf switch and enables embedded
> > utf conversion of pgsql if tcl version >=8.1 and --enable-unicode-conversion

configure.in
doc/src/sgml/installation.sgml
src/include/pg_config.h.in
src/pl/tcl/pltcl.c

index 7dc5af0..9ecee9b 100644 (file)
@@ -397,21 +397,6 @@ AC_SUBST([enable_pltcl_unknown])
 
 
 #
-# If Tcl is enabled (above) then check for pltcl_utf
-#
-AC_MSG_CHECKING([whether to build with PL/Tcl with UTF support])
-if test "$with_tcl" = yes; then
-  PGAC_ARG_BOOL(enable, pltcl-utf, no,
-                [  --enable-pltcl-utf      build PL/Tcl UTF support (if Tcl is enabled)],
-                [AC_DEFINE([ENABLE_PLTCL_UTF])])
-else
-  enable_pltcl_utf=no
-fi
-AC_MSG_RESULT([$enable_pltcl_utf])
-AC_SUBST([enable_pltcl_utf])
-
-
-#
 # Optionally build Perl modules (Pg.pm and PL/Perl)
 #
 AC_MSG_CHECKING([whether to build Perl modules])
index a2804e7..7801595 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.58 2001/09/21 23:20:02 petere Exp $ -->
+<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.59 2001/10/01 15:33:21 momjian Exp $ -->
 
 <chapter id="installation">
  <title><![%standalone-include[<productname>PostgreSQL</>]]>
@@ -692,17 +692,6 @@ su - postgres
       </varlistentry>
 
       <varlistentry>
-       <term><option>--enable-pltcl-utf</option></term>
-       <listitem>
-        <para>
-         Enables enables PL/Tcl <function>Tcl_UtfToExternal</> and <function>Tcl_ExternalToUtf</>
-         conversion support. These functions needed for Tcl versions 8.1
-         and above for proper handling of 8-bit characters.
-        </para>
-       </listitem>
-      </varlistentry>
-
-      <varlistentry>
        <term><option>--enable-odbc</option></term>
        <listitem>
         <para>
index c8bee9b..8c3f457 100644 (file)
@@ -8,7 +8,7 @@
  * or in pg_config.h afterwards.  Of course, if you edit pg_config.h, then your
  * changes will be overwritten the next time you run configure.
  *
- * $Id: pg_config.h.in,v 1.7 2001/09/22 22:54:32 petere Exp $
+ * $Id: pg_config.h.in,v 1.8 2001/10/01 15:33:31 momjian Exp $
  */
 
 #ifndef PG_CONFIG_H
@@ -89,9 +89,6 @@
 /* --enable-pltcl-unknown */
 #undef ENABLE_PLTCL_UNKNOWN
 
-/* --enable-pltcl-utf */
-#undef ENABLE_PLTCL_UTF
-
 /* --enable-nls */
 #undef ENABLE_NLS
 
index 8e686ed..5800320 100644 (file)
@@ -31,7 +31,7 @@
  *       ENHANCEMENTS, OR MODIFICATIONS.
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.39 2001/09/06 02:56:32 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.40 2001/10/01 15:33:31 momjian Exp $
  *
  **********************************************************************/
 
 #include "catalog/pg_language.h"
 #include "catalog/pg_type.h"
 
-#if defined(ENABLE_PLTCL_UTF) && TCL_MAJOR_VERSION == 8 \
+#if defined(UNICODE_CONVERSION) && TCL_MAJOR_VERSION == 8 \
        && TCL_MINOR_VERSION > 0
-#      define UTF_BEGIN        do { Tcl_DString _pltcl_ds_tmp
-#       define UTF_END         Tcl_DStringFree(&_pltcl_ds_tmp); } while (0)
-#       define UTF_U2E(x)      (Tcl_UtfToExternalDString(NULL,(x),-1,&_pltcl_ds_tmp))
-#      define UTF_E2U(x)       (Tcl_ExternalToUtfDString(NULL,(x),-1,&_pltcl_ds_tmp))
-#else /* ENABLE_PLTCL_UTF */
+
+#include "mb/pg_wchar.h"
+
+static pg_enconv *tcl_enconv;
+
+static unsigned char *
+utf_u2e(unsigned char *src) {
+       return pg_do_encoding_conversion(src,strlen(src),
+               NULL,tcl_enconv->from_unicode);
+}
+
+static unsigned char *
+utf_e2u(unsigned char *src) {
+       return pg_do_encoding_conversion(src,strlen(src),
+               tcl_enconv->to_unicode,NULL);
+}
+
+#      define PLTCL_UTF
+#      define UTF_BEGIN        do { \
+                                       unsigned char *_pltcl_utf_src; \
+                                       unsigned char *_pltcl_utf_dst
+#       define UTF_END         if (_pltcl_utf_src!=_pltcl_utf_dst) \
+                                       pfree(_pltcl_utf_dst); } while (0)
+#       define UTF_U2E(x)      (_pltcl_utf_dst=utf_u2e(_pltcl_utf_src=(x)))
+#       define UTF_E2U(x)      (_pltcl_utf_dst=utf_e2u(_pltcl_utf_src=(x)))
+#else /* PLTCL_UTF */
 #      define  UTF_BEGIN
 #      define  UTF_END
 #      define  UTF_U2E(x)      (x)
 #      define  UTF_E2U(x)      (x)
-#endif /* ENABLE_PLTCL_UTF */
+#endif /* PLTCL_UTF */
 
 /**********************************************************************
  * The information we cache about loaded procedures
@@ -197,6 +218,14 @@ pltcl_init_all(void)
        if (!pltcl_firstcall)
                return;
 
+#ifdef PLTCL_UTF
+       /************************************************************
+        * Do unicode conversion initialization
+        ************************************************************/
+
+       tcl_enconv=pg_get_enconv_by_encoding(GetDatabaseEncoding());
+#endif
+
        /************************************************************
         * Create the dummy hold interpreter to prevent close of
         * stdout and stderr on DeleteInterp