270
270
thd->net.vio= save_vio;
275
Execute commands from bootstrap_file.
277
Used when creating the initial grant tables.
280
pthread_handler_t handle_bootstrap(void *arg)
283
FILE *file=bootstrap_file;
285
const char* found_semicolon= NULL;
287
/* The following must be called before DBUG_ENTER */
288
thd->thread_stack= (char*) &thd;
289
if (my_thread_init() || thd->store_globals())
291
close_connection(thd, ER_OUT_OF_RESOURCES, 1);
295
DBUG_ENTER("handle_bootstrap");
297
pthread_detach_this_thread();
298
thd->thread_stack= (char*) &thd;
300
if (thd->variables.max_join_size == HA_POS_ERROR)
301
thd->options |= OPTION_BIG_SELECTS;
303
thd_proc_info(thd, 0);
304
thd->version=refresh_version;
305
thd->security_ctx->priv_user=
306
thd->security_ctx->user= (char*) my_strdup("boot", MYF(MY_WME));
307
thd->security_ctx->priv_host[0]=0;
309
Make the "client" handle multiple results. This is necessary
310
to enable stored procedures with SELECTs and Dynamic SQL
313
thd->client_capabilities|= CLIENT_MULTI_RESULTS;
315
buff= (char*) thd->net.buff;
316
thd->init_for_queries();
317
while (fgets(buff, thd->net.max_packet, file))
319
/* strlen() can't be deleted because fgets() doesn't return length */
320
ulong length= (ulong) strlen(buff);
321
while (buff[length-1] != '\n' && !feof(file))
324
We got only a part of the current string. Will try to increase
325
net buffer then read the rest of the current string.
327
/* purecov: begin tested */
328
if (net_realloc(&(thd->net), 2 * thd->net.max_packet))
330
net_end_statement(thd);
334
buff= (char*) thd->net.buff;
335
fgets(buff + length, thd->net.max_packet - length, file);
336
length+= (ulong) strlen(buff + length);
340
break; /* purecov: inspected */
342
while (length && (my_isspace(thd->charset(), buff[length-1]) ||
343
buff[length-1] == ';'))
347
/* Skip lines starting with delimiter */
348
if (strncmp(buff, STRING_WITH_LEN("delimiter")) == 0)
351
thd->query_length=length;
352
thd->query= (char*) thd->memdup_w_gap(buff, length+1,
354
thd->query[length] = '\0';
355
DBUG_PRINT("query",("%-.4096s",thd->query));
358
We don't need to obtain LOCK_thread_count here because in bootstrap
359
mode we have only one thread.
361
thd->query_id=next_query_id();
363
mysql_parse(thd, thd->query, length, & found_semicolon);
364
close_thread_tables(thd); // Free tables
366
bootstrap_error= thd->is_error();
367
net_end_statement(thd);
372
free_root(thd->mem_root,MYF(MY_KEEP_PREALLOC));
373
free_root(&thd->transaction.mem_root,MYF(MY_KEEP_PREALLOC));
381
(void) pthread_mutex_lock(&LOCK_thread_count);
383
(void) pthread_mutex_unlock(&LOCK_thread_count);
384
(void) pthread_cond_broadcast(&COND_thread_count);
390
/* This works because items are allocated with sql_alloc() */
392
void free_items(Item *item)
395
DBUG_ENTER("free_items");
396
for (; item ; item=next)
404
/* This works because items are allocated with sql_alloc() */
406
void cleanup_items(Item *item)
408
DBUG_ENTER("cleanup_items");
409
for (; item ; item=item->next)
415
274
Ends the current transaction and (maybe) begin the next.