Commit 28a18fef authored by Otto Kekäläinen's avatar Otto Kekäläinen
Browse files

Merge tag 'upstream/5.5.50' into ubuntu-14.04

Upstream version 5.5.50
parents 3747036d 95c6357a
/* /* Copyright (c) 2000, 2016, Oracle and/or its affiliates.
Copyright (c) 2000, 2010, Oracle and/or its affiliates. Copyright (c) 2009, 2016, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
......
/* /*
Copyright (c) 2002, 2013, Oracle and/or its affiliates. Copyright (c) 2002, 2016, Oracle and/or its affiliates.
Copyright (c) 2011, 2013, Monty Program Ab Copyright (c) 2011, 2016, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -480,8 +480,10 @@ sp_name::init_qname(THD *thd) ...@@ -480,8 +480,10 @@ sp_name::init_qname(THD *thd)
bool bool
check_routine_name(LEX_STRING *ident) check_routine_name(LEX_STRING *ident)
{ {
if (!ident || !ident->str || !ident->str[0] || DBUG_ASSERT(ident);
ident->str[ident->length-1] == ' ') DBUG_ASSERT(ident->str);
if (!ident->str[0] || ident->str[ident->length-1] == ' ')
{ {
my_error(ER_SP_WRONG_NAME, MYF(0), ident->str); my_error(ER_SP_WRONG_NAME, MYF(0), ident->str);
return TRUE; return TRUE;
......
...@@ -1092,7 +1092,8 @@ void end_connection(THD *thd) ...@@ -1092,7 +1092,8 @@ void end_connection(THD *thd)
} }
if (!thd->killed && (net->error && net->vio != 0)) if (!thd->killed && (net->error && net->vio != 0))
thd->print_aborted_warning(1, ER(ER_UNKNOWN_ERROR)); thd->print_aborted_warning(1,
thd->stmt_da->is_error() ? thd->stmt_da->message() : ER(ER_UNKNOWN_ERROR));
} }
......
...@@ -1452,32 +1452,35 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd) ...@@ -1452,32 +1452,35 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
return (BIN_NUM); return (BIN_NUM);
case MY_LEX_CMP_OP: // Incomplete comparison operator case MY_LEX_CMP_OP: // Incomplete comparison operator
lip->next_state= MY_LEX_START; // Allow signed numbers
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP || if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP) state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
lip->yySkip();
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
{ {
lip->next_state= MY_LEX_START; // Allow signed numbers lip->yySkip();
if ((tokval= find_keyword(lip, 2, 0)))
return(tokval); return(tokval);
lip->yyUnget();
} }
state = MY_LEX_CHAR; // Something fishy found return(c);
break;
case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator
lip->next_state= MY_LEX_START;
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP || if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP) state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
{ {
lip->yySkip(); lip->yySkip();
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP) if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP)
{
lip->yySkip(); lip->yySkip();
if ((tokval= find_keyword(lip, 3, 0)))
return(tokval);
lip->yyUnget();
} }
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0))) if ((tokval= find_keyword(lip, 2, 0)))
{
lip->next_state= MY_LEX_START; // Found long op
return(tokval); return(tokval);
lip->yyUnget();
} }
state = MY_LEX_CHAR; // Something fishy found return(c);
break;
case MY_LEX_BOOL: case MY_LEX_BOOL:
if (c != lip->yyPeek()) if (c != lip->yyPeek())
......
...@@ -61,6 +61,8 @@ class MY_LOCALE ...@@ -61,6 +61,8 @@ class MY_LOCALE
grouping(grouping_par), grouping(grouping_par),
errmsgs(errmsgs_par) errmsgs(errmsgs_par)
{} {}
uint repertoire() const
{ return is_ascii ? MY_REPERTOIRE_ASCII : MY_REPERTOIRE_EXTENDED; }
}; };
/* Exported variables */ /* Exported variables */
......
...@@ -5395,6 +5395,7 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors) ...@@ -5395,6 +5395,7 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
temporary table flag) temporary table flag)
@param alter_info [in] Initial list of columns and indexes for the @param alter_info [in] Initial list of columns and indexes for the
table to be created table to be created
@param create_db [in] Database of the created table
@retval @retval
false ok. false ok.
...@@ -5403,7 +5404,8 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors) ...@@ -5403,7 +5404,8 @@ bool check_global_access(THD *thd, ulong want_access, bool no_errors)
*/ */
bool check_fk_parent_table_access(THD *thd, bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
Alter_info *alter_info) Alter_info *alter_info,
const char* create_db)
{ {
Key *key; Key *key;
List_iterator<Key> key_iterator(alter_info->key_list); List_iterator<Key> key_iterator(alter_info->key_list);
...@@ -5443,10 +5445,28 @@ bool check_fk_parent_table_access(THD *thd, ...@@ -5443,10 +5445,28 @@ bool check_fk_parent_table_access(THD *thd,
return true; return true;
} }
} }
else if (thd->lex->copy_db_to(&db_name.str, &db_name.length)) else
{
if (!thd->db)
{
db_name.str= (char *) thd->memdup(create_db, strlen(create_db)+1);
db_name.length= strlen(create_db);
is_qualified_table_name= true;
if(create_db && check_db_name(&db_name))
{
my_error(ER_WRONG_DB_NAME, MYF(0), db_name.str);
return true;
}
}
else
{
if (thd->lex->copy_db_to(&db_name.str, &db_name.length))
return true; return true;
else else
is_qualified_table_name= false; is_qualified_table_name= false;
}
}
// if lower_case_table_names is set then convert tablename to lower case. // if lower_case_table_names is set then convert tablename to lower case.
if (lower_case_table_names) if (lower_case_table_names)
...@@ -7462,7 +7482,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, ...@@ -7462,7 +7482,7 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
goto err; goto err;
} }
if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info)) if (check_fk_parent_table_access(thd, &lex->create_info, &lex->alter_info, create_table->db))
goto err; goto err;
error= FALSE; error= FALSE;
......
...@@ -47,7 +47,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables, ...@@ -47,7 +47,8 @@ bool create_table_precheck(THD *thd, TABLE_LIST *tables,
TABLE_LIST *create_table); TABLE_LIST *create_table);
bool check_fk_parent_table_access(THD *thd, bool check_fk_parent_table_access(THD *thd,
HA_CREATE_INFO *create_info, HA_CREATE_INFO *create_info,
Alter_info *alter_info); Alter_info *alter_info,
const char* create_db);
bool parse_sql(THD *thd, bool parse_sql(THD *thd,
Parser_state *parser_state, Parser_state *parser_state,
......
/* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. /* Copyright (c) 2010, 2016, Oracle and/or its affiliates.
Copyright (c) 2011, 2016, MariaDB
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
......
...@@ -14586,7 +14586,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, ...@@ -14586,7 +14586,8 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->collation.collation); item->collation.collation);
else else
new_field= item->make_string_field(table); new_field= item->make_string_field(table);
new_field->set_derivation(item->collation.derivation); new_field->set_derivation(item->collation.derivation,
item->collation.repertoire);
break; break;
case DECIMAL_RESULT: case DECIMAL_RESULT:
new_field= Field_new_decimal::create_from_item(item); new_field= Field_new_decimal::create_from_item(item);
...@@ -14825,7 +14826,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, ...@@ -14825,7 +14826,8 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
modify_item, convert_blob_length); modify_item, convert_blob_length);
case Item::TYPE_HOLDER: case Item::TYPE_HOLDER:
result= ((Item_type_holder *)item)->make_field_by_type(table); result= ((Item_type_holder *)item)->make_field_by_type(table);
result->set_derivation(item->collation.derivation); result->set_derivation(item->collation.derivation,
item->collation.repertoire);
return result; return result;
default: // Dosen't have to be stored default: // Dosen't have to be stored
return 0; return 0;
......
...@@ -6305,7 +6305,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -6305,7 +6305,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
till this point for the alter operation. till this point for the alter operation.
*/ */
if ((alter_info->flags & ALTER_FOREIGN_KEY) && if ((alter_info->flags & ALTER_FOREIGN_KEY) &&
check_fk_parent_table_access(thd, create_info, alter_info)) check_fk_parent_table_access(thd, create_info, alter_info, new_db))
goto err; goto err;
/* /*
......
This diff is collapsed.
This diff is collapsed.
...@@ -970,7 +970,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -970,7 +970,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token ENGINES_SYM %token ENGINES_SYM
%token ENGINE_SYM %token ENGINE_SYM
%token ENUM %token ENUM
%token EQ /* OPERATOR */
%token EQUAL_SYM /* OPERATOR */ %token EQUAL_SYM /* OPERATOR */
%token ERROR_SYM %token ERROR_SYM
%token ERRORS %token ERRORS
...@@ -1016,7 +1015,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1016,7 +1015,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token GRANTS %token GRANTS
%token GROUP_SYM /* SQL-2003-R */ %token GROUP_SYM /* SQL-2003-R */
%token GROUP_CONCAT_SYM %token GROUP_CONCAT_SYM
%token GT_SYM /* OPERATOR */
%token HANDLER_SYM %token HANDLER_SYM
%token HARD_SYM %token HARD_SYM
%token HASH_SYM %token HASH_SYM
...@@ -1095,7 +1093,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1095,7 +1093,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token LONG_SYM %token LONG_SYM
%token LOOP_SYM %token LOOP_SYM
%token LOW_PRIORITY %token LOW_PRIORITY
%token LT /* OPERATOR */
%token MASTER_CONNECT_RETRY_SYM %token MASTER_CONNECT_RETRY_SYM
%token MASTER_HOST_SYM %token MASTER_HOST_SYM
%token MASTER_LOG_FILE_SYM %token MASTER_LOG_FILE_SYM
...@@ -1439,7 +1436,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); ...@@ -1439,7 +1436,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%left XOR %left XOR
%left AND_SYM AND_AND_SYM %left AND_SYM AND_AND_SYM
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE %left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM %left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM
%left '|' %left '|'
%left '&' %left '&'
%left SHIFT_LEFT SHIFT_RIGHT %left SHIFT_LEFT SHIFT_RIGHT
...@@ -1922,58 +1919,58 @@ master_defs: ...@@ -1922,58 +1919,58 @@ master_defs:
; ;
master_def: master_def:
MASTER_HOST_SYM EQ TEXT_STRING_sys MASTER_HOST_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.host = $3.str; Lex->mi.host = $3.str;
} }
| MASTER_USER_SYM EQ TEXT_STRING_sys | MASTER_USER_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.user = $3.str; Lex->mi.user = $3.str;
} }
| MASTER_PASSWORD_SYM EQ TEXT_STRING_sys | MASTER_PASSWORD_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.password = $3.str; Lex->mi.password = $3.str;
} }
| MASTER_PORT_SYM EQ ulong_num | MASTER_PORT_SYM '=' ulong_num
{ {
Lex->mi.port = $3; Lex->mi.port = $3;
} }
| MASTER_CONNECT_RETRY_SYM EQ ulong_num | MASTER_CONNECT_RETRY_SYM '=' ulong_num
{ {
Lex->mi.connect_retry = $3; Lex->mi.connect_retry = $3;
} }
| MASTER_SSL_SYM EQ ulong_num | MASTER_SSL_SYM '=' ulong_num
{ {
Lex->mi.ssl= $3 ? Lex->mi.ssl= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE; LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
} }
| MASTER_SSL_CA_SYM EQ TEXT_STRING_sys | MASTER_SSL_CA_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.ssl_ca= $3.str; Lex->mi.ssl_ca= $3.str;
} }
| MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys | MASTER_SSL_CAPATH_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.ssl_capath= $3.str; Lex->mi.ssl_capath= $3.str;
} }
| MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys | MASTER_SSL_CERT_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.ssl_cert= $3.str; Lex->mi.ssl_cert= $3.str;
} }
| MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys | MASTER_SSL_CIPHER_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.ssl_cipher= $3.str; Lex->mi.ssl_cipher= $3.str;
} }
| MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys | MASTER_SSL_KEY_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.ssl_key= $3.str; Lex->mi.ssl_key= $3.str;
} }
| MASTER_SSL_VERIFY_SERVER_CERT_SYM EQ ulong_num | MASTER_SSL_VERIFY_SERVER_CERT_SYM '=' ulong_num
{ {
Lex->mi.ssl_verify_server_cert= $3 ? Lex->mi.ssl_verify_server_cert= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE; LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
} }
| MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal | MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal
{ {
Lex->mi.heartbeat_period= (float) $3->val_real(); Lex->mi.heartbeat_period= (float) $3->val_real();
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD || if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
...@@ -2004,7 +2001,7 @@ master_def: ...@@ -2004,7 +2001,7 @@ master_def:
} }
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE; Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
} }
| IGNORE_SERVER_IDS_SYM EQ '(' ignore_server_id_list ')' | IGNORE_SERVER_IDS_SYM '=' '(' ignore_server_id_list ')'
{ {
Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE; Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
} }
...@@ -2025,11 +2022,11 @@ ignore_server_id: ...@@ -2025,11 +2022,11 @@ ignore_server_id:
} }
master_file_def: master_file_def:
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys MASTER_LOG_FILE_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.log_file_name = $3.str; Lex->mi.log_file_name = $3.str;
} }
| MASTER_LOG_POS_SYM EQ ulonglong_num | MASTER_LOG_POS_SYM '=' ulonglong_num
{ {
Lex->mi.pos = $3; Lex->mi.pos = $3;
/* /*
...@@ -2045,11 +2042,11 @@ master_file_def: ...@@ -2045,11 +2042,11 @@ master_file_def:
*/ */
Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos); Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
} }
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys | RELAY_LOG_FILE_SYM '=' TEXT_STRING_sys
{ {
Lex->mi.relay_log_name = $3.str; Lex->mi.relay_log_name = $3.str;
} }
| RELAY_LOG_POS_SYM EQ ulong_num | RELAY_LOG_POS_SYM '=' ulong_num
{ {
Lex->mi.relay_log_pos = $3; Lex->mi.relay_log_pos = $3;
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */ /* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
...@@ -3032,7 +3029,7 @@ opt_set_signal_information: ...@@ -3032,7 +3029,7 @@ opt_set_signal_information:
; ;
signal_information_item_list: signal_information_item_list:
signal_condition_information_item_name EQ signal_allowed_expr signal_condition_information_item_name '=' signal_allowed_expr
{ {
Set_signal_information *info; Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info; info= &thd->m_parser_state->m_yacc.m_set_signal_info;
...@@ -3041,7 +3038,7 @@ signal_information_item_list: ...@@ -3041,7 +3038,7 @@ signal_information_item_list:
info->m_item[index]= $3; info->m_item[index]= $3;
} }
| signal_information_item_list ',' | signal_information_item_list ','
signal_condition_information_item_name EQ signal_allowed_expr signal_condition_information_item_name '=' signal_allowed_expr
{ {
Set_signal_information *info; Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info; info= &thd->m_parser_state->m_yacc.m_set_signal_info;
...@@ -4439,7 +4436,7 @@ opt_linear: ...@@ -4439,7 +4436,7 @@ opt_linear:
opt_key_algo: opt_key_algo:
/* empty */ /* empty */
{ Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;} { Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;}
| ALGORITHM_SYM EQ real_ulong_num | ALGORITHM_SYM '=' real_ulong_num
{ {
switch ($3) { switch ($3) {
case 1: case 1:
...@@ -7076,7 +7073,7 @@ opt_place: ...@@ -7076,7 +7073,7 @@ opt_place:
opt_to: opt_to:
/* empty */ {} /* empty */ {}
| TO_SYM {} | TO_SYM {}
| EQ {} | '=' {}
| AS {} | AS {}
; ;
...@@ -7943,13 +7940,13 @@ bool_pri: ...@@ -7943,13 +7940,13 @@ bool_pri:
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| bool_pri comp_op predicate %prec EQ | bool_pri comp_op predicate %prec '='
{ {
$$= (*$2)(0)->create($1,$3); $$= (*$2)(0)->create($1,$3);
if ($$ == NULL) if ($$ == NULL)
MYSQL_YYABORT; MYSQL_YYABORT;
} }
| bool_pri comp_op all_or_any '(' subselect ')' %prec EQ | bool_pri comp_op all_or_any '(' subselect ')' %prec '='
{ {
$$= all_any_subquery_creator($1, $2, $3, $5); $$= all_any_subquery_creator($1, $2, $3, $5);
if ($$ == NULL) if ($$ == NULL)
...@@ -8172,11 +8169,11 @@ not2: ...@@ -8172,11 +8169,11 @@ not2:
; ;
comp_op: comp_op:
EQ { $$ = &comp_eq_creator; } '=' { $$ = &comp_eq_creator; }
| GE { $$ = &comp_ge_creator; } | GE { $$ = &comp_ge_creator; }
| GT_SYM { $$ = &comp_gt_creator; } | '>' { $$ = &comp_gt_creator; }
| LE { $$ = &comp_le_creator; } | LE { $$ = &comp_le_creator; }
| LT { $$ = &comp_lt_creator; } | '<' { $$ = &comp_lt_creator; }
| NE { $$ = &comp_ne_creator; } | NE { $$ = &comp_ne_creator; }
; ;
...@@ -10197,7 +10194,7 @@ date_time_type: ...@@ -10197,7 +10194,7 @@ date_time_type:
table_alias: table_alias:
/* empty */ /* empty */
| AS | AS
| EQ | '='
; ;
opt_table_alias: opt_table_alias:
...@@ -11100,7 +11097,7 @@ ident_eq_value: ...@@ -11100,7 +11097,7 @@ ident_eq_value:
; ;
equal: equal:
EQ {} '=' {}
| SET_VAR {} | SET_VAR {}
; ;
...@@ -13968,11 +13965,11 @@ handler_rkey_function: ...@@ -13968,11 +13965,11 @@ handler_rkey_function:
; ;
handler_rkey_mode: handler_rkey_mode:
EQ { $$=HA_READ_KEY_EXACT; } '=' { $$=HA_READ_KEY_EXACT; }
| GE { $$=HA_READ_KEY_OR_NEXT; } | GE { $$=HA_READ_KEY_OR_NEXT; }
| LE { $$=HA_READ_KEY_OR_PREV; } | LE { $$=HA_READ_KEY_OR_PREV; }
| GT_SYM { $$=HA_READ_AFTER_KEY; } | '>' { $$=HA_READ_AFTER_KEY; }
| LT { $$=HA_READ_BEFORE_KEY; } | '<' { $$=HA_READ_BEFORE_KEY; }
; ;
/* GRANT / REVOKE */ /* GRANT / REVOKE */
...@@ -14744,7 +14741,7 @@ no_definer: ...@@ -14744,7 +14741,7 @@ no_definer:
; ;
definer: definer:
DEFINER_SYM EQ user DEFINER_SYM '=' user
{ {
thd->lex->definer= get_current_user(thd, $3); thd->lex->definer= get_current_user(thd, $3);
} }
...@@ -14771,11 +14768,11 @@ view_replace: ...@@ -14771,11 +14768,11 @@ view_replace:
; ;
view_algorithm: view_algorithm:
ALGORITHM_SYM EQ UNDEFINED_SYM ALGORITHM_SYM '=' UNDEFINED_SYM
{ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; } { Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
| ALGORITHM_SYM EQ MERGE_SYM | ALGORITHM_SYM '=' MERGE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; } { Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
| ALGORITHM_SYM EQ TEMPTABLE_SYM | ALGORITHM_SYM '=' TEMPTABLE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; } { Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
; ;
......
...@@ -166,6 +166,7 @@ struct pool_timer_t ...@@ -166,6 +166,7 @@ struct pool_timer_t
volatile uint64 next_timeout_check; volatile uint64 next_timeout_check;
int tick_interval; int tick_interval;
bool shutdown; bool shutdown;
pthread_t timer_thread_id;
}; };
static pool_timer_t pool_timer; static pool_timer_t pool_timer;
...@@ -603,12 +604,12 @@ void check_stall(thread_group_t *thread_group) ...@@ -603,12 +604,12 @@ void check_stall(thread_group_t *thread_group)
static void start_timer(pool_timer_t* timer) static void start_timer(pool_timer_t* timer)
{ {
pthread_t thread_id;
DBUG_ENTER("start_timer"); DBUG_ENTER("start_timer");
mysql_mutex_init(key_timer_mutex,&timer->mutex, NULL); mysql_mutex_init(key_timer_mutex,&timer->mutex, NULL);
mysql_cond_init(key_timer_cond, &timer->cond, NULL); mysql_cond_init(key_timer_cond, &timer->cond, NULL);
timer->shutdown = false; timer->shutdown = false;
mysql_thread_create(key_timer_thread,&thread_id, NULL, timer_thread, timer); mysql_thread_create(key_timer_thread, &timer->timer_thread_id, NULL,
timer_thread, timer);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -620,6 +621,7 @@ static void stop_timer(pool_timer_t *timer) ...@@ -620,6 +621,7 @@ static void stop_timer(pool_timer_t *timer)
timer->shutdown = true; timer->shutdown = true;
mysql_cond_signal(&timer->cond); mysql_cond_signal(&timer->cond);
mysql_mutex_unlock(&timer->mutex); mysql_mutex_unlock(&timer->mutex);
pthread_join(timer->timer_thread_id, NULL);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
......
...@@ -2106,7 +2106,6 @@ innobase_convert_name( ...@@ -2106,7 +2106,6 @@ innobase_convert_name(
A wrapper function of innobase_convert_name(), convert a table or A wrapper function of innobase_convert_name(), convert a table or
index name to the MySQL system_charset_info (UTF-8) and quote it if needed. index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
@return pointer to the end of buf */ @return pointer to the end of buf */
static inline
void void
innobase_format_name( innobase_format_name(
/*==================*/ /*==================*/
...@@ -8685,6 +8684,36 @@ ha_innobase::check( ...@@ -8685,6 +8684,36 @@ ha_innobase::check(
DBUG_RETURN(HA_ADMIN_CORRUPT); DBUG_RETURN(HA_ADMIN_CORRUPT);
} }
if (prebuilt->table->corrupted) {
char index_name[MAX_FULL_NAME_LEN + 1];
/* If some previous operation has marked the table as
corrupted in memory, and has not propagated such to
clustered index, we will do so here */
index = dict_table_get_first_index(prebuilt->table);
if (!dict_index_is_corrupted(index)) {
row_mysql_lock_data_dictionary(prebuilt->trx);
dict_set_corrupted(index);
row_mysql_unlock_data_dictionary(prebuilt->trx);
}
innobase_format_name(index_name, sizeof index_name,
index->name, TRUE);
push_warning_printf(thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
HA_ERR_INDEX_CORRUPT,
"InnoDB: Index %s is marked as"
" corrupted",
index_name);
/* Now that the table is already marked as corrupted,
there is no need to check any index of this table */
prebuilt->trx->op_info = "";
DBUG_RETURN(HA_ADMIN_CORRUPT);
}
prebuilt->trx->op_info = "checking table"; prebuilt->trx->op_info = "checking table";
old_isolation_level = prebuilt->trx->isolation_level; old_isolation_level = prebuilt->trx->isolation_level;
...@@ -8761,6 +8790,15 @@ ha_innobase::check( ...@@ -8761,6 +8790,15 @@ ha_innobase::check(
prebuilt->index_usable = row_merge_is_index_usable( prebuilt->index_usable = row_merge_is_index_usable(
prebuilt->trx, prebuilt->index); prebuilt->trx, prebuilt->index);
DBUG_EXECUTE_IF(
"dict_set_index_corrupted",
if (!dict_index_is_clust(index)) {
prebuilt->index_usable = FALSE;
row_mysql_lock_data_dictionary(prebuilt->trx);
dict_set_corrupted(index);
row_mysql_unlock_data_dictionary(prebuilt->trx);
});
if (UNIV_UNLIKELY(!prebuilt->index_usable)) { if (UNIV_UNLIKELY(!prebuilt->index_usable)) {
innobase_format_name( innobase_format_name(
index_name, sizeof index_name, index_name, sizeof index_name,
......
...@@ -654,6 +654,19 @@ class ha_innobase_add_index : public handler_add_index ...@@ -654,6 +654,19 @@ class ha_innobase_add_index : public handler_add_index
~ha_innobase_add_index() {} ~ha_innobase_add_index() {}
}; };
/*****************************************************************//**
A wrapper function of innobase_convert_name(), convert a table or
index name to the MySQL system_charset_info (UTF-8) and quote it if needed.
@return pointer to the end of buf */
void
innobase_format_name(
/*==================*/
char* buf, /*!< out: buffer for converted identifier */
ulint buflen, /*!< in: length of buf, in bytes */
const char* name, /*!< in: index or table name to format */
ibool is_index_name); /*!< in: index name */
/*******************************************************************//** /*******************************************************************//**
Create indexes. Create indexes.
@return 0 or error number */ @return 0 or error number */
...@@ -715,6 +728,28 @@ ha_innobase::add_index( ...@@ -715,6 +728,28 @@ ha_innobase::add_index(
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
/* Check if any of the existing indexes are marked as corruption,
and if they are, refuse adding more indexes. */
for (dict_index_t* check_index = dict_table_get_first_index(indexed_table);
check_index != NULL;
check_index = dict_table_get_next_index(check_index)) {
if (dict_index_is_corrupted(check_index)) {
char index_name[MAX_FULL_NAME_LEN + 1];
innobase_format_name(index_name, sizeof index_name,
check_index->name, TRUE);
push_warning_printf(user_thd,
MYSQL_ERROR::WARN_LEVEL_WARN,
HA_ERR_INDEX_CORRUPT,
"InnoDB: Index %s is marked as"
" corrupted",
index_name);
DBUG_RETURN(HA_ERR_INDEX_CORRUPT);
}
}
/* Check that index keys are sensible */ /* Check that index keys are sensible */
error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table); error = innobase_check_index_keys(key_info, num_of_keys, prebuilt->table);
......
...@@ -46,7 +46,7 @@ static mysql_mutex_t LOCK_checkpoint; ...@@ -46,7 +46,7 @@ static mysql_mutex_t LOCK_checkpoint;
static mysql_cond_t COND_checkpoint; static mysql_cond_t COND_checkpoint;
/** @brief control structure for checkpoint background thread */ /** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL checkpoint_control= static MA_SERVICE_THREAD_CONTROL checkpoint_control=
{THREAD_DEAD, FALSE, &LOCK_checkpoint, &COND_checkpoint}; {0, FALSE, FALSE, &LOCK_checkpoint, &COND_checkpoint};
/* is ulong like pagecache->blocks_changed */ /* is ulong like pagecache->blocks_changed */
static ulong pages_to_flush_before_next_checkpoint; static ulong pages_to_flush_before_next_checkpoint;
static PAGECACHE_FILE *dfiles, /**< data files to flush in background */ static PAGECACHE_FILE *dfiles, /**< data files to flush in background */
...@@ -326,7 +326,6 @@ static int really_execute_checkpoint(void) ...@@ -326,7 +326,6 @@ static int really_execute_checkpoint(void)
int ma_checkpoint_init(ulong interval) int ma_checkpoint_init(ulong interval)
{ {
pthread_t th;
int res= 0; int res= 0;
DBUG_ENTER("ma_checkpoint_init"); DBUG_ENTER("ma_checkpoint_init");
if (ma_service_thread_control_init(&checkpoint_control)) if (ma_service_thread_control_init(&checkpoint_control))
...@@ -334,14 +333,14 @@ int ma_checkpoint_init(ulong interval) ...@@ -334,14 +333,14 @@ int ma_checkpoint_init(ulong interval)
else if (interval > 0) else if (interval > 0)
{ {
compile_time_assert(sizeof(void *) >= sizeof(ulong)); compile_time_assert(sizeof(void *) >= sizeof(ulong));
if (!(res= mysql_thread_create(key_thread_checkpoint, if ((res= mysql_thread_create(key_thread_checkpoint,
&th, NULL, ma_checkpoint_background, &checkpoint_control.thread, NULL,
(void *)interval))) ma_checkpoint_background,
{ (void*) interval)))
/* thread lives, will have to be killed */ checkpoint_control.killed= TRUE;
checkpoint_control.status= THREAD_RUNNING;
}
} }
else
checkpoint_control.killed= TRUE;
DBUG_RETURN(res); DBUG_RETURN(res);
} }
...@@ -717,7 +716,6 @@ pthread_handler_t ma_checkpoint_background(void *arg) ...@@ -717,7 +716,6 @@ pthread_handler_t ma_checkpoint_background(void *arg)
DBUG_EXECUTE_IF("maria_checkpoint_indirect", level= CHECKPOINT_INDIRECT;); DBUG_EXECUTE_IF("maria_checkpoint_indirect", level= CHECKPOINT_INDIRECT;);
ma_checkpoint_execute(level, FALSE); ma_checkpoint_execute(level, FALSE);
} }
my_service_thread_signal_end(&checkpoint_control);
my_thread_end(); my_thread_end();
return 0; return 0;
} }
......
...@@ -54,7 +54,7 @@ static mysql_mutex_t LOCK_soft_sync; ...@@ -54,7 +54,7 @@ static mysql_mutex_t LOCK_soft_sync;
static mysql_cond_t COND_soft_sync; static mysql_cond_t COND_soft_sync;
/** @brief control structure for checkpoint background thread */ /** @brief control structure for checkpoint background thread */
static MA_SERVICE_THREAD_CONTROL soft_sync_control= static MA_SERVICE_THREAD_CONTROL soft_sync_control=
{THREAD_DEAD, FALSE, &LOCK_soft_sync, &COND_soft_sync}; {0, FALSE, FALSE, &LOCK_soft_sync, &COND_soft_sync};
/* transaction log file descriptor */ /* transaction log file descriptor */
...@@ -8819,7 +8819,6 @@ ma_soft_sync_background( void *arg __attribute__((unused))) ...@@ -8819,7 +8819,6 @@ ma_soft_sync_background( void *arg __attribute__((unused)))
if (my_service_thread_sleep(&soft_sync_control, sleep)) if (my_service_thread_sleep(&soft_sync_control, sleep))
break; break;
} }
my_service_thread_signal_end(&soft_sync_control);
my_thread_end(); my_thread_end();
DBUG_RETURN(0); DBUG_RETURN(0);
} }
...@@ -8832,7 +8831,6 @@ ma_soft_sync_background( void *arg __attribute__((unused))) ...@@ -8832,7 +8831,6 @@ ma_soft_sync_background( void *arg __attribute__((unused)))
int translog_soft_sync_start(void) int translog_soft_sync_start(void)
{ {
pthread_t th;
int res= 0; int res= 0;
uint32 min, max; uint32 min, max;
DBUG_ENTER("translog_soft_sync_start"); DBUG_ENTER("translog_soft_sync_start");
...@@ -8847,9 +8845,10 @@ int translog_soft_sync_start(void) ...@@ -8847,9 +8845,10 @@ int translog_soft_sync_start(void)
soft_need_sync= 1; soft_need_sync= 1;
if (!(res= ma_service_thread_control_init(&soft_sync_control))) if (!(res= ma_service_thread_control_init(&soft_sync_control)))
if (!(res= mysql_thread_create(key_thread_soft_sync, if ((res= mysql_thread_create(key_thread_soft_sync,
&th, NULL, ma_soft_sync_background, NULL))) &soft_sync_control.thread, NULL,
soft_sync_control.status= THREAD_RUNNING; ma_soft_sync_background, NULL)))
soft_sync_control.killed= TRUE;
DBUG_RETURN(res); DBUG_RETURN(res);
} }
......
...@@ -500,8 +500,8 @@ static void test_key_cache(PAGECACHE *pagecache, ...@@ -500,8 +500,8 @@ static void test_key_cache(PAGECACHE *pagecache,
const char *where, my_bool lock); const char *where, my_bool lock);
#endif #endif
#define PAGECACHE_HASH(p, f, pos) (((ulong) (pos) + \ #define PAGECACHE_HASH(p, f, pos) (((size_t) (pos) + \
(ulong) (f).file) & (p->hash_entries-1)) (size_t) (f).file) & (p->hash_entries-1))
#define FILE_HASH(f) ((uint) (f).file & (PAGECACHE_CHANGED_BLOCKS_HASH - 1)) #define FILE_HASH(f) ((uint) (f).file & (PAGECACHE_CHANGED_BLOCKS_HASH - 1))
#define DEFAULT_PAGECACHE_DEBUG_LOG "pagecache_debug.log" #define DEFAULT_PAGECACHE_DEBUG_LOG "pagecache_debug.log"
...@@ -639,10 +639,10 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache, ...@@ -639,10 +639,10 @@ static my_bool pagecache_fwrite(PAGECACHE *pagecache,
{ {
char buff[80]; char buff[80];
uint len= my_sprintf(buff, uint len= my_sprintf(buff,
(buff, "fwrite: fd: %d id: %u page: %lu", (buff, "fwrite: fd: %d id: %u page: %llu",
filedesc->file, filedesc->file,
_ma_file_callback_to_id(filedesc->callback_data), _ma_file_callback_to_id(filedesc->callback_data),
(ulong) pageno)); pageno));
(void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY, (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY,
(uchar*) buff, len); (uchar*) buff, len);
} }
...@@ -741,11 +741,11 @@ static inline uint next_power(uint value) ...@@ -741,11 +741,11 @@ static inline uint next_power(uint value)
*/ */
ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
uint division_limit, uint age_threshold, uint division_limit, uint age_threshold,
uint block_size, myf my_readwrite_flags) uint block_size, myf my_readwrite_flags)
{ {
ulong blocks, hash_links, length; size_t blocks, hash_links, length;
int error; int error;
DBUG_ENTER("init_pagecache"); DBUG_ENTER("init_pagecache");
DBUG_ASSERT(block_size >= 512); DBUG_ASSERT(block_size >= 512);
...@@ -782,10 +782,10 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, ...@@ -782,10 +782,10 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
DBUG_PRINT("info", ("block_size: %u", block_size)); DBUG_PRINT("info", ("block_size: %u", block_size));
DBUG_ASSERT(((uint)(1 << pagecache->shift)) == block_size); DBUG_ASSERT(((uint)(1 << pagecache->shift)) == block_size);
blocks= (ulong) (use_mem / (sizeof(PAGECACHE_BLOCK_LINK) + blocks= use_mem / (sizeof(PAGECACHE_BLOCK_LINK) +
2 * sizeof(PAGECACHE_HASH_LINK) + 2 * sizeof(PAGECACHE_HASH_LINK) +
sizeof(PAGECACHE_HASH_LINK*) * sizeof(PAGECACHE_HASH_LINK*) *
5/4 + block_size)); 5/4 + block_size);
/* /*
We need to support page cache with just one block to be able to do We need to support page cache with just one block to be able to do
scanning of rows-in-block files scanning of rows-in-block files
...@@ -816,7 +816,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, ...@@ -816,7 +816,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
blocks--; blocks--;
/* Allocate memory for cache page buffers */ /* Allocate memory for cache page buffers */
if ((pagecache->block_mem= if ((pagecache->block_mem=
my_large_malloc((ulong) blocks * pagecache->block_size, my_large_malloc(blocks * pagecache->block_size,
MYF(MY_WME)))) MYF(MY_WME))))
{ {
/* /*
...@@ -824,7 +824,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, ...@@ -824,7 +824,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
For each block 2 hash links are allocated For each block 2 hash links are allocated
*/ */
if ((pagecache->block_root= if ((pagecache->block_root=
(PAGECACHE_BLOCK_LINK*) my_malloc((size_t) length, MYF(0)))) (PAGECACHE_BLOCK_LINK*) my_malloc(length, MYF(0))))
break; break;
my_large_free(pagecache->block_mem); my_large_free(pagecache->block_mem);
pagecache->block_mem= 0; pagecache->block_mem= 0;
...@@ -832,7 +832,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, ...@@ -832,7 +832,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
blocks= blocks / 4*3; blocks= blocks / 4*3;
} }
pagecache->blocks_unused= blocks; pagecache->blocks_unused= blocks;
pagecache->disk_blocks= (long) blocks; pagecache->disk_blocks= blocks;
pagecache->hash_links= hash_links; pagecache->hash_links= hash_links;
pagecache->hash_root= pagecache->hash_root=
(PAGECACHE_HASH_LINK**) ((char*) pagecache->block_root + (PAGECACHE_HASH_LINK**) ((char*) pagecache->block_root +
...@@ -887,7 +887,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, ...@@ -887,7 +887,7 @@ ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem,
PAGECACHE_CHANGED_BLOCKS_HASH); PAGECACHE_CHANGED_BLOCKS_HASH);
pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0; pagecache->blocks= pagecache->disk_blocks > 0 ? pagecache->disk_blocks : 0;
DBUG_RETURN((ulong) pagecache->disk_blocks); DBUG_RETURN((size_t)pagecache->disk_blocks);
err: err:
error= my_errno; error= my_errno;
...@@ -978,11 +978,11 @@ static int flush_all_key_blocks(PAGECACHE *pagecache) ...@@ -978,11 +978,11 @@ static int flush_all_key_blocks(PAGECACHE *pagecache)
So we disable it for now. So we disable it for now.
*/ */
#if NOT_USED /* keep disabled until code is fixed see above !! */ #if NOT_USED /* keep disabled until code is fixed see above !! */
ulong resize_pagecache(PAGECACHE *pagecache, size_t resize_pagecache(PAGECACHE *pagecache,
size_t use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold) uint age_threshold)
{ {
ulong blocks; size_t blocks;
struct st_my_thread_var *thread; struct st_my_thread_var *thread;
WQUEUE *wqueue; WQUEUE *wqueue;
...@@ -1379,7 +1379,7 @@ static void link_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block, ...@@ -1379,7 +1379,7 @@ static void link_block(PAGECACHE *pagecache, PAGECACHE_BLOCK_LINK *block,
("linked block: %u:%1u status: %x #requests: %u #available: %u", ("linked block: %u:%1u status: %x #requests: %u #available: %u",
PCBLOCK_NUMBER(pagecache, block), at_end, block->status, PCBLOCK_NUMBER(pagecache, block), at_end, block->status,
block->requests, pagecache->blocks_available)); block->requests, pagecache->blocks_available));
KEYCACHE_DBUG_ASSERT((ulong) pagecache->blocks_available <= KEYCACHE_DBUG_ASSERT(pagecache->blocks_available <=
pagecache->blocks_used); pagecache->blocks_used);
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -2018,7 +2018,7 @@ static PAGECACHE_BLOCK_LINK *find_block(PAGECACHE *pagecache, ...@@ -2018,7 +2018,7 @@ static PAGECACHE_BLOCK_LINK *find_block(PAGECACHE *pagecache,
/* There are some never used blocks, take first of them */ /* There are some never used blocks, take first of them */
block= &pagecache->block_root[pagecache->blocks_used]; block= &pagecache->block_root[pagecache->blocks_used];
block->buffer= ADD_TO_PTR(pagecache->block_mem, block->buffer= ADD_TO_PTR(pagecache->block_mem,
((ulong) pagecache->blocks_used* (pagecache->blocks_used*
pagecache->block_size), pagecache->block_size),
uchar*); uchar*);
pagecache->blocks_used++; pagecache->blocks_used++;
...@@ -4870,7 +4870,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache, ...@@ -4870,7 +4870,7 @@ my_bool pagecache_collect_changed_blocks_with_lsn(PAGECACHE *pagecache,
LSN *min_rec_lsn) LSN *min_rec_lsn)
{ {
my_bool error= 0; my_bool error= 0;
ulong stored_list_size= 0; size_t stored_list_size= 0;
uint file_hash; uint file_hash;
char *ptr; char *ptr;
LSN minimum_rec_lsn= LSN_MAX; LSN minimum_rec_lsn= LSN_MAX;
......
...@@ -117,20 +117,20 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK; ...@@ -117,20 +117,20 @@ typedef struct st_pagecache_hash_link PAGECACHE_HASH_LINK;
typedef struct st_pagecache typedef struct st_pagecache
{ {
size_t mem_size; /* specified size of the cache memory */ size_t mem_size; /* specified size of the cache memory */
ulong min_warm_blocks; /* min number of warm blocks; */ size_t min_warm_blocks; /* min number of warm blocks; */
ulong age_threshold; /* age threshold for hot blocks */ size_t age_threshold; /* age threshold for hot blocks */
ulonglong time; /* total number of block link operations */ ulonglong time; /* total number of block link operations */
ulong hash_entries; /* max number of entries in the hash table */ size_t hash_entries; /* max number of entries in the hash table */
long hash_links; /* max number of hash links */ ssize_t hash_links; /* max number of hash links */
long hash_links_used; /* number of hash links taken from free links pool */ ssize_t hash_links_used; /* number of hash links taken from free links pool */
long disk_blocks; /* max number of blocks in the cache */ ssize_t disk_blocks; /* max number of blocks in the cache */
ulong blocks_used; /* maximum number of concurrently used blocks */ size_t blocks_used; /* maximum number of concurrently used blocks */
ulong blocks_unused; /* number of currently unused blocks */ size_t blocks_unused; /* number of currently unused blocks */
ulong blocks_changed; /* number of currently dirty blocks */ size_t blocks_changed; /* number of currently dirty blocks */
ulong warm_blocks; /* number of blocks in warm sub-chain */ size_t warm_blocks; /* number of blocks in warm sub-chain */
ulong cnt_for_resize_op; /* counter to block resize operation */ size_t cnt_for_resize_op; /* counter to block resize operation */
ulong blocks_available; /* number of blocks available in the LRU chain */ size_t blocks_available; /* number of blocks available in the LRU chain */
long blocks; /* max number of blocks in the cache */ ssize_t blocks; /* max number of blocks in the cache */
uint32 block_size; /* size of the page buffer of a cache block */ uint32 block_size; /* size of the page buffer of a cache block */
PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */ PAGECACHE_HASH_LINK **hash_root;/* arr. of entries into hash table buckets */
PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */ PAGECACHE_HASH_LINK *hash_link_root;/* memory for hash table links */
...@@ -155,12 +155,12 @@ typedef struct st_pagecache ...@@ -155,12 +155,12 @@ typedef struct st_pagecache
*/ */
ulonglong param_buff_size; /* size the memory allocated for the cache */ ulonglong param_buff_size; /* size the memory allocated for the cache */
ulong param_block_size; /* size of the blocks in the key cache */ size_t param_block_size; /* size of the blocks in the key cache */
ulong param_division_limit; /* min. percentage of warm blocks */ size_t param_division_limit; /* min. percentage of warm blocks */
ulong param_age_threshold; /* determines when hot block is downgraded */ size_t param_age_threshold; /* determines when hot block is downgraded */
/* Statistics variables. These are reset in reset_pagecache_counters(). */ /* Statistics variables. These are reset in reset_pagecache_counters(). */
ulong global_blocks_changed; /* number of currently dirty blocks */ size_t global_blocks_changed; /* number of currently dirty blocks */
ulonglong global_cache_w_requests;/* number of write requests (write hits) */ ulonglong global_cache_w_requests;/* number of write requests (write hits) */
ulonglong global_cache_write; /* number of writes from cache to files */ ulonglong global_cache_write; /* number of writes from cache to files */
ulonglong global_cache_r_requests;/* number of read requests (read hits) */ ulonglong global_cache_r_requests;/* number of read requests (read hits) */
...@@ -193,10 +193,10 @@ typedef enum pagecache_flush_filter_result ...@@ -193,10 +193,10 @@ typedef enum pagecache_flush_filter_result
/* The default key cache */ /* The default key cache */
extern PAGECACHE dflt_pagecache_var, *dflt_pagecache; extern PAGECACHE dflt_pagecache_var, *dflt_pagecache;
extern ulong init_pagecache(PAGECACHE *pagecache, size_t use_mem, extern size_t init_pagecache(PAGECACHE *pagecache, size_t use_mem,
uint division_limit, uint age_threshold, uint division_limit, uint age_threshold,
uint block_size, myf my_read_flags); uint block_size, myf my_read_flags);
extern ulong resize_pagecache(PAGECACHE *pagecache, extern size_t resize_pagecache(PAGECACHE *pagecache,
size_t use_mem, uint division_limit, size_t use_mem, uint division_limit,
uint age_threshold); uint age_threshold);
extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit, extern void change_pagecache_param(PAGECACHE *pagecache, uint division_limit,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment