From: | RISKO Gergely <risko(at)atom(dot)hu> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | funny (cache (?)) bug in postgres (7.x tested) |
Date: | 2001-06-28 19:39:18 |
Message-ID: | 20010628213918.A18977@atom.hu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello!
I found a funny bug in postgres with c functions. (or feature??)
Let's say we have got an function like this:
CREATE FUNCTION hupper(text)
RETURNS text
AS '/fun.so'
LANGUAGE 'c';
and fun.c:
#include <postgresql/postgres.h>
#include <postgresql/utils/elog.h>
#include <postgresql/libpq/libpq-fs.h>
text *hupper (text *a) {
int hossz,i;
hossz=a->vl_len;
for (i=0;i<hossz;i++)
{
char ch;
ch=a->vl_dat[i];
if ((ch>=97)&(ch<=122)) ch=ch-32;
else if (ch=='á') ch='Á';
else if (ch=='é') ch='É';
else if (ch=='í') ch='Í';
else if (ch=='ó') ch='Ó';
else if (ch=='õ') ch='Õ';
else if (ch=='ö') ch='Ö';
else if (ch=='ú') ch='Ú';
else if (ch=='û') ch='Û';
else if (ch=='ü') ch='Ü';
a->vl_dat[i]=ch;
}
return a;
}
We use this to make hungarian upper (=Hupper).
And two select:
gergo=> select mire from mamapenz;
mire
-------
betet
ebed
ebed
ebed
ebed
ebed
(6 rows)
gergo=> select hupper(mire) from mamapenz;
hupper
--------
BETET
EBED
EBED
EBED
EBED
EBED
(6 rows)
this is good, and now:
gergo=> select mire from mamapenz;
^^^^^^^^^^^^^^^^^^^^^
mire
-------
BETET
EBED
EBED
EBED
EBED
EBED
(6 rows)
After once hupper run on the table it will be upper case even I don't use hupper.
It can be fixed with a postgres restart or with 10-20 minutes of waiting.
If this is documented, sorry (but please point out where).
Thanks,
RISKO Gergely
From | Date | Subject | |
---|---|---|---|
Next Message | Mike Cianflone | 2001-06-29 01:16:58 | Order of triggers |
Previous Message | Alex Pilosov | 2001-06-28 17:24:32 | Re: functions returning records |