Re: PL/Perl compilation error - Mailing list pgsql-general

From Tom Lane
Subject Re: PL/Perl compilation error
Date
Msg-id 672.971793169@sss.pgh.pa.us
Whole thread Raw
In response to Re: PL/Perl compilation error  (Gilles DAROLD <gilles@darold.net>)
Responses Re: PL/Perl compilation error  (Alex Pilosov <alex@pilosoft.com>)
List pgsql-general
Gilles DAROLD <gilles@darold.net> writes:
>> The problem is this will break on older copies of Perl.

> This problem is solved by perl itself !

Yeah, it is: there is a module called Devel::PPPort that isolates
user C code from the incompatibilities of different Perl APIs.  Until
someone gets around to submitting a proper fix using PPPort, we'll stick
with the POLLUTE=1 solution we have now.  I see no reason to install an
incomplete solution that will fail on older Perls --- we are not in the
business of forcing people to update their Perls.

I was going to point you to the pgsql-bugs archive for 3/25/00, but
there seems to be a gap in the archive in March, so attached are the
relevant messages.

            regards, tom lane


------- Forwarded Messages

Date:    Sat, 25 Mar 2000 13:15:28 +0100
From:    Marc Lehmann <pcg@goof.com>
To:      pgsql-bugs@postgresql.org
Subject: [BUGS] perl5 interface won't compile

============================================================================
                        POSTGRESQL BUG REPORT TEMPLATE
============================================================================


Your name        :    Marc Lehmann
Your email address    :    pcg@goof.com


System Configuration
---------------------
  Architecture (example: Intel Pentium)      :

  Operating System (example: Linux 2.0.26 ELF)     :

  PostgreSQL version (example: PostgreSQL-6.5.1):   PostgreSQL-7.0beta3

  Compiler used (example:  gcc 2.8.0)        :


Please enter a FULL description of your problem:
------------------------------------------------

the perl interface does not compile with newer perl versions (5.006 and
probably 5.005 without options).

Please describe a way to repeat the problem.   Please try to provide a

(sorry, just found out that plperl also won't compile, so I have "re-added"
another, a second diff against plperl ;)

concise reproducible example, if at all possible:
----------------------------------------------------------------------

"make"




If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

A diff against Pg.xs is attached, however, it will not compile with older
perl versions (it is the prefered long-term solution).

So, for the forseeable future, it might be a better to create the Makefile
using

   perl Makefile.PL POLLUTE=1

which will enable some kind of compatibility mode.

A preferable but better solution would be to use the Devel::PPPort module
(on CPAN) to get rid of versiondependonitis (in which case you will need
to apply both diffs and additionally include ppport.h, preferably after
renaming it to something else.

===PATCH 1===================================================================

diff -r -u perl5o/Pg.c perl5/Pg.c
--- perl5o/Pg.c    Sat Mar 25 13:09:05 2000
+++ perl5/Pg.c    Sat Mar 25 13:10:38 2000
@@ -1407,7 +1407,7 @@
         ps.caption   = caption;
         Newz(0, ps.fieldName, items + 1 - 11, char*);
         for (i = 11; i < items; i++) {
-            ps.fieldName[i - 11] = (char *)SvPV(ST(i), na);
+            ps.fieldName[i - 11] = (char *)SvPV_nolen(ST(i));
         }
         PQprint(fout, res, &ps);
         Safefree(ps.fieldName);
@@ -3182,7 +3182,7 @@
                 EXTEND(sp, cols);
                 while (col < cols) {
                     if (PQgetisnull(res->result, res->row, col)) {
-                        PUSHs(&sv_undef);
+                        PUSHs(&PL_sv_undef);
                     } else {
                         char *val = PQgetvalue(res->result, res->row, col);
                         PUSHs(sv_2mortal((SV*)newSVpv(val, 0)));
@@ -3238,7 +3238,7 @@
         ps.caption   = caption;
         Newz(0, ps.fieldName, items + 1 - 11, char*);
         for (i = 11; i < items; i++) {
-            ps.fieldName[i - 11] = (char *)SvPV(ST(i), na);
+            ps.fieldName[i - 11] = (char *)SvPV_nolen(ST(i));
         }
         PQprint(fout, res->result, &ps);
         Safefree(ps.fieldName);
diff -r -u perl5o/Pg.xs perl5/Pg.xs
--- perl5o/Pg.xs    Sat Mar 11 04:08:37 2000
+++ perl5/Pg.xs    Sat Mar 25 13:10:36 2000
@@ -581,7 +581,7 @@
         ps.caption   = caption;
         Newz(0, ps.fieldName, items + 1 - 11, char*);
         for (i = 11; i < items; i++) {
-            ps.fieldName[i - 11] = (char *)SvPV(ST(i), na);
+            ps.fieldName[i - 11] = (char *)SvPV_nolen(ST(i));
         }
         PQprint(fout, res, &ps);
         Safefree(ps.fieldName);
@@ -1252,7 +1252,7 @@
                 EXTEND(sp, cols);
                 while (col < cols) {
                     if (PQgetisnull(res->result, res->row, col)) {
-                        PUSHs(&sv_undef);
+                        PUSHs(&PL_sv_undef);
                     } else {
                         char *val = PQgetvalue(res->result, res->row, col);
                         PUSHs(sv_2mortal((SV*)newSVpv(val, 0)));
@@ -1292,7 +1292,7 @@
         ps.caption   = caption;
         Newz(0, ps.fieldName, items + 1 - 11, char*);
         for (i = 11; i < items; i++) {
-            ps.fieldName[i - 11] = (char *)SvPV(ST(i), na);
+            ps.fieldName[i - 11] = (char *)SvPV_nolen(ST(i));
         }
         PQprint(fout, res->result, &ps);
         Safefree(ps.fieldName);

===PATCH 2===================================================================

diff -u -r plperlo/plperl.c plperl/plperl.c
--- plperlo/plperl.c    Sat Mar 25 13:17:31 2000
+++ plperl/plperl.c    Sat Mar 25 13:18:32 2000
@@ -309,12 +309,12 @@
     perl_eval_sv(s, G_SCALAR | G_EVAL | G_KEEPERR);
     SPAGAIN;

-    if (SvTRUE(GvSV(errgv))) {
+    if (SvTRUE(GvSV(PL_errgv))) {
         POPs;
         PUTBACK;
         FREETMPS;
         LEAVE;
-        elog(ERROR, "creation of function failed : %s", SvPV(GvSV(errgv), na));
+        elog(ERROR, "creation of function failed : %s", SvPV_nolen(GvSV(PL_errgv)));
     }

     /*
@@ -413,12 +413,12 @@
         elog(ERROR, "plperl : didn't get a return item from function");
     }

-    if (SvTRUE(GvSV(errgv))) {
+    if (SvTRUE(GvSV(PL_errgv))) {
         POPs;
         PUTBACK ;
         FREETMPS ;
         LEAVE;
-        elog(ERROR, "plperl : error from function : %s", SvPV(GvSV(errgv), na));
+        elog(ERROR, "plperl : error from function : %s", SvPV_nolen(GvSV(PL_errgv)));
     }

     retval = newSVsv(POPs);
@@ -632,7 +632,7 @@
         elog(ERROR, "plperl: SPI_finish() failed");

     retval = (Datum) (*fmgr_faddr(&prodesc->result_in_func))
-            (SvPV(perlret, na),
+            (SvPV_nolen(perlret),
              prodesc->result_in_elem,
             prodesc->result_in_len);

@@ -2168,6 +2168,6 @@
         }
     }
     sv_catpv(output, "}");
-    output = perl_eval_pv(SvPV(output, na), TRUE);
+    output = perl_eval_pv(SvPV_nolen(output), TRUE);
     return output;
 }

=============================================================================

--
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@opengroup.org |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |

------- Message 2

Date:    Sat, 25 Mar 2000 11:49:09 -0500
From:    Tom Lane <tgl@sss.pgh.pa.us>
To:      Marc Lehmann <pcg@goof.com>
cc:      pgsql-bugs@postgresql.org, pgsql-hackers@postgreSQL.org
Subject: Re: [BUGS] perl5 interface won't compile

Marc Lehmann <pcg@goof.com> writes:
> the perl interface does not compile with newer perl versions (5.006 and
> probably 5.005 without options).

We've seen this reported a few times, but in fact the perl code *does*
compile against 5.005_03 --- without options --- and AFAICT that is
still considered the current stable release of Perl.  I'm pretty
hesitant to break backwards compatibility with pre-5.005 versions
just yet.

However, you are the first complainant who has suggested approaches
other than a non-backward-compatible source patch, so I'm all ears.

> So, for the forseeable future, it might be a better to create the Makefile
> using
>    perl Makefile.PL POLLUTE=1
> which will enable some kind of compatibility mode.

Interesting.  I could not find anything about POLLUTE at www.perl.com.
What does it do, and will it cause problems on pre-5.005 perls?

> A preferable but better solution would be to use the Devel::PPPort module
> (on CPAN) to get rid of versiondependonitis (in which case you will need
> to apply both diffs and additionally include ppport.h, preferably after
> renaming it to something else.

This looks like it could be the Right Thing To Do.  Anyone have time to
make it happen (and perhaps even access to a few different perl versions
to test it)?

            regards, tom lane

------- Message 3

Date:    Sat, 25 Mar 2000 15:27:17 -0500
From:    Tom Lane <tgl@sss.pgh.pa.us>
To:      Bruce Momjian <pgman@candle.pha.pa.us>, Marc Lehmann <pcg@goof.com>,
     pgsql-bugs@postgresql.org
Subject: Re: [BUGS] perl5 interface won't compile

I said
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
>> I have added your POLLUTE=1 solution to interfaces/perl5 and
>> plperl.  Please try tomorrow's snapshot to see if this works for you.

> I think the more interesting question is whether that breaks older
> Perls...

I have now tried it with perl 5.004_04 (which was current about two
years ago), and I get

$ make plperl/Makefile
cd plperl && perl Makefile.PL POLLUTE=1
'POLLUTE' is not a known MakeMaker parameter name.
Writing Makefile for plperl

after which it seems to be happy.  Assuming this fixes the problem
for bleeding-edge perls, this looks like a good stopgap answer until
someone feels like doing something with Devel::PPPort.

            regards, tom lane

------- End of Forwarded Messages

pgsql-general by date:

Previous
From: Gunnar R|nning
Date:
Subject: Re: web programming
Next
From: mkennedy@hssinc.com (Matthew Kennedy)
Date:
Subject: alter table, add foreign key constraint