Thread: BUG #8385: greek symbols as function name

BUG #8385: greek symbols as function name

From
kolmyk@hotmail.com
Date:
The following bug has been logged on the website:

Bug reference:      8385
Logged by:          Alessio
Email address:      kolmyk@hotmail.com
PostgreSQL version: 9.2.3
Operating system:   Windows 8
Description:

create or replace function α(β int, ξ int, μ float) returns float as $$
select (β + ξ) * μ $$ language sql;
select α(1, 2, 0.1);
-- it works
select ascii(proname), * from pg_proc where length(proname) = 1;
-- return code 60536 although select ascii('α') retruns 945
select * from pg_proc where proname = 'α';
-- returns nothing

Re: BUG #8385: greek symbols as function name

From
Kevin Grittner
Date:
"kolmyk@hotmail.com" <kolmyk@hotmail.com> wrote:=0A=0A> Operating system:=
=C2=A0 Windows 8=0A=0A> create or replace function =CE=B1(=CE=B2 int, =CE=
=BE int, =CE=BC float) returns float as $$=0A> select (=CE=B2 + =CE=BE) * =
=CE=BC $$ language sql;=0A> select =CE=B1(1, 2, 0.1);=0A> -- it works=0A> s=
elect ascii(proname), * from pg_proc where length(proname) =3D 1;=0A> -- re=
turn code 60536 although select ascii('=CE=B1') retruns 945=0A> select * fr=
om pg_proc where proname =3D '=CE=B1';=0A> -- returns nothing=0A=0AHere's w=
hat I get on Ubuntu 12.10.=C2=A0 The bug is likely to be=0AWindows-specific=
.=C2=A0 Whether it is a bug in Windows or in PostgreSQL=0Acharacter-handlin=
g under Windows I can say myself, since I haven't=0Ahad any reason to use W=
indows for years.=0A=0Atest=3D# create or replace function =CE=B1(=CE=B2 in=
t, =CE=BE int, =CE=BC float) returns float as $$=0Aselect (=CE=B2 + =CE=BE)=
 * =CE=BC $$ language sql;=0ACREATE FUNCTION=0Atest=3D# \df+=0A=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
 List of functions=0A=C2=A0Schema | Name | Result data type |=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Argument=
 data types=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 |=C2=A0 Type=C2=A0 | Security | Volatility |=C2=A0 Ow=
ner=C2=A0 | Language |=C2=A0=C2=A0=C2=A0=C2=A0 Source code=C2=A0=C2=A0=C2=
=A0=C2=A0 | Description=0A--------+------+------------------+--------------=
----------------------------------+--------+----------+------------+-------=
--+----------+---------------------+-------------=0A=C2=A0public | =CE=B1=
=C2=A0=C2=A0=C2=A0 | double precision | "=CE=B2" integer, "=CE=BE" integer,=
 "=CE=BC" double precision | normal | invoker=C2=A0 | volatile=C2=A0=C2=A0 =
| kgrittn | sql=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 +|=0A=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 | select (=CE=B2 + =CE=BE) * =CE=BC=C2=A0 |=0A(1 row)=0A=0Ates=
t=3D# select =CE=B1(1, 2, 0.1);=0A=C2=A0 =CE=B1 =C2=A0=0A-----=0A=C2=A00.3=
=0A(1 row)=0A=0Atest=3D# select ascii(proname), proname from pg_proc where =
length(proname) =3D 1;=0A=C2=A0ascii | proname=0A-------+---------=0A=C2=A0=
=C2=A0 945 | =CE=B1=0A(1 row)=0A=0Atest=3D# select ascii('=CE=B1');=0A=C2=
=A0ascii=0A-------=0A=C2=A0=C2=A0 945=0A(1 row)=0A=0Atest=3D# select pronam=
e from pg_proc where proname =3D '=CE=B1';=0A=C2=A0proname=0A---------=0A=
=C2=A0=CE=B1=0A(1 row)=0A=0A--=0AKevin Grittner=0AEDB: http://www.enterpris=
edb.com=0AThe Enterprise PostgreSQL Company

Re: BUG #8385: greek symbols as function name

From
Kevin Grittner
Date:
Kevin Grittner <kgrittn@ymail.com> wrote:=0A=0A> Whether it is a bug in Win=
dows or in PostgreSQL character-=0A> handling under Windows I can say mysel=
f, since I haven't=0A> had any reason to use Windows for years.=0A=0AEr, th=
at should have been I *can't* say.=0A=0A>> create or replace function =CE=
=B1(=CE=B2 int, =CE=BE int, =CE=BC float) returns=0Afloat as $$=0A>> select=
 (=CE=B2 + =CE=BE) * =CE=BC $$ language sql;=0A>> select =CE=B1(1, 2, 0.1);=
=0A>> -- it works=0A>> select ascii(proname), * from pg_proc where length(p=
roname) =3D 1;=0A>> -- return code 60536 although select ascii('=CE=B1') re=
truns 945=0A>> select * from pg_proc where proname =3D '=CE=B1';=0A>> -- re=
turns nothing=0A=0AIt occurs to me that the behavior you are seeing would b=
e=0Aconsistent with 945 being considered an uppercase letter, with=0A60536 =
being considered its lowercase form.=C2=A0 Normal PostgreSQL=0Acase-folding=
 of identifiers would then cause exactly the symptoms=0Ayou are seeing.=C2=
=A0 You could test this theory by quoting its use as=0Aan identifier:=0A=0A=
create or replace function "=CE=B1"(=CE=B2 int, =CE=BE int, =CE=BC float) r=
eturns float=0Aas $$=0A=C2=A0 select (=CE=B2 + =CE=BE) * =CE=BC $$ language=
 sql;=0Aselect "=CE=B1"(1, 2, 0.1);=0Aselect ascii(proname), * from pg_proc=
 where length(proname) =3D 1;=0Aselect * from pg_proc where proname =3D '=
=CE=B1';=0A=0AIf that behaves correctly, you need to sort out what about yo=
ur=0Aenvironment is causing the odd case-folding.=0A=0A--=0AKevin Grittner=
=0AEDB: http://www.enterprisedb.com=0AThe Enterprise PostgreSQL Company

Re: BUG #8385: greek symbols as function name

From
Tom Lane
Date:
Kevin Grittner <kgrittn@ymail.com> writes:
> It occurs to me that the behavior you are seeing would be
> consistent with 945 being considered an uppercase letter, with
> 60536 being considered its lowercase form.  Normal PostgreSQL
> case-folding of identifiers would then cause exactly the symptoms
> you are seeing.

Hmm ... identifier case-folding isn't really supposed to do anything to
multibyte characters.  I wonder if this isn't a variant of the issue
recently fixed in commit d535136b5d60b19f7ffa777b97ed301739c15a9d.

            regards, tom lane

Re: BUG #8385: greek symbols as function name

From
Kevin Grittner
Date:
Tom Lane <tgl@sss.pgh.pa.us> wrote:=0A> Kevin Grittner <kgrittn@ymail.com> =
writes:=0A>> It occurs to me that the behavior you are seeing would be=0A>>=
 consistent with 945 being considered an uppercase letter, with=0A>> 60536 =
being considered its lowercase form.=A0 Normal PostgreSQL=0A>> case-folding=
 of identifiers would then cause exactly the symptoms=0A>> you are seeing.=
=0A>=0A> Hmm ... identifier case-folding isn't really supposed to do anythi=
ng to=0A> multibyte characters.=A0 I wonder if this isn't a variant of the =
issue=0A> recently fixed in commit d535136b5d60b19f7ffa777b97ed301739c15a9d=
.=0A=0AMaybe.=A0 I notice that if you interpret the first byte as a Unicode=
=0Acode point (as opposed to the first byte of a UTF-8 encoded=0Acharacter)=
, it is an uppercase letter.=A0 But I can't quite see how=0Athat gets to th=
e decimal 60536 value.=A0 Also, going to a commit=0Aprior to the referenced=
 fix I still don't see any problem on my=0Amachine.=A0 That doesn't rule ou=
t a platform-specific manifestation=0Aof the issue, though.=0A=0A--=0AKevin=
 Grittner=0AEDB: http://www.enterprisedb.com=0AThe Enterprise PostgreSQL Co=
mpany