Fix page replace was broken if passed the same page pointer

master
Yury Kurlykov 2019-10-31 03:09:54 +10:00
parent 918a2a0192
commit c914cddcc3
2 changed files with 8 additions and 0 deletions

View File

@ -66,6 +66,10 @@
* @brief No more pages left in the file.
*/
#define YDB_ERR_NO_MORE_PAGES (-12)
/**
* @brief The addresses of pages are the same.
*/
#define YDB_ERR_SAME_PAGE_ADDRESS (-13)
/**
* @brief An unknown error has occurred.
*/

View File

@ -318,6 +318,10 @@ YDB_Error ydb_replace_current_page(YDB_Engine *instance, YDB_TablePage *page) {
THROW_IF_NULL(instance->in_use, YDB_ERR_INSTANCE_NOT_IN_USE);
THROW_IF_NULL(page, YDB_ERR_PAGE_NOT_INITIALIZED);
if (instance->curr_page == page) {
return YDB_ERR_SAME_PAGE_ADDRESS;
}
// Seek to current page in file
fseek(instance->fd, instance->curr_page_offset, SEEK_SET);