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

Method insert

sql/sql_class.cc:4580–4625  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4578*/
4579
4580int Statement_map::insert(THD *thd, Statement *statement)
4581{
4582 if (my_hash_insert(&st_hash, (uchar*) statement))
4583 {
4584 /*
4585 Delete is needed only in case of an insert failure. In all other
4586 cases hash_delete will also delete the statement.
4587 */
4588 delete statement;
4589 my_error(ER_OUT_OF_RESOURCES, MYF(0));
4590 goto err_st_hash;
4591 }
4592 if (statement->name.str && my_hash_insert(&names_hash, (uchar*) statement))
4593 {
4594 my_error(ER_OUT_OF_RESOURCES, MYF(0));
4595 goto err_names_hash;
4596 }
4597 mysql_mutex_lock(&LOCK_prepared_stmt_count);
4598 /*
4599 We don't check that prepared_stmt_count is <= max_prepared_stmt_count
4600 because we would like to allow to lower the total limit
4601 of prepared statements below the current count. In that case
4602 no new statements can be added until prepared_stmt_count drops below
4603 the limit.
4604 */
4605 if (prepared_stmt_count >= max_prepared_stmt_count)
4606 {
4607 mysql_mutex_unlock(&LOCK_prepared_stmt_count);
4608 my_error(ER_MAX_PREPARED_STMT_COUNT_REACHED, MYF(0),
4609 max_prepared_stmt_count);
4610 goto err_max;
4611 }
4612 prepared_stmt_count++;
4613 mysql_mutex_unlock(&LOCK_prepared_stmt_count);
4614
4615 last_found_statement= statement;
4616 return 0;
4617
4618err_max:
4619 if (statement->name.str)
4620 my_hash_delete(&names_hash, (uchar*) statement);
4621err_names_hash:
4622 my_hash_delete(&st_hash, (uchar*) statement);
4623err_st_hash:
4624 return 1;
4625}
4626
4627
4628void Statement_map::close_transient_cursors()

Callers 1

create_thdFunction · 0.45

Calls 3

my_hash_insertFunction · 0.85
my_errorFunction · 0.85
my_hash_deleteFunction · 0.85

Tested by

no test coverage detected