summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorEugene Kosov <claprix@yandex.ru>2019-04-25 16:29:55 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2019-04-25 16:29:55 +0300
commit6c5c1f0b2fc71ab7e90dc7798180135e7967a264 (patch)
treee12f852c318eea21e71c5f68148eff76aa86c3c2 /extra
parentbc145193c164b895a52b943e73fff53952d48a60 (diff)
downloadmariadb-git-6c5c1f0b2fc71ab7e90dc7798180135e7967a264.tar.gz
MDEV-19231 make DB_SUCCESS equal to 0
It's a micro optimization. On most platforms CPUs has instructions to compare with 0 fast. DB_SUCCESS is the most popular outcome of functions and this patch optimized code like (err == DB_SUCCESS) BtrBulk::finish(): bogus assertion fixed fil_node_t::read_page0(): corrected usage of os_file_read() que_eval_sql(): bugus assertion removed. Apparently it checked that the field was assigned after having been zero-initialized at object creation. It turns out that the return type of os_file_read_func() was changed in mysql/mysql-server@98909cefbc37e54efc6452c7e95bccbf64ac9213 (MySQL 5.7) from ibool to dberr_t. The reviewer (if there was any) failed to point out that because of future merges, it could be a bad idea to change the return type of a function without changing the function name. This change was applied to MariaDB 10.2.2 in commit 2e814d4702d71a04388386a9f591d14a35980bfe but the MariaDB-specific code was not fully adjusted accordingly, e.g. in fil_node_open_file(). Essentially, code like !os_file_read(...) became dead code in MariaDB and later in Mariabackup 10.2, and we could be dealing with an uninitialized buffer after a failed page read.
Diffstat (limited to 'extra')
-rw-r--r--extra/mariabackup/backup_copy.cc4
-rw-r--r--extra/mariabackup/changed_page_bitmap.cc2
-rw-r--r--extra/mariabackup/fil_cur.cc6
-rw-r--r--extra/mariabackup/xtrabackup.cc12
4 files changed, 12 insertions, 12 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc
index 30ec5539c2d..fa665a798ac 100644
--- a/extra/mariabackup/backup_copy.cc
+++ b/extra/mariabackup/backup_copy.cc
@@ -559,9 +559,9 @@ datafile_read(datafile_cur_t *cursor)
return(XB_FIL_CUR_EOF);
}
- if (!os_file_read(IORequestRead,
+ if (os_file_read(IORequestRead,
cursor->file, cursor->buf, cursor->buf_offset,
- to_read)) {
+ to_read) != DB_SUCCESS) {
return(XB_FIL_CUR_ERROR);
}
diff --git a/extra/mariabackup/changed_page_bitmap.cc b/extra/mariabackup/changed_page_bitmap.cc
index f6e9812b0c5..a21c498527a 100644
--- a/extra/mariabackup/changed_page_bitmap.cc
+++ b/extra/mariabackup/changed_page_bitmap.cc
@@ -195,7 +195,7 @@ log_online_read_bitmap_page(
ut_a(bitmap_file->offset % MODIFIED_PAGE_BLOCK_SIZE == 0);
success = os_file_read(IORequestRead,
bitmap_file->file, page, bitmap_file->offset,
- MODIFIED_PAGE_BLOCK_SIZE);
+ MODIFIED_PAGE_BLOCK_SIZE) == DB_SUCCESS;
if (UNIV_UNLIKELY(!success)) {
diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc
index fd5e1bc02dd..b5e7ba6a83e 100644
--- a/extra/mariabackup/fil_cur.cc
+++ b/extra/mariabackup/fil_cur.cc
@@ -253,7 +253,7 @@ xb_fil_cur_open(
if (!node->space->crypt_data
&& os_file_read(IORequestRead,
node->handle, cursor->buf, 0,
- page_size.physical())) {
+ page_size.physical()) == DB_SUCCESS) {
mutex_enter(&fil_system->mutex);
if (!node->space->crypt_data) {
node->space->crypt_data
@@ -442,8 +442,8 @@ read_retry:
cursor->buf_offset = offset;
cursor->buf_page_no = (ulint)(offset / page_size);
- if (!os_file_read(IORequestRead, cursor->file, cursor->buf, offset,
- (ulint) to_read)) {
+ if (os_file_read(IORequestRead, cursor->file, cursor->buf, offset,
+ (ulint) to_read) != DB_SUCCESS) {
ret = XB_FIL_CUR_ERROR;
goto func_exit;
}
diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc
index 4b6ba960c05..07d21029733 100644
--- a/extra/mariabackup/xtrabackup.cc
+++ b/extra/mariabackup/xtrabackup.cc
@@ -3302,8 +3302,8 @@ static dberr_t xb_assign_undo_space_start()
page = static_cast<byte*>(ut_align(buf, UNIV_PAGE_SIZE));
retry:
- if (!os_file_read(IORequestRead, file, page, TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE,
- UNIV_PAGE_SIZE)) {
+ if (os_file_read(IORequestRead, file, page, TRX_SYS_PAGE_NO * UNIV_PAGE_SIZE,
+ UNIV_PAGE_SIZE) != DB_SUCCESS) {
msg("Reading TRX_SYS page failed.");
error = DB_ERROR;
goto func_exit;
@@ -4655,7 +4655,7 @@ xb_space_create_file(
free(buf);
- if (!ret) {
+ if (ret != DB_SUCCESS) {
msg("mariabackup: could not write the first page to %s",
path);
os_file_close(*file);
@@ -4947,7 +4947,7 @@ xtrabackup_apply_delta(
<< page_size_shift);
success = os_file_read(IORequestRead, src_file,
incremental_buffer, offset, page_size);
- if (!success) {
+ if (success != DB_SUCCESS) {
goto error;
}
@@ -4980,7 +4980,7 @@ xtrabackup_apply_delta(
success = os_file_read(IORequestRead, src_file,
incremental_buffer,
offset, page_in_buffer * page_size);
- if (!success) {
+ if (success != DB_SUCCESS) {
goto error;
}
@@ -5029,7 +5029,7 @@ xtrabackup_apply_delta(
success = os_file_write(IORequestWrite,
dst_path, dst_file, buf, off, page_size);
- if (!success) {
+ if (success != DB_SUCCESS) {
goto error;
}
}