33
33
* ENHANCEMENTS, OR MODIFICATIONS.
34
34
*
35
35
* IDENTIFICATION
36
- * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.57 2004/11/17 21:23:36 tgl Exp $
36
+ * $PostgreSQL: pgsql/src/pl/plperl/plperl.c,v 1.58 2004/11/18 21:35:42 tgl Exp $
37
37
*
38
38
**********************************************************************/
39
39
@@ -240,7 +240,6 @@ plperl_init_interp(void)
240
240
* Initialize the proc and query hash tables
241
241
************************************************************/
242
242
plperl_proc_hash = newHV ();
243
-
244
243
}
245
244
246
245
@@ -497,10 +496,7 @@ plperl_get_elem(HV *hash, char *key)
497
496
{
498
497
SV * * svp = hv_fetch (hash , key , strlen (key ), FALSE);
499
498
if (!svp )
500
- {
501
499
elog (ERROR , "plperl: key '%s' not found" , key );
502
- return NULL ;
503
- }
504
500
return SvTYPE (* svp ) == SVt_NULL ? NULL : SvPV (* svp , PL_na );
505
501
}
506
502
@@ -659,7 +655,10 @@ plperl_create_sub(char *s, bool trusted)
659
655
int count ;
660
656
661
657
if (trusted && !plperl_safe_init_done )
658
+ {
662
659
plperl_safe_init ();
660
+ SPAGAIN ;
661
+ }
663
662
664
663
ENTER ;
665
664
SAVETMPS ;
@@ -760,50 +759,40 @@ plperl_call_perl_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo)
760
759
XPUSHs (sv_2mortal (newSVpv ("undef" , 0 )));
761
760
for (i = 0 ; i < desc -> nargs ; i ++ )
762
761
{
763
- if (desc -> arg_is_rowtype [i ])
762
+ if (fcinfo -> argnull [i ])
763
+ XPUSHs (& PL_sv_undef );
764
+ else if (desc -> arg_is_rowtype [i ])
764
765
{
765
- if (fcinfo -> argnull [i ])
766
- XPUSHs (& PL_sv_undef );
767
- else
768
- {
769
- HeapTupleHeader td ;
770
- Oid tupType ;
771
- int32 tupTypmod ;
772
- TupleDesc tupdesc ;
773
- HeapTupleData tmptup ;
774
- SV * hashref ;
775
-
776
- td = DatumGetHeapTupleHeader (fcinfo -> arg [i ]);
777
- /* Extract rowtype info and find a tupdesc */
778
- tupType = HeapTupleHeaderGetTypeId (td );
779
- tupTypmod = HeapTupleHeaderGetTypMod (td );
780
- tupdesc = lookup_rowtype_tupdesc (tupType , tupTypmod );
781
- /* Build a temporary HeapTuple control structure */
782
- tmptup .t_len = HeapTupleHeaderGetDatumLength (td );
783
- tmptup .t_data = td ;
784
-
785
- /*
786
- * plperl_build_tuple_argument better return a mortal SV.
787
- */
788
- hashref = plperl_build_tuple_argument (& tmptup , tupdesc );
789
- XPUSHs (hashref );
790
- }
766
+ HeapTupleHeader td ;
767
+ Oid tupType ;
768
+ int32 tupTypmod ;
769
+ TupleDesc tupdesc ;
770
+ HeapTupleData tmptup ;
771
+ SV * hashref ;
772
+
773
+ td = DatumGetHeapTupleHeader (fcinfo -> arg [i ]);
774
+ /* Extract rowtype info and find a tupdesc */
775
+ tupType = HeapTupleHeaderGetTypeId (td );
776
+ tupTypmod = HeapTupleHeaderGetTypMod (td );
777
+ tupdesc = lookup_rowtype_tupdesc (tupType , tupTypmod );
778
+ /* Build a temporary HeapTuple control structure */
779
+ tmptup .t_len = HeapTupleHeaderGetDatumLength (td );
780
+ tmptup .t_data = td ;
781
+
782
+ /* plperl_build_tuple_argument better return a mortal SV */
783
+ hashref = plperl_build_tuple_argument (& tmptup , tupdesc );
784
+ XPUSHs (hashref );
791
785
}
792
786
else
793
787
{
794
- if (fcinfo -> argnull [i ])
795
- XPUSHs (& PL_sv_undef );
796
- else
797
- {
798
- char * tmp ;
799
-
800
- tmp = DatumGetCString (FunctionCall3 (& (desc -> arg_out_func [i ]),
801
- fcinfo -> arg [i ],
802
- ObjectIdGetDatum (desc -> arg_typioparam [i ]),
803
- Int32GetDatum (-1 )));
804
- XPUSHs (sv_2mortal (newSVpv (tmp , 0 )));
805
- pfree (tmp );
806
- }
788
+ char * tmp ;
789
+
790
+ tmp = DatumGetCString (FunctionCall3 (& (desc -> arg_out_func [i ]),
791
+ fcinfo -> arg [i ],
792
+ ObjectIdGetDatum (desc -> arg_typioparam [i ]),
793
+ Int32GetDatum (-1 )));
794
+ XPUSHs (sv_2mortal (newSVpv (tmp , 0 )));
795
+ pfree (tmp );
807
796
}
808
797
}
809
798
PUTBACK ;
@@ -848,6 +837,7 @@ plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo, S
848
837
{
849
838
dSP ;
850
839
SV * retval ;
840
+ Trigger * tg_trigger ;
851
841
int i ;
852
842
int count ;
853
843
@@ -856,8 +846,9 @@ plperl_call_perl_trigger_func(plperl_proc_desc *desc, FunctionCallInfo fcinfo, S
856
846
857
847
PUSHMARK (sp );
858
848
XPUSHs (td );
859
- for (i = 0 ; i < ((TriggerData * ) fcinfo -> context )-> tg_trigger -> tgnargs ; i ++ )
860
- XPUSHs (sv_2mortal (newSVpv (((TriggerData * ) fcinfo -> context )-> tg_trigger -> tgargs [i ], 0 )));
849
+ tg_trigger = ((TriggerData * ) fcinfo -> context )-> tg_trigger ;
850
+ for (i = 0 ; i < tg_trigger -> tgnargs ; i ++ )
851
+ XPUSHs (sv_2mortal (newSVpv (tg_trigger -> tgargs [i ], 0 )));
861
852
PUTBACK ;
862
853
863
854
count = perl_call_sv (desc -> reference , G_SCALAR | G_EVAL | G_KEEPERR );
0 commit comments