Lists: | pgsql-general |
---|
From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | lower function |
Date: | 2005-04-06 16:52:18 |
Message-ID: | 425413C2.5020000@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Hello,
I have a database with encoding latin2, ctype hu_HU, posgresql 8.0.1.
Keyword split is a plperl function:
create or replace function keywords_split(text) returns text as $$
my $text = lc $_[0];
return $text;
$$
language plperl;
My problem is:
$ psql teszt;
Welcome to psql 8.0.1, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
teszt=# select lower('úéöÖÉÁ');
lower
--------
úéööéá
(1 row)
teszt=# select keywords_split('AúéöÖÉÁ');
keywords_split
----------------
aúéöÖÉÁ
(1 row)
teszt=# select lower('úéöÖÉÁ');
lower
--------
úéöÖÉÁ
(1 row)
Mage
From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Mage" <mage(at)mage(dot)hu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 17:49:46 |
Message-ID: | 20050406194932.9625427@uruguay |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Mage wrote:
> teszt=# select keywords_split('AúéöÖÉÁ');
> keywords_split
> ----------------
> aúéöÖÉÁ
> (1 row)
What happens if you add
use locale;
in your perl function before calling lc ?
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | Daniel Verite <daniel(at)manitou-mail(dot)org>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 18:05:10 |
Message-ID: | 425424D6.8040305@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Daniel Verite wrote:
> Mage wrote:
>
>
>
>>teszt=# select keywords_split('AúéöÖÉÁ');
>> keywords_split
>>----------------
>> aúéöÖÉÁ
>>(1 row)
>>
>>
>
>What happens if you add
> use locale;
>in your perl function before calling lc ?
>
>
with use locale;:
select keywords_split('AúéöÖÉÁ');
ERROR: creation of Perl function failed: 'require' trapped by operation
mask at (eval 6) line 2.
Another problem:
create or replace function keywords_split(text) returns text as $$
my $res = spi_exec_query("select lower('" . $_[0] . "')");
my $text = 'test' . $res->{rows}[0]->{lower};
return $text;
$$
language plperl;
# select keywords_split('AúéöÖÉÁ');
keywords_split
----------------
testaúéöÖÉÁ
(1 row)
The spi_exec_query with lower also don't work.
I have found another bug in a plperl trigger which I can't reproduce. I
find plperl a bit buggy.
Mage
From: | "Daniel Verite" <daniel(at)manitou-mail(dot)org> |
---|---|
To: | "Mage" <mage(at)mage(dot)hu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 18:25:45 |
Message-ID: | 20050406202531.7955747@uruguay |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Mage wrote:
> with use locale;:
>
> select keywords_split('AúéöÖÉÁ');
> ERROR: creation of Perl function failed: 'require' trapped by operation
> mask at (eval 6) line 2.
Ah. So maybe it would work with plperlu instead of plperl.
--
Daniel
PostgreSQL-powered mail user agent and storage: http://www.manitou-mail.org
From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 19:27:35 |
Message-ID: | 42543827.5020708@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Daniel Verite wrote:
> Mage wrote:
>
>
>
>>with use locale;:
>>
>>select keywords_split('AúéöÖÉÁ');
>>ERROR: creation of Perl function failed: 'require' trapped by operation
>>mask at (eval 6) line 2.
>>
>>
>
>Ah. So maybe it would work with plperlu instead of plperl.
>
>
I did, and it didn't help.
Mage
From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 19:44:43 |
Message-ID: | 42543C2B.2080005@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
It's serious.
teszt=# select lower('AúéöÖÉÁ');
lower
---------
aúéööéá
(1 row)
teszt=# create or replace function keywords_split(text) returns text as $$
teszt$# return '';
teszt$# $$
teszt-# language plperlu;
CREATE FUNCTION
teszt=# select keywords_split('');
keywords_split
----------------
(1 row)
teszt=# select lower('AúéöÖÉÁ');
lower
---------
aúéöÖÉÁ
(1 row)
Mage
From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Mage <mage(at)mage(dot)hu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 20:40:28 |
Message-ID: | 5927.1112820028@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Mage <mage(at)mage(dot)hu> writes:
> It's serious.
That's a Perl bug not a Postgres bug: libperl should not change the
process's locale settings, or at least if it does it should restore
the prior settings before returning. It doesn't.
regards, tom lane
From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 22:26:10 |
Message-ID: | 42546202.3010109@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Tom Lane wrote:
>Mage <mage(at)mage(dot)hu> writes:
>
>
>>It's serious.
>>
>>
>
>That's a Perl bug not a Postgres bug: libperl should not change the
>process's locale settings, or at least if it does it should restore
>the prior settings before returning. It doesn't.
>
>
>
I checked with show all, client and server encoding remained latin2, and
lc_ctype remained hu_HU. However, the lower function got corrupted
(encoding) until the end of the session.
I can reproduce the bug on an Debian Sarge and on a Gentoo. Both are
up-to-date.
What should I do? Subscribe to perl list and tell about this? I have to
write a trigger which can't be written well in plpgsql. My options are
to learn python or tcl on basic level in one day. I am not sure I want
and can do this.
Mage
From: | Scott Marlowe <smarlowe(at)g2switchworks(dot)com> |
---|---|
To: | Mage <mage(at)mage(dot)hu> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-06 22:37:34 |
Message-ID: | 1112827054.20921.52.camel@state.g2switchworks.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
On Wed, 2005-04-06 at 17:26, Mage wrote:
> Tom Lane wrote:
>
> >Mage <mage(at)mage(dot)hu> writes:
> >
> >
> >>It's serious.
> >>
> >>
> >
> >That's a Perl bug not a Postgres bug: libperl should not change the
> >process's locale settings, or at least if it does it should restore
> >the prior settings before returning. It doesn't.
> >
> >
> >
> I checked with show all, client and server encoding remained latin2, and
> lc_ctype remained hu_HU. However, the lower function got corrupted
> (encoding) until the end of the session.
>
> I can reproduce the bug on an Debian Sarge and on a Gentoo. Both are
> up-to-date.
>
> What should I do? Subscribe to perl list and tell about this? I have to
> write a trigger which can't be written well in plpgsql. My options are
> to learn python or tcl on basic level in one day. I am not sure I want
> and can do this.
You're far more likely to learn tcl or python or php in an afternoon
than to get a patched perl executable in that time.
But I'd still report the bug to them.
From: | Mage <mage(at)mage(dot)hu> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: lower function |
Date: | 2005-04-07 12:42:09 |
Message-ID: | 42552AA1.4090503@mage.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Scott Marlowe wrote:
>
>You're far more likely to learn tcl or python or php in an afternoon
>than to get a patched perl executable in that time.
>
>But I'd still report the bug to them.
>
>
create or replace function keywords_split(text) returns text as $$
use locale;
use POSIX qw(locale_h);
setlocale(LC_CTYPE,'hu_HU');
return '';
$$
language plperlu;
It works. And it's so nasty. I have to insert these into every plperl
function.
I am not subscribed to any perl list. Would someone report this bug?
Mage