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

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Re: dead assignment src/bin/scripts/print.c line 421
Дата
Msg-id 55A3D7C0.7010505@iki.fi
обсуждение исходный текст
Ответ на dead assignment src/bin/scripts/print.c line 421  (Laurent Laborde <kerdezixe@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Laurent Laborde
Дата:
Сообщение: Re: dead assignment src/bin/scripts/print.c line 421
Следующее
От: Andrew Dunstan
Дата:
Сообщение: Re: PostgreSQL 9.5 Alpha 1 build fail with perl 5.22