175
175
static char* innodb_version_str = (char*) INNODB_VERSION_STR;
177
/** Possible values for system variable "innodb_stats_method". The values
178
are defined the same as its corresponding MyISAM system variable
179
"myisam_stats_method"(see "myisam_stats_method_names"), for better usability */
180
static const char* innodb_stats_method_names[] = {
187
/** Used to define an enumerate type of the system variable innodb_stats_method.
188
This is the same as "myisam_stats_method_typelib" */
189
static TYPELIB innodb_stats_method_typelib = {
190
array_elements(innodb_stats_method_names) - 1,
191
"innodb_stats_method_typelib",
192
innodb_stats_method_names,
177
196
/* The following counter is used to convey information to InnoDB
178
197
about server activity: in selects it is not sensible to call
179
198
srv_active_wake_master_thread after each fetch or search, we only do
3347
3381
err = row_search_max_autoinc(index, col_name, &read_auto_inc);
3385
ulonglong col_max_value;
3387
col_max_value = innobase_get_int_col_max_value(field);
3351
3389
/* At the this stage we do not know the increment
3352
or the offset, so use a default increment of 1. */
3353
auto_inc = read_auto_inc + 1;
3390
nor the offset, so use a default increment of 1. */
3392
auto_inc = innobase_next_autoinc(
3393
read_auto_inc, 1, 1, col_max_value);
3356
3397
case DB_RECORD_NOT_FOUND:
3357
3398
ut_print_timestamp(stderr);
3358
3399
fprintf(stderr, " InnoDB: MySQL and InnoDB data "
3753
/**************************************************************//**
3754
Sets a field in a record to SQL NULL. Uses the record format
3755
information in table to track the null bit in record. */
3758
set_field_in_record_to_null(
3759
/*========================*/
3760
TABLE* table, /*!< in: MySQL table object */
3761
Field* field, /*!< in: MySQL field object */
3762
char* record) /*!< in: a row in MySQL format */
3766
null_offset = (uint) ((char*) field->null_ptr
3767
- (char*) table->record[0]);
3769
record[null_offset] = record[null_offset] | field->null_bit;
3772
3794
/*************************************************************//**
3773
3795
InnoDB uses this function to compare two data fields for which the data type
3774
3796
is such that we must use MySQL code to compare them. NOTE that the prototype
6273
6301
/*****************************************************************//**
6302
Return a display name for the row format
6303
@return row format name */
6306
get_row_format_name(
6307
/*================*/
6308
enum row_type row_format) /*!< in: Row Format */
6310
switch (row_format) {
6311
case ROW_TYPE_COMPACT:
6313
case ROW_TYPE_COMPRESSED:
6314
return("COMPRESSED");
6315
case ROW_TYPE_DYNAMIC:
6317
case ROW_TYPE_REDUNDANT:
6318
return("REDUNDANT");
6319
case ROW_TYPE_DEFAULT:
6321
case ROW_TYPE_FIXED:
6324
case ROW_TYPE_NOT_USED:
6330
/** If file-per-table is missing, issue warning and set ret false */
6331
#define CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE \
6332
if (!srv_file_per_table) { \
6333
push_warning_printf( \
6334
thd, MYSQL_ERROR::WARN_LEVEL_WARN, \
6335
ER_ILLEGAL_HA_CREATE_OPTION, \
6336
"InnoDB: ROW_FORMAT=%s requires" \
6337
" innodb_file_per_table.", \
6338
get_row_format_name(row_format)); \
6342
/** If file-format is Antelope, issue warning and set ret false */
6343
#define CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE \
6344
if (srv_file_format < DICT_TF_FORMAT_ZIP) { \
6345
push_warning_printf( \
6346
thd, MYSQL_ERROR::WARN_LEVEL_WARN, \
6347
ER_ILLEGAL_HA_CREATE_OPTION, \
6348
"InnoDB: ROW_FORMAT=%s requires" \
6349
" innodb_file_format > Antelope.", \
6350
get_row_format_name(row_format)); \
6355
/*****************************************************************//**
6274
6356
Validates the create options. We may build on this function
6275
6357
in future. For now, it checks two specifiers:
6276
6358
KEY_BLOCK_SIZE and ROW_FORMAT
6316
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6317
ER_ILLEGAL_HA_CREATE_OPTION,
6319
" KEY_BLOCK_SIZE = %lu."
6321
" [1, 2, 4, 8, 16]",
6322
create_info->key_block_size);
6327
/* If KEY_BLOCK_SIZE was specified, check for its
6329
if (kbs_specified && !srv_file_per_table) {
6330
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6331
ER_ILLEGAL_HA_CREATE_OPTION,
6332
"InnoDB: KEY_BLOCK_SIZE"
6333
" requires innodb_file_per_table.");
6337
if (kbs_specified && srv_file_format < DICT_TF_FORMAT_ZIP) {
6338
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6339
ER_ILLEGAL_HA_CREATE_OPTION,
6340
"InnoDB: KEY_BLOCK_SIZE"
6341
" requires innodb_file_format >"
6346
/* Now check for ROW_FORMAT specifier. */
6347
if (create_info->used_fields & HA_CREATE_USED_ROW_FORMAT) {
6348
switch (form->s->row_type) {
6349
const char* row_format_name;
6350
case ROW_TYPE_COMPRESSED:
6351
case ROW_TYPE_DYNAMIC:
6353
= form->s->row_type == ROW_TYPE_COMPRESSED
6357
/* These two ROW_FORMATs require
6358
srv_file_per_table and srv_file_format */
6393
/* Valid KEY_BLOCK_SIZE, check its dependencies. */
6359
6394
if (!srv_file_per_table) {
6360
push_warning_printf(
6362
MYSQL_ERROR::WARN_LEVEL_WARN,
6396
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6363
6397
ER_ILLEGAL_HA_CREATE_OPTION,
6364
"InnoDB: ROW_FORMAT=%s"
6365
" requires innodb_file_per_table.",
6398
"InnoDB: KEY_BLOCK_SIZE requires"
6399
" innodb_file_per_table.");
6371
6402
if (srv_file_format < DICT_TF_FORMAT_ZIP) {
6372
push_warning_printf(
6374
MYSQL_ERROR::WARN_LEVEL_WARN,
6375
ER_ILLEGAL_HA_CREATE_OPTION,
6376
"InnoDB: ROW_FORMAT=%s"
6377
" requires innodb_file_format >"
6383
/* Cannot specify KEY_BLOCK_SIZE with
6384
ROW_FORMAT = DYNAMIC.
6385
However, we do allow COMPRESSED to be
6386
specified with KEY_BLOCK_SIZE. */
6388
&& form->s->row_type == ROW_TYPE_DYNAMIC) {
6389
push_warning_printf(
6391
MYSQL_ERROR::WARN_LEVEL_WARN,
6392
ER_ILLEGAL_HA_CREATE_OPTION,
6393
"InnoDB: cannot specify"
6394
" ROW_FORMAT = DYNAMIC with"
6395
" KEY_BLOCK_SIZE.");
6401
case ROW_TYPE_REDUNDANT:
6402
case ROW_TYPE_COMPACT:
6403
case ROW_TYPE_DEFAULT:
6404
/* Default is COMPACT. */
6406
= form->s->row_type == ROW_TYPE_REDUNDANT
6410
/* Cannot specify KEY_BLOCK_SIZE with these
6411
format specifiers. */
6412
if (kbs_specified) {
6413
push_warning_printf(
6415
MYSQL_ERROR::WARN_LEVEL_WARN,
6416
ER_ILLEGAL_HA_CREATE_OPTION,
6417
"InnoDB: cannot specify"
6418
" ROW_FORMAT = %s with"
6404
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6405
ER_ILLEGAL_HA_CREATE_OPTION,
6406
"InnoDB: KEY_BLOCK_SIZE requires"
6407
" innodb_file_format > Antelope.");
6428
MYSQL_ERROR::WARN_LEVEL_WARN,
6429
ER_ILLEGAL_HA_CREATE_OPTION,
6430
"InnoDB: invalid ROW_FORMAT specifier.");
6412
push_warning_printf(
6413
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6414
ER_ILLEGAL_HA_CREATE_OPTION,
6415
"InnoDB: invalid KEY_BLOCK_SIZE = %lu."
6416
" Valid values are [1, 2, 4, 8, 16]",
6417
create_info->key_block_size);
6423
/* Check for a valid Innodb ROW_FORMAT specifier and
6424
other incompatibilities. */
6425
switch (row_format) {
6426
case ROW_TYPE_COMPRESSED:
6427
CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE;
6428
CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE;
6430
case ROW_TYPE_DYNAMIC:
6431
CHECK_ERROR_ROW_TYPE_NEEDS_FILE_PER_TABLE;
6432
CHECK_ERROR_ROW_TYPE_NEEDS_GT_ANTELOPE;
6433
/* fall through since dynamic also shuns KBS */
6434
case ROW_TYPE_COMPACT:
6435
case ROW_TYPE_REDUNDANT:
6436
if (kbs_specified) {
6437
push_warning_printf(
6438
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6439
ER_ILLEGAL_HA_CREATE_OPTION,
6440
"InnoDB: cannot specify ROW_FORMAT = %s"
6441
" with KEY_BLOCK_SIZE.",
6442
get_row_format_name(row_format));
6446
case ROW_TYPE_DEFAULT:
6448
case ROW_TYPE_FIXED:
6450
case ROW_TYPE_NOT_USED:
6452
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6453
ER_ILLEGAL_HA_CREATE_OPTION, \
6454
"InnoDB: invalid ROW_FORMAT specifier.");
6518
6541
DBUG_RETURN(HA_ERR_TO_BIG_ROW);
6521
/* Get the transaction associated with the current thd, or create one
6522
if not yet created */
6524
parent_trx = check_trx_exists(thd);
6526
/* In case MySQL calls this in the middle of a SELECT query, release
6527
possible adaptive hash latch to avoid deadlocks of threads */
6529
trx_search_latch_release_if_reserved(parent_trx);
6531
trx = innobase_trx_allocate(thd);
6533
if (lower_case_table_names) {
6534
srv_lower_case_table_names = TRUE;
6536
srv_lower_case_table_names = FALSE;
6539
6544
strcpy(name2, name);
6541
6546
normalize_table_name(norm_name, name2);
6543
/* Latch the InnoDB data dictionary exclusively so that no deadlocks
6544
or lock waits can happen in it during a table create operation.
6545
Drop table etc. do this latching in row0mysql.c. */
6547
row_mysql_lock_data_dictionary(trx);
6549
6548
/* Create the table definition in InnoDB */
6553
6552
/* Validate create options if innodb_strict_mode is set. */
6554
6553
if (!create_options_are_valid(thd, form, create_info)) {
6555
error = ER_ILLEGAL_HA_CREATE_OPTION;
6554
DBUG_RETURN(ER_ILLEGAL_HA_CREATE_OPTION);
6559
if (create_info->key_block_size
6560
|| (create_info->used_fields & HA_CREATE_USED_KEY_BLOCK_SIZE)) {
6557
if (create_info->key_block_size) {
6561
6558
/* Determine the page_zip.ssize corresponding to the
6562
6559
requested page size (key_block_size) in kilobytes. */
6564
6561
ulint ssize, ksize;
6565
6562
ulint key_block_size = create_info->key_block_size;
6564
/* Set 'flags' to the correct key_block_size.
6565
It will be zero if key_block_size is an invalid number.*/
6567
6566
for (ssize = ksize = 1; ssize <= DICT_TF_ZSSIZE_MAX;
6568
6567
ssize++, ksize <<= 1) {
6569
6568
if (key_block_size == ksize) {
6578
6577
if (!srv_file_per_table) {
6579
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6580
ER_ILLEGAL_HA_CREATE_OPTION,
6581
"InnoDB: KEY_BLOCK_SIZE"
6582
" requires innodb_file_per_table.");
6579
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6580
ER_ILLEGAL_HA_CREATE_OPTION,
6581
"InnoDB: KEY_BLOCK_SIZE requires"
6582
" innodb_file_per_table.");
6586
6586
if (file_format < DICT_TF_FORMAT_ZIP) {
6587
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6588
ER_ILLEGAL_HA_CREATE_OPTION,
6589
"InnoDB: KEY_BLOCK_SIZE"
6590
" requires innodb_file_format >"
6588
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6589
ER_ILLEGAL_HA_CREATE_OPTION,
6590
"InnoDB: KEY_BLOCK_SIZE requires"
6591
" innodb_file_format > Antelope.");
6596
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6597
ER_ILLEGAL_HA_CREATE_OPTION,
6599
" KEY_BLOCK_SIZE=%lu.",
6600
create_info->key_block_size);
6596
push_warning_printf(
6597
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6598
ER_ILLEGAL_HA_CREATE_OPTION,
6599
"InnoDB: ignoring KEY_BLOCK_SIZE=%lu.",
6600
create_info->key_block_size);
6604
row_type = form->s->row_type;
6604
row_format = form->s->row_type;
6607
/* KEY_BLOCK_SIZE was specified. */
6608
if (!(create_info->used_fields & HA_CREATE_USED_ROW_FORMAT)) {
6609
/* ROW_FORMAT was not specified;
6610
default to ROW_FORMAT=COMPRESSED */
6611
row_type = ROW_TYPE_COMPRESSED;
6612
} else if (row_type != ROW_TYPE_COMPRESSED) {
6607
/* if ROW_FORMAT is set to default,
6608
automatically change it to COMPRESSED.*/
6609
if (row_format == ROW_TYPE_DEFAULT) {
6610
row_format = ROW_TYPE_COMPRESSED;
6611
} else if (row_format != ROW_TYPE_COMPRESSED) {
6613
6612
/* ROW_FORMAT other than COMPRESSED
6614
6613
ignores KEY_BLOCK_SIZE. It does not
6615
6614
make sense to reject conflicting
6646
const char* row_format_name;
6643
switch (row_format) {
6647
6644
case ROW_TYPE_REDUNDANT:
6649
6646
case ROW_TYPE_COMPRESSED:
6650
6647
case ROW_TYPE_DYNAMIC:
6652
= row_type == ROW_TYPE_COMPRESSED
6656
6648
if (!srv_file_per_table) {
6657
6649
push_warning_printf(
6659
MYSQL_ERROR::WARN_LEVEL_WARN,
6650
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6660
6651
ER_ILLEGAL_HA_CREATE_OPTION,
6661
"InnoDB: ROW_FORMAT=%s"
6662
" requires innodb_file_per_table.",
6652
"InnoDB: ROW_FORMAT=%s requires"
6653
" innodb_file_per_table.",
6654
get_row_format_name(row_format));
6664
6655
} else if (file_format < DICT_TF_FORMAT_ZIP) {
6665
6656
push_warning_printf(
6667
MYSQL_ERROR::WARN_LEVEL_WARN,
6657
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6668
6658
ER_ILLEGAL_HA_CREATE_OPTION,
6669
"InnoDB: ROW_FORMAT=%s"
6670
" requires innodb_file_format >"
6659
"InnoDB: ROW_FORMAT=%s requires"
6660
" innodb_file_format > Antelope.",
6661
get_row_format_name(row_format));
6674
6663
flags |= DICT_TF_COMPACT
6675
| (DICT_TF_FORMAT_ZIP
6676
<< DICT_TF_FORMAT_SHIFT);
6664
| (DICT_TF_FORMAT_ZIP
6665
<< DICT_TF_FORMAT_SHIFT);
6680
6669
/* fall through */
6681
6670
case ROW_TYPE_NOT_USED:
6682
6671
case ROW_TYPE_FIXED:
6685
MYSQL_ERROR::WARN_LEVEL_WARN,
6686
ER_ILLEGAL_HA_CREATE_OPTION,
6687
"InnoDB: assuming ROW_FORMAT=COMPACT.");
6674
thd, MYSQL_ERROR::WARN_LEVEL_WARN,
6675
ER_ILLEGAL_HA_CREATE_OPTION,
6676
"InnoDB: assuming ROW_FORMAT=COMPACT.");
6688
6677
case ROW_TYPE_DEFAULT:
6689
6678
case ROW_TYPE_COMPACT:
6690
6679
flags = DICT_TF_COMPACT;
6705
6694
/* Check for name conflicts (with reserved name) for
6706
6695
any user indices to be created. */
6707
if (innobase_index_name_is_reserved(trx, form->key_info,
6696
if (innobase_index_name_is_reserved(thd, form->key_info,
6708
6697
form->s->keys)) {
6701
if (IS_MAGIC_TABLE_AND_USER_DENIED_ACCESS(norm_name, thd)) {
6702
DBUG_RETURN(HA_ERR_GENERIC);
6713
6705
if (create_info->options & HA_LEX_CREATE_TMP_TABLE) {
6714
6706
flags |= DICT_TF2_TEMPORARY << DICT_TF2_SHIFT;
6709
/* Get the transaction associated with the current thd, or create one
6710
if not yet created */
6712
parent_trx = check_trx_exists(thd);
6714
/* In case MySQL calls this in the middle of a SELECT query, release
6715
possible adaptive hash latch to avoid deadlocks of threads */
6717
trx_search_latch_release_if_reserved(parent_trx);
6719
trx = innobase_trx_allocate(thd);
6721
/* Latch the InnoDB data dictionary exclusively so that no deadlocks
6722
or lock waits can happen in it during a table create operation.
6723
Drop table etc. do this latching in row0mysql.c. */
6725
row_mysql_lock_data_dictionary(trx);
6717
6727
error = create_table_def(trx, form, norm_name,
6718
6728
create_info->options & HA_LEX_CREATE_TMP_TABLE ? name2 : NULL,
6798
6808
setup at this stage and so we use thd. */
6800
6810
/* We need to copy the AUTOINC value from the old table if
6801
this is an ALTER TABLE or CREATE INDEX because CREATE INDEX
6802
does a table copy too. */
6811
this is an ALTER|OPTIMIZE TABLE or CREATE INDEX because CREATE INDEX
6812
does a table copy too. If query was one of :
6814
CREATE TABLE ...AUTO_INCREMENT = x; or
6815
ALTER TABLE...AUTO_INCREMENT = x; or
6816
OPTIMIZE TABLE t; or
6817
CREATE INDEX x on t(...);
6819
Find out a table definition from the dictionary and get
6820
the current value of the auto increment field. Set a new
6821
value to the auto increment field if the value is greater
6822
than the maximum value in the column. */
6804
6824
if (((create_info->used_fields & HA_CREATE_USED_AUTO)
6805
6825
|| thd_sql_command(thd) == SQLCOM_ALTER_TABLE
6826
|| thd_sql_command(thd) == SQLCOM_OPTIMIZE
6806
6827
|| thd_sql_command(thd) == SQLCOM_CREATE_INDEX)
6807
6828
&& create_info->auto_increment_value > 0) {
6809
/* Query was one of :
6810
CREATE TABLE ...AUTO_INCREMENT = x; or
6811
ALTER TABLE...AUTO_INCREMENT = x; or
6812
CREATE INDEX x on t(...);
6813
Find out a table definition from the dictionary and get
6814
the current value of the auto increment field. Set a new
6815
value to the auto increment field if the value is greater
6816
than the maximum value in the column. */
6818
6830
auto_inc_value = create_info->auto_increment_value;
6820
6832
dict_table_autoinc_lock(innobase_table);
7514
/*********************************************************************//**
7515
Calculate Record Per Key value. Need to exclude the NULL value if
7516
innodb_stats_method is set to "nulls_ignored"
7517
@return estimated record per key value */
7522
dict_index_t* index, /*!< in: dict_index_t structure */
7523
ulint i, /*!< in: the column we are
7524
calculating rec per key */
7525
ha_rows records) /*!< in: estimated total records */
7527
ha_rows rec_per_key;
7529
ut_ad(i < dict_index_get_n_unique(index));
7531
/* Note the stat_n_diff_key_vals[] stores the diff value with
7532
n-prefix indexing, so it is always stat_n_diff_key_vals[i + 1] */
7533
if (index->stat_n_diff_key_vals[i + 1] == 0) {
7535
rec_per_key = records;
7536
} else if (srv_innodb_stats_method == SRV_STATS_NULLS_IGNORED) {
7537
ib_int64_t num_null;
7539
/* Number of rows with NULL value in this
7541
num_null = records - index->stat_n_non_null_key_vals[i];
7543
/* In theory, index->stat_n_non_null_key_vals[i]
7544
should always be less than the number of records.
7545
Since this is statistics value, the value could
7546
have slight discrepancy. But we will make sure
7547
the number of null values is not a negative number. */
7548
num_null = (num_null < 0) ? 0 : num_null;
7550
/* If the number of NULL values is the same as or
7551
large than that of the distinct values, we could
7552
consider that the table consists mostly of NULL value.
7553
Set rec_per_key to 1. */
7554
if (index->stat_n_diff_key_vals[i + 1] <= num_null) {
7557
/* Need to exclude rows with NULL values from
7558
rec_per_key calculation */
7559
rec_per_key = (ha_rows)(
7560
(records - num_null)
7561
/ (index->stat_n_diff_key_vals[i + 1]
7565
rec_per_key = (ha_rows)
7566
(records / index->stat_n_diff_key_vals[i + 1]);
7569
return(rec_per_key);
7500
7572
/*********************************************************************//**
7501
7573
Returns statistics information of the table to the MySQL interpreter,
7502
7574
in various fields of the handle object. */
7507
uint flag) /*!< in: what information MySQL requests */
7577
ha_innobase::info_low(
7578
/*==================*/
7579
uint flag, /*!< in: what information MySQL
7581
bool called_from_analyze) /* in: TRUE if called from
7509
7584
dict_table_t* ib_table;
7510
7585
dict_index_t* index;
7511
7586
ha_rows rec_per_key;
7512
7587
ib_int64_t n_rows;
7515
7588
char path[FN_REFLEN];
7516
7589
os_file_stat_t stat_info;
7519
7591
DBUG_ENTER("info");
7521
7593
/* If we are forcing recovery at a high level, we will suppress
7522
7594
statistics calculation on tables, because that may crash the
7523
7595
server if an index is badly corrupted. */
7525
if (srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE) {
7527
/* We return success (0) instead of HA_ERR_CRASHED,
7528
because we want MySQL to process this query and not
7529
stop, like it would do if it received the error code
7535
7597
/* We do not know if MySQL can call this function before calling
7536
7598
external_lock(). To be safe, update the thd of the current table
7613
7682
prebuilt->autoinc_last_value = 0;
7685
page_size = dict_table_zip_size(ib_table);
7686
if (page_size == 0) {
7687
page_size = UNIV_PAGE_SIZE;
7616
7690
stats.records = (ha_rows)n_rows;
7617
7691
stats.deleted = 0;
7618
stats.data_file_length = ((ulonglong)
7619
ib_table->stat_clustered_index_size)
7621
stats.index_file_length = ((ulonglong)
7622
ib_table->stat_sum_of_other_index_sizes)
7692
stats.data_file_length
7693
= ((ulonglong) ib_table->stat_clustered_index_size)
7695
stats.index_file_length =
7696
((ulonglong) ib_table->stat_sum_of_other_index_sizes)
7699
dict_table_stats_unlock(ib_table, RW_S_LATCH);
7625
7701
/* Since fsp_get_available_space_in_free_extents() is
7626
7702
acquiring latches inside InnoDB, we do not call it if we
7627
7703
are asked by MySQL to avoid locking. Another reason to
7628
7704
avoid the call is that it uses quite a lot of CPU.
7630
We do not update delete_length if no locking is requested
7631
so the "old" value can remain. delete_length is initialized
7632
to 0 in the ha_statistics' constructor. */
7633
if (!(flag & HA_STATUS_NO_LOCK)) {
7635
/* lock the data dictionary to avoid races with
7636
ibd_file_missing and tablespace_discarded */
7637
row_mysql_lock_data_dictionary(prebuilt->trx);
7639
/* ib_table->space must be an existent tablespace */
7640
if (!ib_table->ibd_file_missing
7641
&& !ib_table->tablespace_discarded) {
7643
stats.delete_length =
7644
fsp_get_available_space_in_free_extents(
7645
ib_table->space) * 1024;
7706
if (flag & HA_STATUS_NO_LOCK) {
7707
/* We do not update delete_length if no
7708
locking is requested so the "old" value can
7709
remain. delete_length is initialized to 0 in
7710
the ha_statistics' constructor. */
7711
} else if (UNIV_UNLIKELY
7712
(srv_force_recovery >= SRV_FORCE_NO_IBUF_MERGE)) {
7713
/* Avoid accessing the tablespace if
7714
innodb_crash_recovery is set to a high value. */
7715
stats.delete_length = 0;
7719
avail_space = fsp_get_available_space_in_free_extents(
7722
if (avail_space == ULLINT_UNDEFINED) {
7650
7725
thd = ha_thd();
8349
8439
parameters below. We must not invoke update_thd()
8350
8440
either, because the calling threads may change.
8351
8441
CAREFUL HERE, OR MEMORY CORRUPTION MAY OCCUR! */
8352
case HA_EXTRA_IGNORE_DUP_KEY:
8442
case HA_EXTRA_INSERT_WITH_UPDATE:
8353
8443
thd_to_trx(ha_thd())->duplicates |= TRX_DUP_IGNORE;
8445
case HA_EXTRA_NO_IGNORE_DUP_KEY:
8446
thd_to_trx(ha_thd())->duplicates &= ~TRX_DUP_IGNORE;
8355
8448
case HA_EXTRA_WRITE_CAN_REPLACE:
8356
8449
thd_to_trx(ha_thd())->duplicates |= TRX_DUP_REPLACE;
8358
8451
case HA_EXTRA_WRITE_CANNOT_REPLACE:
8359
8452
thd_to_trx(ha_thd())->duplicates &= ~TRX_DUP_REPLACE;
8361
case HA_EXTRA_NO_IGNORE_DUP_KEY:
8362
thd_to_trx(ha_thd())->duplicates &=
8363
~(TRX_DUP_IGNORE | TRX_DUP_REPLACE);
8365
8454
default:/* Do nothing */
10591
/***********************************************************************
10692
/*********************************************************************//**
10592
10693
This function checks each index name for a table against reserved
10593
system default primary index name 'GEN_CLUST_INDEX'. If a name matches,
10594
this function pushes an warning message to the client, and returns true. */
10694
system default primary index name 'GEN_CLUST_INDEX'. If a name
10695
matches, this function pushes an warning message to the client,
10697
@return true if the index name matches the reserved name */
10595
10698
extern "C" UNIV_INTERN
10597
10700
innobase_index_name_is_reserved(
10598
10701
/*============================*/
10599
/* out: true if an index name
10600
matches the reserved name */
10601
const trx_t* trx, /* in: InnoDB transaction handle */
10602
const KEY* key_info, /* in: Indexes to be created */
10603
ulint num_of_keys) /* in: Number of indexes to
10702
THD* thd, /*!< in/out: MySQL connection */
10703
const KEY* key_info, /*!< in: Indexes to be created */
10704
ulint num_of_keys) /*!< in: Number of indexes to
10604
10705
be created. */
10606
10707
const KEY* key;
10907
11008
innodb_change_buffering_validate,
10908
11009
innodb_change_buffering_update, "inserts");
11011
static MYSQL_SYSVAR_ENUM(stats_method, srv_innodb_stats_method,
11012
PLUGIN_VAR_RQCMDARG,
11013
"Specifies how InnoDB index statistics collection code should "
11014
"treat NULLs. Possible values are NULLS_EQUAL (default), "
11015
"NULLS_UNEQUAL and NULLS_IGNORED",
11016
NULL, NULL, SRV_STATS_NULLS_EQUAL, &innodb_stats_method_typelib);
11018
#if defined UNIV_DEBUG || defined UNIV_IBUF_DEBUG
11019
static MYSQL_SYSVAR_UINT(change_buffering_debug, ibuf_debug,
11020
PLUGIN_VAR_RQCMDARG,
11021
"Debug flags for InnoDB change buffering (0=none)",
11022
NULL, NULL, 0, 0, 1, 0);
11023
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
11025
static MYSQL_SYSVAR_BOOL(random_read_ahead, srv_random_read_ahead,
11026
PLUGIN_VAR_NOCMDARG,
11027
"Whether to use read ahead for random access within an extent.",
11028
NULL, NULL, FALSE);
10910
11030
static MYSQL_SYSVAR_ULONG(read_ahead_threshold, srv_read_ahead_threshold,
10911
11031
PLUGIN_VAR_RQCMDARG,
10912
11032
"Number of pages that must be accessed sequentially for InnoDB to "