Thread: BUG #5339: Version of Perl detected incorrectly

BUG #5339: Version of Perl detected incorrectly

From
"Jonathan "Duke" Leto"
Date:
The following bug has been logged online:

Bug reference:      5339
Logged by:          Jonathan "Duke" Leto
Email address:      jonathan@leto.net
PostgreSQL version: master 0f50d482
Operating system:   CentOS 5.4 (Linux kernel 2.6.18)
Description:        Version of Perl detected incorrectly
Details:

$  perl -v

This is perl 5, version 11, subversion 4 (v5.11.4-114-ga4cc961*) built for
x86_64-linux

checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 8kB
checking for segment size... 1GB
checking for WAL block size... 8kB
checking for WAL segment size... 16MB
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking if gcc supports -Wdeclaration-after-statement... yes
checking if gcc supports -Wendif-labels... yes
checking if gcc supports -fno-strict-aliasing... yes
checking if gcc supports -fwrapv... yes
checking whether the C compiler still works... yes
checking how to run the C preprocessor... gcc -E
checking allow thread-safe client libraries... yes
checking whether to build with Tcl... no
checking whether to build Perl modules... no
checking whether to build Python modules... no
checking whether to build with GSSAPI support... no
checking whether to build with Kerberos 5 support... no
checking whether to build with PAM support... no
checking whether to build with LDAP support... no
checking whether to build with Bonjour support... no
checking whether to build with OpenSSL support... no
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ld used by GCC... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for ranlib... ranlib
checking for strip... strip
checking whether it is possible to strip libraries... yes
checking for ar... ar
checking for tar... /bin/tar
checking whether ln -s works... yes
checking for gawk... gawk
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for bison... /usr/bin/bison
configure: using bison (GNU Bison) 2.3
checking for flex... configure: WARNING:
*** The installed version of Flex, /usr/bin/flex, is too old to use with
PostgreSQL.
*** Flex version 2.5.31 or later is required, but this is /usr/bin/flex
version 2.5.4.
configure: WARNING:
*** The installed version of Flex, /usr/bin/lex, is too old to use with
PostgreSQL.
*** Flex version 2.5.31 or later is required, but this is /usr/bin/lex
version 2.5.4.
no
configure: WARNING:
*** Without Flex you will not be able to build PostgreSQL from CVS nor
*** change any of the scanner definition files.  You can obtain Flex from
*** a GNU mirror site.  (If you are using the official distribution of
*** PostgreSQL then you do not need to worry about this because the Flex
*** output is pre-generated.)
checking for perl... /home/leto/bin/perl
configure: using perl
configure: WARNING:
*** The installed version of Perl, /home/leto/bin/perl, is too old to use
with PostgreSQL.
*** Perl version 5.8 or later is required, but this is .
configure: WARNING:
*** Without Perl you will not be able to build PostgreSQL from CVS.
*** You can obtain Perl from any CPAN mirror site.
*** (If you are using the official distribution of PostgreSQL then you do
not
*** need to worry about this, because the Perl output is pre-generated.)
checking for main in -lm... yes
checking for library containing setproctitle... no
checking for library containing dlopen... -ldl
checking for library containing socket... none required
checking for library containing shl_load... no
checking for library containing getopt_long... none required
checking for library containing crypt... -lcrypt
checking for library containing fdatasync... none required
checking for library containing gethostbyname_r... none required
checking for library containing shmget... none required
checking for -lreadline... no
checking for -ledit... no
configure: error: readline library not found
If you have readline already installed, see config.log for details on the
failure.  It is possible the compiler isn't looking in the proper
directory.
Use --without-readline to disable readline support.

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Mon, Feb 22, 2010 at 10:57, Jonathan <jonathan@leto.net> wrote:
>
> The following bug has been logged online:
>
> Bug reference: =C2=A0 =C2=A0 =C2=A05339
> Logged by: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Jonathan "Duke" Leto
> Email address: =C2=A0 =C2=A0 =C2=A0jonathan@leto.net
> PostgreSQL version: master 0f50d482
> Operating system: =C2=A0 CentOS 5.4 (Linux kernel 2.6.18)
> Description: =C2=A0 =C2=A0 =C2=A0 =C2=A0Version of Perl detected incorrec=
tly
> Details:
>
> $ =C2=A0perl -v
>
> This is perl 5, version 11, subversion 4 (v5.11.4-114-ga4cc961*) built for
> x86_64-linux
...
> checking for perl... /home/leto/bin/perl
> configure: using perl
> configure: WARNING:
> *** The installed version of Perl, /home/leto/bin/perl, is too old to use
> with PostgreSQL.
> *** Perl version 5.8 or later is required, but this is .

Yeah find the below which attempts to clean this up a bit.  Instead of
parsing perl -v output, we just "use" the min required version and
rely on perl error out for us.   Its also more or less what we do at
runtime in plc_perl_boot.pl now.

Thoughts?

*** a/configure
--- b/configure
***************
*** 6867,6884 **** fi
  fi

  if test "$PERL"; then
!   pgac_perl_version=3D`$PERL -v 2>/dev/null | sed -n 's/This is perl,
v[a-z ]*//p' | sed 's/ .*//'`
!   { $as_echo "$as_me:$LINENO: using perl $pgac_perl_version" >&5
! $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
!   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
!     $AWK '{ if ($1 =3D 5 && $2 >=3D 8) exit 1; else exit 0;}'
!   then
      { $as_echo "$as_me:$LINENO: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** Perl version 5.8 or later is required, but this is
$pgac_perl_version." >&5
  $as_echo "$as_me: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** Perl version 5.8 or later is required, but this is
$pgac_perl_version." >&2;}
      PERL=3D""
    fi
  fi
--- 6867,6880 ----
  fi

  if test "$PERL"; then
!   perl_version_error=3D`$PERL -e 'use 5.00801;' 2>&1`
!   if test -n "$perl_version_error"; then
      { $as_echo "$as_me:$LINENO: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** $perl_version_error." >&5
  $as_echo "$as_me: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** $perl_version_error." >&2;}
      PERL=3D""
    fi
  fi

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Mon, Feb 22, 2010 at 12:44, Alex Hunsaker <badalex@gmail.com> wrote:
> On Mon, Feb 22, 2010 at 10:57, Jonathan <jonathan@leto.net> wrote:
>> configure: using perl
>> configure: WARNING:
>> *** The installed version of Perl, /home/leto/bin/perl, is too old to use
>> with PostgreSQL.
>> *** Perl version 5.8 or later is required, but this is .
>
> Yeah find the below which attempts to clean this up a bit.

For the curious this what it looks like after (I of course bumped the
check to the non-existent perl 5.11.10 version):

configure: WARNING:
*** The installed version of Perl, /usr/bin/perl, is too old to use
with PostgreSQL.
*** Perl v5.11.10 required--this is only v5.10.1, stopped at -e line 1.

Re: BUG #5339: Version of Perl detected incorrectly

From
Alvaro Herrera
Date:
Alex Hunsaker escribió:
> On Mon, Feb 22, 2010 at 10:57, Jonathan <jonathan@leto.net> wrote:

> > checking for perl... /home/leto/bin/perl
> > configure: using perl
> > configure: WARNING:
> > *** The installed version of Perl, /home/leto/bin/perl, is too old to use
> > with PostgreSQL.
> > *** Perl version 5.8 or later is required, but this is .
>
> Yeah find the below which attempts to clean this up a bit.  Instead of
> parsing perl -v output, we just "use" the min required version and
> rely on perl error out for us.   Its also more or less what we do at
> runtime in plc_perl_boot.pl now.

You need to patch configure.in.  configure is a generated file.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: BUG #5339: Version of Perl detected incorrectly

From
Tim Bunce
Date:
Using
        perl -e 'use 5.008010'

would be a more reliable way for configure to test the perl version.

Tim.

On Mon, Feb 22, 2010 at 05:57:56PM +0000, Jonathan Duke Leto wrote:
>
> The following bug has been logged online:
>
> Bug reference:      5339
> Logged by:          Jonathan "Duke" Leto
> Email address:      jonathan@leto.net
> PostgreSQL version: master 0f50d482
> Operating system:   CentOS 5.4 (Linux kernel 2.6.18)
> Description:        Version of Perl detected incorrectly
> Details:
>
> $  perl -v
>
> This is perl 5, version 11, subversion 4 (v5.11.4-114-ga4cc961*) built for
> x86_64-linux
>
> checking build system type... x86_64-unknown-linux-gnu
> checking host system type... x86_64-unknown-linux-gnu
> checking which template to use... linux
> checking whether to build with 64-bit integer date/time support... yes
> checking whether NLS is wanted... no
> checking for default port number... 5432
> checking for block size... 8kB
> checking for segment size... 1GB
> checking for WAL block size... 8kB
> checking for WAL segment size... 16MB
> checking for gcc... gcc
> checking for C compiler default output file name... a.out
> checking whether the C compiler works... yes
> checking whether we are cross compiling... no
> checking for suffix of executables...
> checking for suffix of object files... o
> checking whether we are using the GNU C compiler... yes
> checking whether gcc accepts -g... yes
> checking for gcc option to accept ISO C89... none needed
> checking if gcc supports -Wdeclaration-after-statement... yes
> checking if gcc supports -Wendif-labels... yes
> checking if gcc supports -fno-strict-aliasing... yes
> checking if gcc supports -fwrapv... yes
> checking whether the C compiler still works... yes
> checking how to run the C preprocessor... gcc -E
> checking allow thread-safe client libraries... yes
> checking whether to build with Tcl... no
> checking whether to build Perl modules... no
> checking whether to build Python modules... no
> checking whether to build with GSSAPI support... no
> checking whether to build with Kerberos 5 support... no
> checking whether to build with PAM support... no
> checking whether to build with LDAP support... no
> checking whether to build with Bonjour support... no
> checking whether to build with OpenSSL support... no
> checking for grep that handles long lines and -e... /bin/grep
> checking for egrep... /bin/grep -E
> checking for ld used by GCC... /usr/bin/ld
> checking if the linker (/usr/bin/ld) is GNU ld... yes
> checking for ranlib... ranlib
> checking for strip... strip
> checking whether it is possible to strip libraries... yes
> checking for ar... ar
> checking for tar... /bin/tar
> checking whether ln -s works... yes
> checking for gawk... gawk
> checking for a thread-safe mkdir -p... /bin/mkdir -p
> checking for bison... /usr/bin/bison
> configure: using bison (GNU Bison) 2.3
> checking for flex... configure: WARNING:
> *** The installed version of Flex, /usr/bin/flex, is too old to use with
> PostgreSQL.
> *** Flex version 2.5.31 or later is required, but this is /usr/bin/flex
> version 2.5.4.
> configure: WARNING:
> *** The installed version of Flex, /usr/bin/lex, is too old to use with
> PostgreSQL.
> *** Flex version 2.5.31 or later is required, but this is /usr/bin/lex
> version 2.5.4.
> no
> configure: WARNING:
> *** Without Flex you will not be able to build PostgreSQL from CVS nor
> *** change any of the scanner definition files.  You can obtain Flex from
> *** a GNU mirror site.  (If you are using the official distribution of
> *** PostgreSQL then you do not need to worry about this because the Flex
> *** output is pre-generated.)
> checking for perl... /home/leto/bin/perl
> configure: using perl
> configure: WARNING:
> *** The installed version of Perl, /home/leto/bin/perl, is too old to use
> with PostgreSQL.
> *** Perl version 5.8 or later is required, but this is .
> configure: WARNING:
> *** Without Perl you will not be able to build PostgreSQL from CVS.
> *** You can obtain Perl from any CPAN mirror site.
> *** (If you are using the official distribution of PostgreSQL then you do
> not
> *** need to worry about this, because the Perl output is pre-generated.)
> checking for main in -lm... yes
> checking for library containing setproctitle... no
> checking for library containing dlopen... -ldl
> checking for library containing socket... none required
> checking for library containing shl_load... no
> checking for library containing getopt_long... none required
> checking for library containing crypt... -lcrypt
> checking for library containing fdatasync... none required
> checking for library containing gethostbyname_r... none required
> checking for library containing shmget... none required
> checking for -lreadline... no
> checking for -ledit... no
> configure: error: readline library not found
> If you have readline already installed, see config.log for details on the
> failure.  It is possible the compiler isn't looking in the proper
> directory.
> Use --without-readline to disable readline support.
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

Re: BUG #5339: Version of Perl detected incorrectly

From
Tom Lane
Date:
Alex Hunsaker <badalex@gmail.com> writes:
> On Mon, Feb 22, 2010 at 10:57, Jonathan <jonathan@leto.net> wrote:
>> This is perl 5, version 11, subversion 4 (v5.11.4-114-ga4cc961*) built for
>> x86_64-linux

Ugh.  Can't they manage to keep that message reasonably consistent?

> !   perl_version_error=`$PERL -e 'use 5.00801;' 2>&1`

This is not a path towards an acceptable solution, as it effectively
assumes what we are setting out to prove, namely that we have found
a reasonably modern version of perl.  Try it in perl 4...

            regards, tom lane

Re: BUG #5339: Version of Perl detected incorrectly

From
Jonathan Leto
Date:
Howdy,

On Mon, Feb 22, 2010 at 12:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alex Hunsaker <badalex@gmail.com> writes:
>> On Mon, Feb 22, 2010 at 10:57, Jonathan <jonathan@leto.net> wrote:
>>> This is perl 5, version 11, subversion 4 (v5.11.4-114-ga4cc961*) built =
for
>>> x86_64-linux
>
> Ugh. =A0Can't they manage to keep that message reasonably consistent?

The form of the version string is the closest release version
(5.11.4), the number of commits ahead of that (114) and the SHA1 of
the actual commit. What flavor of consistency are you looking for?

>
>> ! =A0 perl_version_error=3D`$PERL -e 'use 5.00801;' 2>&1`
>
> This is not a path towards an acceptable solution, as it effectively
> assumes what we are setting out to prove, namely that we have found
> a reasonably modern version of perl. =A0Try it in perl 4...

These words don't seem to make sense. Can you translate? The the code
that Tim suggested is the most succinct way to ask Perl if it is at
least a certain minimum version, instead of inspecting the output of
"perl -v" and performing voodoo.

>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0regards, tom lane
>

In short, +1 to Tim's suggestion.


--=20
Jonathan "Duke" Leto
jonathan@leto.net
http://leto.net

Re: BUG #5339: Version of Perl detected incorrectly

From
Tom Lane
Date:
Jonathan Leto <jonathan@leto.net> writes:
> On Mon, Feb 22, 2010 at 12:07 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> This is perl 5, version 11, subversion 4 (v5.11.4-114-ga4cc961*) built for
>>> x86_64-linux
>>
>> Ugh.  Can't they manage to keep that message reasonably consistent?

> The form of the version string is the closest release version
> (5.11.4), the number of commits ahead of that (114) and the SHA1 of
> the actual commit. What flavor of consistency are you looking for?

The output format of "perl -v" has been reasonably consistent for well
over a decade, eg (examples captured from various machines around my
house)

    This is perl, version 4.0
    This is perl, v5.8.7 built for PA-RISC2.0
    This is perl, v5.10.0 built for darwin-thread-multi-2level

Why did 5.11 feel a need to go off in a new direction?  They haven't
added any actual new information AFAICS, just made it harder to parse.

>> This is not a path towards an acceptable solution, as it effectively
>> assumes what we are setting out to prove, namely that we have found
>> a reasonably modern version of perl.  Try it in perl 4...

> These words don't seem to make sense. Can you translate?

Which part of "it doesn't work in perl 4" is not clear to you?
Yes, I'm aware that it *fails* in perl 4, but it doesn't produce
an error message that would be helpful to a non Perl hacker:

$ /usr/local/bin/perl4 -e 'use 5.008001;'
syntax error in file /tmp/perl-ea01429 at line 1, next 2 tokens "use 5.008001"
Execution of /tmp/perl-ea01429 aborted due to compilation errors.

That isn't going to lead to people realizing that they need a newer
Perl, it's just going to lead to bug reports --- sent to *us*.
I am not prepared to compromise one inch on the clarity of the error
message put out by configure.

            regards, tom lane

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Mon, Feb 22, 2010 at 13:07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alex Hunsaker <badalex@gmail.com> writes:
>> ! =C2=A0 perl_version_error=3D`$PERL -e 'use 5.00801;' 2>&1`
>
> This is not a path towards an acceptable solution, as it effectively
> assumes what we are setting out to prove, namely that we have found
> a reasonably modern version of perl. =C2=A0Try it in perl 4...

Well I would if I had it sitting around =3D).  I did try to compile
one... but chickened out as soon as I hit an error:
$ make
`sh  cflags perly.o` perly.c
      CCCMD =3D  cc -c  -O
In file included from perly.y:38:
perl.h:279: error: conflicting types for =E2=80=98sys_errlist=E2=80=99
/usr/include/bits/sys_errlist.h:28: note: previous declaration of
=E2=80=98sys_errlist=E2=80=99 was here
In file included from perl.h:540,
                 from perly.y:38:
arg.h:685:1: warning: "AF_LOCAL" redefined
In file included from /usr/include/sys/socket.h:40,
                 from /usr/include/netinet/in.h:25,
                 from perl.h:224,
                 from perly.y:38:
/usr/include/bits/socket.h:116:1: warning: this is the location of the
previous definition


How about something like the below?  Basically If we find "This is
perl v4" we bail right then.  Otherwise we use the version check I
proposed up-thread?  I may have inadvertently used some
bash/gnu-isms... sorry about that.

*** a/configure
--- b/configure
***************
*** 6867,6884 **** fi
  fi

  if test "$PERL"; then
!   pgac_perl_version=3D`$PERL -v 2>/dev/null | sed -n 's/This is perl,
v[a-z ]*//p' | sed 's/ .*//'`
!   { $as_echo "$as_me:$LINENO: using perl $pgac_perl_version" >&5
! $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
!   if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
!     $AWK '{ if ($1 =3D 5 && $2 >=3D 8) exit 1; else exit 0;}'
!   then
      { $as_echo "$as_me:$LINENO: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** Perl version 5.8 or later is required, but this is
$pgac_perl_version." >&5
  $as_echo "$as_me: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** Perl version 5.8 or later is required, but this is
$pgac_perl_version." >&2;}
      PERL=3D""
    fi
  fi
--- 6867,6885 ----
  fi

  if test "$PERL"; then
!   perl_version_error=3D""
!   if $PERL -v 2>/dev/null | grep -q 'This is perl, v4' 2>/dev/null; then
!     perl_version_error=3D"Perl version 5.8 or later is required, but
this is perl v4"
!   else
!     perl_version_error=3D`$PERL -e 'use 5.00801;' 2>&1`
!   fi
!   if test -n "$perl_version_error"; then
      { $as_echo "$as_me:$LINENO: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** $perl_version_error." >&5
  $as_echo "$as_me: WARNING:
  *** The installed version of Perl, $PERL, is too old to use with PostgreS=
QL.
! *** $perl_version_error." >&2;}
      PERL=3D""
    fi
  fi


Thoughts?

Re: BUG #5339: Version of Perl detected incorrectly

From
David Fetter
Date:
On Mon, Feb 22, 2010 at 02:17:57PM -0700, Alex Hunsaker wrote:
> On Mon, Feb 22, 2010 at 13:07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> > Alex Hunsaker <badalex@gmail.com> writes:
> >> !   perl_version_error=`$PERL -e 'use 5.00801;' 2>&1`
> >
> > This is not a path towards an acceptable solution, as it effectively
> > assumes what we are setting out to prove, namely that we have found
> > a reasonably modern version of perl.  Try it in perl 4...
>
> Well I would if I had it sitting around =).  I did try to compile
> one... but chickened out as soon as I hit an error:
> $ make
> `sh  cflags perly.o` perly.c
>       CCCMD =  cc -c  -O
> In file included from perly.y:38:
> perl.h:279: error: conflicting types for ‘sys_errlist’
> /usr/include/bits/sys_errlist.h:28: note: previous declaration of
> ‘sys_errlist’ was here
> In file included from perl.h:540,
>                  from perly.y:38:
> arg.h:685:1: warning: "AF_LOCAL" redefined
> In file included from /usr/include/sys/socket.h:40,
>                  from /usr/include/netinet/in.h:25,
>                  from perl.h:224,
>                  from perly.y:38:
> /usr/include/bits/socket.h:116:1: warning: this is the location of the
> previous definition
>
>
> How about something like the below?  Basically If we find "This is
> perl v4" we bail right then.  Otherwise we use the version check I
> proposed up-thread?  I may have inadvertently used some
> bash/gnu-isms... sorry about that.
>
> *** a/configure
> --- b/configure

Edit configure.in, not configure :)

Cheers,
David.
--
David Fetter <david@fetter.org> http://fetter.org/
Phone: +1 415 235 3778  AIM: dfetter666  Yahoo!: dfetter
Skype: davidfetter      XMPP: david.fetter@gmail.com
iCal: webcal://www.tripit.com/feed/ical/people/david74/tripit.ics

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

Re: BUG #5339: Version of Perl detected incorrectly

From
Tom Lane
Date:
Alex Hunsaker <badalex@gmail.com> writes:
> How about something like the below?

I still think that this is optimizing the wrong thing.  We care about
the clarity of the message the user sees, not about how short or clean
the Perl code is.  I'm inclined to stay with the same basic
implementation and just hack up the regexp some more to cope with 5.11's
more verbose -v output.

            regards, tom lane

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Mon, Feb 22, 2010 at 14:17, Alex Hunsaker <badalex@gmail.com> wrote:
> On Mon, Feb 22, 2010 at 13:07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Alex Hunsaker <badalex@gmail.com> writes:
>>> !   perl_version_error=`$PERL -e 'use 5.00801;' 2>&1`
...
> How about something like the below?

Find attached one that modifies config/perl.m4 as well :)

Attachment

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Mon, Feb 22, 2010 at 14:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Alex Hunsaker <badalex@gmail.com> writes:
>> How about something like the below?
>
> I still think that this is optimizing the wrong thing. =C2=A0We care about
> the clarity of the message the user sees, not about how short or clean
> the Perl code is. =C2=A0I'm inclined to stay with the same basic
> implementation and just hack up the regexp some more to cope with 5.11's
> more verbose -v output.

Cant argue with that.  However, I dont think my sed foo is up to the
challenge ATM. :)

BTW this is the perl commit that changed it:

commit ded326e4b6fad7e2479796691d0c27b89d2fe080
Author: David Golden <dagolden@cpan.org>
Date:   Thu Nov 12 10:46:30 2009 -0500

    Change perl -v version format

    New format:

      This is perl 5, version 11, subversion 1 (v5.11.1) ...

    The rationale for this change is that the Perl 5 interpreter will never
    increment PERL_REVISION from 5 to 6, so we want people to start focusing
    on the PERL_VERSION number as most significant and PERL_SUBVERSION as
    equivalent to a "release number".  In other words, "perl 5" is a
    language, this is the 11th version of it, and the second release of that
    version (counting from zero).  Among other things, this makes the
    output of -v and -V more consistent.

    The old v-string style is included for familiarity and usage in code.
    For builds from git, it will include the same extended format as it
    did before, e.g. "(v5.11.1-176-gaf24cc9*)"

Re: BUG #5339: Version of Perl detected incorrectly

From
Jonathan Leto
Date:
Howdy,

First, thanks to everyone for the quick responses to my bug report.

> The output format of "perl -v" has been reasonably consistent for well
> over a decade, eg (examples captured from various machines around my
> house)
>
> =A0 =A0 =A0 =A0This is perl, version 4.0
> =A0 =A0 =A0 =A0This is perl, v5.8.7 built for PA-RISC2.0
> =A0 =A0 =A0 =A0This is perl, v5.10.0 built for darwin-thread-multi-2level
>
> Why did 5.11 feel a need to go off in a new direction? =A0They haven't
> added any actual new information AFAICS, just made it harder to parse.

Perl 5 recently changed their VCS to git, and to allow for reporting
that someone is running a non-release development version, they
tweaked their version output slightly.


>>> This is not a path towards an acceptable solution, as it effectively
>>> assumes what we are setting out to prove, namely that we have found
>>> a reasonably modern version of perl. =A0Try it in perl 4...
>
>> These words don't seem to make sense. Can you translate?
>
> Which part of "it doesn't work in perl 4" is not clear to you?
> Yes, I'm aware that it *fails* in perl 4, but it doesn't produce
> an error message that would be helpful to a non Perl hacker:

You got me. I forgot that 'use' is not in Perl 4. But the error is not
going to be seen my the end user, is it? I thought the purpose of the
script was to be executed by ./configure and depending on whether it
exits successfully or not, you know if you have the proper version of
perl. Am I misunderstanding something?

>
> $ /usr/local/bin/perl4 -e 'use 5.008001;'
> syntax error in file /tmp/perl-ea01429 at line 1, next 2 tokens "use 5.00=
8001"
> Execution of /tmp/perl-ea01429 aborted due to compilation errors.
>
> That isn't going to lead to people realizing that they need a newer
> Perl, it's just going to lead to bug reports --- sent to *us*.
> I am not prepared to compromise one inch on the clarity of the error
> message put out by configure.

I totally agree with you that clarity of error messages are very
important. I think a hybrid approach will work well: first check for
Perl 5, then use the proposed method by Tim. If Perl 5 is not found,
then some loud message can be printed out, like:

Postgres only works with Perl version X.X.X and higher (or somesuch)


Duke


--=20
Jonathan "Duke" Leto
jonathan@leto.net
http://leto.net

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Mon, Feb 22, 2010 at 14:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I'm inclined to stay with the same basic
> implementation and just hack up the regexp some more to cope with 5.11's
> more verbose -v output.

And here is a stab at that:
$ echo "This is perl, version 4.0" | sed -n 's/This is perl.*v[a-z
]*\([0-9]\.[\.0-9]*\).*$/\1/p'
4.0
$ echo "This is perl, v5.8.0" | sed -n 's/This is perl.*v[a-z
]*\([0-9]\.[\.0-9]*\).*$/\1/p'
5.8.0
$ echo "This is perl, v5.10.1" | sed -n 's/This is perl.*v[a-z
]*\([0-9]\.[\.0-9]*\).*$/\1/p'
5.10.1
$ echo "This is perl 5, version 11, subversion 4
(v5.11.4-114-ga4cc961*) built for" | sed -n 's/This is perl.*v[a-z
]*\([0-9]\.[\.0-9]*\).*$/\1/p'
5.11.4

---
*** config/perl.m4
--- config/perl.m4
***************
*** 10,16 **** if test -z "$PERL"; then
  fi

  if test "$PERL"; then
!   pgac_perl_version=`$PERL -v 2>/dev/null | sed -n ['s/This is perl,
v[a-z ]*//p'] | sed ['s/ .*//']`
    AC_MSG_NOTICE([using perl $pgac_perl_version])
    if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
      $AWK '{ if ([$]1 = 5 && [$]2 >= 8) exit 1; else exit 0;}'
--- 10,16 ----
  fi

  if test "$PERL"; then
!   pgac_perl_version=`$PERL -v 2>/dev/null | sed -n ['s/This is
perl.*v[a-z ]*\([0-9]\.[\.0-9]*\).*$/\1/p']`
    AC_MSG_NOTICE([using perl $pgac_perl_version])
    if echo "$pgac_perl_version" | sed ['s/[.a-z_]/ /g'] | \
      $AWK '{ if ([$]1 = 5 && [$]2 >= 8) exit 1; else exit 0;}'
*** configure
--- configure
***************
*** 6867,6873 **** fi
  fi

  if test "$PERL"; then
!   pgac_perl_version=`$PERL -v 2>/dev/null | sed -n 's/This is perl,
v[a-z ]*//p' | sed 's/ .*//'`
    { $as_echo "$as_me:$LINENO: using perl $pgac_perl_version" >&5
  $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
    if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \
--- 6867,6873 ----
  fi

  if test "$PERL"; then
!   pgac_perl_version=`$PERL -v 2>/dev/null | sed -n 's/This is
perl.*v[a-z ]*\([0-9]\.[\.0-9]*\).*$/\1/p'`
    { $as_echo "$as_me:$LINENO: using perl $pgac_perl_version" >&5
  $as_echo "$as_me: using perl $pgac_perl_version" >&6;}
    if echo "$pgac_perl_version" | sed 's/[.a-z_]/ /g' | \

Re: BUG #5339: Version of Perl detected incorrectly

From
Alex Hunsaker
Date:
On Tue, Feb 23, 2010 at 00:50, Alex Hunsaker <badalex@gmail.com> wrote:
> On Mon, Feb 22, 2010 at 14:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I'm inclined to stay with the same basic
>> implementation and just hack up the regexp some more to cope with 5.11's
>> more verbose -v output.
>
> And here is a stab at that:

Grr... stupid word wrapping.  Attached.

Attachment

Re: BUG #5339: Version of Perl detected incorrectly

From
Tom Lane
Date:
Alex Hunsaker <badalex@gmail.com> writes:
> On Tue, Feb 23, 2010 at 00:50, Alex Hunsaker <badalex@gmail.com> wrote:
>> On Mon, Feb 22, 2010 at 14:31, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>>> I'm inclined to stay with the same basic
>>> implementation and just hack up the regexp some more to cope with 5.11's
>>> more verbose -v output.
>>
>> And here is a stab at that:

> Grr... stupid word wrapping.  Attached.

Looks good, applied.  I did throw in one more [0-9] just to be on the
safe side.

BTW, it's really *not* necessary to include configure in submitted
diffs.  That's a derived file.

            regards, tom lane

Re: BUG #5339: Version of Perl detected incorrectly

From
Tim Bunce
Date:
On Mon, Feb 22, 2010 at 04:31:05PM -0500, Tom Lane wrote:
> Alex Hunsaker <badalex@gmail.com> writes:
> > How about something like the below?
>
> I still think that this is optimizing the wrong thing.  We care about
> the clarity of the message the user sees, not about how short or clean
> the Perl code is.  I'm inclined to stay with the same basic
> implementation and just hack up the regexp some more to cope with 5.11's
> more verbose -v output.

There's no need to try to parse the perl -v output, which is intended
for humans and may change in future.  Using

    perl -e 'print $]'

will give you the version number in floating point format for all
versions of perl. For perl5 the format is 5.xxxyyy so testing
for >= 5.008 (or ideally 5.008001) will work fine.

Tim.

Re: BUG #5339: Version of Perl detected incorrectly

From
Tom Lane
Date:
Tim Bunce <Tim.Bunce@pobox.com> writes:
> On Mon, Feb 22, 2010 at 04:31:05PM -0500, Tom Lane wrote:
>> I still think that this is optimizing the wrong thing.  We care about
>> the clarity of the message the user sees, not about how short or clean
>> the Perl code is.

> There's no need to try to parse the perl -v output, which is intended
> for humans and may change in future.  Using

>     perl -e 'print $]'

will give you the version number in floating point format for all
versions of perl.

$ /usr/local/bin/perl4 -e 'print $]'
$RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
Patch level: 36

I will refrain from further comment.

            regards, tom lane

Re: BUG #5339: Version of Perl detected incorrectly

From
Tim Bunce
Date:
On Tue, Feb 23, 2010 at 04:02:11PM -0500, Tom Lane wrote:
> Tim Bunce <Tim.Bunce@pobox.com> writes:
> > On Mon, Feb 22, 2010 at 04:31:05PM -0500, Tom Lane wrote:
> >> I still think that this is optimizing the wrong thing.  We care about
> >> the clarity of the message the user sees, not about how short or clean
> >> the Perl code is.
>
> > There's no need to try to parse the perl -v output, which is intended
> > for humans and may change in future.  Using
>
> >     perl -e 'print $]'
>
> will give you the version number in floating point format for all
> versions of perl.
>
> $ /usr/local/bin/perl4 -e 'print $]'
> $RCSfile: perl.c,v $$Revision: 4.0.1.8 $$Date: 1993/02/05 19:39:30 $
> Patch level: 36
>
> I will refrain from further comment.

Ah, sorry. It needs to be in numeric context:

    perl -e 'print($]+0)'

Tim.