Re: pltcl bug in 7.2? - Mailing list pgsql-general

From Yury Don
Subject Re: pltcl bug in 7.2?
Date
Msg-id 11514697604.20020420001554@vpcit.ru
Whole thread Raw
In response to Re: pltcl bug in 7.2?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hello Tom,

Friday, April 19, 2002, 8:32:16 PM, you wrote:

TL> Yury Don <yura@vpcit.ru> writes:
>> Hello All,
>> We have a database with koi8-r encoding, tables and fields names
>> mostly in russian, and we have a trigger function on pltcl. With postgresql 7.1 everything
>> worked well, but in 7.2 we are getting an error "utf_to_local: could
>> not convert UTF-8" in the following construction
>> foreach field [array names NEW] {
>>   if {[info exists OLD(${field})]} ....

TL> Hmm.  Someone added code in 7.2 to support conversion between the
TL> database's encoding (whatever you specified with -E) and the UTF-8
TL> encoding that Tcl wants to use all the time.  Sounds like you've
TL> found a bug in that code.

>> Also this error occures in any calling of NEW or OLD, for example
>> [array get NEW] also raises those error.

TL> Do you see it *only* in references to NEW/OLD?  Can you pass the
TL> same data in normal parameters to a Tcl function?

TL>                         regards, tom lane

I can see this error only in trigger functions when I call NEW or OLD
and trigger table has a fields with names containing cyrillic characters.
Any other variables, parameters, with cyrillic characters don't raise
this error. For example following code works well (relname contains cyrillic characters):

spi_exec "SELECT relname FROM pg_class WHERE oid=$TG_relid"
elog DEBUG "$relname"

This code also works without errors:
CREATE or replace FUNCTION tmp1(text) RETURNS text AS '
  return $1
}
' LANGUAGE 'pltcl';
select tmp1('<here some text with cyrillic characters>');

But the following code raises an error "utf_to_local: could not convert
UTF-8" (trigger table has a fields with names containing cyrillic characters)

CREATE or replace FUNCTION log_event() RETURNS opaque AS '
  foreach field [array names NEW] {
    elog DEBUG "field=$field"
  }
return OK
}
' LANGUAGE 'pltcl';

And in postgresql.log I see strings
field=<field name>
for fields whose names consist of only latin characters and string
field=
for fields whose names include cyrillic characters

Postgres 7.2.1 on Debian Linux, compiled with --enable-multibyte,
--enable-unicode-conversion, --enable-locale. Tcl version 8.3.

--
Best regards,
 Yury                            mailto:yura@vpcit.ru


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Disabling libpq clients stderr output from backend
Next
From: webmaster
Date:
Subject: creating table w/ php help