forked from mysql/mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic_ids.cc
70 lines (55 loc) · 1.75 KB
/
dynamic_ids.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "dynamic_ids.h"
Server_ids::Server_ids()
: dynamic_ids(PSI_NOT_INSTRUMENTED)
{
}
bool Server_ids::unpack_dynamic_ids(char *param_dynamic_ids)
{
char *token= NULL, *last= NULL;
uint num_items= 0;
DBUG_ENTER("Server_ids::unpack_dynamic_ids");
token= my_strtok_r(param_dynamic_ids, " ", &last);
if (token == NULL)
DBUG_RETURN(TRUE);
num_items= atoi(token);
for (uint i=0; i < num_items; i++)
{
token= my_strtok_r(NULL, " ", &last);
if (token == NULL)
DBUG_RETURN(TRUE);
else
{
ulong val= atol(token);
dynamic_ids.insert_unique(val);
}
}
DBUG_RETURN(FALSE);
}
bool Server_ids::pack_dynamic_ids(String *buffer)
{
DBUG_ENTER("Server_ids::pack_dynamic_ids");
if (buffer->set_int(dynamic_ids.size(), FALSE, &my_charset_bin))
DBUG_RETURN(TRUE);
for (ulong i= 0;
i < dynamic_ids.size(); i++)
{
ulong s_id= dynamic_ids[i];
if (buffer->append(" ") ||
buffer->append_ulonglong(s_id))
DBUG_RETURN(TRUE);
}
DBUG_RETURN(FALSE);
}