Re: heapgettup() with NoMovementScanDirection unused in core?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: heapgettup() with NoMovementScanDirection unused in core?
Дата
Msg-id 3584648.1674861350@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: heapgettup() with NoMovementScanDirection unused in core?  (Melanie Plageman <melanieplageman@gmail.com>)
Ответы Re: heapgettup() with NoMovementScanDirection unused in core?  (David Rowley <dgrowleyml@gmail.com>)
Список pgsql-hackers
Melanie Plageman <melanieplageman@gmail.com> writes:
> On Fri, Jan 27, 2023 at 05:05:16PM -0500, Tom Lane wrote:
>> AFAIR, there is noplace today that depends on the exact encoding
>> of ForwardScanDirection and BackwardScanDirection, and I'm not
>> sure that we want to introduce such a dependency.

> I think you mean the enum value when you say encoding? I actually
> started using the ScanDirection value in the refactor of heapgettup()
> and heapgettup_pagemode() which I proposed here [1]. Why wouldn't we
> want to introduce such a dependency?

It's just that in general, depending on the numeric values of an
enum isn't a great coding practice.

After thinking about it for awhile, I'd be happier if we added
something like this to sdir.h, and then used it rather than
directly depending on multiplication:

/*
 * Determine the net effect of two direction specifications.
 * This relies on having ForwardScanDirection = +1, BackwardScanDirection = -1,
 * and will probably not do what you want if applied to any other values.
 */
#define CombineScanDirections(a, b)  ((a) * (b))

The main thing this'd buy us is being able to grep for uses of the
trick.  If it's written as just multiplication, good luck being
able to find what's depending on that, should you ever need to.

>> 4. I don't think the proposed test case is worth the cycles.

> Just the one I wrote or any test case?

I think that all this code is quite well-tested already, so I'm
not sure what's the point of adding another test for it.

            regards, tom lane



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

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: Re: improving user.c error messages
Следующее
От: Corey Huinker
Дата:
Сообщение: Add n_tup_newpage_upd to pg_stat table views