Re: [BUGS] utf-8 flag always off in plperl function arguments

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Kamholz <davekam(at)pobox(dot)com>
Cc: pgsql-patches(at)postgreSQL(dot)org
Subject: Re: [BUGS] utf-8 flag always off in plperl function arguments
Date: 2004-12-05 20:22:07
Message-ID: 18458.1102278127@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

David Kamholz <davekam(at)pobox(dot)com> writes:
> *** plperl.c.orig Sat Dec 4 02:09:24 2004
> --- plperl.c Sat Dec 4 03:41:33 2004
> ***************
> *** 57,62 ****
> --- 57,63 ----
> #include "utils/lsyscache.h"
> #include "utils/syscache.h"
> #include "utils/typcache.h"
> + #include "mb/pg_wchar.h"

> /* perl stuff */
> #include "EXTERN.h"
> ***************
> *** 803,814 ****
> else
> {
> char *tmp;

> tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]),
> fcinfo->arg[i],
> ObjectIdGetDatum(desc->arg_typioparam[i]),
> Int32GetDatum(-1)));
> ! XPUSHs(sv_2mortal(newSVpv(tmp, 0)));
> pfree(tmp);
> }
> }
> --- 804,818 ----
> else
> {
> char *tmp;
> + SV *sv;

> tmp = DatumGetCString(FunctionCall3(&(desc->arg_out_func[i]),
> fcinfo->arg[i],
> ObjectIdGetDatum(desc->arg_typioparam[i]),
> Int32GetDatum(-1)));
> ! sv = newSVpv(tmp, 0);
> ! if (GetDatabaseEncoding() == PG_UTF8) SvUTF8_on(sv);
> ! XPUSHs(sv_2mortal(sv));
> pfree(tmp);
> }
> }
> ***************
> *** 1553,1558 ****
> --- 1557,1563 ----
> {
> int i;
> HV *hv;
> + SV *sv;
> Datum attr;
> bool isnull;
> char *attname;
> ***************
> *** 1601,1608 ****
> attr,
> ObjectIdGetDatum(typioparam),
> Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
> !
> ! hv_store(hv, attname, namelen, newSVpv(outputstr, 0), 0);
> }

> return sv_2mortal(newRV((SV *)hv));
> --- 1606,1614 ----
> attr,
> ObjectIdGetDatum(typioparam),
> Int32GetDatum(tupdesc->attrs[i]->atttypmod)));
> ! sv = newSVpv(outputstr, 0);
> ! if (GetDatabaseEncoding() == PG_UTF8) SvUTF8_on(sv);
> ! hv_store(hv, attname, namelen, sv, 0);
> }

> return sv_2mortal(newRV((SV *)hv));

I don't think we can accept this patch as-is, mainly because it is going
to require some configuration checks (older Perls don't seem to have
SvUTF8_on()). That means it's probably too late to consider it for 8.0.
I agree something like this should make its way into 8.1 though.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2004-12-05 20:29:27 Re: RC1 and OSX
Previous Message Theodore Petrosky 2004-12-05 20:14:22 RC1 and OSX

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-12-05 22:42:10 Re: 8.0.0beta5 FailedAssertion (Crash) when casting composite types
Previous Message Tom Lane 2004-12-05 19:33:18 Re: patch contrib/pgcrypto for win32 (2)