1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-07 00:04:31 +03:00

move MEM_ROOT::read_only into flags

This commit is contained in:
Sergei Golubchik
2023-11-23 09:56:56 +01:00
parent d1ca8fbb76
commit 69d78cd3f8
4 changed files with 11 additions and 18 deletions

View File

@@ -23,6 +23,8 @@
#define ALLOC_MAX_BLOCK_TO_DROP 4096 #define ALLOC_MAX_BLOCK_TO_DROP 4096
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10 #define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
#define ROOT_FLAG_READ_ONLY 4
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@@ -52,10 +54,6 @@ typedef struct st_mem_root
unsigned short first_block_usage; unsigned short first_block_usage;
unsigned short flags; unsigned short flags;
#ifdef PROTECT_STATEMENT_MEMROOT
int read_only;
#endif
void (*error_handler)(void); void (*error_handler)(void);
const char *name; const char *name;
} MEM_ROOT; } MEM_ROOT;

View File

@@ -24,6 +24,7 @@
#define EXTRA_DEBUG #define EXTRA_DEBUG
#define ROOT_FLAG_THREAD_SPECIFIC 1 #define ROOT_FLAG_THREAD_SPECIFIC 1
#define ROOT_FLAG_READ_ONLY 4
/* data packed in MEM_ROOT -> min_malloc */ /* data packed in MEM_ROOT -> min_malloc */
@@ -74,9 +75,6 @@ void init_alloc_root(MEM_ROOT *mem_root, const char *name, size_t block_size,
mem_root->first_block_usage= 0; mem_root->first_block_usage= 0;
mem_root->total_alloc= 0; mem_root->total_alloc= 0;
mem_root->name= name; mem_root->name= name;
#ifdef PROTECT_STATEMENT_MEMROOT
mem_root->read_only= 0;
#endif
#if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG)) #if !(defined(HAVE_valgrind) && defined(EXTRA_DEBUG))
if (pre_alloc_size) if (pre_alloc_size)
@@ -218,10 +216,7 @@ void *alloc_root(MEM_ROOT *mem_root, size_t length)
DBUG_ENTER("alloc_root"); DBUG_ENTER("alloc_root");
DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name)); DBUG_PRINT("enter",("root: %p name: %s", mem_root, mem_root->name));
DBUG_ASSERT(alloc_root_inited(mem_root)); DBUG_ASSERT(alloc_root_inited(mem_root));
DBUG_ASSERT((mem_root->flags & ROOT_FLAG_READ_ONLY) == 0);
#ifdef PROTECT_STATEMENT_MEMROOT
DBUG_ASSERT(mem_root->read_only == 0);
#endif
DBUG_EXECUTE_IF("simulate_out_of_memory", DBUG_EXECUTE_IF("simulate_out_of_memory",
{ {

View File

@@ -1477,7 +1477,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
{ {
// Don't count a call ended with an error as normal run // Don't count a call ended with an error as normal run
executed_counter= 0; executed_counter= 0;
main_mem_root.read_only= 0; main_mem_root.flags &= ~ROOT_FLAG_READ_ONLY;
reset_instrs_executed_counter(); reset_instrs_executed_counter();
} }
#endif #endif
@@ -1597,10 +1597,10 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
#ifdef PROTECT_STATEMENT_MEMROOT #ifdef PROTECT_STATEMENT_MEMROOT
if (!err_status) if (!err_status)
{ {
if (!main_mem_root.read_only && if (!(main_mem_root.flags & ROOT_FLAG_READ_ONLY) &&
has_all_instrs_executed()) has_all_instrs_executed())
{ {
main_mem_root.read_only= 1; main_mem_root.flags |= ROOT_FLAG_READ_ONLY;
} }
++executed_counter; ++executed_counter;
DBUG_PRINT("info", ("execute counter: %lu", executed_counter)); DBUG_PRINT("info", ("execute counter: %lu", executed_counter));

View File

@@ -176,7 +176,7 @@ public:
/* /*
The following data member is wholly for debugging purpose. The following data member is wholly for debugging purpose.
It can be used for possible crash analysis to determine how many times It can be used for possible crash analysis to determine how many times
the stored routine was executed before the mem_root marked read_only the stored routine was executed before the mem_root marked ROOT_FLAG_READ_ONLY
was requested for a memory chunk. Additionally, a value of this data was requested for a memory chunk. Additionally, a value of this data
member is output to the log with DBUG_PRINT. member is output to the log with DBUG_PRINT.
*/ */
@@ -4489,7 +4489,7 @@ reexecute:
#ifdef PROTECT_STATEMENT_MEMROOT #ifdef PROTECT_STATEMENT_MEMROOT
// There was reprepare so the counter of runs should be reset // There was reprepare so the counter of runs should be reset
executed_counter= 0; executed_counter= 0;
mem_root->read_only= 0; mem_root->flags &= ~ROOT_FLAG_READ_ONLY;
#endif #endif
goto reexecute; goto reexecute;
} }
@@ -4498,7 +4498,7 @@ reexecute:
#ifdef PROTECT_STATEMENT_MEMROOT #ifdef PROTECT_STATEMENT_MEMROOT
if (!error) if (!error)
{ {
mem_root->read_only= 1; mem_root->flags |= ROOT_FLAG_READ_ONLY;
++executed_counter; ++executed_counter;
DBUG_PRINT("info", ("execute counter: %lu", executed_counter)); DBUG_PRINT("info", ("execute counter: %lu", executed_counter));
@@ -4507,7 +4507,7 @@ reexecute:
{ {
// Error on call shouldn't be counted as a normal run // Error on call shouldn't be counted as a normal run
executed_counter= 0; executed_counter= 0;
mem_root->read_only= 0; mem_root->flags &= ~ROOT_FLAG_READ_ONLY;
} }
#endif #endif