Re: warning handling in Perl scripts

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: David E(dot) Wheeler <david(at)justatheory(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Peter Eisentraut <peter_e(at)gmx(dot)net>, Robert Haas <robertmhaas(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: warning handling in Perl scripts
Date: 2012-06-25 15:51:09
Message-ID: 1340638930-sup-4698@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Excerpts from David E. Wheeler's message of lun jun 25 11:23:34 -0400 2012:
> On Jun 25, 2012, at 3:35 PM, Tom Lane wrote:
>
> > +1 for the concept of turning warnings into errors, but is that really
> > the cleanest, most idiomatic way to do so in Perl? Sheesh.
>
> It’s the most backward-compatible, but the most idiomatic way to do it lexically is:
>
> use warnings 'FATAL';
>
> However, that works only for the current lexical scope. If there are warnings in the code you are calling from the current scope, the use of `local $SIG{__WARN__}` is required.

So lets add 'FATAL' to the already existing "use warnings" lines in
Catalog.pm and genbki.pl.

I think the other files we should add this to are generate-errcodes.pl,
generate-plerrorcodes.pl, generate-spiexceptions.pl, Gen_fmgrtab.pl.
Maybe psql/create_help.pl too.

We have a bunch of files in ECPG and MSVC areas and others in src/tools;
not sure about those.

We also have gen_qsort_tuple.pl which amusingly does not even
use warnings.

--
Álvaro Herrera <alvherre(at)commandprompt(dot)com>
The PostgreSQL Company - Command Prompt, Inc.
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2012-06-25 15:57:36 Re: new --maintenance-db options
Previous Message Tom Lane 2012-06-25 15:50:25 Re: pg_upgrade broken by xlog numbering