Re: dead assignment src/bin/scripts/print.c line 421 - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: dead assignment src/bin/scripts/print.c line 421
Date
Msg-id 55A3D7C0.7010505@iki.fi
Whole thread Raw
In response to dead assignment src/bin/scripts/print.c line 421  (Laurent Laborde <kerdezixe@gmail.com>)
List pgsql-hackers
On 07/13/2015 04:56 PM, Laurent Laborde wrote:
> Friendly greetings !
>
> in file src/bin/scripts/print.c line 421 :
> need_recordsep = false;
> then set to true line 424.
>
> Now i'm pretty sure it's a meaningless "bug" without any consequence (the
> commit that introduced it is 15 years old).
>
> There is a lot of (apparently) dead assignment here and there but some
> assigment could be used for debugging purpose so ... why not. But this one ?

The code in question looks like this:

> for (f = footers; f; f = f->next)
> {
>     if (need_recordsep)
>     {
>         print_separator(cont->opt->recordSep, fout);
>         need_recordsep = false;
>     }
>     fputs(f->data, fout);
>     need_recordsep = true;
> }

Hmm. It does kind of make sense. Right after printing the separator, you 
don't need to print a separator because you just printed one.  But as 
soon as you print the field, you need a separator again. It would be 
quite understandable without that dead assignment too, and that's 
probably how I would've written it in the first place. But since that's 
how it is and has been for 15 years, I'm inclined to just leave it so.

- Heikki



pgsql-hackers by date:

Previous
From: Laurent Laborde
Date:
Subject: Re: dead assignment src/bin/scripts/print.c line 421
Next
From: Andrew Dunstan
Date:
Subject: Re: PostgreSQL 9.5 Alpha 1 build fail with perl 5.22