|
1 | 1 | /**********************************************************************
|
2 | 2 | * plperl.c - perl as a procedural language for PostgreSQL
|
3 | 3 | *
|
4 |
| - * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.133 2007/12/01 15:20:34 adunstan Exp $ |
| 4 | + * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.134 2007/12/01 17:58:42 tgl Exp $ |
5 | 5 | *
|
6 | 6 | **********************************************************************/
|
7 | 7 |
|
|
23 | 23 | #include "miscadmin.h"
|
24 | 24 | #include "nodes/makefuncs.h"
|
25 | 25 | #include "parser/parse_type.h"
|
| 26 | +#include "utils/fmgroids.h" |
26 | 27 | #include "utils/guc.h"
|
27 | 28 | #include "utils/lsyscache.h"
|
28 | 29 | #include "utils/memutils.h"
|
@@ -508,50 +509,37 @@ plperl_safe_init(void)
|
508 | 509 | eval_pv(SAFE_OK, FALSE);
|
509 | 510 | if (GetDatabaseEncoding() == PG_UTF8)
|
510 | 511 | {
|
511 |
| - |
512 | 512 | /*
|
513 | 513 | * Fill in just enough information to set up this perl
|
514 | 514 | * function in the safe container and call it.
|
515 | 515 | * For some reason not entirely clear, it prevents errors that
|
516 | 516 | * can arise from the regex code later trying to load
|
517 | 517 | * utf8 modules.
|
518 | 518 | */
|
519 |
| - |
520 | 519 | plperl_proc_desc desc;
|
521 | 520 | FunctionCallInfoData fcinfo;
|
522 |
| - FmgrInfo outfunc; |
523 |
| - HeapTuple typeTup; |
524 |
| - Form_pg_type typeStruct; |
525 | 521 | SV *ret;
|
526 | 522 | SV *func;
|
527 | 523 |
|
528 | 524 | /* make sure we don't call ourselves recursively */
|
529 | 525 | plperl_safe_init_done = true;
|
530 | 526 |
|
531 | 527 | /* compile the function */
|
532 |
| - func = plperl_create_sub( |
533 |
| - "utf8fix", |
534 |
| - "return shift =~ /\\xa9/i ? 'true' : 'false' ;", |
535 |
| - true); |
536 |
| - |
| 528 | + func = plperl_create_sub("utf8fix", |
| 529 | + "return shift =~ /\\xa9/i ? 'true' : 'false' ;", |
| 530 | + true); |
537 | 531 |
|
538 | 532 | /* set up to call the function with a single text argument 'a' */
|
539 | 533 | desc.reference = func;
|
540 | 534 | desc.nargs = 1;
|
541 | 535 | desc.arg_is_rowtype[0] = false;
|
| 536 | + fmgr_info(F_TEXTOUT, &(desc.arg_out_func[0])); |
| 537 | + |
| 538 | + fcinfo.arg[0] = DirectFunctionCall1(textin, CStringGetDatum("a")); |
542 | 539 | fcinfo.argnull[0] = false;
|
543 |
| - fcinfo.arg[0] = |
544 |
| - DatumGetTextP(DirectFunctionCall1(textin, |
545 |
| - CStringGetDatum("a"))); |
546 |
| - typeTup = SearchSysCache(TYPEOID, |
547 |
| - TEXTOID, |
548 |
| - 0, 0, 0); |
549 |
| - typeStruct = (Form_pg_type) GETSTRUCT(typeTup); |
550 |
| - fmgr_info(typeStruct->typoutput,&(desc.arg_out_func[0])); |
551 |
| - ReleaseSysCache(typeTup); |
552 | 540 |
|
553 | 541 | /* and make the call */
|
554 |
| - ret = plperl_call_perl_func(&desc,&fcinfo); |
| 542 | + ret = plperl_call_perl_func(&desc, &fcinfo); |
555 | 543 | }
|
556 | 544 | }
|
557 | 545 |
|
|
0 commit comments