Re: dead assignment src/bin/scripts/print.c line 421

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Laurent Laborde <kerdezixe(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: dead assignment src/bin/scripts/print.c line 421
Date: 2015-07-13 15:22:40
Message-ID: 55A3D7C0.7010505@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2015-07-13 15:36:19 Re: PostgreSQL 9.5 Alpha 1 build fail with perl 5.22
Previous Message Laurent Laborde 2015-07-13 15:11:13 Re: dead assignment src/bin/scripts/print.c line 421