@@ -312,9 +312,8 @@ namespace
312312 const ULONG usedPages = sequence * pageMgr.pagesPerPIP + pipUsed;
313313
314314 const bool allocateExactNumberOfPages = dbb->dbb_flags & DBB_no_reserve;
315- const auto allocatedPages = pageSpace->extend (tdbb, usedPages + initPages, allocateExactNumberOfPages);
316- if (allocatedPages.has_value ())
317- initPages = allocatedPages.value ();
315+ if (const auto allocatedPages = pageSpace->extend (tdbb, usedPages + initPages, allocateExactNumberOfPages))
316+ initPages = allocatedPages;
318317 else
319318 {
320319 // For some reason fast file extension failed, maybe it is not supported by filesystem, or
@@ -1938,7 +1937,7 @@ ULONG PageSpace::usedPages(const Database* dbb)
19381937 return pgSpace->usedPages ();
19391938}
19401939
1941- std::optional< ULONG> PageSpace::extend (thread_db* tdbb, const ULONG pageNum, bool forceSize)
1940+ ULONG PageSpace::extend (thread_db* tdbb, const ULONG pageNum, bool forceSize)
19421941{
19431942/* *************************************
19441943 *
@@ -1958,7 +1957,7 @@ std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, boo
19581957 fb_assert (dbb == tdbb->getDatabase ());
19591958
19601959 if (!PIO_fast_extension_is_supported (*file))
1961- return std:: nullopt ;
1960+ return 0 ;
19621961
19631962 // First, check it with the cached `maxPageNumber` value.
19641963 if (pageNum < maxPageNumber || pageNum < maxAlloc ())
@@ -1989,10 +1988,9 @@ std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, boo
19891988 try
19901989 {
19911990 if (!PIO_extend (tdbb, file, extPages, dbb->dbb_page_size ))
1992- return std:: nullopt ;
1991+ return 0 ;
19931992
1994- // File was extended, reset cached value
1995- maxPageNumber = 0 ;
1993+ maxPageNumber += extPages;
19961994
19971995 return extPages;
19981996 }
@@ -2013,7 +2011,7 @@ std::optional<ULONG> PageSpace::extend(thread_db* tdbb, const ULONG pageNum, boo
20132011 {
20142012 gds__log (" Error extending file \" %s\" by %lu page(s).\n Currently allocated %lu pages, requested page number %lu" ,
20152013 file->fil_string , extPages, maxPageNumber, pageNum);
2016- return std:: nullopt ;
2014+ return 0 ;
20172015 }
20182016 }
20192017 }
0 commit comments