Re: warning handling in Perl scripts

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: warning handling in Perl scripts
Date: 2012-06-27 14:07:33
Message-ID: 4FEB13A5.8050900@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 06/24/2012 04:05 PM, Robert Haas wrote:
> On Sun, Jun 24, 2012 at 2:40 PM, Peter Eisentraut<peter_e(at)gmx(dot)net> wrote:
>> Every time I make a change to the structure of the catalog files,
>> genbki.pl produces a bunch of warnings (like "Use of uninitialized value
>> in string eq at genbki.pl line ..."), and produces corrupted output
>> files, that are then (possibly) detected later by the compiler. Also,
>> getting out of that is difficult because due to the complicated
>> dependency relationship between the involved files, you need to remove a
>> bunch of files manually, or clean everything. So error handling could
>> be better.
>>
>> It seems that adding
>>
>> diff --git a/src/backend/catalog/genbki.pl b/src/backend/catalog/genbki.pl
>> index ebc4825..7d66da9 100644
>> --- a/src/backend/catalog/genbki.pl
>> +++ b/src/backend/catalog/genbki.pl
>> @@ -19,6 +19,8 @@
>> use strict;
>> use warnings;
>>
>> +local $SIG{__WARN__} = sub { die $_[0] };
>> +
>> my @input_files;
>> our @include_path;
>> my $output_path = '';
>>
>> would address that.
>>
>> Could that cause any other problems? Should it be added to all Perl
>> scripts?
> This seems like a band-aid. How about if we instead add whatever
> error-handling the script is missing, so that it produces an
> appropriate, human-readable error message?

I realise I'm late to this party, but I'm with Robert. The root cause of
the errors should be fixed.

That's not to say that making warnings fatal might not also be a good
idea as a general defense mechanism.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2012-06-27 14:14:29 Regarding WAL Format Changes
Previous Message Magnus Hagander 2012-06-27 14:06:56 Re: Posix Shared Mem patch