diff options
Diffstat (limited to 'storage')
61 files changed, 657 insertions, 335 deletions
diff --git a/storage/connect/CMakeLists.txt b/storage/connect/CMakeLists.txt index 86f44edc7c9..c8747f889c6 100644 --- a/storage/connect/CMakeLists.txt +++ b/storage/connect/CMakeLists.txt @@ -109,6 +109,7 @@ IF(CONNECT_WITH_LIBXML2) FIND_PACKAGE(LibXml2) IF (LIBXML2_FOUND) INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + SET(ZLIB_LIBRARY "z") # see ZLIB_INCLUDE_DIR below SET(XML_LIBRARY ${LIBXML2_LIBRARIES}) SET(CONNECT_SOURCES ${CONNECT_SOURCES} libdoc.cpp libdoc.h) add_definitions(-DLIBXML2_SUPPORT) @@ -325,6 +326,14 @@ IF(NOT TARGET connect) RETURN() ENDIF() +# Don't link with bundled zlib and systel libxml2 at the same time. +# System libxml2 uses system zlib, might conflict with the bundled one. +IF (XML_LIBRARY AND BUILD_BUNDLED_ZLIB) + GET_PROPERTY(INCS TARGET connect PROPERTY INCLUDE_DIRECTORIES) + LIST(REMOVE_ITEM INCS ${ZLIB_INCLUDE_DIR}) + SET_PROPERTY(TARGET connect PROPERTY INCLUDE_DIRECTORIES ${INCS}) +ENDIF() + IF(WIN32) IF (libmongoc-1.0_FOUND) SET_TARGET_PROPERTIES(connect PROPERTIES LINK_FLAGS diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index 39123b18c59..21bca637eab 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -254,7 +254,7 @@ bool CntOpenTable(PGLOBAL g, PTDB tdbp, MODE mode, char *c1, char *c2, try { if (!c1) { - if (mode == MODE_INSERT) +// if (mode == MODE_INSERT) or CHECK TABLE // Allocate all column blocks for that table tdbp->ColDB(g, NULL, 0); diff --git a/storage/connect/global.h b/storage/connect/global.h index 472d09408c3..36e8a311124 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -1,7 +1,7 @@ /***********************************************************************/ /* GLOBAL.H: Declaration file used by all CONNECT implementations. */ /* (C) Copyright MariaDB Corporation Ab */ -/* Author Olivier Bertrand 1993-2017 */ +/* Author Olivier Bertrand 1993-2018 */ /***********************************************************************/ /***********************************************************************/ @@ -192,7 +192,7 @@ typedef struct _global { /* Global structure */ PACTIVITY Activityp; char Message[MAX_STR]; ulong More; /* Used by jsonudf */ - int Createas; /* To pass info to created table */ + int Createas; /* To pass multi to ext tables */ void *Xchk; /* indexes in create/alter */ short Alchecked; /* Checked for ALTER */ short Mrr; /* True when doing mrr */ diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 7530163fba5..7e2cad77d8d 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -170,9 +170,9 @@ #define JSONMAX 10 // JSON Default max grp size extern "C" { - char version[]= "Version 1.06.0007 August 06, 2018"; + char version[]= "Version 1.06.0008 October 06, 2018"; #if defined(__WIN__) - char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; + char compver[]= "Version 1.06.0008 " __DATE__ " " __TIME__; char slash= '\\'; #else // !__WIN__ char slash= '/'; @@ -1778,13 +1778,13 @@ bool ha_connect::CheckVirtualIndex(TABLE_SHARE *s) bool ha_connect::IsPartitioned(void) { #ifdef WITH_PARTITION_STORAGE_ENGINE - if (tshp) + if (tshp) return tshp->partition_info_str_len > 0; else if (table && table->part_info) return true; else #endif - return false; + return false; } // end of IsPartitioned @@ -3290,6 +3290,58 @@ ha_rows ha_connect::records() } // end of records +int ha_connect::check(THD* thd, HA_CHECK_OPT* check_opt) +{ + int rc = HA_ADMIN_OK; + PGLOBAL g = ((table && table->in_use) ? GetPlug(table->in_use, xp) : + (xp) ? xp->g : NULL); + DBUG_ENTER("ha_connect::check"); + + if (!g || !table || xmod != MODE_READ) + DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); + + // Do not close the table if it was opened yet (possible?) + if (IsOpened()) { + if (IsPartitioned() && CheckColumnList(g)) // map can have been changed + rc = HA_ADMIN_CORRUPT; + else if (tdbp->OpenDB(g)) // Rewind table + rc = HA_ADMIN_CORRUPT; + + } else if (xp->CheckQuery(valid_query_id)) { + tdbp = NULL; // Not valid anymore + + if (OpenTable(g, false)) + rc = HA_ADMIN_CORRUPT; + + } else // possible? + DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR); + + if (rc == HA_ADMIN_OK) { + TABTYPE type = GetTypeID(GetStringOption("Type", "*")); + + if (IsFileType(type)) { + if (check_opt->flags & T_MEDIUM) { + // TO DO + do { + if ((rc = CntReadNext(g, tdbp)) == RC_FX) + break; + + } while (rc != RC_EF); + + rc = (rc == RC_EF) ? HA_ADMIN_OK : HA_ADMIN_CORRUPT; + } else if (check_opt->flags & T_EXTEND) { + // TO DO + } // endif's flags + + } // endif file type + + } else + PushWarning(g, thd, 1); + + DBUG_RETURN(rc); +} // end of check + + /** Return an error message specific to this handler. @@ -3309,7 +3361,8 @@ bool ha_connect::get_error_message(int error, String* buf) if (trace(1)) htrc("GEM(%d): %s\n", error, g->Message); - buf->append(g->Message); + buf->append(ErrConvString(g->Message, strlen(g->Message), + &my_charset_latin1).ptr()); } else buf->append("Cannot retrieve error message"); @@ -3424,7 +3477,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); rc = 0; } else - rc = HA_ERR_INTERNAL_ERROR; + rc = HA_ERR_CRASHED_ON_USAGE; // Table must be repaired } // endif rc @@ -3440,6 +3493,9 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT*) rc = HA_ERR_INTERNAL_ERROR; } // end catch + if (rc) + my_message(ER_WARN_DATA_OUT_OF_RANGE, g->Message, MYF(0)); + return rc; } // end of optimize @@ -4501,14 +4557,16 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, // case SQLCOM_REPLACE_SELECT: // newmode= MODE_UPDATE; // To be checked // break; - case SQLCOM_DELETE: - case SQLCOM_DELETE_MULTI: + case SQLCOM_DELETE_MULTI: + *cras = true; + case SQLCOM_DELETE: case SQLCOM_TRUNCATE: newmode= MODE_DELETE; break; - case SQLCOM_UPDATE: case SQLCOM_UPDATE_MULTI: - newmode= MODE_UPDATE; + *cras = true; + case SQLCOM_UPDATE: + newmode= MODE_UPDATE; break; case SQLCOM_SELECT: case SQLCOM_OPTIMIZE: @@ -4533,8 +4591,10 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, newmode= MODE_ANY; break; // } // endif partitioned - - default: + case SQLCOM_REPAIR: // TODO implement it + newmode = MODE_UPDATE; + break; + default: htrc("Unsupported sql_command=%d\n", thd_sql_command(thd)); strcpy(g->Message, "CONNECT Unsupported command"); my_message(ER_NOT_ALLOWED_COMMAND, g->Message, MYF(0)); @@ -4546,17 +4606,18 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, switch (thd_sql_command(thd)) { case SQLCOM_CREATE_TABLE: *chk= true; - *cras= true; + break; + case SQLCOM_UPDATE_MULTI: + case SQLCOM_DELETE_MULTI: + *cras= true; case SQLCOM_INSERT: case SQLCOM_LOAD: case SQLCOM_INSERT_SELECT: // case SQLCOM_REPLACE: // case SQLCOM_REPLACE_SELECT: case SQLCOM_DELETE: - case SQLCOM_DELETE_MULTI: case SQLCOM_TRUNCATE: case SQLCOM_UPDATE: - case SQLCOM_UPDATE_MULTI: case SQLCOM_SELECT: case SQLCOM_OPTIMIZE: case SQLCOM_SET_OPTION: @@ -4584,8 +4645,9 @@ MODE ha_connect::CheckMode(PGLOBAL g, THD *thd, break; // } // endif partitioned - case SQLCOM_CHECK: // TODO implement it - case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... + case SQLCOM_CHECK: // TODO implement it + case SQLCOM_ANALYZE: // TODO implement it + case SQLCOM_END: // Met in procedures: IF(EXISTS(SELECT... newmode= MODE_READ; break; default: @@ -4867,7 +4929,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) #endif // 0 if (cras) - g->Createas= 1; // To tell created table to ignore FLAG + g->Createas= 1; // To tell external tables of a multi-table command if (trace(1)) { #if 0 @@ -6190,9 +6252,9 @@ int ha_connect::create(const char *name, TABLE *table_arg, LEX_STRING cnc = table_arg->s->connect_string; #ifdef WITH_PARTITION_STORAGE_ENGINE partition_info *part_info= table_arg->part_info; -#else +#else // !WITH_PARTITION_STORAGE_ENGINE #define part_info 0 -#endif // WITH_PARTITION_STORAGE_ENGINE +#endif // !WITH_PARTITION_STORAGE_ENGINE xp= GetUser(thd, xp); PGLOBAL g= xp->g; @@ -7248,7 +7310,7 @@ maria_declare_plugin(connect) 0x0107, /* version number (1.05) */ NULL, /* status variables */ connect_system_variables, /* system variables */ - "1.06.0007", /* string version */ + "1.06.0008", /* string version */ MariaDB_PLUGIN_MATURITY_STABLE /* maturity */ } maria_declare_plugin_end; diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index 4c5bf5856cc..07b1c2d2e7d 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -347,11 +347,7 @@ PFIL CondFilter(PGLOBAL g, Item *cond); //PFIL CheckFilter(PGLOBAL g); /** admin commands - called from mysql_admin_table */ -virtual int check(THD* thd, HA_CHECK_OPT* check_opt) -{ - // TODO: implement it - return HA_ADMIN_OK; // Just to avoid error message with checktables -} // end of check +virtual int check(THD* thd, HA_CHECK_OPT* check_opt); /** Number of rows in table. It will only be called if diff --git a/storage/connect/mysql-test/connect/disabled.def b/storage/connect/mysql-test/connect/disabled.def index 0dcf030613d..827ed58b835 100644 --- a/storage/connect/mysql-test/connect/disabled.def +++ b/storage/connect/mysql-test/connect/disabled.def @@ -9,14 +9,15 @@ # Do not use any TAB characters for whitespace. # ############################################################################## -jdbc : Variable settings depend on machine configuration -jdbc_new : Variable settings depend on machine configuration -jdbc_oracle : Variable settings depend on machine configuration -jdbc_postgresql : Variable settings depend on machine configuration -json_mongo_c : Need MongoDB running and its C Driver installed -json_java_2 : Need MongoDB running and its Java Driver installed -json_java_3 : Need MongoDB running and its Java Driver installed -mongo_c : Need MongoDB running and its C Driver installed -mongo_java_2 : Need MongoDB running and its Java Driver installed -mongo_java_3 : Need MongoDB running and its Java Driver installed -tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed +infoschema-9739 : Crashes with MariaDB 10.0 +jdbc : Variable settings depend on machine configuration +jdbc_new : Variable settings depend on machine configuration +jdbc_oracle : Variable settings depend on machine configuration +jdbc_postgresql : Variable settings depend on machine configuration +json_mongo_c : Need MongoDB running and its C Driver installed +json_java_2 : Need MongoDB running and its Java Driver installed +json_java_3 : Need MongoDB running and its Java Driver installed +mongo_c : Need MongoDB running and its C Driver installed +mongo_java_2 : Need MongoDB running and its Java Driver installed +mongo_java_3 : Need MongoDB running and its Java Driver installed +tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed diff --git a/storage/connect/mysql-test/connect/r/mysql_exec.result b/storage/connect/mysql-test/connect/r/mysql_exec.result index c0400bc82e7..cc77240503b 100644 --- a/storage/connect/mysql-test/connect/r/mysql_exec.result +++ b/storage/connect/mysql-test/connect/r/mysql_exec.result @@ -35,6 +35,8 @@ insert ignore into t1(id) values(NULL) 1 1 Affected rows Warning 0 1364 Field 'msg' doesn't have a default value update t1 set msg = 'Four' where id = 4 0 1 Affected rows select * from t1 0 2 Result set columns +Warnings: +Warning 1105 Result set columns # # Checking Using Procedure # @@ -48,9 +50,13 @@ CALL p1('insert ignore into t1(id) values(NULL)'); command warnings number message insert ignore into t1(id) values(NULL) 1 1 Affected rows Warning 0 1364 Field 'msg' doesn't have a default value +Warnings: +Warning 1105 Affected rows CALL p1('update t1 set msg = "Five" where id = 5'); command warnings number message update t1 set msg = "Five" where id = 5 0 1 Affected rows +Warnings: +Warning 1105 Affected rows DROP PROCEDURE p1; DROP TABLE t1; connection slave; diff --git a/storage/connect/mysql-test/connect/r/odbc_postgresql.result b/storage/connect/mysql-test/connect/r/odbc_postgresql.result index 3426d23e29c..dc23dbdb990 100644 --- a/storage/connect/mysql-test/connect/r/odbc_postgresql.result +++ b/storage/connect/mysql-test/connect/r/odbc_postgresql.result @@ -99,9 +99,9 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu mtr public t1 a 4 int4 10 4 0 10 0 mtr public t2 a 4 int4 10 4 0 10 0 mtr public v1 a 4 int4 10 4 0 10 1 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1 DROP TABLE t1; # All columns in the schemas "public" and "schema1" CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.%'; @@ -110,16 +110,16 @@ Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Bu mtr public t1 a 4 int4 10 4 0 10 0 mtr public t2 a 4 int4 10 4 0 10 0 mtr public v1 a 4 int4 10 4 0 10 1 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 t2 a 1 bpchar 10 60 NULL NULL 0 -mtr schema1 v1 a 1 bpchar 10 60 NULL NULL 1 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1 DROP TABLE t1; # All tables "t1" in all schemas CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.%.t1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks mtr public t1 a 4 int4 10 4 0 10 0 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 DROP TABLE t1; # Table "t1" in the schema "public" CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.public.t1'; @@ -131,14 +131,14 @@ DROP TABLE t1; CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='%.schema1.t1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 DROP TABLE t1; # All tables "t1" in all schemas (Catalog name is ignored by PostgreSQL) CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' CATFUNC=Columns TABNAME='xxx.%.t1'; SELECT * FROM t1 ORDER BY Table_Schema, Table_Name; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks mtr public t1 a 4 int4 10 4 0 10 0 -mtr schema1 t1 a 1 bpchar 10 60 NULL NULL 0 +mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 DROP TABLE t1; # # Checking tables diff --git a/storage/connect/odbconn.cpp b/storage/connect/odbconn.cpp index f7b1a43a95d..6687513fa6c 100644 --- a/storage/connect/odbconn.cpp +++ b/storage/connect/odbconn.cpp @@ -2354,11 +2354,11 @@ int ODBConn::GetCatInfo(CATPARM *cap) if (!Check(rc)) ThrowDBX(rc, fnc, hstmt); - rc = SQLNumResultCols(hstmt, &ncol); - - // n because we no more ignore the first column - if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol) - ThrowDBX(MSG(COL_NUM_MISM)); + // Some data source do not implement SQLNumResultCols + if (Check(SQLNumResultCols(hstmt, &ncol))) + // n because we no more ignore the first column + if ((n = (UWORD)qrp->Nbcol) > (UWORD)ncol) + ThrowDBX(MSG(COL_NUM_MISM)); // Unconditional to handle STRBLK's pval = (PVAL *)PlugSubAlloc(g, NULL, n * sizeof(PVAL)); diff --git a/storage/connect/tabext.cpp b/storage/connect/tabext.cpp index 139e4199ed9..f2d5eb0e69d 100644 --- a/storage/connect/tabext.cpp +++ b/storage/connect/tabext.cpp @@ -125,6 +125,12 @@ EXTDEF::EXTDEF(void) /***********************************************************************/ bool EXTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { + if (g->Createas) { + strcpy(g->Message, + "Multiple-table UPDATE/DELETE commands are not supported"); + return true; + } // endif multi + Desc = NULL; Tabname = GetStringCatInfo(g, "Name", (Catfunc & (FNC_TABLE | FNC_COL)) ? NULL : Name); diff --git a/storage/connect/tabjdbc.cpp b/storage/connect/tabjdbc.cpp index 275b5edaeae..adb3fc4fb51 100644 --- a/storage/connect/tabjdbc.cpp +++ b/storage/connect/tabjdbc.cpp @@ -1157,8 +1157,9 @@ bool TDBXJDC::OpenDB(PGLOBAL g) /* Get the command to execute. */ /*********************************************************************/ if (!(Cmdlist = MakeCMD(g))) { - Jcp->Close(); - return true; + // Next lines commented out because of CHECK TABLE + //Jcp->Close(); + //return true; } // endif Query Rows = 1; @@ -1189,8 +1190,10 @@ int TDBXJDC::ReadDB(PGLOBAL g) Fpos++; // Used for progress info Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; return RC_OK; - } else + } else { + PushWarning(g, this, 1); return RC_EF; + } // endif Cmdlist } // end of ReadDB diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp index 605b3822430..ceffafac02c 100644 --- a/storage/connect/tabmysql.cpp +++ b/storage/connect/tabmysql.cpp @@ -1587,8 +1587,9 @@ bool TDBMYEXC::OpenDB(PGLOBAL g) /* Get the command to execute. */ /*********************************************************************/ if (!(Cmdlist = MakeCMD(g))) { - Myc.Close(); - return true; + // Next lines commented out because of CHECK TABLE + //Myc.Close(); + //return true; } // endif Cmdlist return false; @@ -1647,8 +1648,10 @@ int TDBMYEXC::ReadDB(PGLOBAL g) ++N; return RC_OK; - } else - return RC_EF; + } else { + PushWarning(g, this, 1); + return RC_EF; + } // endif Cmdlist } // end of ReadDB diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index f7bc3934fbd..fddfb0c0420 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -1249,9 +1249,10 @@ bool TDBXDBC::OpenDB(PGLOBAL g) /* Get the command to execute. */ /*********************************************************************/ if (!(Cmdlist = MakeCMD(g))) { - Ocp->Close(); - return true; - } // endif Query + // Next lines commented out because of CHECK TABLE + //Ocp->Close(); + //return true; + } // endif Cmdlist Rows = 1; return false; @@ -1274,8 +1275,10 @@ int TDBXDBC::ReadDB(PGLOBAL g) Fpos++; // Used for progress info Cmdlist = (Nerr > Mxr) ? NULL : Cmdlist->Next; return RC_OK; - } else - return RC_EF; + } else { + PushWarning(g, this, 1); + return RC_EF; + } // endif Cmdlist } // end of ReadDB diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index ed669069b96..dcfff4e8e9f 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. - Copyright (c) 2010, 2017, MariaDB Corporation. +/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. + Copyright (c) 2010, 2018, MariaDB Corporation. 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 @@ -98,7 +98,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, /* fall through */ case HA_KEYTYPE_VARTEXT1: keyinfo->flag|= HA_VAR_LENGTH_KEY; - length+= 2; + /* + For BTREE algorithm, key length, greater than or equal + to 255, is packed on 3 bytes. + */ + if (keyinfo->algorithm == HA_KEY_ALG_BTREE) + length+= size_to_store_key_length(keyinfo->seg[j].length); + else + length+= 2; /* Save number of bytes used to store length */ keyinfo->seg[j].bit_start= 1; break; @@ -107,7 +114,14 @@ int heap_create(const char *name, HP_CREATE_INFO *create_info, /* fall_through */ case HA_KEYTYPE_VARTEXT2: keyinfo->flag|= HA_VAR_LENGTH_KEY; - length+= 2; + /* + For BTREE algorithm, key length, greater than or equal + to 255, is packed on 3 bytes. + */ + if (keyinfo->algorithm == HA_KEY_ALG_BTREE) + length+= size_to_store_key_length(keyinfo->seg[j].length); + else + length+= 2; /* Save number of bytes used to store length */ keyinfo->seg[j].bit_start= 2; /* diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index b241192e286..436612c195f 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 1996, 2018, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2012, Facebook Inc. Copyright (c) 2013, 2018, MariaDB Corporation. diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index bde8303ead5..b01cd657369 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -645,9 +645,7 @@ dict_mem_table_col_rename( s += len + 1; } - /* This could fail if the data dictionaries are out of sync. - Proceed with the renaming anyway. */ - ut_ad(!strcmp(from, s)); + ut_ad(!my_strcasecmp(system_charset_info, from, s)); dict_mem_table_col_rename_low(table, static_cast<unsigned>(nth_col), to, s, is_virtual); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 8dd42c03f85..aadd0e7a554 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -67,7 +67,7 @@ ulong fts_max_total_cache_size; /** This is FTS result cache limit for each query and would be a configurable variable */ -ulong fts_result_cache_limit; +size_t fts_result_cache_limit; /** Variable specifying the maximum FTS max token size */ ulong fts_max_token_size; diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index b6a6849f26f..f4f10b7f016 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -75,7 +75,7 @@ struct fts_query_t { fts_table_t fts_index_table;/*!< FTS auxiliary index table def */ - ulint total_size; /*!< total memory size used by query */ + size_t total_size; /*!< total memory size used by query */ fts_doc_ids_t* deleted; /*!< Deleted doc ids that need to be filtered from the output */ diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 84253d88983..2d3d41eb9a5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -5947,7 +5947,8 @@ innobase_build_v_templ( name = dict_table_get_v_col_name(ib_table, z); } - ut_ad(!ut_strcmp(name, field->field_name)); + ut_ad(!my_strcasecmp(system_charset_info, name, + field->field_name)); #endif const dict_v_col_t* vcol; @@ -5978,12 +5979,10 @@ innobase_build_v_templ( dict_col_t* col = dict_table_get_nth_col( ib_table, j); -#ifdef UNIV_DEBUG - const char* name = dict_table_get_col_name( - ib_table, j); - - ut_ad(!ut_strcmp(name, field->field_name)); -#endif + ut_ad(!my_strcasecmp(system_charset_info, + dict_table_get_col_name( + ib_table, j), + field->field_name)); s_templ->vtempl[j] = static_cast< mysql_row_templ_t*>( @@ -20321,10 +20320,10 @@ static MYSQL_SYSVAR_ULONG(ft_total_cache_size, fts_max_total_cache_size, "Total memory allocated for InnoDB Fulltext Search cache", NULL, NULL, 640000000, 32000000, 1600000000, 0); -static MYSQL_SYSVAR_ULONG(ft_result_cache_limit, fts_result_cache_limit, +static MYSQL_SYSVAR_SIZE_T(ft_result_cache_limit, fts_result_cache_limit, PLUGIN_VAR_RQCMDARG, "InnoDB Fulltext search query result cache limit in bytes", - NULL, NULL, 2000000000L, 1000000L, 4294967295UL, 0); + NULL, NULL, 2000000000L, 1000000L, SIZE_T_MAX, 0); static MYSQL_SYSVAR_ULONG(ft_min_token_size, fts_min_token_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 82256b1738b..7a4d4221e09 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -6955,7 +6955,6 @@ innobase_rename_column_try( pars_info_add_ull_literal(info, "tableid", user_table->id); pars_info_add_int4_literal(info, "nth", nth_col); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); trx->op_info = "renaming column in SYS_COLUMNS"; @@ -6965,7 +6964,7 @@ innobase_rename_column_try( "PROCEDURE RENAME_SYS_COLUMNS_PROC () IS\n" "BEGIN\n" "UPDATE SYS_COLUMNS SET NAME=:new\n" - "WHERE TABLE_ID=:tableid AND NAME=:old\n" + "WHERE TABLE_ID=:tableid\n" "AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -6989,8 +6988,10 @@ err_exit: index = dict_table_get_next_index(index)) { for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (strcmp(dict_index_get_nth_field(index, i)->name, - from)) { + if (my_strcasecmp( + system_charset_info, + dict_index_get_nth_field(index, i)->name, + from)) { continue; } @@ -6998,7 +6999,6 @@ err_exit: pars_info_add_ull_literal(info, "indexid", index->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -7007,14 +7007,14 @@ err_exit: "BEGIN\n" "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS=:nth;\n" /* Try again, in case there is a prefix_len encoded in SYS_FIELDS.POS */ "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" "END;\n", @@ -7040,7 +7040,9 @@ rename_foreign: foreign_modified = false; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->foreign_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->foreign_col_names[i], + from)) { continue; } @@ -7048,7 +7050,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -7057,8 +7058,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET FOR_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND FOR_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -7082,7 +7082,9 @@ rename_foreign: dict_foreign_t* foreign = *it; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->referenced_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->referenced_col_names[i], + from)) { continue; } @@ -7090,7 +7092,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -7099,8 +7100,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET REF_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND REF_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index cad9ef37560..11749c991f0 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -394,7 +394,7 @@ extern ulong fts_max_cache_size; extern ulong fts_max_total_cache_size; /** Variable specifying the FTS result cache limit for each query */ -extern ulong fts_result_cache_limit; +extern size_t fts_result_cache_limit; /** Variable specifying the maximum FTS max token size */ extern ulong fts_max_token_size; diff --git a/storage/innobase/include/fts0types.h b/storage/innobase/include/fts0types.h index 55a698e8b66..0bcb8d5a1d3 100644 --- a/storage/innobase/include/fts0types.h +++ b/storage/innobase/include/fts0types.h @@ -163,7 +163,7 @@ struct fts_cache_t { the document from the table. Each element is of type fts_doc_t */ - ulint total_size; /*!< total size consumed by the ilist + size_t total_size; /*!< total size consumed by the ilist field of all nodes. SYNC is run whenever this gets too big */ fts_sync_t* sync; /*!< sync structure to sync data to @@ -245,7 +245,7 @@ struct fts_fetch_t { fts_sql_callback read_record; /*!< Callback for reading index record */ - ulint total_memory; /*!< Total memory used */ + size_t total_memory; /*!< Total memory used */ }; /** For horizontally splitting an FTS auxiliary index */ diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc index 427bf345930..953f3070a11 100644 --- a/storage/innobase/row/row0merge.cc +++ b/storage/innobase/row/row0merge.cc @@ -3970,11 +3970,18 @@ row_merge_file_create_low( /* This temp file open does not go through normal file APIs, add instrumentation to register with performance schema */ - struct PSI_file_locker* locker; PSI_file_locker_state state; - locker = PSI_FILE_CALL(get_thread_file_name_locker)( - &state, innodb_temp_file_key, PSI_FILE_OPEN, - "Innodb Merge Temp File", &locker); + if (!path) { + path = mysql_tmpdir; + } + static const char label[] = "/Innodb Merge Temp File"; + char* name = static_cast<char*>( + ut_malloc_nokey(strlen(path) + sizeof label)); + strcpy(name, path); + strcat(name, label); + PSI_file_locker* locker = PSI_FILE_CALL(get_thread_file_name_locker)( + &state, innodb_temp_file_key, PSI_FILE_OPEN, + path ? name : label, &locker); if (locker != NULL) { PSI_FILE_CALL(start_file_open_wait)(locker, __FILE__, @@ -3987,6 +3994,7 @@ row_merge_file_create_low( PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)( locker, fd); } + ut_free(name); #endif if (fd < 0) { diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 434d538a7ad..4b20d378473 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -3673,9 +3673,7 @@ defer: rw_lock_x_unlock(dict_index_get_lock(index)); } - /* As we don't insert entries to SYSTEM TABLES for temp-tables - we need to avoid running removal of these entries. */ - if (!dict_table_is_temporary(table)) { + if (!table->is_temporary()) { /* We use the private SQL parser of Innobase to generate the query graphs needed in deleting the dictionary data from system tables in Innobase. Deleting a row from SYS_INDEXES table also @@ -4557,6 +4555,9 @@ row_rename_table_for_mysql( " = TO_BINARY(:old_table_name);\n" "END;\n" , FALSE, trx); + if (err != DB_SUCCESS) { + goto end; + } } else if (n_constraints_to_drop > 0) { /* Drop some constraints of tmp tables. */ diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 7caec1fd834..90bf354e325 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -891,8 +891,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, if (level > param->max_level) param->max_level=level; - if (_ma_get_keynr(share, anc_page->buff) != - (uint) (keyinfo - share->keyinfo)) + if (_ma_get_keynr(share, anc_page->buff) != keyinfo->key_nr) _ma_check_print_error(param, "Page at %s is not marked for index %u", llstr(anc_page->pos, llbuff), (uint) (keyinfo - share->keyinfo)); @@ -916,7 +915,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, info->last_key.keyinfo= tmp_key.keyinfo= keyinfo; info->lastinx= ~0; /* Safety */ tmp_key.data= tmp_key_buff; - for ( ;; ) + for ( ;; _ma_copy_key(&info->last_key, &tmp_key)) { if (nod_flag) { @@ -998,7 +997,6 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, tmp_key.data); } } - _ma_copy_key(&info->last_key, &tmp_key); (*key_checksum)+= maria_byte_checksum(tmp_key.data, tmp_key.data_length); record= _ma_row_pos_from_key(&tmp_key); @@ -5753,8 +5751,7 @@ static int sort_insert_key(MARIA_SORT_PARAM *sort_param, a_length= share->keypage_header + nod_flag; key_block->end_pos= anc_buff + share->keypage_header; bzero(anc_buff, share->keypage_header); - _ma_store_keynr(share, anc_buff, (uint) (sort_param->keyinfo - - share->keyinfo)); + _ma_store_keynr(share, anc_buff, sort_param->keyinfo->key_nr); lastkey=0; /* No previous key in block */ } else diff --git a/storage/maria/ma_ft_boolean_search.c b/storage/maria/ma_ft_boolean_search.c index a37a1322ad0..52a476b36ff 100644 --- a/storage/maria/ma_ft_boolean_search.c +++ b/storage/maria/ma_ft_boolean_search.c @@ -457,7 +457,7 @@ static int _ft2_search_no_lock(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) */ ftbw->off=off; ftbw->key_root= info->cur_row.lastpos; - ftbw->keyinfo=& info->s->ft2_keyinfo; + ftbw->keyinfo= info->last_key.keyinfo= & info->s->ft2_keyinfo; r= _ma_search_first(info, ftbw->keyinfo, ftbw->key_root); DBUG_ASSERT(r==0); /* found something */ memcpy(lastkey_buf+off, info->last_key.data, diff --git a/storage/maria/ma_write.c b/storage/maria/ma_write.c index 66bf77e0a80..c4b2280c27d 100644 --- a/storage/maria/ma_write.c +++ b/storage/maria/ma_write.c @@ -669,13 +669,18 @@ static int w_search(register MARIA_HA *info, uint32 comp_flag, MARIA_KEY *key, else { /* popular word. two-level tree. going down */ - my_off_t root=dup_key_pos; - keyinfo= &share->ft2_keyinfo; - get_key_full_length_rdonly(off, key); - key+=off; + my_off_t root= dup_key_pos; + MARIA_KEY subkey; + get_key_full_length_rdonly(off, key->data); + subkey.keyinfo= keyinfo= &share->ft2_keyinfo; + subkey.data= key->data + off; + subkey.data_length= key->data_length - off; + subkey.ref_length= key->ref_length; + subkey.flag= key->flag; + /* we'll modify key entry 'in vivo' */ keypos-= keyinfo->keylength + page.node; - error= _ma_ck_real_write_btree(info, key, &root, comp_flag); + error= _ma_ck_real_write_btree(info, &subkey, &root, comp_flag); _ma_dpointer(share, keypos+HA_FT_WLEN, root); subkeys--; /* should there be underflow protection ? */ DBUG_ASSERT(subkeys < 0); diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 7737c2af6fc..bf0c1eab3e3 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -11810,7 +11810,8 @@ int ha_mroonga::storage_encode_key_timestamp2(Field *field, const uchar *key, #endif #ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2 -int ha_mroonga::storage_encode_key_datetime2(Field *field, const uchar *key, +int ha_mroonga::storage_encode_key_datetime2(Field *field, bool is_null, + const uchar *key, uchar *buf, uint *size) { MRN_DBUG_ENTER_METHOD(); @@ -11818,7 +11819,7 @@ int ha_mroonga::storage_encode_key_datetime2(Field *field, const uchar *key, bool truncated = false; Field_datetimef *datetime2_field = (Field_datetimef *)field; - longlong packed_time = + longlong packed_time = is_null ? 0 : my_datetime_packed_from_binary(key, datetime2_field->decimals()); MYSQL_TIME mysql_time; TIME_from_longlong_datetime_packed(&mysql_time, packed_time); @@ -11945,6 +11946,7 @@ int ha_mroonga::storage_encode_key(Field *field, const uchar *key, MRN_DBUG_ENTER_METHOD(); int error; bool truncated = false; + bool is_null = false; const uchar *ptr = key; error = mrn_change_encoding(ctx, field->charset()); @@ -11952,6 +11954,7 @@ int ha_mroonga::storage_encode_key(Field *field, const uchar *key, DBUG_RETURN(error); if (field->null_bit) { + is_null = *ptr; ptr += 1; } @@ -12049,7 +12052,7 @@ int ha_mroonga::storage_encode_key(Field *field, const uchar *key, #endif #ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2 case MYSQL_TYPE_DATETIME2: - error = storage_encode_key_datetime2(field, ptr, buf, size); + error = storage_encode_key_datetime2(field, is_null, ptr, buf, size); break; #endif #ifdef MRN_HAVE_MYSQL_TYPE_TIME2 diff --git a/storage/mroonga/ha_mroonga.hpp b/storage/mroonga/ha_mroonga.hpp index b769583d434..71ec40ee63a 100644 --- a/storage/mroonga/ha_mroonga.hpp +++ b/storage/mroonga/ha_mroonga.hpp @@ -796,7 +796,7 @@ private: uchar *buf, uint *size); #endif #ifdef MRN_HAVE_MYSQL_TYPE_DATETIME2 - int storage_encode_key_datetime2(Field *field, const uchar *key, + int storage_encode_key_datetime2(Field *field, bool is_null, const uchar *key, uchar *buf, uint *size); #endif #ifdef MRN_HAVE_MYSQL_TYPE_TIME2 diff --git a/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp b/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp index 0038a7fe34f..fa3c49a4236 100644 --- a/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp +++ b/storage/mroonga/lib/mrn_multiple_column_key_codec.cpp @@ -89,11 +89,13 @@ namespace mrn { for (int i = 0; i < n_key_parts && current_mysql_key < mysql_key_end; i++) { KEY_PART_INFO *key_part = &(key_info_->key_part[i]); Field *field = key_part->field; + bool is_null = false; DBUG_PRINT("info", ("mroonga: key_part->length=%u", key_part->length)); if (field->null_bit) { DBUG_PRINT("info", ("mroonga: field has null bit")); *current_grn_key = 0; + is_null = *current_mysql_key; current_mysql_key += 1; current_grn_key += 1; (*grn_key_length)++; @@ -164,7 +166,7 @@ namespace mrn { { Field_datetimef *datetimef_field = static_cast<Field_datetimef *>(field); - long long int mysql_datetime_packed = + long long int mysql_datetime_packed = is_null ? 0 : my_datetime_packed_from_binary(current_mysql_key, datetimef_field->decimals()); MYSQL_TIME mysql_time; diff --git a/storage/myisammrg/mysql-test/storage_engine/disabled.def b/storage/myisammrg/mysql-test/storage_engine/disabled.def index 227e33029d8..55fc952c20e 100644 --- a/storage/myisammrg/mysql-test/storage_engine/disabled.def +++ b/storage/myisammrg/mysql-test/storage_engine/disabled.def @@ -1,3 +1,4 @@ insert_delayed : MDEV-12880 - INSERT DELAYED is not detected as inapplicable to a table under lock lock_concurrent : MDEV-12882 - Assertion failure select_high_prio : MDEV-12885 - MDL_SHARED_READ_ONLY is taken instead of MDL_SHARED_READ +lock : MDEV-17145 (Unexpected ER_LOCK_WAIT_TIMEOUT) diff --git a/storage/perfschema/unittest/pfs-t.cc b/storage/perfschema/unittest/pfs-t.cc index b8814f2ad2d..fd018c1b0c5 100644 --- a/storage/perfschema/unittest/pfs-t.cc +++ b/storage/perfschema/unittest/pfs-t.cc @@ -1,4 +1,4 @@ -/* Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. +/* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. 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 @@ -898,6 +898,7 @@ void test_init_disabled() psi->create_file(file_key_A, "foo-instrumented", (File) 12); file_A1= lookup_file_by_name("foo-instrumented"); ok(file_A1 != NULL, "file_A1 instrumented"); + destroy_file(reinterpret_cast<PFS_thread*>(psi->get_thread()), file_A1); /* broken key + enabled T-1: no instrumentation */ @@ -1149,6 +1150,8 @@ void test_locker_disabled() psi->create_file(file_key_A, "foo", (File) 12); file_A1= (PSI_file*) lookup_file_by_name("foo"); ok(file_A1 != NULL, "instrumented"); + destroy_file(reinterpret_cast<PFS_thread*>(psi->get_thread()), + reinterpret_cast<PFS_file*>(file_A1)); socket_class_A->m_enabled= true; socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0); diff --git a/storage/xtradb/.clang-format b/storage/xtradb/.clang-format new file mode 100644 index 00000000000..d757d0a5a05 --- /dev/null +++ b/storage/xtradb/.clang-format @@ -0,0 +1,111 @@ +# generated with: +# clang-format-5.0 -style=Google --dump-config + +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeCategories: + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: false +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +SortUsingDeclarations: true +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +TabWidth: 8 + + +# changes for MySQL 5.x (InnoDB) +AlignConsecutiveDeclarations: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: All +ColumnLimit: 78 +DerivePointerAlignment: false +IndentWidth: 8 +MaxEmptyLinesToKeep: 2 +PointerAlignment: Right +ReflowComments: false +SortIncludes: false +SpaceAfterCStyleCast: true +UseTab: Always diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index ad1b1a0aa57..c45f88707a5 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -65,9 +65,6 @@ IF(UNIX) LINK_LIBRARIES(${AIO_LIBRARY}) ENDIF() ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1") - IF(HAVE_LIBNUMA) - LINK_LIBRARIES(numa) - ENDIF() ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*") ADD_DEFINITIONS("-DUNIV_HPUX") ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX") @@ -505,7 +502,21 @@ SET(INNOBASE_SOURCES ut/ut0wqueue.cc ut/ut0timer.cc) +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") + enable_language(ASM) + LIST(APPEND INNOBASE_SOURCES + ut/crc32_power8/crc32.S + ut/crc32_power8/crc32_wrapper.c + ) +ENDIF() + +UNSET(NUMA_LIBRARY) +IF(HAVE_LIBNUMA) + SET(NUMA_LIBRARY "numa") +ENDIF() + MYSQL_ADD_PLUGIN(xtradb ${INNOBASE_SOURCES} STORAGE_ENGINE + DEFAULT RECOMPILE_FOR_EMBEDDED LINK_LIBRARIES ${ZLIB_LIBRARY} diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index a6b0dabe110..357fcc0c872 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -55,6 +55,9 @@ Created 11/5/1995 Heikki Tuuri #include "page0zip.h" #include "srv0mon.h" #include "buf0checksum.h" + +UNIV_INTERN my_bool srv_numa_interleave = FALSE; + #ifdef HAVE_LIBNUMA #include <numa.h> #include <numaif.h> @@ -1405,7 +1408,8 @@ buf_chunk_init( /*===========*/ buf_pool_t* buf_pool, /*!< in: buffer pool instance */ buf_chunk_t* chunk, /*!< out: chunk of buffers */ - ulint mem_size) /*!< in: requested size in bytes */ + ulint mem_size, /*!< in: requested size in bytes */ + bool populate) /*!< in: virtual page preallocation */ { buf_block_t* block; byte* frame; @@ -1421,7 +1425,7 @@ buf_chunk_init( + (UNIV_PAGE_SIZE - 1), UNIV_PAGE_SIZE); chunk->mem_size = mem_size; - chunk->mem = os_mem_alloc_large(&chunk->mem_size); + chunk->mem = os_mem_alloc_large(&chunk->mem_size, populate); if (UNIV_UNLIKELY(chunk->mem == NULL)) { @@ -1641,6 +1645,7 @@ buf_pool_init_instance( /*===================*/ buf_pool_t* buf_pool, /*!< in: buffer pool instance */ ulint buf_pool_size, /*!< in: size in bytes */ + bool populate, /*!< in: virtual page preallocation */ ulint instance_no) /*!< in: id of the instance */ { ulint i; @@ -1667,7 +1672,7 @@ buf_pool_init_instance( buf_pool->chunks = chunk = (buf_chunk_t*) mem_zalloc(sizeof *chunk); - if (!buf_chunk_init(buf_pool, chunk, buf_pool_size)) { + if (!buf_chunk_init(buf_pool, chunk, buf_pool_size, populate)) { mem_free(chunk); mem_free(buf_pool); @@ -1822,6 +1827,7 @@ dberr_t buf_pool_init( /*==========*/ ulint total_size, /*!< in: size of the total pool in bytes */ + bool populate, /*!< in: virtual page preallocation */ ulint n_instances) /*!< in: number of instances */ { ulint i; @@ -1854,7 +1860,7 @@ buf_pool_init( for (i = 0; i < n_instances; i++) { buf_pool_t* ptr = &buf_pool_ptr[i]; - if (buf_pool_init_instance(ptr, size, i) != DB_SUCCESS) { + if (buf_pool_init_instance(ptr, size, populate, i) != DB_SUCCESS) { /* Free all the instances created so far. */ buf_pool_free(i); diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index e9168d9f5d5..f73bf3bdc58 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -200,8 +200,9 @@ buf_dump( { #define SHOULD_QUIT() (SHUTTING_DOWN() && obey_shutdown) + static const char format_name[]= "%s.incomplete"; char full_filename[OS_FILE_MAX_PATH]; - char tmp_filename[OS_FILE_MAX_PATH + sizeof "incomplete"]; + char tmp_filename[OS_FILE_MAX_PATH + sizeof(format_name)]; char now[32]; FILE* f; ulint i; @@ -212,7 +213,7 @@ buf_dump( srv_buf_dump_filename); ut_snprintf(tmp_filename, sizeof(tmp_filename), - "%s.incomplete", full_filename); + format_name, full_filename); buf_dump_status(STATUS_NOTICE, "Dumping buffer pool(s) to %s", full_filename); diff --git a/storage/xtradb/dict/dict0crea.cc b/storage/xtradb/dict/dict0crea.cc index 2fe9f8af4ec..639785bf84a 100644 --- a/storage/xtradb/dict/dict0crea.cc +++ b/storage/xtradb/dict/dict0crea.cc @@ -1363,6 +1363,21 @@ dict_create_or_check_foreign_constraint_tables(void) row_mysql_lock_data_dictionary(trx); + DBUG_EXECUTE_IF( + "create_and_drop_garbage", + err = que_eval_sql( + NULL, + "PROCEDURE CREATE_GARBAGE_TABLE_PROC () IS\n" + "BEGIN\n" + "CREATE TABLE\n" + "\"test/#sql-ib-garbage\"(ID CHAR);\n" + "CREATE UNIQUE CLUSTERED INDEX PRIMARY" + " ON \"test/#sql-ib-garbage\"(ID);\n" + "END;\n", FALSE, trx); + ut_ad(err == DB_SUCCESS); + row_drop_table_for_mysql("test/#sql-ib-garbage", + trx, TRUE, TRUE);); + /* Check which incomplete table definition to drop. */ if (sys_foreign_err == DB_CORRUPTION) { diff --git a/storage/xtradb/dict/dict0mem.cc b/storage/xtradb/dict/dict0mem.cc index ab6167b920b..4ef3d5df750 100644 --- a/storage/xtradb/dict/dict0mem.cc +++ b/storage/xtradb/dict/dict0mem.cc @@ -499,9 +499,7 @@ dict_mem_table_col_rename( s += len + 1; } - /* This could fail if the data dictionaries are out of sync. - Proceed with the renaming anyway. */ - ut_ad(!strcmp(from, s)); + ut_ad(!my_strcasecmp(system_charset_info, from, s)); dict_mem_table_col_rename_low(table, nth_col, to, s); } diff --git a/storage/xtradb/fts/fts0blex.cc b/storage/xtradb/fts/fts0blex.cc index 2d71934fa0e..a8f231268ac 100644 --- a/storage/xtradb/fts/fts0blex.cc +++ b/storage/xtradb/fts/fts0blex.cc @@ -701,9 +701,9 @@ extern int fts0blex (yyscan_t yyscanner); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; #line 43 "fts0blex.l" @@ -753,7 +753,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -984,9 +984,9 @@ case YY_STATE_EOF(INITIAL): static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1118,15 +1118,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1151,11 +1151,11 @@ static yy_state_type yy_get_previous_state (yyscan_t yyscanner) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - register int yy_is_jam; + int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; + char *yy_cp = yyg->yy_c_buf_p; - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1912,7 +1912,7 @@ int fts0blex_destroy (yyscan_t yyscanner) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { - register int i; + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } @@ -1921,7 +1921,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yys #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 5981c24c470..02d81551e75 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -67,7 +67,7 @@ UNIV_INTERN ulong fts_max_total_cache_size; /** This is FTS result cache limit for each query and would be a configurable variable */ -UNIV_INTERN ulong fts_result_cache_limit; +UNIV_INTERN size_t fts_result_cache_limit; /** Variable specifying the maximum FTS max token size */ UNIV_INTERN ulong fts_max_token_size; @@ -4308,7 +4308,7 @@ fts_sync_begin( if (fts_enable_diag_print) { ib_logf(IB_LOG_LEVEL_INFO, "FTS SYNC for table %s, deleted count: %ld size: " - "%lu bytes", + "%zu bytes", sync->table->name, ib_vector_size(cache->deleted_doc_ids), cache->total_size); diff --git a/storage/xtradb/fts/fts0que.cc b/storage/xtradb/fts/fts0que.cc index 9966656e772..b9ad43c626a 100644 --- a/storage/xtradb/fts/fts0que.cc +++ b/storage/xtradb/fts/fts0que.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, MariaDB Corporation. +Copyright (c) 2017, 2018, MariaDB Corporation. 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 the Free Software @@ -76,7 +76,7 @@ struct fts_query_t { fts_table_t fts_index_table;/*!< FTS auxiliary index table def */ - ulint total_size; /*!< total memory size used by query */ + size_t total_size; /*!< total memory size used by query */ fts_doc_ids_t* deleted; /*!< Deleted doc ids that need to be filtered from the output */ @@ -4058,7 +4058,7 @@ fts_query( /* Log memory consumption & result size */ ib_logf(IB_LOG_LEVEL_INFO, "Full Search Memory: " - "%lu (bytes), Row: %lu .", + "%zu (bytes), Row: %lu .", query.total_size, (*result)->rankings_by_id ? rbt_size((*result)->rankings_by_id) diff --git a/storage/xtradb/fts/fts0tlex.cc b/storage/xtradb/fts/fts0tlex.cc index d4d9b4c48d1..28fac9bf704 100644 --- a/storage/xtradb/fts/fts0tlex.cc +++ b/storage/xtradb/fts/fts0tlex.cc @@ -697,9 +697,9 @@ extern int fts0tlex (yyscan_t yyscanner); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; #line 44 "fts0tlex.l" @@ -749,7 +749,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -976,9 +976,9 @@ case YY_STATE_EOF(INITIAL): static int yy_get_next_buffer (yyscan_t yyscanner) { struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = yyg->yytext_ptr; - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = yyg->yytext_ptr; + int number_to_move, i; int ret_val; if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) @@ -1110,15 +1110,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner) { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; yy_current_state = yyg->yy_start; for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1143,11 +1143,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) { - register int yy_is_jam; + int yy_is_jam; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ - register char *yy_cp = yyg->yy_c_buf_p; + char *yy_cp = yyg->yy_c_buf_p; - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { yyg->yy_last_accepting_state = yy_current_state; @@ -1905,7 +1905,7 @@ int fts0tlex_destroy (yyscan_t yyscanner) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { - register int i; + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } @@ -1914,7 +1914,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yys #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused)) MY_ATTRIBUTE((unused))) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index eb860ef4d62..1a63bd815df 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -5,6 +5,7 @@ Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. +Copyright (c) 2013, 2018, MariaDB Corporation. Portions of this file contain modifications contributed and copyrighted by Google, Inc. Those modifications are gratefully acknowledged and are described @@ -3527,13 +3528,13 @@ innobase_convert_identifier( ibool file_id)/*!< in: TRUE=id is a table or database name; FALSE=id is an UTF-8 string */ { - char nz2[MAX_TABLE_NAME_LEN + 1]; const char* s = id; int q; - if (file_id) { + char nz[MAX_TABLE_NAME_LEN + 1]; + char nz2[MAX_TABLE_NAME_LEN + 1]; - char nz[MAX_TABLE_NAME_LEN + 1]; + if (file_id) { /* Decode the table name. The MySQL function expects a NUL-terminated string. The input and output strings @@ -20678,10 +20679,10 @@ static MYSQL_SYSVAR_ULONG(ft_total_cache_size, fts_max_total_cache_size, "Total memory allocated for InnoDB Fulltext Search cache", NULL, NULL, 640000000, 32000000, 1600000000, 0); -static MYSQL_SYSVAR_ULONG(ft_result_cache_limit, fts_result_cache_limit, +static MYSQL_SYSVAR_SIZE_T(ft_result_cache_limit, fts_result_cache_limit, PLUGIN_VAR_RQCMDARG, "InnoDB Fulltext search query result cache limit in bytes", - NULL, NULL, 2000000000L, 1000000L, 4294967295UL, 0); + NULL, NULL, 2000000000L, 1000000L, SIZE_T_MAX, 0); static MYSQL_SYSVAR_ULONG(ft_min_token_size, fts_min_token_size, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, @@ -22103,15 +22104,6 @@ int ha_innobase::multi_range_read_explain_info(uint mrr_mode, char *str, size_t return ds_mrr.dsmrr_explain_info(mrr_mode, str, size); } -/* - A helper function used only in index_cond_func_innodb -*/ - -bool ha_innobase::is_thd_killed() -{ - return thd_kill_level(user_thd); -} - /********************************************************************** Issue a warning that the row is too big. */ UNIV_INTERN diff --git a/storage/xtradb/handler/ha_innodb.h b/storage/xtradb/handler/ha_innodb.h index 3dbbc53a0e3..7f5a1b5817f 100644 --- a/storage/xtradb/handler/ha_innodb.h +++ b/storage/xtradb/handler/ha_innodb.h @@ -206,7 +206,7 @@ class ha_innobase: public handler char* remote_path); const char* check_table_options(THD *thd, TABLE* table, HA_CREATE_INFO* create_info, const bool use_tablespace, const ulint file_format); - int create(const char *name, register TABLE *form, + int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); int truncate(); int delete_table(const char *name); @@ -389,10 +389,6 @@ public: * @return idx_cond if pushed; NULL if not pushed */ class Item* idx_cond_push(uint keyno, class Item* idx_cond); - - /* An helper function for index_cond_func_innodb: */ - bool is_thd_killed(); - private: /** The multi range read session object */ DsMrr_impl ds_mrr; diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 81077758bae..3bad086414c 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -4635,7 +4635,6 @@ innobase_rename_column_try( pars_info_add_ull_literal(info, "tableid", user_table->id); pars_info_add_int4_literal(info, "nth", nth_col); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); trx->op_info = "renaming column in SYS_COLUMNS"; @@ -4645,7 +4644,7 @@ innobase_rename_column_try( "PROCEDURE RENAME_SYS_COLUMNS_PROC () IS\n" "BEGIN\n" "UPDATE SYS_COLUMNS SET NAME=:new\n" - "WHERE TABLE_ID=:tableid AND NAME=:old\n" + "WHERE TABLE_ID=:tableid\n" "AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -4669,8 +4668,10 @@ err_exit: index = dict_table_get_next_index(index)) { for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (strcmp(dict_index_get_nth_field(index, i)->name, - from)) { + if (my_strcasecmp( + system_charset_info, + dict_index_get_nth_field(index, i)->name, + from)) { continue; } @@ -4678,7 +4679,6 @@ err_exit: pars_info_add_ull_literal(info, "indexid", index->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4687,14 +4687,14 @@ err_exit: "BEGIN\n" "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS=:nth;\n" /* Try again, in case there is a prefix_len encoded in SYS_FIELDS.POS */ "UPDATE SYS_FIELDS SET COL_NAME=:new\n" - "WHERE INDEX_ID=:indexid AND COL_NAME=:old\n" + "WHERE INDEX_ID=:indexid\n" "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" "END;\n", @@ -4720,7 +4720,9 @@ rename_foreign: foreign_modified = false; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->foreign_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->foreign_col_names[i], + from)) { continue; } @@ -4728,7 +4730,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4737,8 +4738,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET FOR_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND FOR_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); @@ -4762,7 +4762,9 @@ rename_foreign: dict_foreign_t* foreign = *it; for (unsigned i = 0; i < foreign->n_fields; i++) { - if (strcmp(foreign->referenced_col_names[i], from)) { + if (my_strcasecmp(system_charset_info, + foreign->referenced_col_names[i], + from)) { continue; } @@ -4770,7 +4772,6 @@ rename_foreign: pars_info_add_str_literal(info, "id", foreign->id); pars_info_add_int4_literal(info, "nth", i); - pars_info_add_str_literal(info, "old", from); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( @@ -4779,8 +4780,7 @@ rename_foreign: "BEGIN\n" "UPDATE SYS_FOREIGN_COLS\n" "SET REF_COL_NAME=:new\n" - "WHERE ID=:id AND POS=:nth\n" - "AND REF_COL_NAME=:old;\n" + "WHERE ID=:id AND POS=:nth;\n" "END;\n", FALSE, trx); diff --git a/storage/xtradb/include/buf0buf.h b/storage/xtradb/include/buf0buf.h index 0944b5d4067..b4ea4d56e31 100644 --- a/storage/xtradb/include/buf0buf.h +++ b/storage/xtradb/include/buf0buf.h @@ -217,6 +217,7 @@ dberr_t buf_pool_init( /*=========*/ ulint size, /*!< in: Size of the total pool in bytes */ + bool populate, /*!< in: Force virtual page preallocation */ ulint n_instances); /*!< in: Number of instances */ /********************************************************************//** Frees the buffer pool at shutdown. This must not be invoked before diff --git a/storage/xtradb/include/fts0fts.h b/storage/xtradb/include/fts0fts.h index 4c2d247e0a6..ce30a17c4b4 100644 --- a/storage/xtradb/include/fts0fts.h +++ b/storage/xtradb/include/fts0fts.h @@ -355,7 +355,7 @@ extern ulong fts_max_cache_size; extern ulong fts_max_total_cache_size; /** Variable specifying the FTS result cache limit for each query */ -extern ulong fts_result_cache_limit; +extern size_t fts_result_cache_limit; /** Variable specifying the maximum FTS max token size */ extern ulong fts_max_token_size; diff --git a/storage/xtradb/include/fts0types.h b/storage/xtradb/include/fts0types.h index 0dad75d8f1b..9ecd9080881 100644 --- a/storage/xtradb/include/fts0types.h +++ b/storage/xtradb/include/fts0types.h @@ -161,7 +161,7 @@ struct fts_cache_t { the document from the table. Each element is of type fts_doc_t */ - ulint total_size; /*!< total size consumed by the ilist + size_t total_size; /*!< total size consumed by the ilist field of all nodes. SYNC is run whenever this gets too big */ fts_sync_t* sync; /*!< sync structure to sync data to @@ -243,7 +243,7 @@ struct fts_fetch_t { fts_sql_callback read_record; /*!< Callback for reading index record */ - ulint total_memory; /*!< Total memory used */ + size_t total_memory; /*!< Total memory used */ }; /** For horizontally splitting an FTS auxiliary index */ diff --git a/storage/xtradb/include/os0proc.h b/storage/xtradb/include/os0proc.h index 613e3bd6947..d6aafccf48e 100644 --- a/storage/xtradb/include/os0proc.h +++ b/storage/xtradb/include/os0proc.h @@ -58,7 +58,8 @@ UNIV_INTERN void* os_mem_alloc_large( /*===============*/ - ulint* n); /*!< in/out: number of bytes */ + ulint* n, /*!< in/out: number of bytes */ + bool populate); /*!< in: virtual page preallocation */ /****************************************************************//** Frees large pages memory. */ UNIV_INTERN diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index 9aafb88522f..67e4d90d6df 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 39 +#define INNODB_VERSION_BUGFIX 41 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 83.1 +#define PERCONA_INNODB_VERSION 84.1 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ diff --git a/storage/xtradb/log/log0online.cc b/storage/xtradb/log/log0online.cc index af32237243b..42e92ea6f0e 100644 --- a/storage/xtradb/log/log0online.cc +++ b/storage/xtradb/log/log0online.cc @@ -1522,10 +1522,10 @@ log_online_open_bitmap_file_read_only( if (srv_data_home_len && srv_data_home[srv_data_home_len-1] != SRV_PATH_SEPARATOR) { - ut_snprintf(bitmap_file->name, FN_REFLEN, "%s%c%s", + ut_snprintf(bitmap_file->name, sizeof(bitmap_file->name), "%s%c%s", srv_data_home, SRV_PATH_SEPARATOR, name); } else { - ut_snprintf(bitmap_file->name, FN_REFLEN, "%s%s", + ut_snprintf(bitmap_file->name, sizeof(bitmap_file->name), "%s%s", srv_data_home, name); } bitmap_file->file diff --git a/storage/xtradb/os/os0proc.cc b/storage/xtradb/os/os0proc.cc index ff6d65e4ae6..6c9116e1397 100644 --- a/storage/xtradb/os/os0proc.cc +++ b/storage/xtradb/os/os0proc.cc @@ -32,6 +32,14 @@ Created 9/30/1995 Heikki Tuuri #include "ut0mem.h" #include "ut0byte.h" +/* Linux release version */ +#if defined(UNIV_LINUX) && defined(_GNU_SOURCE) +#include <string.h> /* strverscmp() */ +#include <sys/utsname.h> /* uname() */ +#endif + +#include "ha_prototypes.h" + /* FreeBSD for example has only MAP_ANON, Linux has MAP_ANONYMOUS and MAP_ANON but MAP_ANON is marked as deprecated */ #if defined(MAP_ANONYMOUS) @@ -40,10 +48,36 @@ MAP_ANON but MAP_ANON is marked as deprecated */ #define OS_MAP_ANON MAP_ANON #endif +/* Linux's MAP_POPULATE */ +#if defined(MAP_POPULATE) +#define OS_MAP_POPULATE MAP_POPULATE +#else +#define OS_MAP_POPULATE 0 +#endif + UNIV_INTERN ibool os_use_large_pages; /* Large page size. This may be a boot-time option on some platforms */ UNIV_INTERN ulint os_large_page_size; + +/****************************************************************//** +Retrieve and compare operating system release. +@return TRUE if the OS release is equal to, or later than release. */ +UNIV_INTERN +bool +os_compare_release( +/*===============*/ + const char* release /*!< in: OS release */ + MY_ATTRIBUTE((unused))) +{ +#if defined(UNIV_LINUX) && defined(_GNU_SOURCE) + struct utsname name; + return uname(&name) == 0 && strverscmp(name.release, release) >= 0; +#else + return false; +#endif +} + /****************************************************************//** Converts the current process id to a number. It is not guaranteed that the number is unique. In Linux returns the 'process number' of the current @@ -69,7 +103,8 @@ UNIV_INTERN void* os_mem_alloc_large( /*===============*/ - ulint* n) /*!< in/out: number of bytes */ + ulint* n, /*!< in/out: number of bytes */ + bool populate) /*!< in: virtual page preallocation */ { void* ptr; ulint size; @@ -155,12 +190,13 @@ skip: ut_ad(ut_is_2pow(size)); size = *n = ut_2pow_round(*n + (size - 1), size); ptr = mmap(NULL, size, PROT_READ | PROT_WRITE, - MAP_PRIVATE | OS_MAP_ANON, -1, 0); - if (UNIV_UNLIKELY(ptr == (void*) -1)) { + MAP_PRIVATE | OS_MAP_ANON | + (populate ? OS_MAP_POPULATE : 0), -1, 0); + if (UNIV_UNLIKELY(ptr == MAP_FAILED)) { fprintf(stderr, "InnoDB: mmap(%lu bytes) failed;" " errno %lu\n", (ulong) size, (ulong) errno); - ptr = NULL; + return NULL; } else { os_fast_mutex_lock(&ut_list_mutex); ut_total_allocated_memory += size; @@ -168,6 +204,25 @@ skip: UNIV_MEM_ALLOC(ptr, size); } #endif + +#if OS_MAP_ANON && OS_MAP_POPULATE + /* MAP_POPULATE is only supported for private mappings + since Linux 2.6.23. */ + populate = populate && !os_compare_release("2.6.23"); + + if (populate) { + ib_logf(IB_LOG_LEVEL_WARN, "InnoDB: Warning: mmap(MAP_POPULATE) " + "is not supported for private mappings. " + "Forcing preallocation by faulting in pages.\n"); + } +#endif + + /* Initialize the entire buffer to force the allocation + of physical memory page frames. */ + if (populate) { + memset(ptr, '\0', size); + } + return(ptr); } diff --git a/storage/xtradb/pars/lexyy.cc b/storage/xtradb/pars/lexyy.cc index 62122bb9f6f..bc6544b099d 100644 --- a/storage/xtradb/pars/lexyy.cc +++ b/storage/xtradb/pars/lexyy.cc @@ -1187,9 +1187,9 @@ extern int yylex (void); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; #line 112 "pars0lex.l" @@ -1238,7 +1238,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2380,9 +2380,9 @@ case YY_STATE_EOF(id): */ static int yy_get_next_buffer (void) { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -2515,14 +2515,14 @@ static int yy_get_next_buffer (void) yy_state_type yy_get_previous_state (void) { - register yy_state_type yy_current_state; - register char *yy_cp; + yy_state_type yy_current_state; + char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2547,10 +2547,10 @@ static int yy_get_next_buffer (void) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -3070,7 +3070,7 @@ MY_ATTRIBUTE((unused)) static int yylex_destroy (void) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } @@ -3079,7 +3079,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; diff --git a/storage/xtradb/row/row0import.cc b/storage/xtradb/row/row0import.cc index 47918e156ea..c1735f68ea2 100644 --- a/storage/xtradb/row/row0import.cc +++ b/storage/xtradb/row/row0import.cc @@ -4235,4 +4235,3 @@ row_import_for_mysql( return(row_import_cleanup(prebuilt, trx, err)); } - diff --git a/storage/xtradb/row/row0log.cc b/storage/xtradb/row/row0log.cc index d86dcb077e5..0fc1af64b74 100644 --- a/storage/xtradb/row/row0log.cc +++ b/storage/xtradb/row/row0log.cc @@ -236,7 +236,7 @@ row_log_block_allocate( DBUG_ENTER("row_log_block_allocate"); if (log_buf.block == NULL) { log_buf.size = srv_sort_buf_size; - log_buf.block = (byte*) os_mem_alloc_large(&log_buf.size); + log_buf.block = (byte*) os_mem_alloc_large(&log_buf.size, false); DBUG_EXECUTE_IF("simulate_row_log_allocation_failure", if (log_buf.block) os_mem_free_large(log_buf.block, log_buf.size); @@ -2916,8 +2916,8 @@ row_log_allocate( if (log_tmp_is_encrypted()) { ulint size = srv_sort_buf_size; - log->crypt_head = static_cast<byte *>(os_mem_alloc_large(&size)); - log->crypt_tail = static_cast<byte *>(os_mem_alloc_large(&size)); + log->crypt_head = static_cast<byte *>(os_mem_alloc_large(&size, false)); + log->crypt_tail = static_cast<byte *>(os_mem_alloc_large(&size, false)); if (!log->crypt_head || !log->crypt_tail) { row_log_free(log); diff --git a/storage/xtradb/row/row0merge.cc b/storage/xtradb/row/row0merge.cc index 5f60f61866f..e1b0a9f0610 100644 --- a/storage/xtradb/row/row0merge.cc +++ b/storage/xtradb/row/row0merge.cc @@ -3343,9 +3343,17 @@ row_merge_file_create_low( performance schema */ struct PSI_file_locker* locker = NULL; PSI_file_locker_state state; + if (!path) { + path = mysql_tmpdir; + } + static const char label[] = "/Innodb Merge Temp File"; + char* name = static_cast<char*>( + ut_malloc(strlen(path) + sizeof label)); + strcpy(name, path); + strcat(name, label); locker = PSI_FILE_CALL(get_thread_file_name_locker)( &state, innodb_file_temp_key, PSI_FILE_OPEN, - "Innodb Merge Temp File", &locker); + path ? name : label, &locker); if (locker != NULL) { PSI_FILE_CALL(start_file_open_wait)(locker, __FILE__, @@ -3358,6 +3366,7 @@ row_merge_file_create_low( PSI_FILE_CALL(end_file_open_wait_and_bind_to_descriptor)( locker, fd); } + ut_free(name); #endif if (fd < 0) { @@ -3888,7 +3897,7 @@ row_merge_build_indexes( block_size = 3 * srv_sort_buf_size; block = static_cast<row_merge_block_t*>( - os_mem_alloc_large(&block_size)); + os_mem_alloc_large(&block_size, false)); if (block == NULL) { DBUG_RETURN(DB_OUT_OF_MEMORY); @@ -3898,7 +3907,7 @@ row_merge_build_indexes( encryption/decryption. */ if (log_tmp_is_encrypted()) { crypt_block = static_cast<row_merge_block_t*>( - os_mem_alloc_large(&block_size)); + os_mem_alloc_large(&block_size, false)); if (crypt_block == NULL) { DBUG_RETURN(DB_OUT_OF_MEMORY); diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 804d55af965..88ebe24f3bb 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -4059,7 +4059,9 @@ row_drop_table_for_mysql( dict_stats_recalc_pool_del(table); dict_stats_defrag_pool_del(table, NULL); - btr_defragment_remove_table(table); + if (btr_defragment_thread_active) { + btr_defragment_remove_table(table); + } /* Remove stats for this table and all of its indexes from the persistent storage if it exists and if there are stats for this @@ -4288,95 +4290,87 @@ row_drop_table_for_mysql( info = pars_info_create(); - pars_info_add_str_literal(info, "table_name", name); + pars_info_add_str_literal(info, "name", name); - err = que_eval_sql(info, - "PROCEDURE DROP_TABLE_PROC () IS\n" - "sys_foreign_id CHAR;\n" - "table_id CHAR;\n" - "index_id CHAR;\n" - "foreign_id CHAR;\n" - "space_id INT;\n" - "found INT;\n" + if (strcmp(name, "SYS_FOREIGN") && strcmp(name, "SYS_FOREIGN_COLS") + && dict_table_get_low("SYS_FOREIGN") + && dict_table_get_low("SYS_FOREIGN_COLS")) { + err = que_eval_sql( + info, + "PROCEDURE DROP_FOREIGN_PROC () IS\n" + "fid CHAR;\n" - "DECLARE CURSOR cur_fk IS\n" - "SELECT ID FROM SYS_FOREIGN\n" - "WHERE FOR_NAME = :table_name\n" - "AND TO_BINARY(FOR_NAME)\n" - " = TO_BINARY(:table_name)\n" - "LOCK IN SHARE MODE;\n" + "DECLARE CURSOR fk IS\n" + "SELECT ID FROM SYS_FOREIGN\n" + "WHERE FOR_NAME = :name\n" + "AND TO_BINARY(FOR_NAME) = TO_BINARY(:name)\n" + "FOR UPDATE;\n" - "DECLARE CURSOR cur_idx IS\n" - "SELECT ID FROM SYS_INDEXES\n" - "WHERE TABLE_ID = table_id\n" - "LOCK IN SHARE MODE;\n" + "BEGIN\n" + "OPEN fk;\n" + "WHILE 1 = 1 LOOP\n" + " FETCH fk INTO fid;\n" + " IF (SQL % NOTFOUND) THEN RETURN; END IF;\n" + " DELETE FROM SYS_FOREIGN_COLS WHERE ID = fid;\n" + " DELETE FROM SYS_FOREIGN WHERE ID = fid;\n" + "END LOOP;\n" + "CLOSE fk;\n" + "END;\n", FALSE, trx); + if (err == DB_SUCCESS) { + info = pars_info_create(); + pars_info_add_str_literal(info, "name", name); + goto do_drop; + } + } else { +do_drop: + err = que_eval_sql( + info, + "PROCEDURE DROP_TABLE_PROC () IS\n" + "table_id CHAR;\n" + "index_id CHAR;\n" - "BEGIN\n" - "SELECT ID INTO table_id\n" - "FROM SYS_TABLES\n" - "WHERE NAME = :table_name\n" - "LOCK IN SHARE MODE;\n" - "IF (SQL % NOTFOUND) THEN\n" - " RETURN;\n" - "END IF;\n" - "SELECT SPACE INTO space_id\n" - "FROM SYS_TABLES\n" - "WHERE NAME = :table_name;\n" - "IF (SQL % NOTFOUND) THEN\n" - " RETURN;\n" - "END IF;\n" - "found := 1;\n" - "SELECT ID INTO sys_foreign_id\n" - "FROM SYS_TABLES\n" - "WHERE NAME = 'SYS_FOREIGN'\n" - "LOCK IN SHARE MODE;\n" - "IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - "END IF;\n" - "IF (:table_name = 'SYS_FOREIGN') THEN\n" - " found := 0;\n" - "END IF;\n" - "IF (:table_name = 'SYS_FOREIGN_COLS') THEN\n" - " found := 0;\n" - "END IF;\n" - "OPEN cur_fk;\n" - "WHILE found = 1 LOOP\n" - " FETCH cur_fk INTO foreign_id;\n" - " IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - " ELSE\n" - " DELETE FROM SYS_FOREIGN_COLS\n" - " WHERE ID = foreign_id;\n" - " DELETE FROM SYS_FOREIGN\n" - " WHERE ID = foreign_id;\n" - " END IF;\n" - "END LOOP;\n" - "CLOSE cur_fk;\n" - "found := 1;\n" - "OPEN cur_idx;\n" - "WHILE found = 1 LOOP\n" - " FETCH cur_idx INTO index_id;\n" - " IF (SQL % NOTFOUND) THEN\n" - " found := 0;\n" - " ELSE\n" - " DELETE FROM SYS_FIELDS\n" - " WHERE INDEX_ID = index_id;\n" - " DELETE FROM SYS_INDEXES\n" - " WHERE ID = index_id\n" - " AND TABLE_ID = table_id;\n" - " END IF;\n" - "END LOOP;\n" - "CLOSE cur_idx;\n" - "DELETE FROM SYS_TABLESPACES\n" - "WHERE SPACE = space_id;\n" - "DELETE FROM SYS_DATAFILES\n" - "WHERE SPACE = space_id;\n" - "DELETE FROM SYS_COLUMNS\n" - "WHERE TABLE_ID = table_id;\n" - "DELETE FROM SYS_TABLES\n" - "WHERE NAME = :table_name;\n" - "END;\n" - , FALSE, trx); + "DECLARE CURSOR cur_idx IS\n" + "SELECT ID FROM SYS_INDEXES\n" + "WHERE TABLE_ID = table_id\n" + "FOR UPDATE;\n" + + "BEGIN\n" + "SELECT ID INTO table_id\n" + "FROM SYS_TABLES WHERE NAME = :name FOR UPDATE;\n" + "IF (SQL % NOTFOUND) THEN RETURN; END IF;\n" + "OPEN cur_idx;\n" + "WHILE 1 = 1 LOOP\n" + " FETCH cur_idx INTO index_id;\n" + " IF (SQL % NOTFOUND) THEN EXIT; END IF;\n" + " DELETE FROM SYS_FIELDS\n" + " WHERE INDEX_ID = index_id;\n" + " DELETE FROM SYS_INDEXES\n" + " WHERE ID = index_id AND TABLE_ID = table_id;\n" + "END LOOP;\n" + "CLOSE cur_idx;\n" + + "DELETE FROM SYS_COLUMNS WHERE TABLE_ID = table_id;\n" + "DELETE FROM SYS_TABLES WHERE NAME = :name;\n" + + "END;\n", FALSE, trx); + + if (err == DB_SUCCESS && table->space + && dict_table_get_low("SYS_TABLESPACES") + && dict_table_get_low("SYS_DATAFILES")) { + info = pars_info_create(); + pars_info_add_int4_literal(info, "id", + lint(table->space)); + err = que_eval_sql( + info, + "PROCEDURE DROP_SPACE_PROC () IS\n" + "BEGIN\n" + "DELETE FROM SYS_TABLESPACES\n" + "WHERE SPACE = :id;\n" + "DELETE FROM SYS_DATAFILES\n" + "WHERE SPACE = :id;\n" + "END;\n", FALSE, trx); + } + } switch (err) { ibool is_temp; @@ -4524,7 +4518,6 @@ row_drop_table_for_mysql( case DB_OUT_OF_FILE_SPACE: err = DB_MUST_GET_MORE_FILE_SPACE; - trx->error_state = err; row_mysql_handle_errors(&err, trx, NULL, NULL); @@ -5135,6 +5128,18 @@ row_rename_table_for_mysql( goto funct_exit; } + /* Wait for background fts sync to finish */ + for (retry = 1; dict_fts_index_syncing(table); ++retry) { + DICT_BG_YIELD(trx); + if (retry % 100 == 0) { + ib_logf(IB_LOG_LEVEL_INFO, + "Unable to rename table %s to new name" + " %s because FTS sync is running on table." + " Retrying\n", + old_name, new_name); + } + } + /* We use the private SQL parser of Innobase to generate the query graphs needed in updating the dictionary data from system tables. */ @@ -5311,8 +5316,9 @@ row_rename_table_for_mysql( } } - if ((dict_table_has_fts_index(table) - || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) + if (err == DB_SUCCESS + && (dict_table_has_fts_index(table) + || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_FTS_HAS_DOC_ID)) && !dict_tables_have_same_db(old_name, new_name)) { err = fts_rename_aux_tables(table, new_name, trx); if (err != DB_TABLE_NOT_FOUND) { diff --git a/storage/xtradb/srv/srv0conc.cc b/storage/xtradb/srv/srv0conc.cc index e90f744cfa4..77749b75d99 100644 --- a/storage/xtradb/srv/srv0conc.cc +++ b/storage/xtradb/srv/srv0conc.cc @@ -285,6 +285,7 @@ srv_conc_enter_innodb_with_atomics( notified_mysql = TRUE; } + DEBUG_SYNC_C("user_thread_waiting"); trx->op_info = "sleeping before entering InnoDB"; sleep_in_us = srv_thread_sleep_delay; diff --git a/storage/xtradb/srv/srv0srv.cc b/storage/xtradb/srv/srv0srv.cc index 25f7e71a583..392ece25679 100644 --- a/storage/xtradb/srv/srv0srv.cc +++ b/storage/xtradb/srv/srv0srv.cc @@ -175,7 +175,6 @@ use simulated aio we build below with threads. Currently we support native aio on windows and linux */ /* make srv_use_native_aio to be visible for other plugins */ my_bool srv_use_native_aio = TRUE; -UNIV_INTERN my_bool srv_numa_interleave = FALSE; /* Default compression level if page compression is used and no compression level is set for the table*/ diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc index 5bef0dffa8e..6b3ffbe38eb 100644 --- a/storage/xtradb/srv/srv0start.cc +++ b/storage/xtradb/srv/srv0start.cc @@ -2153,7 +2153,8 @@ innobase_start_or_create_for_mysql() ib_logf(IB_LOG_LEVEL_INFO, "Initializing buffer pool, size = %.1f%c", size, unit); - err = buf_pool_init(srv_buf_pool_size, srv_buf_pool_instances); + err = buf_pool_init(srv_buf_pool_size, static_cast<bool>(srv_numa_interleave), + srv_buf_pool_instances); if (err != DB_SUCCESS) { ib_logf(IB_LOG_LEVEL_ERROR, diff --git a/storage/xtradb/trx/trx0purge.cc b/storage/xtradb/trx/trx0purge.cc index 893dc8f398c..11522ea5f9c 100644 --- a/storage/xtradb/trx/trx0purge.cc +++ b/storage/xtradb/trx/trx0purge.cc @@ -258,7 +258,7 @@ trx_purge_add_update_undo_to_history( fts_drop_orphaned_tables(), and roll back recovered transactions. */ ut_ad(srv_undo_sources || trx->undo_no == 0 - || ((srv_startup_is_before_trx_rollback_phase + || ((srv_is_being_started || trx_rollback_or_clean_is_active) && purge_sys->state == PURGE_STATE_INIT)); |