Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16910e4

Browse files
committed
Next version of patch.
Now with documentation update and disabling of UTF conversion for Tcl <=8.0On Fri, 24 Aug 2001, Vsevolod Lobko wrote:> On Thu, 23 Aug 2001, Tom Lane wrote:>> > > Is this looks better?> >> > It does, but one small gripe: the lack of semicolons will probably cause> > pg_indent to mess up the indentation. (I know emacs' autoindent mode> > will not work nicely with it, either.) Please set up the macros so that> > you write> >> > UTF_BEGIN;> > Tcl_DStringAppend(&unknown_src, UTF_E2U(part), -1);> > UTF_END;> >> > and then I'll be happy.>> Attached revised patch>> > Your point about overhead is a good one, so I retract the gripe about> > using a configure switch. But please include documentation patches to> > describe the configure option in the administrator's guide (installation> > section).>> This patch still uses configure switch for enabling feature.>> For enabling based on tcl version we have 2 posibilites:> 1) having feature enabled by default, but in pltcl.c check for tcl> version and disable it for old versions> 2) enable or disable at configure time based on tcl version, but there> are problem - current configure don't checks for tcl version at all> and my configure skills not enought for adding this>Vsevolod Lobko
1 parent37c0b64 commit16910e4

File tree

4 files changed

+77
-14
lines changed

4 files changed

+77
-14
lines changed

‎configure.in

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,21 @@ AC_MSG_RESULT([$enable_pltcl_unknown])
409409
AC_SUBST([enable_pltcl_unknown])
410410

411411

412+
#
413+
# If Tcl is enabled (above) then check for pltcl_utf
414+
#
415+
AC_MSG_CHECKING([whether to build with PL/Tcl with UTF support])
416+
if test "$with_tcl" = yes; then
417+
PGAC_ARG_BOOL(enable, pltcl-utf, no,
418+
[ --enable-pltcl-utf build PL/Tcl UTF support (if Tcl is enabled)],
419+
[AC_DEFINE([ENABLE_PLTCL_UTF])])
420+
else
421+
enable_pltcl_utf=no
422+
fi
423+
AC_MSG_RESULT([$enable_pltcl_utf])
424+
AC_SUBST([enable_pltcl_utf])
425+
426+
412427
#
413428
# Optionally build Perl modules (Pg.pm and PL/Perl)
414429
#

‎doc/src/sgml/installation.sgml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.51 2001/08/28 14:20:24 petere Exp $ -->
1+
<!-- $Header: /cvsroot/pgsql/doc/src/sgml/installation.sgml,v 1.52 2001/09/06 02:56:32 momjian Exp $ -->
22

33
<chapter id="installation">
44
<title><![%flattext-install-include[<productname>PostgreSQL</>]]>
@@ -683,6 +683,17 @@ su - postgres
683683
</listitem>
684684
</varlistentry>
685685

686+
<varlistentry>
687+
<term>--enable-pltcl-utf</term>
688+
<listitem>
689+
<para>
690+
Enables enables PL/Tcl Tcl_UtfToExternal and Tcl_ExternalToUtf
691+
conversion support. These functions needed for Tcl versions 8.1
692+
and above for proper handling of 8-bit characters.
693+
</para>
694+
</listitem>
695+
</varlistentry>
696+
686697
<varlistentry>
687698
<term>--enable-odbc</term>
688699
<listitem>

‎src/include/pg_config.h.in

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
99
* changes will be overwritten the next time you run configure.
1010
*
11-
* $Id: pg_config.h.in,v 1.1 2001/08/24 14:07:49 petere Exp $
11+
* $Id: pg_config.h.in,v 1.2 2001/09/06 02:56:32 momjian Exp $
1212
*/
1313

1414
#ifndefPG_CONFIG_H
@@ -84,6 +84,9 @@
8484
/* --enable-pltcl-unknown */
8585
#undef ENABLE_PLTCL_UNKNOWN
8686

87+
/* --enable-pltcl-utf */
88+
#undef ENABLE_PLTCL_UTF
89+
8790
/* --enable-nls */
8891
#undef ENABLE_NLS
8992

‎src/pl/tcl/pltcl.c

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
* ENHANCEMENTS, OR MODIFICATIONS.
3232
*
3333
* IDENTIFICATION
34-
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.38 2001/08/02 15:45:55 momjian Exp $
34+
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.39 2001/09/06 02:56:32 momjian Exp $
3535
*
3636
**********************************************************************/
3737

@@ -59,6 +59,18 @@
5959
#include"catalog/pg_language.h"
6060
#include"catalog/pg_type.h"
6161

62+
#if defined(ENABLE_PLTCL_UTF)&&TCL_MAJOR_VERSION==8 \
63+
&&TCL_MINOR_VERSION>0
64+
#defineUTF_BEGINdo { Tcl_DString _pltcl_ds_tmp
65+
# defineUTF_ENDTcl_DStringFree(&_pltcl_ds_tmp); } while (0)
66+
# defineUTF_U2E(x)(Tcl_UtfToExternalDString(NULL,(x),-1,&_pltcl_ds_tmp))
67+
#defineUTF_E2U(x)(Tcl_ExternalToUtfDString(NULL,(x),-1,&_pltcl_ds_tmp))
68+
#else/* ENABLE_PLTCL_UTF */
69+
#defineUTF_BEGIN
70+
#defineUTF_END
71+
#defineUTF_U2E(x)(x)
72+
#defineUTF_E2U(x)(x)
73+
#endif/* ENABLE_PLTCL_UTF */
6274

6375
/**********************************************************************
6476
* The information we cache about loaded procedures
@@ -333,7 +345,9 @@ pltcl_init_load_unknown(Tcl_Interp *interp)
333345
SPI_tuptable->tupdesc,fno);
334346
if (part!=NULL)
335347
{
336-
Tcl_DStringAppend(&unknown_src,part,-1);
348+
UTF_BEGIN;
349+
Tcl_DStringAppend(&unknown_src,UTF_E2U(part),-1);
350+
UTF_END;
337351
pfree(part);
338352
}
339353
}
@@ -613,7 +627,9 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
613627
}
614628
proc_source=DatumGetCString(DirectFunctionCall1(textout,
615629
PointerGetDatum(&procStruct->prosrc)));
616-
Tcl_DStringAppend(&proc_internal_body,proc_source,-1);
630+
UTF_BEGIN;
631+
Tcl_DStringAppend(&proc_internal_body,UTF_E2U(proc_source),-1);
632+
UTF_END;
617633
pfree(proc_source);
618634
Tcl_DStringAppendElement(&proc_internal_def,
619635
Tcl_DStringValue(&proc_internal_body));
@@ -715,7 +731,9 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
715731
fcinfo->arg[i],
716732
ObjectIdGetDatum(prodesc->arg_out_elem[i]),
717733
Int32GetDatum(prodesc->arg_out_len[i])));
718-
Tcl_DStringAppendElement(&tcl_cmd,tmp);
734+
UTF_BEGIN;
735+
Tcl_DStringAppendElement(&tcl_cmd,UTF_E2U(tmp));
736+
UTF_END;
719737
pfree(tmp);
720738
}
721739
}
@@ -777,13 +795,15 @@ pltcl_func_handler(PG_FUNCTION_ARGS)
777795
if (SPI_finish()!=SPI_OK_FINISH)
778796
elog(ERROR,"pltcl: SPI_finish() failed");
779797

798+
UTF_BEGIN;
780799
if (fcinfo->isnull)
781800
retval= (Datum)0;
782801
else
783802
retval=FunctionCall3(&prodesc->result_in_func,
784-
PointerGetDatum(interp->result),
803+
PointerGetDatum(UTF_U2E(interp->result)),
785804
ObjectIdGetDatum(prodesc->result_in_elem),
786805
Int32GetDatum(-1));
806+
UTF_END;
787807

788808
/************************************************************
789809
* Finally we may restore normal error handling.
@@ -929,7 +949,9 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
929949

930950
proc_source=DatumGetCString(DirectFunctionCall1(textout,
931951
PointerGetDatum(&procStruct->prosrc)));
932-
Tcl_DStringAppend(&proc_internal_body,proc_source,-1);
952+
UTF_BEGIN;
953+
Tcl_DStringAppend(&proc_internal_body,UTF_E2U(proc_source),-1);
954+
UTF_END;
933955
pfree(proc_source);
934956
Tcl_DStringAppendElement(&proc_internal_def,
935957
Tcl_DStringValue(&proc_internal_body));
@@ -1230,11 +1252,13 @@ pltcl_trigger_handler(PG_FUNCTION_ARGS)
12301252
************************************************************/
12311253
modnulls[attnum-1]=' ';
12321254
fmgr_info(typinput,&finfo);
1255+
UTF_BEGIN;
12331256
modvalues[attnum-1]=
12341257
FunctionCall3(&finfo,
1235-
CStringGetDatum(ret_values[i++]),
1258+
CStringGetDatum(UTF_U2E(ret_values[i++])),
12361259
ObjectIdGetDatum(typelem),
12371260
Int32GetDatum(tupdesc->attrs[attnum-1]->atttypmod));
1261+
UTF_END;
12381262
}
12391263

12401264
rettup=SPI_modifytuple(trigdata->tg_relation,rettup,tupdesc->natts,
@@ -1558,7 +1582,9 @@ pltcl_SPI_exec(ClientData cdata, Tcl_Interp *interp,
15581582
/************************************************************
15591583
* Execute the query and handle return codes
15601584
************************************************************/
1561-
spi_rc=SPI_exec(argv[query_idx],count);
1585+
UTF_BEGIN;
1586+
spi_rc=SPI_exec(UTF_U2E(argv[query_idx]),count);
1587+
UTF_END;
15621588
memcpy(&Warn_restart,&save_restart,sizeof(Warn_restart));
15631589

15641590
switch (spi_rc)
@@ -1794,7 +1820,9 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
17941820
/************************************************************
17951821
* Prepare the plan and check for errors
17961822
************************************************************/
1797-
plan=SPI_prepare(argv[1],nargs,qdesc->argtypes);
1823+
UTF_BEGIN;
1824+
plan=SPI_prepare(UTF_U2E(argv[1]),nargs,qdesc->argtypes);
1825+
UTF_END;
17981826

17991827
if (plan==NULL)
18001828
{
@@ -2078,11 +2106,13 @@ pltcl_SPI_execp(ClientData cdata, Tcl_Interp *interp,
20782106
************************************************************/
20792107
for (j=0;j<callnargs;j++)
20802108
{
2109+
UTF_BEGIN;
20812110
qdesc->argvalues[j]=
20822111
FunctionCall3(&qdesc->arginfuncs[j],
2083-
CStringGetDatum(callargs[j]),
2112+
CStringGetDatum(UTF_U2E(callargs[j])),
20842113
ObjectIdGetDatum(qdesc->argtypelems[j]),
20852114
Int32GetDatum(qdesc->arglen[j]));
2115+
UTF_END;
20862116
}
20872117

20882118
/************************************************************
@@ -2377,7 +2407,9 @@ pltcl_set_tuple_values(Tcl_Interp *interp, char *arrayname,
23772407
attr,
23782408
ObjectIdGetDatum(typelem),
23792409
Int32GetDatum(tupdesc->attrs[i]->attlen)));
2380-
Tcl_SetVar2(interp,*arrptr,*nameptr,outputstr,0);
2410+
UTF_BEGIN;
2411+
Tcl_SetVar2(interp,*arrptr,*nameptr,UTF_E2U(outputstr),0);
2412+
UTF_END;
23812413
pfree(outputstr);
23822414
}
23832415
else
@@ -2448,7 +2480,9 @@ pltcl_build_tuple_argument(HeapTuple tuple, TupleDesc tupdesc,
24482480
ObjectIdGetDatum(typelem),
24492481
Int32GetDatum(tupdesc->attrs[i]->attlen)));
24502482
Tcl_DStringAppendElement(retval,attname);
2451-
Tcl_DStringAppendElement(retval,outputstr);
2483+
UTF_BEGIN;
2484+
Tcl_DStringAppendElement(retval,UTF_E2U(outputstr));
2485+
UTF_END;
24522486
pfree(outputstr);
24532487
}
24542488
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp