Re: Strange coding in mvdistinct.c

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Strange coding in mvdistinct.c
Дата
Msg-id 30400.1555366344@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Strange coding in mvdistinct.c  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Strange coding in mvdistinct.c  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Re: Strange coding in mvdistinct.c  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Список pgsql-hackers
Oh, and as I continue to grep, I found this in dependencies.c:

            dependencies = (MVDependencies *) repalloc(dependencies,
                                                       offsetof(MVDependencies, deps)
                                                       + dependencies->ndeps * sizeof(MVDependency));

I'm pretty sure this is an actual bug: the calculation should be

                       offsetof(MVDependencies, deps)
                       + dependencies->ndeps * sizeof(MVDependency *));

because deps is an array of MVDependency* not MVDependency.

This would lead to an overallocation not underallocation, and it's
probably pretty harmless because ndeps can't get too large (I hope;
if it could, this would have O(N^2) performance problems).  Still,
you oughta fix it.

(There's a similar calculation later in the file that gets it right.)

            regards, tom lane



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Strange coding in mvdistinct.c
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: Strange coding in mvdistinct.c