21 #include "my_global.h"
48 static bool setup_actor_hash_inited=
false;
59 setup_actor_array= NULL;
65 if (unlikely(setup_actor_array == NULL))
76 setup_actor_array= NULL;
81 static uchar *setup_actor_hash_get_key(
const uchar *
entry,
size_t *length,
88 DBUG_ASSERT(typed_entry != NULL);
89 setup_actor= *typed_entry;
90 DBUG_ASSERT(setup_actor != NULL);
93 return const_cast<uchar*
> (
reinterpret_cast<const uchar*
> (result));
105 lf_hash_init(&setup_actor_hash,
sizeof(
PFS_setup_actor*), LF_HASH_UNIQUE,
106 0, 0, setup_actor_hash_get_key, &my_charset_bin);
108 setup_actor_hash_inited=
true;
116 if (setup_actor_hash_inited)
118 lf_hash_destroy(&setup_actor_hash);
119 setup_actor_hash_inited=
false;
127 if (! setup_actor_hash_inited)
135 const char *user, uint user_length,
136 const char *host, uint host_length,
137 const char *role, uint role_length)
139 DBUG_ASSERT(user_length <= USERNAME_LENGTH);
140 DBUG_ASSERT(host_length <= HOSTNAME_LENGTH);
143 memcpy(ptr, user, user_length);
147 memcpy(ptr, host, host_length);
151 memcpy(ptr, role, role_length);
161 return HA_ERR_RECORD_FILE_FULL;
163 PFS_thread *thread= PFS_thread::get_current_thread();
164 if (unlikely(thread == NULL))
165 return HA_ERR_OUT_OF_MEM;
167 LF_PINS *pins= get_setup_actor_hash_pins(thread);
168 if (unlikely(pins == NULL))
169 return HA_ERR_OUT_OF_MEM;
171 static uint PFS_ALIGNED setup_actor_monotonic_index= 0;
180 pfs= setup_actor_array +
index;
186 set_setup_actor_key(&pfs->
m_key,
187 user->ptr(), user->length(),
188 host->ptr(), host->length(),
189 role->ptr(), role->length());
198 res= lf_hash_insert(&setup_actor_hash, pins, &pfs);
199 if (likely(res == 0))
207 return HA_ERR_FOUND_DUPP_KEY;
208 return HA_ERR_OUT_OF_MEM;
213 return HA_ERR_RECORD_FILE_FULL;
218 PFS_thread *thread= PFS_thread::get_current_thread();
219 if (unlikely(thread == NULL))
220 return HA_ERR_OUT_OF_MEM;
222 LF_PINS* pins= get_setup_actor_hash_pins(thread);
223 if (unlikely(pins == NULL))
224 return HA_ERR_OUT_OF_MEM;
227 set_setup_actor_key(&key,
228 user->ptr(), user->length(),
229 host->ptr(), host->length(),
230 role->ptr(), role->length());
236 if (entry && (entry != MY_ERRPTR))
243 lf_hash_search_unpin(pins);
248 int reset_setup_actor()
250 PFS_thread *thread= PFS_thread::get_current_thread();
251 if (unlikely(thread == NULL))
252 return HA_ERR_OUT_OF_MEM;
254 LF_PINS* pins= get_setup_actor_hash_pins(thread);
255 if (unlikely(pins == NULL))
256 return HA_ERR_OUT_OF_MEM;
261 for ( ; pfs < pfs_last; pfs++)
265 lf_hash_delete(&setup_actor_hash, pins,
274 long setup_actor_count()
276 return setup_actor_hash.count;
285 const char *user, uint user_length,
286 const char *host, uint host_length,
293 LF_PINS* pins= get_setup_actor_hash_pins(thread);
294 if (unlikely(pins == NULL))
300 for (i= 1; i<=4; i++)
309 set_setup_actor_key(&key, user, user_length, host, host_length,
"%", 1);
312 set_setup_actor_key(&key, user, user_length,
"%", 1,
"%", 1);
315 set_setup_actor_key(&key,
"%", 1, host, host_length,
"%", 1);
318 set_setup_actor_key(&key,
"%", 1,
"%", 1,
"%", 1);
324 if (entry && (entry != MY_ERRPTR))
326 lf_hash_search_unpin(pins);
331 lf_hash_search_unpin(pins);