MCPcopy Create free account
hub / github.com/MariaDB/server / lock_tables_if

Method lock_tables_if

plugin/handler_socket/handlersocket/database.cpp:357–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355}
356
357void
358dbcontext::lock_tables_if()
359{
360 if (lock_failed) {
361 return;
362 }
363 if (for_write_flag && !user_level_lock_locked) {
364 if (user_lock->get_lock()) {
365 user_level_lock_locked = true;
366 } else {
367 lock_failed = true;
368 return;
369 }
370 }
371 if (lock == 0) {
372 const size_t num_max = table_vec.size();
373 TABLE **const tables = DENA_ALLOCA_ALLOCATE(TABLE *, num_max + 1);
374 size_t num_open = 0;
375 for (size_t i = 0; i < num_max; ++i) {
376 if (table_vec[i].refcount > 0) {
377 tables[num_open++] = table_vec[i].table;
378 }
379 table_vec[i].modified = false;
380 }
381 lock = thd->lock = mysql_lock_tables(thd, &tables[0], num_open, 0);
382 statistic_increment(lock_tables_count, &LOCK_status);
383 thd_proc_info(thd, &info_message_buf[0]);
384 DENA_VERBOSE(100, fprintf(stderr, "HNDSOCK lock tables %p %p %zu %zu\n",
385 thd, lock, num_max, num_open));
386 if (lock == 0) {
387 lock_failed = true;
388 DENA_VERBOSE(10, fprintf(stderr, "HNDSOCK failed to lock tables %p\n",
389 thd));
390 }
391 if (for_write_flag) {
392 thd->set_current_stmt_binlog_format_row();
393 }
394 DENA_ALLOCA_FREE(tables);
395 }
396 DBG_LOCK(fprintf(stderr, "HNDSOCK tblnum=%d\n", (int)tblnum));
397}
398
399void
400dbcontext::unlock_tables_if()

Callers

nothing calls this directly

Calls 4

mysql_lock_tablesFunction · 0.85
get_lockMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected