1
/* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
1
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
3
3
This program is free software; you can redistribute it and/or modify
4
4
it under the terms of the GNU General Public License as published by
44
44
volatile uint32 events_statements_history_long_index= 0;
45
45
/** EVENTS_STATEMENTS_HISTORY_LONG circular buffer. */
46
46
PFS_events_statements *events_statements_history_long_array= NULL;
47
static unsigned char *h_long_stmts_digest_token_array= NULL;
49
50
Initialize table EVENTS_STATEMENTS_HISTORY_LONG.
52
53
int init_events_statements_history_long(uint events_statements_history_long_sizing)
54
56
events_statements_history_long_size= events_statements_history_long_sizing;
55
57
events_statements_history_long_full= false;
56
58
PFS_atomic::store_u32(&events_statements_history_long_index, 0);
62
64
PFS_MALLOC_ARRAY(events_statements_history_long_size, PFS_events_statements,
65
return (events_statements_history_long_array ? 0 : 1);
67
if (events_statements_history_long_array == NULL)
69
cleanup_events_statements_history_long();
73
if (pfs_max_digest_length > 0)
75
h_long_stmts_digest_token_array=
76
PFS_MALLOC_ARRAY(events_statements_history_long_size * pfs_max_digest_length,
77
unsigned char, MYF(MY_ZEROFILL));
78
if (h_long_stmts_digest_token_array == NULL)
80
cleanup_events_statements_history_long();
85
for (index= 0; index < events_statements_history_long_size; index++)
87
events_statements_history_long_array[index].m_digest_storage.reset(h_long_stmts_digest_token_array
88
+ index * pfs_max_digest_length, pfs_max_digest_length);
68
94
/** Cleanup table EVENTS_STATEMENTS_HISTORY_LONG. */
69
95
void cleanup_events_statements_history_long(void)
71
97
pfs_free(events_statements_history_long_array);
98
pfs_free(h_long_stmts_digest_token_array);
72
99
events_statements_history_long_array= NULL;
100
h_long_stmts_digest_token_array= NULL;
75
103
static inline void copy_events_statements(PFS_events_statements *dest,
76
104
const PFS_events_statements *source)
78
memcpy(dest, source, sizeof(PFS_events_statements));
106
/* Copy all attributes except DIGEST */
107
memcpy(dest, source, my_offsetof(PFS_events_statements, m_digest_storage));
110
dest->m_digest_storage.copy(& source->m_digest_storage);