@@ -38,14 +38,18 @@ bool flag_programs= true;
38
38
/* * Current index in Stat array where new record is to be inserted. */
39
39
volatile uint32 program_index= 0 ;
40
40
41
+ /* * Max size of the program array. */
41
42
ulong program_max= 0 ;
43
+ /* * Number of stored program instanes lost. */
42
44
ulong program_lost= 0 ;
45
+ /* * True when program array is full. */
46
+ bool program_full;
43
47
44
48
LF_HASH program_hash;
45
49
static bool program_hash_inited= false ;
46
50
47
51
/* *
48
- Initialize table EVENTS_STATEMENTS_SUMMARY_BY_ROUTINE .
52
+ Initialize table EVENTS_STATEMENTS_SUMMARY_BY_PROGRAM .
49
53
@param param performance schema sizing
50
54
*/
51
55
int init_program (const PFS_global_param *param)
@@ -56,6 +60,7 @@ int init_program(const PFS_global_param *param)
56
60
*/
57
61
program_max= param->m_program_sizing ;
58
62
program_lost= 0 ;
63
+ program_full= false ;
59
64
60
65
if (program_max == 0 )
61
66
return 0 ;
@@ -202,10 +207,18 @@ find_or_create_program(PFS_thread *thread,
202
207
const char *schema_name,
203
208
uint schema_name_length)
204
209
{
210
+ bool is_enabled, is_timed;
211
+
205
212
if (program_array == NULL || program_max == 0 ||
206
213
object_name_length ==0 || schema_name_length == 0 )
207
214
return NULL ;
208
215
216
+ if (program_full)
217
+ {
218
+ program_lost++;
219
+ return NULL ;
220
+ }
221
+
209
222
LF_PINS *pins= get_program_hash_pins (thread);
210
223
if (unlikely (pins == NULL ))
211
224
return NULL ;
@@ -239,6 +252,15 @@ find_or_create_program(PFS_thread *thread,
239
252
240
253
lf_hash_search_unpin (pins);
241
254
255
+ /*
256
+ First time while inserting this record to program array we need to
257
+ find out if it is enabled and timed.
258
+ */
259
+ lookup_setup_object (thread, object_type,
260
+ schema_name, schema_name_length,
261
+ object_name, object_name_length,
262
+ &is_enabled, &is_timed);
263
+
242
264
/* Else create a new record in program stat array. */
243
265
while (++attempts <= program_max)
244
266
{
@@ -258,15 +280,9 @@ find_or_create_program(PFS_thread *thread,
258
280
pfs->m_object_name_length = object_name_length;
259
281
pfs->m_schema_name = pfs->m_object_name + object_name_length + 1 ;
260
282
pfs->m_schema_name_length = schema_name_length;
283
+ pfs->m_enabled = is_enabled;
284
+ pfs->m_timed = is_timed;
261
285
262
- /*
263
- First time while inserting this record to program array we need to
264
- find out if it is enabled and timed.
265
- */
266
- lookup_setup_object (thread, pfs->m_type ,
267
- pfs->m_schema_name , pfs->m_schema_name_length ,
268
- pfs->m_object_name , pfs->m_object_name_length ,
269
- &pfs->m_enabled , &pfs->m_timed );
270
286
271
287
/* Insert this record. */
272
288
int res= lf_hash_insert (&program_hash, pins, &pfs);
@@ -297,6 +313,7 @@ find_or_create_program(PFS_thread *thread,
297
313
}
298
314
}
299
315
program_lost++;
316
+ program_full= true ;
300
317
return NULL ;
301
318
}
302
319
@@ -330,6 +347,7 @@ void drop_program(PFS_thread *thread,
330
347
lf_hash_delete (&program_hash, pins,
331
348
key.m_hash_key , key.m_key_length );
332
349
pfs->m_lock .allocated_to_free ();
350
+ program_full= false ;
333
351
}
334
352
335
353
lf_hash_search_unpin (pins);
0 commit comments