Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd092524

Browse files
committed
> Here's a patch I added against plperl, originally against beta5, now
> against rc1. It simply checks with GetDatabaseEncoding() if the current> database is in UTF-8, and if so, sets the UTF-8 flag on the arguments> that are passed to perl. This means that it isn't necessary to> utf8::upgrade() every string, as perl has no way of knowing offhand> that a string is UTF-8 -- but postgres does, because the database> encoding is specified, so it makes sense to turn the flag on. You> should also be able to properly manipulate UTF-8 strings now from> plperl as opposed to plperlu, because otherwise you'd have to use> encoding 'utf8' which was not allowed. It could also eliminate some> unexpected bugs if you assume that perl knows the string is unicode.It> is enabled only for perl 5.6 and higher, so earlier versions will not> be affected.>> I have been assured by crab that the patch is quite harmless and will> not break anything. It would be great to see it in 8 final! :-)David Kamholz
1 parent0851a6f commitd092524

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

‎src/pl/plperl/plperl.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* ENHANCEMENTS, OR MODIFICATIONS.
3434
*
3535
* IDENTIFICATION
36-
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.76 2005/06/05 03:16:35 momjian Exp $
36+
* $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.77 2005/06/15 00:35:16 momjian Exp $
3737
*
3838
**********************************************************************/
3939

@@ -54,6 +54,7 @@
5454
#include"utils/memutils.h"
5555
#include"utils/typcache.h"
5656
#include"miscadmin.h"
57+
#include"mb/pg_wchar.h"
5758

5859
/* perl stuff */
5960
#include"EXTERN.h"
@@ -649,6 +650,7 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
649650
SV*retval;
650651
inti;
651652
intcount;
653+
SV*sv;
652654

653655
ENTER;
654656
SAVETMPS;
@@ -688,7 +690,11 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
688690

689691
tmp=DatumGetCString(FunctionCall1(&(desc->arg_out_func[i]),
690692
fcinfo->arg[i]));
691-
XPUSHs(sv_2mortal(newSVpv(tmp,0)));
693+
sv=newSVpv(tmp,0);
694+
#ifPERL_BCDVERSION >=0x5006000L
695+
if (GetDatabaseEncoding()==PG_UTF8)SvUTF8_on(sv);
696+
#endif
697+
XPUSHs(sv_2mortal(sv));
692698
pfree(tmp);
693699
}
694700
}
@@ -1261,6 +1267,7 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
12611267
Oidtypoutput;
12621268
booltypisvarlena;
12631269
intnamelen;
1270+
SV*sv;
12641271

12651272
if (tupdesc->attrs[i]->attisdropped)
12661273
continue;
@@ -1283,7 +1290,11 @@ plperl_hash_from_tuple(HeapTuple tuple, TupleDesc tupdesc)
12831290
outputstr=DatumGetCString(OidFunctionCall1(typoutput,
12841291
attr));
12851292

1286-
hv_store(hv,attname,namelen,newSVpv(outputstr,0),0);
1293+
sv=newSVpv(outputstr,0);
1294+
#ifPERL_BCDVERSION >=0x5006000L
1295+
if (GetDatabaseEncoding()==PG_UTF8)SvUTF8_on(sv);
1296+
#endif
1297+
hv_store(hv,attname,namelen,sv,0);
12871298
}
12881299

12891300
returnnewRV_noinc((SV*)hv);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp