Tom Lane wrote:
Bruce Momjian [EMAIL PROTECTED] writes:
I am seeing the following compile warnings in CVS. I am using for perl:
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
I believe these two:
plperl.c:948: warning: `ret_hv' might be used uninitialized in this function
plperl.c:949: warning: `ret_av' might be used uninitialized in this function
indicate an actual bug --- at least, it's far from clear that the code
can't try to use an uninitialized value. I trust that the authors of
plperl will step up and fix it; I'm not sufficiently clear on what cases
they are trying to support to want to touch it.
I don't currently have the resources to clean this up properly. The
attached patch tries to make clear in a comment what the code is doing,
and also initializes these variables to NULL. If someone wants to take a
stab at cleaning this up they are welcome to - I don't expect to be able
to for quite a while.
The others indicate sloppiness in the C code generated by perl's XS
functionality. There's nothing we can do about them. FWIW, less
obsolete versions of Perl generate fewer warnings --- the only one of
these that I see on 5.8.0 and up is
SPI.c:158: warning: unused variable `items'
The patch also addresses this issue.
cheers
andrew
Index: SPI.xs
===
RCS file: /home/cvsmirror/pgsql/src/pl/plperl/SPI.xs,v
retrieving revision 1.10
diff -c -r1.10 SPI.xs
*** SPI.xs 20 Nov 2004 19:07:40 - 1.10
--- SPI.xs 21 Nov 2004 15:02:15 -
***
*** 94,96
--- 94,100
RETVAL = newRV_noinc((SV*) ret_hash);
OUTPUT:
RETVAL
+
+
+ BOOT:
+ items = 0; /* avoid 'unused variable' warning */
Index: plperl.c
===
RCS file: /home/cvsmirror/pgsql/src/pl/plperl/plperl.c,v
retrieving revision 1.59
diff -c -r1.59 plperl.c
*** plperl.c 20 Nov 2004 19:07:40 - 1.59
--- plperl.c 21 Nov 2004 20:40:50 -
***
*** 963,971
if (prodesc-fn_retistuple fcinfo-resultinfo) /* set of tuples */
{
/* SRF support */
! HV *ret_hv;
! AV *ret_av;
FuncCallContext *funcctx;
int call_cntr;
int max_calls;
--- 963,988
if (prodesc-fn_retistuple fcinfo-resultinfo) /* set of tuples */
{
+
+ /*
+ * This branch will be taken when the function call
+ * appears on a context that can return a set of tuples
+ * even if it only actually returns a single tuple
+ * (e.g. select a from foo() where foor returns a singletone
+ * of some composite type with member a). In this case, the
+ * return value will be a hashref. If a rowset is returned
+ * it will be an arrayref whose members will be hashrefs.
+ *
+ * Care is taken in the code only to refer to the appropriate
+ * one of ret_hv and ret_av, only one of which is therefore
+ * valid for any given call.
+ *
+ * XXX This code is in dire need of cleanup.
+ */
+
/* SRF support */
! HV *ret_hv = NULL;
! AV *ret_av = NULL;
FuncCallContext *funcctx;
int call_cntr;
int max_calls;
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/docs/faqs/FAQ.html