NULL checks of deferenced pointers in picksplit method of intarray

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема NULL checks of deferenced pointers in picksplit method of intarray
Дата
Msg-id CAB7nPqRr+kWGutuFR+OLhZir=81h8MAPoTjw7ijktTNwCi4Q9Q@mail.gmail.com
обсуждение исходный текст
Ответы Re: NULL checks of deferenced pointers in picksplit method of intarray  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-hackers
Hi all,

Coverity is pointing out that _int_split.c has unnecessary checks for
deferenced pointers in 5 places.

-                       if (inter_d != (ArrayType *) NULL)
-                               pfree(inter_d);
+                       pfree(inter_d);
In this case inter_d is generated by inner_int_inter, a routine that
always generates an ArrayType with at least new_intArrayType.

In two places there is as well this pattern:
-                       if (datum_l)
-                               pfree(datum_l);
-                       if (union_dr)
-                               pfree(union_dr);
+                       pfree(datum_l);
+                       pfree(union_dr);
And that one:
-                       if (datum_r)
-                               pfree(datum_r);
-                       if (union_dl)
-                               pfree(union_dl);
+                       pfree(datum_r);
+                       pfree(union_dl);
union_dr and union_dl are generated by inner_int_union which never
returns NULL. Similarly, datum_r and datum_l are created with
copy_intArrayType the first time, which never returns NULL, and their
values are changed at each loop step. Also, as far as I understood
from this code, no elements manipulated are NULL, perhaps this is
worth an assertion?

Attached is a patch to adjust those things.
Regards,
--
Michael

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Performance improvement for joins where outer side is unique
Следующее
От: Sawada Masahiko
Дата:
Сообщение: Re: Proposal: knowing detail of config files via SQL