MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / put_dbopt

Function put_dbopt

sql/sql_db.cc:206–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204*/
205
206static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create)
207{
208 my_dbopt_t *opt;
209 uint length;
210 my_bool error= 0;
211 DBUG_ENTER("put_dbopt");
212
213 length= (uint) strlen(dbname);
214
215 mysql_rwlock_wrlock(&LOCK_dboptions);
216 if (!(opt= (my_dbopt_t*) my_hash_search(&dboptions, (uchar*) dbname,
217 length)))
218 {
219 /* Options are not in the hash, insert them */
220 char *tmp_name;
221 if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL),
222 &opt, (uint) sizeof(*opt), &tmp_name, (uint) length+1,
223 NullS))
224 {
225 error= 1;
226 goto end;
227 }
228
229 opt->name= tmp_name;
230 strmov(opt->name, dbname);
231 opt->name_length= length;
232
233 if ((error= my_hash_insert(&dboptions, (uchar*) opt)))
234 {
235 my_free(opt);
236 goto end;
237 }
238 }
239
240 /* Update / write options in hash */
241 opt->charset= create->default_table_charset;
242
243end:
244 mysql_rwlock_unlock(&LOCK_dboptions);
245 DBUG_RETURN(error);
246}
247
248
249/*

Callers 1

load_db_optFunction · 0.85

Calls 5

my_hash_searchFunction · 0.85
my_multi_mallocFunction · 0.85
strmovFunction · 0.85
my_hash_insertFunction · 0.85
my_freeFunction · 0.85

Tested by

no test coverage detected