8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 17:23:03 +01:00

The ability to retrieve the total number of pages in the database, the (#7888)

number of pages in use, and the number of free pages via the
GET_CONTEXT.

Co-authored-by: Daniil <daniil@localhost.localdomain>
This commit is contained in:
Danuul3 2023-11-29 16:49:54 +03:00 committed by GitHub
parent 12f5664e4b
commit cf4d9d98f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -142,6 +142,12 @@ Usage:
|
DECFLOAT_TRAPS | Exceptional conditions in operations with DECFLOAT
| values that cause a trap.
|
PAGES_ALLOCATED | Current value of allocated pages in the database.
|
PAGES_USED | Current value of allocated pages in the database.
|
PAGES_FREE | Current value of free pages in the database.
Notes:
To prevent DoS attacks against Firebird Server you are not allowed to have

View File

@ -432,6 +432,12 @@ static const char
FALSE_VALUE[] = "FALSE",
TRUE_VALUE[] = "TRUE";
// Get pages
const char
PAGES_ALLOCATED[] = "PAGES_ALLOCATED",
PAGES_USED[] = "PAGES_USED",
PAGES_FREE[] = "PAGES_FREE";
double fbcot(double value) noexcept
{
@ -4583,6 +4589,18 @@ dsc* evlGetContext(thread_db* tdbb, const SysFunction*, const NestValueArray& ar
GuidToString(guidBuffer, &dbb->dbb_guid);
resultStr = string(guidBuffer);
}
else if (nameStr == PAGES_ALLOCATED)
{
resultStr.printf("%" ULONGFORMAT, PageSpace::actAlloc(dbb));
}
else if (nameStr == PAGES_USED)
{
resultStr.printf("%" ULONGFORMAT, PageSpace::usedPages(dbb));
}
else if (nameStr == PAGES_FREE)
{
resultStr.printf("%" ULONGFORMAT, PageSpace::maxAlloc(dbb) - PageSpace::usedPages(dbb));
}
else if (nameStr == DATABASE_FILE_ID)
{
resultStr = dbb->getUniqueFileId();