From d1e230d9db0609773f9df48fcccdffb278eac5c6 Mon Sep 17 00:00:00 2001 From: Hugo Wen Date: Tue, 7 May 2024 11:28:21 -0700 Subject: [PATCH] MDEV-34112 Replace one operator name keyword MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Alternative operator name keywords like `and`, `or`, `xor`, etc., are uncommon in MariaDB and can cause obscure build errors when the GCC flag `-fno-operator-names` is applied. Description of `-fno-operator-names`: https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html > Do not treat the operator name keywords `and`, `bitand`, `bitor`, > `compl`, `not`, `or` and `xor` as synonyms as keywords. Part of the build errors: /local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/sql/sql_select.cc:11171:28: error: expected ‘)’ before ‘and’ 11171 | DBUG_ASSERT(sel >= 0.0 and sel <= 1.00001); | ^~~ /local/p4clients/pkgbuild-LdLa_/workspace/src/RDSMariaDB/include/my_global.h:372:44: note: in definition of macro ‘unlikely’ 372 | #define unlikely(x) __builtin_expect(((x) != 0),0) | ^ ... The build failure is caused by using alternative operator name keywords `and` introduced in commit b66cdbd1e. Replace the `and` keyword with `&&` and target on MariaDB 11.0+ branches which include the commit. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- sql/sql_select.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b6039d3e0e6..27e75a5593f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -11125,7 +11125,7 @@ double table_after_join_selectivity(JOIN *join, uint idx, JOIN_TAB *s, else { sel= records_out / pos->records_read; - DBUG_ASSERT(sel >= 0.0 and sel <= 1.00001); + DBUG_ASSERT(sel >= 0.0 && sel <= 1.00001); if (sel > 1.0) sel= 1.0; }