mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-08-28 09:07:20 +02:00
Change some test macros to return true booleans
These macros work fine when they are used directly in an "if" test or
similar, but as soon as the return values are assigned to boolean
variables (or passed as boolean arguments to some function), they become
bugs, hopefully caught by compiler warnings. To avoid future problems,
fix the definitions so that they return actual booleans.
To further minimize the risk that somebody uses them in back-patched
fixes that only work correctly in branches starting from the current
master and not in old ones, back-patch the change to supported branches
as appropriate.
See also commit af4472bcb8
, and the long
discussion (and larger patch) in the thread mentioned in its commit
message.
Discussion: https://postgr.es/m/18672.1483022414@sss.pgh.pa.us
This commit is contained in:
parent
b21e665f2d
commit
fce4609d5e
@ -237,8 +237,8 @@ struct HeapTupleHeaderData
|
||||
*/
|
||||
#define HEAP_LOCKED_UPGRADED(infomask) \
|
||||
( \
|
||||
((infomask) & HEAP_XMAX_IS_MULTI) && \
|
||||
((infomask) & HEAP_XMAX_LOCK_ONLY) && \
|
||||
((infomask) & HEAP_XMAX_IS_MULTI) != 0 && \
|
||||
((infomask) & HEAP_XMAX_LOCK_ONLY) != 0 && \
|
||||
(((infomask) & (HEAP_XMAX_EXCL_LOCK | HEAP_XMAX_KEYSHR_LOCK)) == 0) \
|
||||
)
|
||||
|
||||
@ -317,7 +317,7 @@ struct HeapTupleHeaderData
|
||||
|
||||
#define HeapTupleHeaderXminCommitted(tup) \
|
||||
( \
|
||||
(tup)->t_infomask & HEAP_XMIN_COMMITTED \
|
||||
((tup)->t_infomask & HEAP_XMIN_COMMITTED) != 0 \
|
||||
)
|
||||
|
||||
#define HeapTupleHeaderXminInvalid(tup) \
|
||||
@ -501,7 +501,7 @@ do { \
|
||||
|
||||
#define HeapTupleHeaderIsHeapOnly(tup) \
|
||||
( \
|
||||
(tup)->t_infomask2 & HEAP_ONLY_TUPLE \
|
||||
((tup)->t_infomask2 & HEAP_ONLY_TUPLE) != 0 \
|
||||
)
|
||||
|
||||
#define HeapTupleHeaderSetHeapOnly(tup) \
|
||||
@ -516,7 +516,7 @@ do { \
|
||||
|
||||
#define HeapTupleHeaderHasMatch(tup) \
|
||||
( \
|
||||
(tup)->t_infomask2 & HEAP_TUPLE_HAS_MATCH \
|
||||
((tup)->t_infomask2 & HEAP_TUPLE_HAS_MATCH) != 0 \
|
||||
)
|
||||
|
||||
#define HeapTupleHeaderSetMatch(tup) \
|
||||
|
Loading…
Reference in New Issue
Block a user