diff options
author | Guilhem Bichot <guilhem@mysql.com> | 2008-06-10 16:44:44 +0200 |
---|---|---|
committer | Guilhem Bichot <guilhem@mysql.com> | 2008-06-10 16:44:44 +0200 |
commit | a0aa81f9a81e5d2fdb0170a814cfd57eefa9e915 (patch) | |
tree | 557e914e5db17c04b59e5e70903b9e8fc4ac414c /include/my_global.h | |
parent | f89c61f5bbb45ae056bae0aee20317a019de6f66 (diff) | |
download | mariadb-git-a0aa81f9a81e5d2fdb0170a814cfd57eefa9e915.tar.gz |
Fix for BUG#36319 "Maria: table is not empty but DELETE and SELECT find no rows":
_ma_scan_block_record() has "while (likely(bits))" where bits is ulonglong, so was cast to long
which lost most significant bits (32-bit linux), and test yielded false.
include/my_global.h:
It's too easy to think that because "if (some_longlong)" works as intended, "if (likely(longlong))" will work too,
though it does not. Making likely() cast to bool.
mysql-test/r/maria2.result:
Result. Before fixing the bug, 810 was 812 and 0 was 812 (DELETE and SELECT found no rows
though they were there).
mysql-test/t/maria2.test:
Testcase for the bug. maria.test is huge now, so starting a second test file instead.
Diffstat (limited to 'include/my_global.h')
-rw-r--r-- | include/my_global.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/include/my_global.h b/include/my_global.h index 47f7243e481..34b5a21beb2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -156,9 +156,14 @@ #define __builtin_expect(x, expected_value) (x) #endif -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) - +/** + The semantics of builtin_expect() are that + 1) its two arguments are long + 2) it's likely that they are == + Those of our likely(x) are that x can be bool/int/longlong/pointer. +*/ +#define likely(x) __builtin_expect(((x) != 0),1) +#define unlikely(x) __builtin_expect(((x) != 0),0) /* The macros below are useful in optimising places where it has been |