1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

memroot improvement: fix savepoint support

savepoint support was added a year ago as get_last_memroot_block()
and free_all_new_blocks(), but it didn't work and was disabled.

* fix it to work
* instead of freeing the memory, only mark blocks free - this feature
  is supposed to be used inside a loop (otherwise there is no need
  to free anything, end of statement will do it anyway). And freeing
  blocks inside a loop is a bad idea, as they'll be all malloc-ed
  on the next iteration again. So, don't.
* fix a bug in mark_blocks_free() - it doesn't change the number of blocks
This commit is contained in:
Sergei Golubchik
2024-09-26 11:52:05 +02:00
parent 4f4c5a2ba9
commit 9f2adffcca
4 changed files with 63 additions and 40 deletions

View File

@@ -60,6 +60,14 @@ typedef struct st_mem_root
PSI_memory_key psi_key;
} MEM_ROOT;
typedef struct st_mem_root_savepoint
{
MEM_ROOT *root;
USED_MEM *free;
USED_MEM *used;
unsigned short first_block_usage;
} MEM_ROOT_SAVEPOINT;
#ifdef __cplusplus
}
#endif