~ubuntu-branches/ubuntu/wily/mysql-5.6/wily

« back to all changes in this revision

Viewing changes to storage/perfschema/pfs_events_statements.cc

  • Committer: Package Import Robot
  • Author(s): Marc Deslauriers
  • Date: 2015-04-16 20:07:10 UTC
  • mto: (1.3.9 vivid-proposed)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: package-import@ubuntu.com-20150416200710-pcrsa022082zj46k
Tags: upstream-5.6.24
ImportĀ upstreamĀ versionĀ 5.6.24

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
2
2
 
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;
47
48
 
48
49
/**
49
50
  Initialize table EVENTS_STATEMENTS_HISTORY_LONG.
51
52
*/
52
53
int init_events_statements_history_long(uint events_statements_history_long_sizing)
53
54
{
 
55
  uint index;
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,
63
65
                     MYF(MY_ZEROFILL));
64
66
 
65
 
  return (events_statements_history_long_array ? 0 : 1);
 
67
  if (events_statements_history_long_array == NULL)
 
68
  {
 
69
    cleanup_events_statements_history_long();
 
70
    return 1;
 
71
  }
 
72
 
 
73
  if (pfs_max_digest_length > 0)
 
74
  {
 
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)
 
79
    {
 
80
      cleanup_events_statements_history_long();
 
81
      return 1;
 
82
    }
 
83
  }
 
84
 
 
85
  for (index= 0; index < events_statements_history_long_size; index++)
 
86
  {
 
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);
 
89
  }
 
90
 
 
91
  return 0;
66
92
}
67
93
 
68
94
/** Cleanup table EVENTS_STATEMENTS_HISTORY_LONG. */
69
95
void cleanup_events_statements_history_long(void)
70
96
{
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;
73
101
}
74
102
 
75
103
static inline void copy_events_statements(PFS_events_statements *dest,
76
104
                                      const PFS_events_statements *source)
77
105
{
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));
 
108
 
 
109
  /* Copy DIGEST */
 
110
  dest->m_digest_storage.copy(& source->m_digest_storage);
79
111
}
80
112
 
81
113
/**