att_isnull

Поиск
Список
Период
Сортировка
От Robert Haas
Тема att_isnull
Дата
Msg-id CA+TgmobHOP8r6cG+UnsDFMrS30-m=jRrCBhgw-nFkn0k9QnFsg@mail.gmail.com
обсуждение исходный текст
Ответы Re: att_isnull  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Список pgsql-hackers
Obviously, this macro does not do what it claims to do:

/*
 * check to see if the ATT'th bit of an array of 8-bit bytes is set.
 */
#define att_isnull(ATT, BITS) (!((BITS)[(ATT) >> 3] & (1 << ((ATT) & 0x07))))

OK, I lied.  It's not at all obvious, or at least it wasn't to me.
The macro actually tests whether the bit is *unset*, because there's
an exclamation point in there.  I think the comment should be updated
to something like "Check a tuple's null bitmap to determine whether
the attribute is null.  Note that a 0 in the null bitmap indicates a
null, while 1 indicates non-null."

There is some kind of broader confusion here, I think, because we
refer in many places to the "null bitmap" but it's actually not a
bitmap of which attributes are null but rather of which attributes are
not null.  That is confusing in and of itself, and it's also not very
intuitive that it uses exactly the opposite convention from what we do
with datum/isnull arrays.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pg12 release notes
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: att_isnull