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

Method check

sql/ha_sequence.cc:417–481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417int ha_sequence::check(THD* thd, HA_CHECK_OPT* check_opt)
418{
419 int error= 0;
420 DBUG_ENTER("ha_sequence::check");
421 /* Check the underlying engine */
422 if ((error= file->check(thd, check_opt)))
423 DBUG_RETURN(error);
424 /* Check number of rows */
425 if ((file->table_flags() & HA_STATS_RECORDS_IS_EXACT))
426 {
427 if (file->stats.records > 1)
428 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
429 ER_SEQUENCE_TABLE_HAS_TOO_MANY_ROWS,
430 ER_THD(thd, ER_SEQUENCE_TABLE_HAS_TOO_MANY_ROWS));
431 else if (file->stats.records == 0)
432 {
433 my_error(ER_SEQUENCE_TABLE_HAS_TOO_FEW_ROWS, MYF(0));
434 DBUG_RETURN(HA_ADMIN_CORRUPT);
435 }
436 }
437 else
438 {
439 if (file->ha_rnd_init_with_error(1))
440 DBUG_RETURN(HA_ADMIN_FAILED);
441 if ((error= file->ha_rnd_next(table->record[0])))
442 {
443 file->ha_rnd_end();
444 if (error == HA_ERR_END_OF_FILE)
445 {
446 my_error(ER_SEQUENCE_TABLE_HAS_TOO_FEW_ROWS, MYF(0));
447 DBUG_RETURN(HA_ADMIN_CORRUPT);
448 }
449 file->print_error(error, MYF(0));
450 DBUG_RETURN(HA_ADMIN_FAILED);
451 }
452 if (!file->ha_rnd_next(table->record[0]))
453 push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
454 ER_SEQUENCE_TABLE_HAS_TOO_MANY_ROWS,
455 ER_THD(thd, ER_SEQUENCE_TABLE_HAS_TOO_MANY_ROWS));
456 file->ha_rnd_end();
457 }
458 /*
459 Initialise the sequence from the table if needed.
460 */
461 if (sequence->initialized == SEQUENCE::SEQ_UNINTIALIZED)
462 {
463 if (sequence->read_stored_values(table))
464 DBUG_RETURN(HA_ADMIN_FAILED);
465 else
466 sequence->initialized= SEQUENCE::SEQ_READY_TO_USE;
467 }
468 DBUG_ASSERT(sequence->initialized == SEQUENCE::SEQ_READY_TO_USE);
469 /* Check and adjust sequence state */
470 if (sequence->check_and_adjust(thd, false, /*adjust_next=*/false))
471 {
472 print_error(HA_ERR_SEQUENCE_INVALID_DATA, MYF(0));
473 DBUG_RETURN(HA_ADMIN_CORRUPT);
474 }

Callers

nothing calls this directly

Calls 12

push_warningFunction · 0.85
my_errorFunction · 0.85
push_warning_printfFunction · 0.85
ha_rnd_nextMethod · 0.80
read_stored_valuesMethod · 0.80
check_and_adjustMethod · 0.80
has_run_outMethod · 0.80
print_errorFunction · 0.50
table_flagsMethod · 0.45
ha_rnd_endMethod · 0.45
print_errorMethod · 0.45

Tested by

no test coverage detected