From 048f814e7b8ee8f32c55ef07372d8867b0c53fb9 Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Sat, 1 Dec 2018 16:56:55 +0100 Subject: [PATCH 01/58] - Make PlugSubAlloc to be exportable Suppress unused parameter from PlugSubSet modified: storage/connect/global.h modified: storage/connect/plugutil.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/tabjson.cpp modified: storage/connect/user_connect.cc - Fix a bug making column catalog XML tables fail modified: storage/connect/tabxml.cpp - Comment out wrong message modified: storage/connect/ha_connect.cc - Update error message when sorting an ODBC table fails modified: storage/connect/tabodbc.cpp - Add error message when gettting an address from an OEM fails. modified: storage/connect/reldef.cpp - Make some modifications useful for OEM module writting Export discovery functions for CSV, JDBC and XML Remove unuseful include from tabjson.h Move TDBXML::data_charset function from header file to source modified: storage/connect/tabfmt.h modified: storage/connect/tabjson.h modified: storage/connect/tabxml.cpp modified: storage/connect/tabxml.h - Update test result modified: storage/connect/mysql-test/connect/r/jdbc_oracle.result --- storage/connect/global.h | 6 +- storage/connect/ha_connect.cc | 2 +- storage/connect/jsonudf.cpp | 12 +- .../mysql-test/connect/r/jdbc_oracle.result | 18 +- storage/connect/plugutil.cpp | 28 +- storage/connect/reldef.cpp | 11 +- storage/connect/tabfmt.h | 2 +- storage/connect/tabjson.cpp | 10 +- storage/connect/tabjson.h | 6 +- storage/connect/tabodbc.cpp | 305 +++++++++--------- storage/connect/tabxml.cpp | 13 +- storage/connect/tabxml.h | 5 +- storage/connect/user_connect.cc | 4 +- 13 files changed, 225 insertions(+), 197 deletions(-) diff --git a/storage/connect/global.h b/storage/connect/global.h index 36e8a311124..dc1e149745f 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -219,11 +219,11 @@ DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir); DllExport BOOL PlugIsAbsolutePath(LPCSTR path); DllExport bool AllocSarea(PGLOBAL, uint); DllExport void FreeSarea(PGLOBAL); -DllExport BOOL PlugSubSet(PGLOBAL, void *, uint); +DllExport BOOL PlugSubSet(void *, uint); +DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t); DllExport char *PlugDup(PGLOBAL g, const char *str); DllExport void *MakePtr(void *, OFFSET); DllExport void htrc(char const *fmt, ...); -//DllExport int GetTraceValue(void); DllExport uint GetTraceValue(void); #if defined(__cplusplus) @@ -233,6 +233,6 @@ DllExport uint GetTraceValue(void); /***********************************************************************/ /* Non exported routine declarations. */ /***********************************************************************/ -void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw +//void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw /*-------------------------- End of Global.H --------------------------*/ diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index c9d8d34bd86..26b7036e5ac 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -4191,7 +4191,7 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos) rc= rnd_next(buf); } else { PGLOBAL g = GetPlug((table) ? table->in_use : NULL, xp); - strcpy(g->Message, "Not supported by this table type"); +// strcpy(g->Message, "Not supported by this table type"); my_message(ER_ILLEGAL_HA, g->Message, MYF(0)); rc= HA_ERR_INTERNAL_ERROR; } // endif SetRecpos diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index 26455d572b6..d5a3a840173 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -3055,7 +3055,7 @@ my_bool json_array_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR); g->N = (int)n; return false; @@ -3098,7 +3098,7 @@ void json_array_grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JAR); g->N = GetJsonGroupSize(); } // end of json_array_grp_clear @@ -3132,7 +3132,7 @@ my_bool json_object_grp_init(UDF_INIT *initid, UDF_ARGS *args, char *message) PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB); g->N = (int)n; return false; @@ -3169,7 +3169,7 @@ void json_object_grp_clear(UDF_INIT *initid, char*, char*) { PGLOBAL g = (PGLOBAL)initid->ptr; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Activityp = (PACTIVITY)JsonNew(g, TYPE_JOB); g->N = GetJsonGroupSize(); } // end of json_object_grp_clear @@ -4418,7 +4418,7 @@ char *json_file(UDF_INIT *initid, UDF_ARGS *args, char *result, } else if (initid->const_item) g->N = 1; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); fn = MakePSZ(g, args, 0); if (args->arg_count > 1) { @@ -5662,7 +5662,7 @@ char *jbin_file(UDF_INIT *initid, UDF_ARGS *args, char *result, if (bsp && !bsp->Changed) goto fin; - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Xchk = NULL; fn = MakePSZ(g, args, 0); pretty = (args->arg_count > 2 && args->args[2]) ? (int)*(longlong*)args->args[2] : 3; diff --git a/storage/connect/mysql-test/connect/r/jdbc_oracle.result b/storage/connect/mysql-test/connect/r/jdbc_oracle.result index 2e36891a037..ec314c5f072 100644 --- a/storage/connect/mysql-test/connect/r/jdbc_oracle.result +++ b/storage/connect/mysql-test/connect/r/jdbc_oracle.result @@ -8,12 +8,19 @@ SELECT * FROM t2 WHERE command = 'drop table employee'; command number message drop table employee 0 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist +Warnings: +Warning 1105 Execute: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist + SELECT * FROM t2 WHERE command = 'create table employee (id int not null, name varchar(32), title char(16), salary number(8,2))'; command number message create table employee (id int not null, name varchar(32), title char(16), salary number(8,2)) 0 Affected rows +Warnings: +Warning 1105 Affected rows SELECT * FROM t2 WHERE command = "insert into employee values(4567,'Johnson', 'Engineer', 12560.50)"; command number message insert into employee values(4567,'Johnson', 'Engineer', 12560.50) 1 Affected rows +Warnings: +Warning 1105 Affected rows CREATE TABLE t1 ENGINE=CONNECT TABLE_TYPE=JDBC CATFUNC=tables CONNECTION='jdbc:oracle:thin:@localhost:1521:xe' OPTION_LIST='User=system,Password=manager'; @@ -27,8 +34,8 @@ OPTION_LIST='User=system,Password=manager'; SELECT * FROM t1; Table_Cat Table_Schema Table_Name Column_Name Data_Type Type_Name Column_Size Buffer_Length Decimal_Digits Radix Nullable Remarks NULL SYSTEM EMPLOYEE ID 3 NUMBER 38 0 0 10 0 NULL -NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 0 10 1 NULL -NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 0 10 1 NULL +NULL SYSTEM EMPLOYEE NAME 12 VARCHAR2 32 0 NULL 10 1 NULL +NULL SYSTEM EMPLOYEE TITLE 1 CHAR 16 0 NULL 10 1 NULL NULL SYSTEM EMPLOYEE SALARY 3 NUMBER 8 0 2 10 1 NULL DROP TABLE t1; CREATE SERVER 'oracle' FOREIGN DATA WRAPPER 'oracle.jdbc.driver.OracleDriver' OPTIONS ( @@ -52,7 +59,7 @@ Note 1105 EMPLOYEE: 1 affected rows SELECT * FROM t1; ID NAME TITLE SALARY 4567 Trump Engineer 12560.50 -6214 Clinton Retired 0.00 +6214 Clinton Retired NULL DELETE FROM t1 WHERE id = 6214; Warnings: Note 1105 EMPLOYEE: 1 affected rows @@ -63,8 +70,7 @@ DROP TABLE t1; SELECT * FROM t2 WHERE command = 'drop table employee'; command number message drop table employee 0 Affected rows +Warnings: +Warning 1105 Affected rows DROP TABLE t2; DROP SERVER 'oracle'; -SET GLOBAL connect_jvm_path=NULL; -SET GLOBAL connect_class_path=NULL; -SET GLOBAL time_zone = SYSTEM; diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp index 887527e38ab..048f00be75f 100644 --- a/storage/connect/plugutil.cpp +++ b/storage/connect/plugutil.cpp @@ -514,27 +514,31 @@ void FreeSarea(PGLOBAL g) /* Here there should be some verification done such as validity of */ /* the address and size not larger than memory size. */ /***********************************************************************/ -BOOL PlugSubSet(PGLOBAL g __attribute__((unused)), void *memp, uint size) +BOOL PlugSubSet(void *memp, uint size) { PPOOLHEADER pph = (PPOOLHEADER)memp; pph->To_Free = (OFFSET)sizeof(POOLHEADER); pph->FreeBlk = size - pph->To_Free; - return FALSE; } /* end of PlugSubSet */ +/***********************************************************************/ +/* Use it to export a function that do throwing. */ +/***********************************************************************/ +void *DoThrow(int n) +{ + throw n; +} /* end of DoThrow */ + /***********************************************************************/ /* Program for sub-allocating one item in a storage area. */ -/* Note: SubAlloc routines of OS/2 are no more used to increase the */ -/* code portability and avoid problems when a grammar compiled under */ -/* one version of OS/2 is used under another version. */ -/* The simple way things are done here is also based on the fact */ -/* that no freeing of suballocated blocks is permitted in Plug. */ +/* The simple way things are done here is based on the fact */ +/* that no freeing of suballocated blocks is permitted in CONNECT. */ /***********************************************************************/ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) - { - PPOOLHEADER pph; /* Points on area header. */ +{ + PPOOLHEADER pph; /* Points on area header. */ if (!memp) /*******************************************************************/ @@ -559,8 +563,8 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) if (trace(1)) htrc("PlugSubAlloc: %s\n", g->Message); - throw 1234; - } /* endif size OS32 code */ + DoThrow(1234); + } /* endif size OS32 code */ /*********************************************************************/ /* Do the suballocation the simplest way. */ @@ -574,7 +578,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) memp, pph->To_Free, pph->FreeBlk); return (memp); - } /* end of PlugSubAlloc */ +} /* end of PlugSubAlloc */ /***********************************************************************/ /* Program for sub-allocating and copying a string in a storage area. */ diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index e4f169575f8..30d8063d1a6 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -522,8 +522,15 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g) // Get the function returning an instance of the external DEF class if (!(getdef = (XGETDEF)GetProcAddress((HINSTANCE)Hdll, getname))) { - sprintf(g->Message, MSG(PROCADD_ERROR), GetLastError(), getname); - FreeLibrary((HMODULE)Hdll); + char buf[256]; + DWORD rc = GetLastError(); + + sprintf(g->Message, MSG(PROCADD_ERROR), rc, getname); + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, + (LPTSTR)buf, sizeof(buf), NULL); + strcat(strcat(g->Message, ": "), buf); + FreeLibrary((HMODULE)Hdll); return NULL; } // endif getdef #else // !__WIN__ diff --git a/storage/connect/tabfmt.h b/storage/connect/tabfmt.h index 396bba568ff..10f0757c60b 100644 --- a/storage/connect/tabfmt.h +++ b/storage/connect/tabfmt.h @@ -13,7 +13,7 @@ typedef class TDBFMT *PTDBFMT; /***********************************************************************/ /* Functions used externally. */ /***********************************************************************/ -PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info); +DllExport PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info); /***********************************************************************/ /* CSV table. */ diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 9e4f5ab987d..d20e793ff88 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -299,7 +299,7 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) memset(G, 0, sizeof(GLOBAL)); G->Sarea_Size = tdp->Lrecl * 10; G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); - PlugSubSet(G, G->Sarea, G->Sarea_Size); + PlugSubSet(G->Sarea, G->Sarea_Size); G->jump_level = 0; tjnp->SetG(G); @@ -670,7 +670,7 @@ PTDB JSONDEF::GetTable(PGLOBAL g, MODE m) memset(G, 0, sizeof(GLOBAL)); G->Sarea_Size = Lrecl * 10; G->Sarea = PlugSubAlloc(g, NULL, G->Sarea_Size); - PlugSubSet(G, G->Sarea, G->Sarea_Size); + PlugSubSet(G->Sarea, G->Sarea_Size); G->jump_level = 0; ((TDBJSN*)tdbp)->G = G; } else { @@ -963,7 +963,7 @@ int TDBJSN::ReadDB(PGLOBAL g) return rc; // Recover the memory used for parsing - PlugSubSet(G, G->Sarea, G->Sarea_Size); + PlugSubSet(G->Sarea, G->Sarea_Size); if ((Row = ParseJson(G, To_Line, strlen(To_Line), &Pretty, &Comma))) { Row = FindRow(g); @@ -1079,13 +1079,13 @@ int TDBJSN::MakeTopTree(PGLOBAL g, PJSON jsp) } // end of PrepareWriting /***********************************************************************/ -/* WriteDB: Data Base write routine for DOS access method. */ +/* WriteDB: Data Base write routine for JSON access method. */ /***********************************************************************/ int TDBJSN::WriteDB(PGLOBAL g) { int rc = TDBDOS::WriteDB(g); - PlugSubSet(G, G->Sarea, G->Sarea_Size); + PlugSubSet(G->Sarea, G->Sarea_Size); Row->Clear(); return rc; } // end of WriteDB diff --git a/storage/connect/tabjson.h b/storage/connect/tabjson.h index 2ff72905e86..fcbfe4ed1ec 100644 --- a/storage/connect/tabjson.h +++ b/storage/connect/tabjson.h @@ -1,11 +1,11 @@ /*************** tabjson H Declares Source Code File (.H) **************/ /* Name: tabjson.h Version 1.3 */ /* */ -/* (C) Copyright to the author Olivier BERTRAND 2014 - 2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2014 - 2018 */ /* */ /* This file contains the JSON classes declares. */ /***********************************************************************/ -#include "osutil.h" +//#include "osutil.h" // Unuseful and bad for OEM #include "block.h" #include "colblk.h" #include "json.h" @@ -16,7 +16,7 @@ typedef class JSONDEF *PJDEF; typedef class TDBJSON *PJTDB; typedef class JSONCOL *PJCOL; class TDBJSN; -PQRYRES JSONColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt, bool info); +DllExport PQRYRES JSONColumns(PGLOBAL, PCSZ, PCSZ, PTOS, bool); /***********************************************************************/ /* The JSON tree node. Can be an Object or an Array. */ diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index fddfb0c0420..0fa117c3d2f 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2000-2017 */ +/* (C) Copyright to the author Olivier BERTRAND 2000-2018 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -95,23 +95,23 @@ bool ExactInfo(void); /* Constructor. */ /***********************************************************************/ ODBCDEF::ODBCDEF(void) - { +{ Connect = NULL; Catver = 0; UseCnc = false; - } // end of ODBCDEF constructor +} // end of ODBCDEF constructor /***********************************************************************/ /* DefineAM: define specific AM block values from XDB file. */ /***********************************************************************/ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) - { +{ Desc = Connect = GetStringCatInfo(g, "Connect", NULL); if (!Connect && !Catfunc) { sprintf(g->Message, "Missing connection for ODBC table %s", Name); return true; - } // endif Connect + } // endif Connect if (EXTDEF::DefineAM(g, am, poff)) return true; @@ -123,13 +123,13 @@ bool ODBCDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) Qto= GetIntCatInfo("QueryTimeout", DEFAULT_QUERY_TIMEOUT); UseCnc = GetBoolCatInfo("UseDSN", false); return false; - } // end of DefineAM +} // end of DefineAM /***********************************************************************/ /* GetTable: makes a new Table Description Block. */ /***********************************************************************/ PTDB ODBCDEF::GetTable(PGLOBAL g, MODE m) - { +{ PTDB tdbp = NULL; /*********************************************************************/ @@ -158,10 +158,10 @@ PTDB ODBCDEF::GetTable(PGLOBAL g, MODE m) tdbp = new(g) TDBMUL(tdbp); else if (Multiple == 2) strcpy(g->Message, MSG(NO_ODBC_MUL)); - } // endswitch Catfunc + } // endswitch Catfunc return tdbp; - } // end of GetTable +} // end of GetTable /* -------------------------- Class TDBODBC -------------------------- */ @@ -169,7 +169,7 @@ PTDB ODBCDEF::GetTable(PGLOBAL g, MODE m) /* Implementation of the TDBODBC class. */ /***********************************************************************/ TDBODBC::TDBODBC(PODEF tdp) : TDBEXT(tdp) - { +{ Ocp = NULL; Cnp = NULL; @@ -191,19 +191,19 @@ TDBODBC::TDBODBC(PODEF tdp) : TDBEXT(tdp) Ops.UseCnc = false; } // endif tdp - } // end of TDBODBC standard constructor +} // end of TDBODBC standard constructor TDBODBC::TDBODBC(PTDBODBC tdbp) : TDBEXT(tdbp) - { +{ Ocp = tdbp->Ocp; // is that right ? Cnp = tdbp->Cnp; Connect = tdbp->Connect; Ops = tdbp->Ops; - } // end of TDBODBC copy constructor +} // end of TDBODBC copy constructor // Method PTDB TDBODBC::Clone(PTABS t) - { +{ PTDB tp; PODBCCOL cp1, cp2; PGLOBAL g = t->G; // Is this really useful ??? @@ -213,18 +213,18 @@ PTDB TDBODBC::Clone(PTABS t) for (cp1 = (PODBCCOL)Columns; cp1; cp1 = (PODBCCOL)cp1->GetNext()) { cp2 = new(g) ODBCCOL(cp1, tp); // Make a copy NewPointer(t, cp1, cp2); - } // endfor cp1 + } // endfor cp1 return tp; - } // end of CopyOne +} // end of CopyOne /***********************************************************************/ /* Allocate ODBC column description block. */ /***********************************************************************/ PCOL TDBODBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) - { +{ return new(g) ODBCCOL(cdp, this, cprec, n); - } // end of MakeCol +} // end of MakeCol /***********************************************************************/ /* Extract the filename from connect string and return it. */ @@ -232,7 +232,7 @@ PCOL TDBODBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) /* with a place holder to be used by SetFile. */ /***********************************************************************/ PCSZ TDBODBC::GetFile(PGLOBAL g) - { +{ if (Connect) { char *p1, *p2; int i; @@ -263,18 +263,18 @@ PCSZ TDBODBC::GetFile(PGLOBAL g) memcpy(MulConn, Connect, p1 - Connect); MulConn[p1 - Connect] = '\0'; strcat(strcat(MulConn, "%s"), (p2) ? p2 : ";"); - } // endif p1 + } // endif p1 - } // endif Connect + } // endif Connect return (DBQ) ? DBQ : (PSZ)"???"; - } // end of GetFile +} // end of GetFile /***********************************************************************/ /* Set DBQ and get the new file name into the connect string. */ /***********************************************************************/ void TDBODBC::SetFile(PGLOBAL g, PCSZ fn) - { +{ if (MulConn) { int n = strlen(MulConn) + strlen(fn) - 1; @@ -283,20 +283,20 @@ void TDBODBC::SetFile(PGLOBAL g, PCSZ fn) // of having to reallocate it is reduced. BufSize = n + 6; Connect = (char*)PlugSubAlloc(g, NULL, BufSize); - } // endif n + } // endif n // Make the complete connect string sprintf(Connect, MulConn, fn); - } // endif MultConn + } // endif MultConn DBQ = PlugDup(g, fn); - } // end of SetFile +} // end of SetFile /***********************************************************************/ /* MakeInsert: make the Insert statement used with ODBC connection. */ /***********************************************************************/ bool TDBODBC::MakeInsert(PGLOBAL g) - { +{ PCSZ schmp = NULL; char *catp = NULL, buf[NAM_LEN * 3]; int len = 0; @@ -377,7 +377,7 @@ bool TDBODBC::MakeInsert(PGLOBAL g) } else Query->Append(buf); - } // endfor colp + } // endfor colp Query->Append(") VALUES ("); @@ -390,32 +390,32 @@ bool TDBODBC::MakeInsert(PGLOBAL g) Query->RepLast(')'); return oom; - } // end of MakeInsert +} // end of MakeInsert /***********************************************************************/ /* ODBC Bind Parameter function. */ /***********************************************************************/ bool TDBODBC::BindParameters(PGLOBAL g) - { - PODBCCOL colp; +{ + PODBCCOL colp; - for (colp = (PODBCCOL)Columns; colp; colp = (PODBCCOL)colp->Next) { - colp->AllocateBuffers(g, 0); + for (colp = (PODBCCOL)Columns; colp; colp = (PODBCCOL)colp->Next) { + colp->AllocateBuffers(g, 0); - if (Ocp->BindParam(colp)) - return true; + if (Ocp->BindParam(colp)) + return true; - } // endfor colp + } // endfor colp - return false; - } // end of BindParameters + return false; +} // end of BindParameters #if 0 /***********************************************************************/ /* MakeUpdate: make the SQL statement to send to ODBC connection. */ /***********************************************************************/ char *TDBODBC::MakeUpdate(PGLOBAL g) - { +{ char *qc, *stmt = NULL, cmd[8], tab[96], end[1024]; stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64); @@ -440,60 +440,60 @@ char *TDBODBC::MakeUpdate(PGLOBAL g) strcat(stmt, end); return stmt; - } // end of MakeUpdate +} // end of MakeUpdate /***********************************************************************/ /* MakeDelete: make the SQL statement to send to ODBC connection. */ /***********************************************************************/ char *TDBODBC::MakeDelete(PGLOBAL g) - { - char *qc, *stmt = NULL, cmd[8], from[8], tab[96], end[512]; +{ + char *qc, *stmt = NULL, cmd[8], from[8], tab[96], end[512]; - stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64); - memset(end, 0, sizeof(end)); + stmt = (char*)PlugSubAlloc(g, NULL, strlen(Qrystr) + 64); + memset(end, 0, sizeof(end)); - if (sscanf(Qrystr, "%s %s `%[^`]`%511c", cmd, from, tab, end) > 2 || - sscanf(Qrystr, "%s %s \"%[^\"]\"%511c", cmd, from, tab, end) > 2) - qc = Ocp->GetQuoteChar(); - else if (sscanf(Qrystr, "%s %s %s%511c", cmd, from, tab, end) > 2) - qc = (Quoted) ? Quote : ""; - else { - strcpy(g->Message, "Cannot use this DELETE command"); - return NULL; - } // endif sscanf + if (sscanf(Qrystr, "%s %s `%[^`]`%511c", cmd, from, tab, end) > 2 || + sscanf(Qrystr, "%s %s \"%[^\"]\"%511c", cmd, from, tab, end) > 2) + qc = Ocp->GetQuoteChar(); + else if (sscanf(Qrystr, "%s %s %s%511c", cmd, from, tab, end) > 2) + qc = (Quoted) ? Quote : ""; + else { + strcpy(g->Message, "Cannot use this DELETE command"); + return NULL; + } // endif sscanf - assert(!stricmp(cmd, "delete") && !stricmp(from, "from")); - strcat(strcat(strcat(strcpy(stmt, "DELETE FROM "), qc), TableName), qc); + assert(!stricmp(cmd, "delete") && !stricmp(from, "from")); + strcat(strcat(strcat(strcpy(stmt, "DELETE FROM "), qc), TableName), qc); - if (*end) { - for (int i = 0; end[i]; i++) - if (end[i] == '`') - end[i] = *qc; + if (*end) { + for (int i = 0; end[i]; i++) + if (end[i] == '`') + end[i] = *qc; - strcat(stmt, end); - } // endif end + strcat(stmt, end); + } // endif end - return stmt; - } // end of MakeDelete + return stmt; +} // end of MakeDelete #endif // 0 /***********************************************************************/ /* ResetSize: call by TDBMUL when calculating size estimate. */ /***********************************************************************/ void TDBODBC::ResetSize(void) - { +{ MaxSize = -1; if (Ocp && Ocp->IsOpen()) Ocp->Close(); - } // end of ResetSize +} // end of ResetSize /***********************************************************************/ /* ODBC Cardinality: returns table size in number of rows. */ /***********************************************************************/ int TDBODBC::Cardinality(PGLOBAL g) - { +{ if (!g) return (Mode == MODE_ANY && !Srcdef) ? 1 : 0; @@ -526,7 +526,7 @@ int TDBODBC::Cardinality(PGLOBAL g) Cardinal = 10; // To make MySQL happy return Cardinal; - } // end of Cardinality +} // end of Cardinality /***********************************************************************/ /* ODBC Access Method opening routine. */ @@ -535,7 +535,7 @@ int TDBODBC::Cardinality(PGLOBAL g) /* join block of next table if it exists or else are discarted. */ /***********************************************************************/ bool TDBODBC::OpenDB(PGLOBAL g) - { +{ bool rc = true; if (trace(1)) @@ -571,7 +571,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) Fpos = 0; Curpos = 1; return false; - } // endif use + } // endif use /*********************************************************************/ /* Open an ODBC connection for this table. */ @@ -593,7 +593,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) Use = USE_OPEN; // Do it now in case we are recursively called /*********************************************************************/ - /* Make the command and allocate whatever is used for getting results. */ + /* Make the command and allocate whatever is used for getting results*/ /*********************************************************************/ if (Mode == MODE_READ || Mode == MODE_READX) { if (Memory > 1 && !Srcdef) { @@ -624,7 +624,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) } else return true; - } // endif Memory + } // endif Memory if (!(rc = MakeSQL(g, false))) { for (PODBCCOL colp = (PODBCCOL)Columns; colp; @@ -635,7 +635,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) rc = (Mode == MODE_READ) ? ((Rows = Ocp->ExecDirectSQL(Query->GetStr(), (PODBCCOL)Columns)) < 0) : false; - } // endif rc + } // endif rc } else if (Mode == MODE_INSERT) { if (!(rc = MakeInsert(g))) { @@ -645,7 +645,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) } else rc = BindParameters(g); - } // endif rc + } // endif rc } else if (Mode == MODE_UPDATE || Mode == MODE_DELETE) { rc = false; // wait for CheckCond before calling MakeCommand(g); @@ -655,30 +655,30 @@ bool TDBODBC::OpenDB(PGLOBAL g) if (rc) { Ocp->Close(); return true; - } // endif rc + } // endif rc /*********************************************************************/ /* Reset statistics values. */ /*********************************************************************/ num_read = num_there = num_eq[0] = num_eq[1] = 0; return false; - } // end of OpenDB +} // end of OpenDB #if 0 /***********************************************************************/ /* GetRecpos: return the position of last read record. */ /***********************************************************************/ int TDBODBC::GetRecpos(void) - { +{ return Fpos; - } // end of GetRecpos +} // end of GetRecpos #endif // 0 /***********************************************************************/ /* SetRecpos: set the position of next read record. */ /***********************************************************************/ bool TDBODBC::SetRecpos(PGLOBAL g, int recpos) - { +{ if (Ocp->m_Full) { Fpos = 0; CurNum = recpos - 1; @@ -696,14 +696,15 @@ bool TDBODBC::SetRecpos(PGLOBAL g, int recpos) } // endif recpos } else { - strcpy(g->Message, "This action requires a scrollable cursor"); + strcpy(g->Message, + "This action requires Memory setting or a scrollable cursor"); return true; } // endif's // Indicate the table position was externally set Placed = true; return false; - } // end of SetRecpos +} // end of SetRecpos /***********************************************************************/ /* Data Base indexed read routine for ODBC access method. */ @@ -721,7 +722,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) Rows = Ocp->ExecDirectSQL((char*)Query->GetStr(), (PODBCCOL)Columns); Mode = MODE_READ; return (Rows < 0); - } // endif key + } // endif key return false; } else { @@ -737,7 +738,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) if ((To_CondFil = hc->CheckCond(g, To_CondFil, Cond))) PlugSubAlloc(g, NULL, strlen(To_CondFil->Body) + 1); - } // endif active_index + } // endif active_index if (To_CondFil) if (Query->Append(" AND ") || Query->Append(To_CondFil->Body)) { @@ -762,7 +763,7 @@ bool TDBODBC::ReadKey(PGLOBAL g, OPVAL op, const key_range *kr) /* VRDNDOS: Data Base read routine for odbc access method. */ /***********************************************************************/ int TDBODBC::ReadDB(PGLOBAL g) - { +{ int rc; if (trace(2)) @@ -784,7 +785,7 @@ int TDBODBC::ReadDB(PGLOBAL g) } else return RC_FX; // Error - } // endif Mode + } // endif Mode /*********************************************************************/ /* Now start the reading process. */ @@ -813,7 +814,7 @@ int TDBODBC::ReadDB(PGLOBAL g) Qrp->Nblin++; Fpos++; // Used for memory and pos - } // endif rc + } // endif rc } // endif Placed @@ -821,13 +822,13 @@ int TDBODBC::ReadDB(PGLOBAL g) htrc(" Read: Rbuf=%d rc=%d\n", Rbuf, rc); return rc; - } // end of ReadDB +} // end of ReadDB /***********************************************************************/ /* Data Base Insert write routine for ODBC access method. */ /***********************************************************************/ int TDBODBC::WriteDB(PGLOBAL g) - { +{ int n = Ocp->ExecuteSQL(); if (n < 0) { @@ -837,13 +838,13 @@ int TDBODBC::WriteDB(PGLOBAL g) AftRows += n; return RC_OK; - } // end of WriteDB +} // end of WriteDB /***********************************************************************/ /* Data Base delete line routine for ODBC access method. */ /***********************************************************************/ int TDBODBC::DeleteDB(PGLOBAL g, int irc) - { +{ if (irc == RC_FX) { if (!Query && MakeCommand(g)) return RC_FX; @@ -863,13 +864,13 @@ int TDBODBC::DeleteDB(PGLOBAL g, int irc) } else return RC_OK; // Ignore - } // end of DeleteDB +} // end of DeleteDB /***********************************************************************/ /* Data Base close routine for ODBC access method. */ /***********************************************************************/ void TDBODBC::CloseDB(PGLOBAL g) - { +{ if (Ocp) Ocp->Close(); @@ -877,7 +878,7 @@ void TDBODBC::CloseDB(PGLOBAL g) if (trace(1)) htrc("ODBC CloseDB: closing %s\n", Name); - } // end of CloseDB +} // end of CloseDB /* --------------------------- ODBCCOL ------------------------------- */ @@ -886,33 +887,33 @@ void TDBODBC::CloseDB(PGLOBAL g) /***********************************************************************/ ODBCCOL::ODBCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) : EXTCOL(cdp, tdbp, cprec, i, am) - { +{ // Set additional ODBC access method information for column. Slen = 0; StrLen = &Slen; Sqlbuf = NULL; - } // end of ODBCCOL constructor +} // end of ODBCCOL constructor /***********************************************************************/ /* ODBCCOL private constructor. */ /***********************************************************************/ ODBCCOL::ODBCCOL(void) : EXTCOL() - { +{ Slen = 0; StrLen = &Slen; Sqlbuf = NULL; - } // end of ODBCCOL constructor +} // end of ODBCCOL constructor /***********************************************************************/ /* ODBCCOL constructor used for copying columns. */ /* tdbp is the pointer to the new table descriptor. */ /***********************************************************************/ ODBCCOL::ODBCCOL(ODBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp) - { +{ Slen = col1->Slen; StrLen = col1->StrLen; Sqlbuf = col1->Sqlbuf; - } // end of ODBCCOL copy constructor +} // end of ODBCCOL copy constructor /***********************************************************************/ /* ReadColumn: when SQLFetch is used there is nothing to do as the */ @@ -920,7 +921,7 @@ ODBCCOL::ODBCCOL(ODBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp) /* when calculating MaxSize (Bufp is NULL even when Rows is not). */ /***********************************************************************/ void ODBCCOL::ReadColumn(PGLOBAL g) - { +{ PTDBODBC tdbp = (PTDBODBC)To_Tdb; int i = tdbp->Fpos - 1, n = tdbp->CurNum; @@ -953,7 +954,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) else Value->SetValue_pvblk(Blkp, n); - } // endif Bufp + } // endif Bufp if (Buf_Type == TYPE_DATE) { struct tm dbtime; @@ -980,7 +981,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) htrc("ODBC Column %s: rows=%d buf=%p type=%d value=%s\n", Name, tdbp->Rows, Bufp, Buf_Type, Value->GetCharString(buf)); - } // endif trace + } // endif trace put: if (tdbp->Memory != 2) @@ -997,7 +998,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) } else Crp->Kdata->SetValue(Value, i); - } // end of ReadColumn +} // end of ReadColumn /***********************************************************************/ /* AllocateBuffers: allocate the extended buffer for SQLExtendedFetch */ @@ -1005,7 +1006,7 @@ void ODBCCOL::ReadColumn(PGLOBAL g) /* for the ending null character. */ /***********************************************************************/ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows) - { +{ if (Buf_Type == TYPE_DATE) Sqlbuf = (TIMESTAMP_STRUCT*)PlugSubAlloc(g, NULL, sizeof(TIMESTAMP_STRUCT)); @@ -1019,31 +1020,31 @@ void ODBCCOL::AllocateBuffers(PGLOBAL g, int rows) Blkp = AllocValBlock(g, NULL, Buf_Type, rows, GetBuflen(), GetScale(), true, false, false); Bufp = Blkp->GetValPointer(); - } // endelse + } // endelse if (rows > 1) StrLen = (SQLLEN *)PlugSubAlloc(g, NULL, rows * sizeof(SQLLEN)); - } // end of AllocateBuffers +} // end of AllocateBuffers /***********************************************************************/ /* Returns the buffer to use for Fetch or Extended Fetch. */ /***********************************************************************/ void *ODBCCOL::GetBuffer(DWORD rows) - { +{ if (rows && To_Tdb) { assert(rows == (DWORD)((TDBODBC*)To_Tdb)->Rows); return Bufp; } else return (Buf_Type == TYPE_DATE) ? Sqlbuf : Value->GetTo_Val(); - } // end of GetBuffer +} // end of GetBuffer /***********************************************************************/ /* Returns the buffer length to use for Fetch or Extended Fetch. */ /***********************************************************************/ SWORD ODBCCOL::GetBuflen(void) - { +{ SWORD flen; switch (Buf_Type) { @@ -1059,13 +1060,13 @@ SWORD ODBCCOL::GetBuflen(void) } // endswitch Buf_Type return flen; - } // end of GetBuflen +} // end of GetBuflen /***********************************************************************/ /* WriteColumn: make sure the bind buffer is updated. */ /***********************************************************************/ void ODBCCOL::WriteColumn(PGLOBAL g) - { +{ /*********************************************************************/ /* Do convert the column value if necessary. */ /*********************************************************************/ @@ -1095,7 +1096,7 @@ void ODBCCOL::WriteColumn(PGLOBAL g) *StrLen = (Value->IsNull()) ? SQL_NULL_DATA : (IsTypeChar(Buf_Type)) ? SQL_NTS : 0; - } // end of WriteColumn +} // end of WriteColumn /* -------------------------- Class TDBXDBC -------------------------- */ @@ -1119,7 +1120,7 @@ TDBXDBC::TDBXDBC(PTDBXDBC tdbp) : TDBODBC(tdbp) } // end of TDBXDBC copy constructor PTDB TDBXDBC::Clone(PTABS t) - { +{ PTDB tp; PXSRCCOL cp1, cp2; PGLOBAL g = t->G; // Is this really useful ??? @@ -1129,29 +1130,29 @@ PTDB TDBXDBC::Clone(PTABS t) for (cp1 = (PXSRCCOL)Columns; cp1; cp1 = (PXSRCCOL)cp1->GetNext()) { cp2 = new(g) XSRCCOL(cp1, tp); // Make a copy NewPointer(t, cp1, cp2); - } // endfor cp1 + } // endfor cp1 return tp; - } // end of CopyOne +} // end of CopyOne /***********************************************************************/ /* Allocate XSRC column description block. */ /***********************************************************************/ PCOL TDBXDBC::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) - { +{ PXSRCCOL colp = new(g) XSRCCOL(cdp, this, cprec, n); if (!colp->Flag) Cmdcol = colp->GetName(); return colp; - } // end of MakeCol +} // end of MakeCol /***********************************************************************/ /* MakeCMD: make the SQL statement to send to ODBC connection. */ /***********************************************************************/ PCMD TDBXDBC::MakeCMD(PGLOBAL g) - { +{ PCMD xcmd = NULL; if (To_CondFil) { @@ -1171,14 +1172,14 @@ PCMD TDBXDBC::MakeCMD(PGLOBAL g) xcmd = new(g) CMD(g, Srcdef); return xcmd; - } // end of MakeCMD +} // end of MakeCMD #if 0 /***********************************************************************/ /* ODBC Bind Parameter function. */ /***********************************************************************/ bool TDBXDBC::BindParameters(PGLOBAL g) - { +{ PODBCCOL colp; for (colp = (PODBCCOL)Columns; colp; colp = (PODBCCOL)colp->Next) { @@ -1190,19 +1191,19 @@ bool TDBXDBC::BindParameters(PGLOBAL g) } // endfor colp return false; - } // end of BindParameters +} // end of BindParameters #endif // 0 /***********************************************************************/ /* XDBC GetMaxSize: returns table size (not always one row). */ /***********************************************************************/ int TDBXDBC::GetMaxSize(PGLOBAL g) - { +{ if (MaxSize < 0) MaxSize = 10; // Just a guess return MaxSize; - } // end of GetMaxSize +} // end of GetMaxSize /***********************************************************************/ /* ODBC Access Method opening routine. */ @@ -1211,7 +1212,7 @@ int TDBXDBC::GetMaxSize(PGLOBAL g) /* join block of next table if it exists or else are discarted. */ /***********************************************************************/ bool TDBXDBC::OpenDB(PGLOBAL g) - { +{ bool rc = false; if (trace(1)) @@ -1221,7 +1222,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g) if (Use == USE_OPEN) { strcpy(g->Message, "Multiple execution is not allowed"); return true; - } // endif use + } // endif use /*********************************************************************/ /* Open an ODBC connection for this table. */ @@ -1243,7 +1244,7 @@ bool TDBXDBC::OpenDB(PGLOBAL g) if (Mode != MODE_READ && Mode != MODE_READX) { strcpy(g->Message, "No INSERT/DELETE/UPDATE of XDBC tables"); return true; - } // endif Mode + } // endif Mode /*********************************************************************/ /* Get the command to execute. */ @@ -1256,13 +1257,13 @@ bool TDBXDBC::OpenDB(PGLOBAL g) Rows = 1; return false; - } // end of OpenDB +} // end of OpenDB /***********************************************************************/ /* ReadDB: Data Base read routine for xdbc access method. */ /***********************************************************************/ int TDBXDBC::ReadDB(PGLOBAL g) - { +{ if (Cmdlist) { if (!Query) Query = new(g)STRING(g, 0, Cmdlist->Cmd); @@ -1280,25 +1281,25 @@ int TDBXDBC::ReadDB(PGLOBAL g) return RC_EF; } // endif Cmdlist - } // end of ReadDB +} // end of ReadDB /***********************************************************************/ -/* Data Base delete line routine for ODBC access method. */ +/* Data Base write line routine for XDBC access method. */ /***********************************************************************/ int TDBXDBC::WriteDB(PGLOBAL g) - { +{ strcpy(g->Message, "Execsrc tables are read only"); return RC_FX; - } // end of DeleteDB +} // end of DeleteDB /***********************************************************************/ -/* Data Base delete line routine for ODBC access method. */ +/* Data Base delete line routine for XDBC access method. */ /***********************************************************************/ int TDBXDBC::DeleteDB(PGLOBAL g, int irc) - { +{ strcpy(g->Message, MSG(NO_ODBC_DELETE)); return RC_FX; - } // end of DeleteDB +} // end of DeleteDB /* --------------------------- XSRCCOL ------------------------------- */ @@ -1307,25 +1308,25 @@ int TDBXDBC::DeleteDB(PGLOBAL g, int irc) /***********************************************************************/ XSRCCOL::XSRCCOL(PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i, PCSZ am) : ODBCCOL(cdp, tdbp, cprec, i, am) - { +{ // Set additional ODBC access method information for column. Flag = cdp->GetOffset(); - } // end of XSRCCOL constructor +} // end of XSRCCOL constructor /***********************************************************************/ /* XSRCCOL constructor used for copying columns. */ /* tdbp is the pointer to the new table descriptor. */ /***********************************************************************/ XSRCCOL::XSRCCOL(XSRCCOL *col1, PTDB tdbp) : ODBCCOL(col1, tdbp) - { +{ Flag = col1->Flag; - } // end of XSRCCOL copy constructor +} // end of XSRCCOL copy constructor /***********************************************************************/ /* ReadColumn: set column value according to Flag. */ /***********************************************************************/ void XSRCCOL::ReadColumn(PGLOBAL g) - { +{ PTDBXDBC tdbp = (PTDBXDBC)To_Tdb; switch (Flag) { @@ -1335,15 +1336,15 @@ void XSRCCOL::ReadColumn(PGLOBAL g) default: Value->SetValue_psz("Invalid Flag"); break; } // endswitch Flag - } // end of ReadColumn +} // end of ReadColumn /***********************************************************************/ /* WriteColumn: Should never be called. */ /***********************************************************************/ void XSRCCOL::WriteColumn(PGLOBAL g) - { +{ // Should never be called - } // end of WriteColumn +} // end of WriteColumn /* ---------------------------TDBDRV class --------------------------- */ @@ -1351,9 +1352,9 @@ void XSRCCOL::WriteColumn(PGLOBAL g) /* GetResult: Get the list of ODBC drivers. */ /***********************************************************************/ PQRYRES TDBDRV::GetResult(PGLOBAL g) - { +{ return ODBCDrivers(g, Maxres, false); - } // end of GetResult +} // end of GetResult /* ---------------------------TDBSRC class --------------------------- */ @@ -1361,9 +1362,9 @@ PQRYRES TDBDRV::GetResult(PGLOBAL g) /* GetResult: Get the list of ODBC data sources. */ /***********************************************************************/ PQRYRES TDBSRC::GetResult(PGLOBAL g) - { +{ return ODBCDataSources(g, Maxres, false); - } // end of GetResult +} // end of GetResult /* ---------------------------TDBOTB class --------------------------- */ @@ -1371,7 +1372,7 @@ PQRYRES TDBSRC::GetResult(PGLOBAL g) /* TDBOTB class constructor. */ /***********************************************************************/ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp) - { +{ Dsn = tdp->GetConnect(); Schema = tdp->GetTabschema(); Tab = tdp->GetTabname(); @@ -1381,15 +1382,15 @@ TDBOTB::TDBOTB(PODEF tdp) : TDBDRV(tdp) Ops.Cto = tdp->Cto; Ops.Qto = tdp->Qto; Ops.UseCnc = tdp->UseCnc; - } // end of TDBOTB constructor +} // end of TDBOTB constructor /***********************************************************************/ /* GetResult: Get the list of ODBC tables. */ /***********************************************************************/ PQRYRES TDBOTB::GetResult(PGLOBAL g) - { +{ return ODBCTables(g, Dsn, Schema, Tab, Tabtyp, Maxres, false, &Ops); - } // end of GetResult +} // end of GetResult /* ---------------------------TDBOCL class --------------------------- */ @@ -1405,8 +1406,8 @@ TDBOCL::TDBOCL(PODEF tdp) : TDBOTB(tdp) /* GetResult: Get the list of ODBC table columns. */ /***********************************************************************/ PQRYRES TDBOCL::GetResult(PGLOBAL g) - { +{ return ODBCColumns(g, Dsn, Schema, Tab, Colpat, Maxres, false, &Ops); - } // end of GetResult +} // end of GetResult /* ------------------------ End of Tabodbc --------------------------- */ diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index c96e0844497..fa4854bb618 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -681,6 +681,14 @@ PTDB TDBXML::Clone(PTABS t) return tp; } // end of Clone +/***********************************************************************/ +/* Must not be in tabxml.h because of OEM tables */ +/***********************************************************************/ +const CHARSET_INFO *TDBXML::data_charset() +{ + return &my_charset_utf8_general_ci; +} // end of data_charset + /***********************************************************************/ /* Allocate XML column description block. */ /***********************************************************************/ @@ -2209,8 +2217,9 @@ void XPOSCOL::WriteColumn(PGLOBAL g) TDBXCT::TDBXCT(PXMLDEF tdp) : TDBCAT(tdp) { Topt = tdp->GetTopt(); - Db = (char*)tdp->GetDB(); - Tabn = tdp->Tabname; + //Db = (char*)tdp->GetDB(); + Db = (char*)tdp->Schema; + Tabn = tdp->Tabname; } // end of TDBXCT constructor /***********************************************************************/ diff --git a/storage/connect/tabxml.h b/storage/connect/tabxml.h index f55b7d98de7..102767e965a 100644 --- a/storage/connect/tabxml.h +++ b/storage/connect/tabxml.h @@ -9,6 +9,8 @@ typedef class XMLDEF *PXMLDEF; typedef class TDBXML *PTDBXML; typedef class XMLCOL *PXMLCOL; +DllExport PQRYRES XMLColumns(PGLOBAL, char *, char *, PTOS, bool); + /* --------------------------- XML classes --------------------------- */ /***********************************************************************/ @@ -100,8 +102,7 @@ class DllExport TDBXML : public TDBASE { virtual int DeleteDB(PGLOBAL g, int irc); virtual void CloseDB(PGLOBAL g); virtual int CheckWrite(PGLOBAL g) {Checked = true; return 0;} - virtual const CHARSET_INFO *data_charset() - {return &my_charset_utf8_general_ci;} + virtual const CHARSET_INFO *data_charset(); protected: // Members diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc index e2d3b664aeb..a2a8faf9b38 100644 --- a/storage/connect/user_connect.cc +++ b/storage/connect/user_connect.cc @@ -107,7 +107,7 @@ bool user_connect::user_init() g= PlugInit(NULL, worksize); // Check whether the initialization is complete - if (!g || !g->Sarea || PlugSubSet(g, g->Sarea, g->Sarea_Size) + if (!g || !g->Sarea || PlugSubSet(g->Sarea, g->Sarea_Size) || !(dup= PlgMakeUser(g))) { if (g) printf("%s\n", g->Message); @@ -172,7 +172,7 @@ bool user_connect::CheckCleanup(bool force) } // endif worksize - PlugSubSet(g, g->Sarea, g->Sarea_Size); + PlugSubSet(g->Sarea, g->Sarea_Size); g->Xchk = NULL; g->Createas = 0; g->Alchecked = 0; From 0735423e196e35f4fb5ca5b4bdc16bcbd4af37fe Mon Sep 17 00:00:00 2001 From: Olivier Bertrand Date: Tue, 4 Dec 2018 23:30:16 +0100 Subject: [PATCH 02/58] Fix wrong version number --- storage/connect/ha_connect.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 26b7036e5ac..9b40253b090 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -7307,7 +7307,7 @@ maria_declare_plugin(connect) PLUGIN_LICENSE_GPL, connect_init_func, /* Plugin Init */ connect_done_func, /* Plugin Deinit */ - 0x0107, /* version number (1.05) */ + 0x0106, /* version number (1.06) */ NULL, /* status variables */ connect_system_variables, /* system variables */ "1.06.0008", /* string version */ From 15eaeace394320d96b6bf193f9e049f9358d2b07 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Wed, 12 Dec 2018 19:58:20 +0400 Subject: [PATCH 03/58] MDEV-16987 - ALTER DATABASE possible in read-only mode Forbid ALTER DATABASE under read_only. --- mysql-test/r/read_only.result | 11 +++++++++++ mysql-test/t/read_only.test | 13 +++++++++++++ sql/sql_parse.cc | 1 + 3 files changed, 25 insertions(+) diff --git a/mysql-test/r/read_only.result b/mysql-test/r/read_only.result index 2d0f9d730fd..4afddab6851 100644 --- a/mysql-test/r/read_only.result +++ b/mysql-test/r/read_only.result @@ -162,3 +162,14 @@ delete from mysql.columns_priv where User like 'mysqltest_%'; flush privileges; drop database mysqltest_db1; set global read_only= @start_read_only; +# +# MDEV-16987 - ALTER DATABASE possible in read-only mode +# +GRANT ALTER ON test1.* TO user1@localhost; +CREATE DATABASE test1; +SET GLOBAL read_only=1; +ALTER DATABASE test1 CHARACTER SET utf8; +ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement +SET GLOBAL read_only=0; +DROP DATABASE test1; +DROP USER user1@localhost; diff --git a/mysql-test/t/read_only.test b/mysql-test/t/read_only.test index eb9bea803c2..dd9d6430172 100644 --- a/mysql-test/t/read_only.test +++ b/mysql-test/t/read_only.test @@ -310,3 +310,16 @@ set global read_only= @start_read_only; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc +--echo # +--echo # MDEV-16987 - ALTER DATABASE possible in read-only mode +--echo # +GRANT ALTER ON test1.* TO user1@localhost; +CREATE DATABASE test1; +SET GLOBAL read_only=1; +change_user user1; +--error ER_OPTION_PREVENTS_STATEMENT +ALTER DATABASE test1 CHARACTER SET utf8; +change_user root; +SET GLOBAL read_only=0; +DROP DATABASE test1; +DROP USER user1@localhost; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9f8a625325f..95243ead2fe 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -831,6 +831,7 @@ static bool deny_updates_if_read_only_option(THD *thd, TABLE_LIST *all_tables) DBUG_RETURN(FALSE); if (lex->sql_command == SQLCOM_CREATE_DB || + lex->sql_command == SQLCOM_ALTER_DB || lex->sql_command == SQLCOM_DROP_DB) DBUG_RETURN(TRUE); From 1a7158b88a117f6543e1318a7abdc490cdfd5e67 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 Dec 2018 19:51:40 +0100 Subject: [PATCH 04/58] remove unsed variable --- sql/opt_range.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 005ae92a665..b1f8366d83b 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3322,10 +3322,6 @@ bool create_key_parts_for_pseudo_indexes(RANGE_OPT_PARAM *param, { Field **field_ptr; TABLE *table= param->table; - partition_info *part_info= NULL; - #ifdef WITH_PARTITION_STORAGE_ENGINE - part_info= table->part_info; - #endif uint parts= 0; for (field_ptr= table->field; *field_ptr; field_ptr++) From d1f399408d245dd8b971ba331eaaedf488e083b6 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Sun, 16 Dec 2018 21:50:49 +0200 Subject: [PATCH 05/58] MDEV-6453: Assertion `inited==NONE || (inited==RND && scan)' failed in handler::ha_rnd_init(bool) with InnoDB, joins, AND/OR conditions The inited parameter handler is not initialised when we do a quick_select after a table scan. --- mysql-test/r/range_innodb.result | 18 ++++++++++++++++++ mysql-test/t/range_innodb.test | 17 +++++++++++++++++ sql/sql_select.cc | 4 ++++ 3 files changed, 39 insertions(+) diff --git a/mysql-test/r/range_innodb.result b/mysql-test/r/range_innodb.result index 794e6c7b3cc..8bb1c833a56 100644 --- a/mysql-test/r/range_innodb.result +++ b/mysql-test/r/range_innodb.result @@ -37,3 +37,21 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 10 1 SIMPLE t2 range a,b b 5 NULL 201 Using where; Using join buffer (flat, BNL join) drop table t0,t1,t2; +CREATE TABLE t1 ( +pk INT PRIMARY KEY, f1 INT, f2 CHAR(1), f3 CHAR(1), +KEY(f1), KEY(f2) +) ENGINE=InnoDB; +INSERT INTO t1 VALUES +(1,4,'v',NULL),(2,6,'v',NULL),(3,7,'c',NULL),(4,1,'e',NULL),(5,0,'x',NULL), +(6,7,'i',NULL),(7,7,'e',NULL),(8,1,'p',NULL),(9,7,'s',NULL),(10,1,'j',NULL), +(11,5,'z',NULL),(12,2,'c',NULL),(13,0,'a',NULL),(14,1,'q',NULL),(15,8,'y',NULL), +(16,1,'m',NULL),(17,1,'r',NULL),(18,9,'v',NULL),(19,1,'n',NULL); +CREATE TABLE t2 (f4 INT, f5 CHAR(1)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (4,'q'),(NULL,'j'); +SELECT * FROM t1 AS t1_1, t1 AS t1_2, t2 +WHERE f5 = t1_2.f2 AND ( t1_1.f1 = 103 AND t1_1.f2 = 'o' OR t1_1.pk < f4 ); +pk f1 f2 f3 pk f1 f2 f3 f4 f5 +1 4 v NULL 14 1 q NULL 4 q +2 6 v NULL 14 1 q NULL 4 q +3 7 c NULL 14 1 q NULL 4 q +drop table t1,t2; diff --git a/mysql-test/t/range_innodb.test b/mysql-test/t/range_innodb.test index f76794814ef..605006587cc 100644 --- a/mysql-test/t/range_innodb.test +++ b/mysql-test/t/range_innodb.test @@ -45,3 +45,20 @@ explain select * from t0 left join t2 on t2.a select->quick; tab->select->quick=0; + + if (tab->table->file->inited != handler::NONE) + tab->table->file->ha_index_or_rnd_end(); + return tab->select->test_quick_select(tab->join->thd, tab->keys, (table_map) 0, HA_POS_ERROR, 0, FALSE); From 65525550ab8988a1a1a36d0403824ebaec160347 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 17 Dec 2018 16:09:28 +0100 Subject: [PATCH 06/58] Don't default to bundled zlib This reverts part of c54271723c6 --- cmake/zlib.cmake | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index 840337d1ca3..bfb2b70be74 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -34,11 +34,6 @@ ENDMACRO() MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) - # For NDBCLUSTER: Use bundled zlib by default - IF (NOT WITH_ZLIB) - SET(WITH_ZLIB "bundled" CACHE STRING "By default use bundled zlib on this platform") - ENDIF() - IF(WITH_ZLIB STREQUAL "bundled") MYSQL_USE_BUNDLED_ZLIB() ELSE() From 977073e3dccd32c36d59a0a9dc4d9f8e0331f7c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 18 Dec 2018 12:38:38 +0200 Subject: [PATCH 07/58] After-merge fix --- storage/innobase/fil/fil0crypt.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc index c0c9cc01872..da40ddd8e65 100644 --- a/storage/innobase/fil/fil0crypt.cc +++ b/storage/innobase/fil/fil0crypt.cc @@ -2589,7 +2589,7 @@ fil_space_verify_crypt_checksum(const byte* page, const page_size_t& page_size) if (checksum == BUF_NO_CHECKSUM_MAGIC) { return true; } - if (zip_size) { + if (page_size.is_compressed()) { return checksum == page_zip_calc_checksum( page, page_size.physical(), SRV_CHECKSUM_ALGORITHM_CRC32) From 171271edf8204d6a958a00631ea6ce4050f84b9e Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Tue, 18 Dec 2018 18:07:17 +0530 Subject: [PATCH 08/58] MDEV-18025 Mariabackup fails to detect corrupted page_compressed=1 tables Problem: ======= Mariabackup seems to fail to verify the pages of compressed tables. The reason is that both fil_space_verify_crypt_checksum() and buf_page_is_corrupted() will skip the validation for compressed pages. Fix: ==== Mariabackup should call fil_page_decompress() for compressed and encrypted compressed page. After that, call buf_page_is_corrupted() to check the page corruption. --- extra/mariabackup/fil_cur.cc | 29 ++++++++++-- .../mariabackup/encrypted_page_compressed.opt | 6 +++ .../encrypted_page_compressed.result | 6 +++ .../encrypted_page_compressed.test | 47 +++++++++++++++++++ .../unencrypted_page_compressed.result | 6 +++ .../unencrypted_page_compressed.test | 46 ++++++++++++++++++ storage/innobase/buf/buf0buf.cc | 5 +- 7 files changed, 139 insertions(+), 6 deletions(-) create mode 100644 mysql-test/suite/mariabackup/encrypted_page_compressed.opt create mode 100644 mysql-test/suite/mariabackup/encrypted_page_compressed.result create mode 100644 mysql-test/suite/mariabackup/encrypted_page_compressed.test create mode 100644 mysql-test/suite/mariabackup/unencrypted_page_compressed.result create mode 100644 mysql-test/suite/mariabackup/unencrypted_page_compressed.test diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index c2693e6f616..b677e9973b7 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -31,6 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA #include "fil_cur.h" #include "fil0crypt.h" +#include "fil0pagecompress.h" #include "common.h" #include "read_filt.h" #include "xtrabackup.h" @@ -346,6 +347,7 @@ read_retry: for (page = cursor->buf, i = 0; i < npages; page += cursor->page_size, i++) { ulint page_no = cursor->buf_page_no + i; + ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); if (cursor->space_id == TRX_SYS_SPACE && page_no >= FSP_EXTENT_SIZE @@ -367,12 +369,31 @@ read_retry: memcpy(tmp_page, page, cursor->page_size); if (!fil_space_decrypt(space, tmp_frame, - tmp_page, &decrypted) - || buf_page_is_corrupted(true, tmp_page, - cursor->zip_size, - space)) { + tmp_page, &decrypted)) { goto corrupted; } + + if (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { + goto page_decomp; + } + + if (buf_page_is_corrupted( + true, tmp_page, cursor->zip_size, space)) { + goto corrupted; + } + + } else if (page_type == FIL_PAGE_PAGE_COMPRESSED) { + memcpy(tmp_page, page, cursor->page_size); +page_decomp: + ulint decomp = fil_page_decompress(tmp_frame, tmp_page); + + if (!decomp + || (decomp != srv_page_size && cursor->zip_size) + || buf_page_is_corrupted( + true, tmp_page, cursor->zip_size, space)) { + goto corrupted; + } + } else if (buf_page_is_corrupted(true, page, cursor->zip_size, space)) { corrupted: diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.opt b/mysql-test/suite/mariabackup/encrypted_page_compressed.opt new file mode 100644 index 00000000000..e5a02a1a1c9 --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.opt @@ -0,0 +1,6 @@ +--innodb-encryption-rotate-key-age=2 +--innodb-encryption-threads=4 +--innodb-tablespaces-encryption +--plugin-load-add=$FILE_KEY_MANAGEMENT_SO +--loose-file-key-management +--loose-file-key-management-filename=$MYSQL_TEST_DIR/std_data/logkey.txt diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.result b/mysql-test/suite/mariabackup/encrypted_page_compressed.result new file mode 100644 index 00000000000..92ad84fc04a --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.result @@ -0,0 +1,6 @@ +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); +# Corrupt the table +# xtrabackup backup +FOUND /Database page corruption detected/ in backup.log +drop table t1; diff --git a/mysql-test/suite/mariabackup/encrypted_page_compressed.test b/mysql-test/suite/mariabackup/encrypted_page_compressed.test new file mode 100644 index 00000000000..eaca762d459 --- /dev/null +++ b/mysql-test/suite/mariabackup/encrypted_page_compressed.test @@ -0,0 +1,47 @@ +source include/have_file_key_management.inc; +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes encrypted=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); + +let $MYSQLD_DATADIR=`select @@datadir`; +let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; + +--source include/shutdown_mysqld.inc + +--echo # Corrupt the table + +perl; +use strict; +use warnings; +use Fcntl qw(:DEFAULT :seek); + +my $ibd_file = $ENV{'t1_IBD'}; + +my $chunk; +my $page_size = $ENV{'INNODB_PAGE_SIZE'}; + +sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file"; +sysseek IBD_FILE, $page_size * 3 + 75, SEEK_CUR; +$chunk = '\xAA\xAA\xAA\xAA'; +syswrite IBD_FILE, $chunk, 4; + +close IBD_FILE; +EOF + +--source include/start_mysqld.inc + +echo # xtrabackup backup; +--disable_result_log +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Database page corruption detected +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; + +drop table t1; +rmdir $targetdir; diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.result b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result new file mode 100644 index 00000000000..b4cb27d307b --- /dev/null +++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.result @@ -0,0 +1,6 @@ +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); +# Corrupt the table +# xtrabackup backup +FOUND /Database page corruption detected/ in backup.log +drop table t1; diff --git a/mysql-test/suite/mariabackup/unencrypted_page_compressed.test b/mysql-test/suite/mariabackup/unencrypted_page_compressed.test new file mode 100644 index 00000000000..48df75bc5c2 --- /dev/null +++ b/mysql-test/suite/mariabackup/unencrypted_page_compressed.test @@ -0,0 +1,46 @@ +CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT, c char(200)) ENGINE=InnoDB page_compressed=yes; +insert into t1(b, c) values("mariadb", "mariabackup"); + +let $MYSQLD_DATADIR=`select @@datadir`; +let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; + +--source include/shutdown_mysqld.inc + +--echo # Corrupt the table + +perl; +use strict; +use warnings; +use Fcntl qw(:DEFAULT :seek); + +my $ibd_file = $ENV{'t1_IBD'}; + +my $chunk; +my $page_size = $ENV{'INNODB_PAGE_SIZE'}; + +sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file"; +sysseek IBD_FILE, 16384 * 3 + 75, SEEK_CUR; +$chunk = '\xAA\xAA\xAA\xAA'; +syswrite IBD_FILE, $chunk, 4; + +close IBD_FILE; +EOF + +--source include/start_mysqld.inc + +echo # xtrabackup backup; +--disable_result_log +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog; +--enable_result_log + +--let SEARCH_PATTERN=Database page corruption detected +--let SEARCH_FILE=$backuplog +--source include/search_pattern_in_file.inc +remove_file $backuplog; + +drop table t1; +rmdir $targetdir; diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 11661cf2c40..af68f894aca 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -452,6 +452,8 @@ decompress_with_slot: decrypt. */ if (!fil_space_verify_crypt_checksum( dst_frame, buf_page_get_zip_size(bpage))) { + +decrypt_failed: ib_logf(IB_LOG_LEVEL_ERROR, "Encrypted page %u:%u in file %s" " looks corrupted; key_version=" ULINTPF, @@ -460,7 +462,7 @@ decompress_with_slot: mach_read_from_4( FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + dst_frame)); -decrypt_failed: + /* Mark page encrypted in case it should be. */ if (space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED) { @@ -4769,7 +4771,6 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) not anymore encrypted. */ corrupted = buf_page_is_corrupted(true, dst_frame, zip_size, space); - if (!corrupted) { bpage->encrypted = false; } else { From b0fd06a6f27212cee770961171439a44626d8f14 Mon Sep 17 00:00:00 2001 From: Sergey Vojtovich Date: Tue, 18 Dec 2018 17:07:29 +0400 Subject: [PATCH 09/58] MDEV-15670 - unit.my_atomic failed in buildbot with Signal 11 thrown Workaround glibc bug: https://sourceware.org/bugzilla/show_bug.cgi?id=20116 by making unittest threads joinable. It makes code better anyway. --- unittest/mysys/lf-t.c | 5 ----- unittest/mysys/my_atomic-t.c | 17 +--------------- unittest/mysys/thr_template.c | 31 +++++++++--------------------- unittest/mysys/waiting_threads-t.c | 4 +--- 4 files changed, 11 insertions(+), 46 deletions(-) diff --git a/unittest/mysys/lf-t.c b/unittest/mysys/lf-t.c index 573a56cc1d6..c1c89f60864 100644 --- a/unittest/mysys/lf-t.c +++ b/unittest/mysys/lf-t.c @@ -48,9 +48,6 @@ pthread_handler_t test_lf_pinbox(void *arg) pins= lf_pinbox_get_pins(&lf_allocator.pinbox); } lf_pinbox_put_pins(pins); - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); if (with_my_thread_init) my_thread_end(); @@ -105,7 +102,6 @@ pthread_handler_t test_lf_alloc(void *arg) bad|= lf_allocator.mallocs - lf_alloc_pool_count(&lf_allocator); #endif } - if (!--running_threads) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); if (with_my_thread_init) @@ -159,7 +155,6 @@ pthread_handler_t test_lf_hash(void *arg) lf_hash.size, inserts); bad|= lf_hash.count; } - if (!--running_threads) pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); if (with_my_thread_init) my_thread_end(); diff --git a/unittest/mysys/my_atomic-t.c b/unittest/mysys/my_atomic-t.c index 35e782eb360..5eb988e2e15 100644 --- a/unittest/mysys/my_atomic-t.c +++ b/unittest/mysys/my_atomic-t.c @@ -35,9 +35,6 @@ pthread_handler_t test_atomic_add(void *arg) my_atomic_add32(&bad, -x); my_atomic_rwlock_wrunlock(&rwl); } - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); return 0; } @@ -58,13 +55,6 @@ pthread_handler_t test_atomic_add64(void *arg) my_atomic_add64(&a64, -x); my_atomic_rwlock_wrunlock(&rwl); } - pthread_mutex_lock(&mutex); - if (!--running_threads) - { - bad= (a64 != 0); - pthread_cond_signal(&cond); - } - pthread_mutex_unlock(&mutex); return 0; } @@ -108,9 +98,6 @@ pthread_handler_t test_atomic_fas(void *arg) my_atomic_add32(&bad, -x); my_atomic_rwlock_wrunlock(&rwl); - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); return 0; } @@ -140,9 +127,6 @@ pthread_handler_t test_atomic_cas(void *arg) my_atomic_rwlock_wrunlock(&rwl); } while (!ok) ; } - pthread_mutex_lock(&mutex); - if (!--running_threads) pthread_cond_signal(&cond); - pthread_mutex_unlock(&mutex); return 0; } @@ -178,6 +162,7 @@ void do_tests() } a64=0; test_concurrently("my_atomic_add64", test_atomic_add64, THREADS, CYCLES); + bad= (a64 != 0); my_atomic_rwlock_destroy(&rwl); } diff --git a/unittest/mysys/thr_template.c b/unittest/mysys/thr_template.c index 7304eb50955..d1bc0868ca0 100644 --- a/unittest/mysys/thr_template.c +++ b/unittest/mysys/thr_template.c @@ -20,35 +20,34 @@ #include volatile uint32 bad; -pthread_attr_t thr_attr; pthread_mutex_t mutex; -pthread_cond_t cond; -uint running_threads; void do_tests(); void test_concurrently(const char *test, pthread_handler handler, int n, int m) { - pthread_t t; + pthread_t *threads= malloc(n * sizeof(pthread_t)); + int i; ulonglong now= my_interval_timer(); + assert(threads); bad= 0; diag("Testing %s with %d threads, %d iterations... ", test, n, m); - for (running_threads= n ; n ; n--) + for (i= n; i; i--) { - if (pthread_create(&t, &thr_attr, handler, &m) != 0) + if (pthread_create(&threads[i], 0, handler, &m) != 0) { diag("Could not create thread"); abort(); } } - pthread_mutex_lock(&mutex); - while (running_threads) - pthread_cond_wait(&cond, &mutex); - pthread_mutex_unlock(&mutex); + + for (i= n; i; i--) + pthread_join(threads[i], 0); now= my_interval_timer() - now; + free(threads); ok(!bad, "tested %s in %g secs (%d)", test, ((double)now)/1e9, bad); } @@ -60,9 +59,6 @@ int main(int argc __attribute__((unused)), char **argv) DBUG_SET_INITIAL(argv[1]); pthread_mutex_init(&mutex, 0); - pthread_cond_init(&cond, 0); - pthread_attr_init(&thr_attr); - pthread_attr_setdetachstate(&thr_attr,PTHREAD_CREATE_DETACHED); #ifdef MY_ATOMIC_MODE_RWLOCKS #if defined(HPUX11) || defined(__POWERPC__) /* showed to be very slow (scheduler-related) */ @@ -79,16 +75,7 @@ int main(int argc __attribute__((unused)), char **argv) do_tests(); - /* - workaround until we know why it crashes randomly on some machine - (BUG#22320). - */ -#ifdef NOT_USED - sleep(2); -#endif pthread_mutex_destroy(&mutex); - pthread_cond_destroy(&cond); - pthread_attr_destroy(&thr_attr); my_end(0); return exit_status(); } diff --git a/unittest/mysys/waiting_threads-t.c b/unittest/mysys/waiting_threads-t.c index 35e86aca319..eca6ba408c3 100644 --- a/unittest/mysys/waiting_threads-t.c +++ b/unittest/mysys/waiting_threads-t.c @@ -136,10 +136,8 @@ retry: pthread_mutex_unlock(&lock); pthread_mutex_unlock(& thds[id].lock); wt_thd_destroy(& thds[id].thd); - - if (!--running_threads) /* now, signal when everybody is done with deinit */ - pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); + DBUG_PRINT("wt", ("exiting")); my_thread_end(); return 0; From 1b471face8110b205b9bfb460c839127bc6862dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 18 Dec 2018 16:24:52 +0200 Subject: [PATCH 10/58] MDEV-18025: Apply the fix to XtraDB and adjust tests The fix was accidentally only applied to InnoDB, and encryption tests were not adjusted. --- mysql-test/suite/encryption/r/innodb-bad-key-change.result | 1 + .../suite/encryption/r/innodb-encryption-disable.result | 1 + mysql-test/suite/encryption/r/innodb-missing-key.result | 1 + mysql-test/suite/encryption/t/innodb-bad-key-change.test | 1 + mysql-test/suite/encryption/t/innodb-encryption-disable.test | 1 + mysql-test/suite/encryption/t/innodb-missing-key.test | 1 + storage/xtradb/buf/buf0buf.cc | 5 +++-- 7 files changed, 9 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-bad-key-change.result b/mysql-test/suite/encryption/r/innodb-bad-key-change.result index 51fc7a8cbc4..481dbcb285d 100644 --- a/mysql-test/suite/encryption/r/innodb-bad-key-change.result +++ b/mysql-test/suite/encryption/r/innodb-bad-key-change.result @@ -1,6 +1,7 @@ call mtr.add_suppression("Plugin 'file_key_management' init function returned error"); call mtr.add_suppression("Plugin 'file_key_management' registration.*failed"); call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t1.ibd looks corrupted; key_version=1"); call mtr.add_suppression("mysqld: File .*keysbad3.txt' not found "); # Start server with keys2.txt diff --git a/mysql-test/suite/encryption/r/innodb-encryption-disable.result b/mysql-test/suite/encryption/r/innodb-encryption-disable.result index 4d15098d936..6b6aee2c7e3 100644 --- a/mysql-test/suite/encryption/r/innodb-encryption-disable.result +++ b/mysql-test/suite/encryption/r/innodb-encryption-disable.result @@ -1,4 +1,5 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t[15].ibd looks corrupted; key_version=1"); call mtr.add_suppression("Couldn't load plugins from 'file_key_management*"); create table t5 ( `intcol1` int(32) DEFAULT NULL, diff --git a/mysql-test/suite/encryption/r/innodb-missing-key.result b/mysql-test/suite/encryption/r/innodb-missing-key.result index 53ca0845c25..45a01f03c2b 100644 --- a/mysql-test/suite/encryption/r/innodb-missing-key.result +++ b/mysql-test/suite/encryption/r/innodb-missing-key.result @@ -1,4 +1,5 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t[12].ibd looks corrupted; key_version=1"); # Start server with keys2.txt CREATE TABLE t1(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=19; diff --git a/mysql-test/suite/encryption/t/innodb-bad-key-change.test b/mysql-test/suite/encryption/t/innodb-bad-key-change.test index 9d61770f543..46a6d2fa27f 100644 --- a/mysql-test/suite/encryption/t/innodb-bad-key-change.test +++ b/mysql-test/suite/encryption/t/innodb-bad-key-change.test @@ -11,6 +11,7 @@ call mtr.add_suppression("Plugin 'file_key_management' init function returned error"); call mtr.add_suppression("Plugin 'file_key_management' registration.*failed"); call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[0-9]+\\] in file '.*test.t[12]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t1.ibd looks corrupted; key_version=1"); call mtr.add_suppression("mysqld: File .*keysbad3.txt' not found "); diff --git a/mysql-test/suite/encryption/t/innodb-encryption-disable.test b/mysql-test/suite/encryption/t/innodb-encryption-disable.test index 6ade8d6e3b2..4e6147f7745 100644 --- a/mysql-test/suite/encryption/t/innodb-encryption-disable.test +++ b/mysql-test/suite/encryption/t/innodb-encryption-disable.test @@ -8,6 +8,7 @@ # call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[15]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t[15].ibd looks corrupted; key_version=1"); # Suppression for builds where file_key_management plugin is linked statically call mtr.add_suppression("Couldn't load plugins from 'file_key_management*"); diff --git a/mysql-test/suite/encryption/t/innodb-missing-key.test b/mysql-test/suite/encryption/t/innodb-missing-key.test index 6ea0528825b..c68604fdcf5 100644 --- a/mysql-test/suite/encryption/t/innodb-missing-key.test +++ b/mysql-test/suite/encryption/t/innodb-missing-key.test @@ -8,6 +8,7 @@ # call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t[12].ibd looks corrupted; key_version=1"); --echo --echo # Start server with keys2.txt diff --git a/storage/xtradb/buf/buf0buf.cc b/storage/xtradb/buf/buf0buf.cc index f23e51fb00a..85b337f641a 100644 --- a/storage/xtradb/buf/buf0buf.cc +++ b/storage/xtradb/buf/buf0buf.cc @@ -482,6 +482,8 @@ decompress_with_slot: decrypt. */ if (!fil_space_verify_crypt_checksum( dst_frame, buf_page_get_zip_size(bpage))) { + +decrypt_failed: ib_logf(IB_LOG_LEVEL_ERROR, "Encrypted page %u:%u in file %s" " looks corrupted; key_version=" ULINTPF, @@ -490,7 +492,7 @@ decompress_with_slot: mach_read_from_4( FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION + dst_frame)); -decrypt_failed: + /* Mark page encrypted in case it should be. */ if (space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED) { @@ -4794,7 +4796,6 @@ static dberr_t buf_page_check_corrupt(buf_page_t* bpage, fil_space_t* space) not anymore encrypted. */ corrupted = buf_page_is_corrupted(true, dst_frame, zip_size, space); - if (!corrupted) { bpage->encrypted = false; } else { From 74659e55b7dffcdbb7f8b2cac4ccea92dacebd70 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Tue, 18 Dec 2018 17:31:52 +0100 Subject: [PATCH 11/58] MDEV-16268 : sporadic checksum mismatch when opening system tablespace in backup Attempt to fix by retrying srv_sys_space.open_or_create() if it reports corruption. --- extra/mariabackup/xtrabackup.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index fe768696170..cbd5a72aa34 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -3362,8 +3362,15 @@ xb_load_tablespaces() return(DB_ERROR); } - err = srv_sys_space.open_or_create(false, false, &sum_of_new_sizes, - &flush_lsn); + for (int i= 0; i < 10; i++) { + err = srv_sys_space.open_or_create(false, false, &sum_of_new_sizes, + &flush_lsn); + if (err == DB_PAGE_CORRUPTED || err == DB_CORRUPTION) { + my_sleep(1000); + } + else + break; + } if (err != DB_SUCCESS) { msg("mariabackup: Could not open data files.\n"); From 0c2fc9b3da467132cba7fd3a9d92995c98057f06 Mon Sep 17 00:00:00 2001 From: Ian Gilfillan Date: Mon, 3 Dec 2018 13:54:32 +0200 Subject: [PATCH 12/58] Update InnoDB urls --- storage/innobase/buf/buf0buf.cc | 2 +- storage/innobase/gis/gis0sea.cc | 2 +- storage/innobase/handler/ha_innodb.cc | 4 ++-- storage/innobase/ut/ut0dbg.cc | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/storage/innobase/buf/buf0buf.cc b/storage/innobase/buf/buf0buf.cc index 02568142e7a..8dc2fd20dbe 100644 --- a/storage/innobase/buf/buf0buf.cc +++ b/storage/innobase/buf/buf0buf.cc @@ -4391,7 +4391,7 @@ loop: << ". The most probable cause" " of this error may be that the" " table has been corrupted." - " See https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/"; + " See https://mariadb.com/kb/en/library/innodb-recovery-modes/"; } #if defined UNIV_DEBUG || defined UNIV_BUF_DEBUG diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 5f8657238b0..cdddc346c77 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -773,7 +773,7 @@ rtr_page_get_father_node_ptr( error << ". You should dump + drop + reimport the table to" " fix the corruption. If the crash happens at" " database startup, see " - "https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/" + "https://mariadb.com/kb/en/library/innodb-recovery-modes/" " about forcing" " recovery. Then dump + drop + reimport."; } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 319d6faedda..52940eb2f76 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -22070,7 +22070,7 @@ const char* BUG_REPORT_MSG = const char* FORCE_RECOVERY_MSG = "Please refer to " - "https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/" + "https://mariadb.com/kb/en/library/innodb-recovery-modes/" " for information about forcing recovery."; const char* ERROR_CREATING_MSG = @@ -22088,7 +22088,7 @@ const char* SET_TRANSACTION_MSG = "Please refer to https://mariadb.com/kb/en/library/set-transaction/"; const char* INNODB_PARAMETERS_MSG = - "Please refer to https://mariadb.com/kb/en/library/xtradbinnodb-server-system-variables/"; + "Please refer to https://mariadb.com/kb/en/library/innodb-system-variables/"; /********************************************************************** Converts an identifier from my_charset_filename to UTF-8 charset. diff --git a/storage/innobase/ut/ut0dbg.cc b/storage/innobase/ut/ut0dbg.cc index 56a2eb80337..05b27060a9b 100644 --- a/storage/innobase/ut/ut0dbg.cc +++ b/storage/innobase/ut/ut0dbg.cc @@ -52,7 +52,7 @@ ut_dbg_assertion_failed( " or crashes, even\n" "InnoDB: immediately after the mysqld startup, there may be\n" "InnoDB: corruption in the InnoDB tablespace. Please refer to\n" - "InnoDB: https://mariadb.com/kb/en/library/xtradbinnodb-recovery-modes/\n" + "InnoDB: https://mariadb.com/kb/en/library/innodb-recovery-modes/\n" "InnoDB: about forcing recovery.\n", stderr); fflush(stderr); From da4efd56aa9bc3c39d94a73eb216ca7f559ce734 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Wed, 19 Dec 2018 10:38:29 +0530 Subject: [PATCH 13/58] Backported MDEV-11196(e4d10e09cf31) and MDEV-10360(8a8ba1949bf4) to 10.0 --- mysql-test/r/innodb_ext_key.result | 95 ++++++++++++++++++++++++++ mysql-test/t/innodb_ext_key.test | 106 +++++++++++++++++++++++++++++ sql/table.cc | 48 +++++++++++-- 3 files changed, 244 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/innodb_ext_key.result b/mysql-test/r/innodb_ext_key.result index 2b3b98eb26a..600269ba433 100644 --- a/mysql-test/r/innodb_ext_key.result +++ b/mysql-test/r/innodb_ext_key.result @@ -1068,5 +1068,100 @@ a 1 drop table t1, t2; set optimizer_switch=@save_optimizer_switch; +# +# MDEV-10360: Extended keys: index properties depend on index order +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 ( +index_id bigint(20) unsigned NOT NULL, +index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , +index_object_id int(10) unsigned NOT NULL DEFAULT '0' , +index_date_updated int(10) unsigned DEFAULT NULL , +PRIMARY KEY (index_id), +KEY object (index_class(181),index_object_id), +KEY index_date_updated (index_date_updated) +) engine=innodb; +create table t2 ( +index_id bigint(20) unsigned NOT NULL, +index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , +index_object_id int(10) unsigned NOT NULL DEFAULT '0' , +index_date_updated int(10) unsigned DEFAULT NULL , +PRIMARY KEY (index_id), +KEY index_date_updated (index_date_updated), +KEY object (index_class(181),index_object_id) +) engine=innodb; +insert into t1 select +@a:=A.a + 10*B.a + 100*C.a, +concat('val-', @a), +123456, +A.a + 10*B.a +from +t0 A, t0 B, t0 C; +insert into t2 select * from t1; +# This must have the same query plan as the query below it: +# type=range, key=index_date_updated, key_len=13 +explain +select * from t1 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range index_date_updated index_date_updated 13 NULL # Using index condition +# This used to work from the start: +explain +select * from t2 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 range index_date_updated index_date_updated 13 NULL # Using index condition +drop table t0,t1,t2; +# +# MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' +# was corrupted, server crashes in opt_sum_query +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; +CREATE TABLE t1 ( +pk INT, +f1 VARCHAR(3), +f2 VARCHAR(1024), +PRIMARY KEY (pk), +KEY(f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,'foo','abc'),(2,'bar','def'); +SELECT MAX(t2.pk) FROM t1 t2 INNER JOIN t1 t3 ON t2.f1 = t3.f1 WHERE t2.pk <= 4; +MAX(t2.pk) +2 +drop table t1; +CREATE TABLE t1 ( +pk1 INT, +pk2 INT, +f1 VARCHAR(3), +f2 VARCHAR(1021), +PRIMARY KEY (pk1,pk2), +KEY(f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); +explain +select * from t1 force index(f2) where pk1 <= 5 and pk2 <=5 and f2 = 'abc' and f1 <= '3'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range f2 f2 3070 NULL 1 Using index condition; Using where +drop table t1; +CREATE TABLE t1 ( +f2 INT, +pk2 INT, +f1 VARCHAR(3), +pk1 VARCHAR(1000), +PRIMARY KEY (pk1,pk2), +KEY k1(pk1,f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); +explain +select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range k1 k1 3011 NULL 1 Using index condition; Using where +drop table t1; +set optimizer_switch=@save_ext_key_optimizer_switch; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; set optimizer_switch=@save_ext_key_optimizer_switch; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/t/innodb_ext_key.test b/mysql-test/t/innodb_ext_key.test index 9f3a89ff948..d53deb46348 100644 --- a/mysql-test/t/innodb_ext_key.test +++ b/mysql-test/t/innodb_ext_key.test @@ -693,5 +693,111 @@ drop table t1, t2; set optimizer_switch=@save_optimizer_switch; +--echo # +--echo # MDEV-10360: Extended keys: index properties depend on index order +--echo # +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 ( + index_id bigint(20) unsigned NOT NULL, + index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , + index_object_id int(10) unsigned NOT NULL DEFAULT '0' , + index_date_updated int(10) unsigned DEFAULT NULL , + + PRIMARY KEY (index_id), + KEY object (index_class(181),index_object_id), + KEY index_date_updated (index_date_updated) +) engine=innodb; + +create table t2 ( + index_id bigint(20) unsigned NOT NULL, + index_class varchar(265) COLLATE latin1_general_ci DEFAULT NULL , + index_object_id int(10) unsigned NOT NULL DEFAULT '0' , + index_date_updated int(10) unsigned DEFAULT NULL , + + PRIMARY KEY (index_id), + KEY index_date_updated (index_date_updated), + KEY object (index_class(181),index_object_id) +) engine=innodb; + +insert into t1 select + @a:=A.a + 10*B.a + 100*C.a, + concat('val-', @a), + 123456, + A.a + 10*B.a +from + t0 A, t0 B, t0 C; + +insert into t2 select * from t1; + +--echo # This must have the same query plan as the query below it: +--echo # type=range, key=index_date_updated, key_len=13 +--replace_column 9 # +explain +select * from t1 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; + +--echo # This used to work from the start: +--replace_column 9 # +explain +select * from t2 force index(index_date_updated) +where index_date_updated= 10 and index_id < 800; + +drop table t0,t1,t2; + + +--echo # +--echo # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' +--echo # was corrupted, server crashes in opt_sum_query + +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; + +CREATE TABLE t1 ( + pk INT, + f1 VARCHAR(3), + f2 VARCHAR(1024), + PRIMARY KEY (pk), + KEY(f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; + +INSERT INTO t1 VALUES (1,'foo','abc'),(2,'bar','def'); +SELECT MAX(t2.pk) FROM t1 t2 INNER JOIN t1 t3 ON t2.f1 = t3.f1 WHERE t2.pk <= 4; +drop table t1; + +CREATE TABLE t1 ( + pk1 INT, + pk2 INT, + f1 VARCHAR(3), + f2 VARCHAR(1021), + PRIMARY KEY (pk1,pk2), + KEY(f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; + +INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); +explain +select * from t1 force index(f2) where pk1 <= 5 and pk2 <=5 and f2 = 'abc' and f1 <= '3'; +drop table t1; + +CREATE TABLE t1 ( +f2 INT, +pk2 INT, +f1 VARCHAR(3), +pk1 VARCHAR(1000), +PRIMARY KEY (pk1,pk2), +KEY k1(pk1,f2) +) ENGINE=InnoDB CHARSET utf8 ROW_FORMAT= DYNAMIC; +INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); +explain +select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3'; +drop table t1; + +set optimizer_switch=@save_ext_key_optimizer_switch; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; + set optimizer_switch=@save_ext_key_optimizer_switch; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/sql/table.cc b/sql/table.cc index 98bf6d8b4dd..5a34d47367a 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1690,6 +1690,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, keyinfo= share->key_info; uint primary_key= my_strcasecmp(system_charset_info, share->keynames.type_names[0], primary_key_name) ? MAX_KEY : 0; + KEY* key_first_info= NULL; if (primary_key >= MAX_KEY && keyinfo->flags & HA_NOSAME) { @@ -1769,34 +1770,71 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, keyinfo->name_length+1); } + if (!key) + key_first_info= keyinfo; + if (ext_key_parts > share->key_parts && key) { KEY_PART_INFO *new_key_part= (keyinfo-1)->key_part + (keyinfo-1)->ext_key_parts; + uint add_keyparts_for_this_key= add_first_key_parts; + uint length_bytes= 0, len_null_byte= 0, ext_key_length= 0; + Field *field; /* Do not extend the key that contains a component defined over the beginning of a field. */ for (i= 0; i < keyinfo->user_defined_key_parts; i++) - { + { uint fieldnr= keyinfo->key_part[i].fieldnr; + field= share->field[keyinfo->key_part[i].fieldnr-1]; + + if (field->null_ptr) + len_null_byte= HA_KEY_NULL_LENGTH; + + if (field->type() == MYSQL_TYPE_BLOB || + field->real_type() == MYSQL_TYPE_VARCHAR || + field->type() == MYSQL_TYPE_GEOMETRY) + { + length_bytes= HA_KEY_BLOB_LENGTH; + } + ext_key_length+= keyinfo->key_part[i].length + len_null_byte + + length_bytes; if (share->field[fieldnr-1]->key_length() != keyinfo->key_part[i].length) { - add_first_key_parts= 0; + add_keyparts_for_this_key= 0; break; } } - if (add_first_key_parts < keyinfo->ext_key_parts-keyinfo->user_defined_key_parts) - { + if (add_keyparts_for_this_key) + { + for (i= 0; i < add_keyparts_for_this_key; i++) + { + uint pk_part_length= key_first_info->key_part[i].store_length; + if (keyinfo->ext_key_part_map & 1< MAX_KEY_LENGTH) + { + add_keyparts_for_this_key= i; + break; + } + ext_key_length+= pk_part_length; + } + } + } + + if (add_keyparts_for_this_key < keyinfo->ext_key_parts - + keyinfo->user_defined_key_parts) + { share->ext_key_parts-= keyinfo->ext_key_parts; key_part_map ext_key_part_map= keyinfo->ext_key_part_map; keyinfo->ext_key_parts= keyinfo->user_defined_key_parts; keyinfo->ext_key_flags= keyinfo->flags; keyinfo->ext_key_part_map= 0; - for (i= 0; i < add_first_key_parts; i++) + for (i= 0; i < add_keyparts_for_this_key; i++) { if (ext_key_part_map & 1< Date: Wed, 19 Dec 2018 10:34:30 +0530 Subject: [PATCH 14/58] MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field Create a new constant MAX_DATA_LENGTH_FOR_KEY. Replace the value of MAX_KEY_LENGTH to also include the LENGTH and NULL BYTES of a field. --- mysql-test/r/func_group_innodb.result | 30 +++++++++++++++++++++++++++ mysql-test/t/func_group_innodb.test | 26 +++++++++++++++++++++++ sql/handler.h | 12 ++++++++--- sql/partition_info.cc | 4 ++-- sql/sql_const.h | 12 ++++++++++- sql/table.cc | 2 +- 6 files changed, 79 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/func_group_innodb.result b/mysql-test/r/func_group_innodb.result index 52d5922df95..17b3c1e797e 100644 --- a/mysql-test/r/func_group_innodb.result +++ b/mysql-test/r/func_group_innodb.result @@ -246,4 +246,34 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 range NULL b 263 NULL 3 Using index for group-by DROP TABLE t1; +# +# MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field +# +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; +CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2), +KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go'); +explain +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +MIN(t1.v1) +king +drop table t1; +CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king'), ('bad'); +explain +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No matching min/max row +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +MIN(x.v1) +NULL +drop table t1; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; End of 5.5 tests diff --git a/mysql-test/t/func_group_innodb.test b/mysql-test/t/func_group_innodb.test index c62d3d08496..a65d2326d0f 100644 --- a/mysql-test/t/func_group_innodb.test +++ b/mysql-test/t/func_group_innodb.test @@ -192,4 +192,30 @@ EXPLAIN SELECT MIN(c) FROM t1 GROUP BY b; DROP TABLE t1; +--echo # +--echo # MDEV-17589: Stack-buffer-overflow with indexed varchar (utf8) field +--echo # + +set @save_innodb_file_format= @@innodb_file_format; +set @save_innodb_large_prefix= @@innodb_large_prefix; +set global innodb_file_format = BARRACUDA; +set global innodb_large_prefix = ON; + +CREATE TABLE t1 (v1 varchar(1020), v2 varchar(2), v3 varchar(2), + KEY k1 (v3,v2,v1)) ENGINE=InnoDB CHARACTER SET=utf8 ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king', 'qu','qu'), ('bad','go','go'); +explain +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +SELECT MIN(t1.v1) FROM t1 where t1.v2='qu' and t1.v3='qu'; +drop table t1; + +CREATE TABLE t1 (v1 varchar(1024) CHARACTER SET utf8, KEY v1 (v1)) ENGINE=InnoDB ROW_FORMAT=DYNAMIC; +INSERT INTO t1 VALUES ('king'), ('bad'); +explain +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +SELECT MIN(x.v1) FROM (SELECT t1.* FROM t1 WHERE t1.v1 >= 'p') x; +drop table t1; +set global innodb_file_format = @save_innodb_file_format; +set global innodb_large_prefix = @save_innodb_large_prefix; + --echo End of 5.5 tests diff --git a/sql/handler.h b/sql/handler.h index 52396b84c0d..606adade679 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -384,6 +384,12 @@ enum enum_alter_inplace_result { #define HA_KEY_NULL_LENGTH 1 #define HA_KEY_BLOB_LENGTH 2 +/* Maximum length of any index lookup key, in bytes */ + +#define MAX_KEY_LENGTH (MAX_DATA_LENGTH_FOR_KEY \ + +(MAX_REF_PARTS \ + *(HA_KEY_NULL_LENGTH + HA_KEY_BLOB_LENGTH))) + #define HA_LEX_CREATE_TMP_TABLE 1 #define HA_LEX_CREATE_IF_NOT_EXISTS 2 #define HA_LEX_CREATE_TABLE_LIKE 4 @@ -3233,14 +3239,14 @@ public: uint max_key_parts() const { return MY_MIN(MAX_REF_PARTS, max_supported_key_parts()); } uint max_key_length() const - { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_length()); } + { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_length()); } uint max_key_part_length() const - { return MY_MIN(MAX_KEY_LENGTH, max_supported_key_part_length()); } + { return MY_MIN(MAX_DATA_LENGTH_FOR_KEY, max_supported_key_part_length()); } virtual uint max_supported_record_length() const { return HA_MAX_REC_LENGTH; } virtual uint max_supported_keys() const { return 0; } virtual uint max_supported_key_parts() const { return MAX_REF_PARTS; } - virtual uint max_supported_key_length() const { return MAX_KEY_LENGTH; } + virtual uint max_supported_key_length() const { return MAX_DATA_LENGTH_FOR_KEY; } virtual uint max_supported_key_part_length() const { return 255; } virtual uint min_record_length(uint options) const { return 1; } diff --git a/sql/partition_info.cc b/sql/partition_info.cc index e6a30c8a7f0..7106e741331 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -1990,12 +1990,12 @@ bool partition_info::check_partition_field_length() for (i= 0; i < num_part_fields; i++) store_length+= get_partition_field_store_length(part_field_array[i]); - if (store_length > MAX_KEY_LENGTH) + if (store_length > MAX_DATA_LENGTH_FOR_KEY) DBUG_RETURN(TRUE); store_length= 0; for (i= 0; i < num_subpart_fields; i++) store_length+= get_partition_field_store_length(subpart_field_array[i]); - if (store_length > MAX_KEY_LENGTH) + if (store_length > MAX_DATA_LENGTH_FOR_KEY) DBUG_RETURN(TRUE); DBUG_RETURN(FALSE); } diff --git a/sql/sql_const.h b/sql/sql_const.h index c37d8dd68f7..c0b343c6ca4 100644 --- a/sql/sql_const.h +++ b/sql/sql_const.h @@ -33,7 +33,17 @@ #define MAX_SYS_VAR_LENGTH 32 #define MAX_KEY MAX_INDEXES /* Max used keys */ #define MAX_REF_PARTS 32 /* Max parts used as ref */ -#define MAX_KEY_LENGTH 3072 /* max possible key */ + +/* + Maximum length of the data part of an index lookup key. + + The "data part" is defined as the value itself, not including the + NULL-indicator bytes or varchar length bytes ("the Extras"). We need this + value because there was a bug where length of the Extras were not counted. + + You probably need MAX_KEY_LENGTH, not this constant. +*/ +#define MAX_DATA_LENGTH_FOR_KEY 3072 #if SIZEOF_OFF_T > 4 #define MAX_REFLENGTH 8 /* Max length for record ref */ #else diff --git a/sql/table.cc b/sql/table.cc index 5a34d47367a..ded79de0e83 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1816,7 +1816,7 @@ int TABLE_SHARE::init_from_binary_frm_image(THD *thd, bool write, uint pk_part_length= key_first_info->key_part[i].store_length; if (keyinfo->ext_key_part_map & 1< MAX_KEY_LENGTH) + if (ext_key_length + pk_part_length > MAX_DATA_LENGTH_FOR_KEY) { add_keyparts_for_this_key= i; break; From 82a4d55d5c569a9adfbd863c928bd357c2e5afed Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Wed, 19 Dec 2018 18:57:14 +0530 Subject: [PATCH 15/58] MDEV-15424: Unreasonable SQL Error (1356) on select from view While printing a view containing a window function we were printing it as an Item_field object instead of an Item_window_func object. This is incorrect and this leads to us throwing an error ER_VIEW_INVALID. Fixed by adjusting the Item_ref:print function. Also made UDF function aware if there arguments have window function. --- mysql-test/r/udf.result | 14 ++++++++++++++ mysql-test/r/win.result | 18 ++++++++++++++++++ mysql-test/t/udf.test | 13 +++++++++++++ mysql-test/t/win.test | 13 +++++++++++++ sql/item.cc | 4 +++- sql/item_func.cc | 2 ++ 6 files changed, 63 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 98aa2b50fc6..3a84caa828a 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -465,3 +465,17 @@ a b Hello HL DROP FUNCTION METAPHON; DROP TABLE t1; +# +# MDEV-15424: Unreasonal SQL Error (1356) on select from view +# +CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB"; +create table t1(a int , b int); +insert into t1 values(100, 54), (200, 199); +create view v1 as select myfunc_int(max(a) over (order by b) , b) from t1; +select * from v1; +myfunc_int(max(a) over (order by b) , b) +154 +399 +drop view v1; +drop function myfunc_int; +drop table t1; diff --git a/mysql-test/r/win.result b/mysql-test/r/win.result index e902d62326e..2e80c2c961b 100644 --- a/mysql-test/r/win.result +++ b/mysql-test/r/win.result @@ -3470,3 +3470,21 @@ SELECT DISTINCT MIN(b1) OVER () FROM t1; MIN(b1) OVER () 1 drop table t1; +# +# MDEV-15424: Unreasonal SQL Error (1356) on select from view +# +create table t1 (id int, n1 int); +insert into t1 values (1,1), (2,1), (3,2), (4,4); +create view v1 as SELECT ifnull(max(n1) over (partition by n1),'aaa') FROM t1; +explain select * from v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY ALL NULL NULL NULL NULL 4 +2 DERIVED t1 ALL NULL NULL NULL NULL 4 Using temporary +select * from v1; +ifnull(max(n1) over (partition by n1),'aaa') +1 +1 +2 +4 +drop table t1; +drop view v1; diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 42a813b0782..881e753de7d 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -528,3 +528,16 @@ DROP FUNCTION METAPHON; #INSERT INTO t1 (a) VALUES ('Hello'); #SELECT * FROM t1; DROP TABLE t1; + +--echo # +--echo # MDEV-15424: Unreasonal SQL Error (1356) on select from view +--echo # +--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO"; +create table t1(a int , b int); +insert into t1 values(100, 54), (200, 199); +create view v1 as select myfunc_int(max(a) over (order by b) , b) from t1; +select * from v1; +drop view v1; +drop function myfunc_int; +drop table t1; diff --git a/mysql-test/t/win.test b/mysql-test/t/win.test index b0e1a16fae6..18bdfa31691 100644 --- a/mysql-test/t/win.test +++ b/mysql-test/t/win.test @@ -2227,3 +2227,16 @@ EXPLAIN SELECT DISTINCT MIN(b1) OVER () FROM t1; SELECT DISTINCT MIN(b1) OVER () FROM t1; drop table t1; + +--echo # +--echo # MDEV-15424: Unreasonal SQL Error (1356) on select from view +--echo # + +create table t1 (id int, n1 int); +insert into t1 values (1,1), (2,1), (3,2), (4,4); + +create view v1 as SELECT ifnull(max(n1) over (partition by n1),'aaa') FROM t1; +explain select * from v1; +select * from v1; +drop table t1; +drop view v1; diff --git a/sql/item.cc b/sql/item.cc index 1c0b6cc4043..761c9fbec3d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7815,7 +7815,9 @@ void Item_ref::print(String *str, enum_query_type query_type) { if (ref) { - if ((*ref)->type() != Item::CACHE_ITEM && ref_type() != VIEW_REF && + if ((*ref)->type() != Item::CACHE_ITEM && + (*ref)->type() != Item::WINDOW_FUNC_ITEM && + ref_type() != VIEW_REF && !table_name && name && alias_name_used) { THD *thd= current_thd; diff --git a/sql/item_func.cc b/sql/item_func.cc index 512c8fccab0..89ca25bbfd4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -3484,6 +3484,8 @@ udf_handler::fix_fields(THD *thd, Item_func_or_sum *func, if (item->maybe_null) func->maybe_null=1; func->with_sum_func= func->with_sum_func || item->with_sum_func; + func->with_window_func= func->with_window_func || + item->with_window_func; func->with_field= func->with_field || item->with_field; func->with_param= func->with_param || item->with_param; func->with_subselect|= item->with_subselect; From dd72d7d561d36c2d1f5d3ccad2b388d886230392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 19 Dec 2018 15:45:35 +0200 Subject: [PATCH 16/58] MDEV-18025: Improve test case and consistency checks Write a test case that computes valid crc32 checksums for an encrypted page, but zeroes out the payload area, so that the checksum after decryption fails. xb_fil_cur_read(): Validate the page number before trying any checksum calculation or decrypting or decompression. Also, skip zero-filled pages. For page_compressed pages, ensure that the FIL_PAGE_TYPE was changed. Also, reject FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED if no decryption was attempted. --- extra/mariabackup/fil_cur.cc | 38 ++++++++++++---- mysql-test/suite/innodb/include/crc32.pl | 33 ++++++++++++++ .../encrypted_page_corruption.result | 2 +- .../encrypted_page_corruption.test | 43 ++++++++++++++----- 4 files changed, 97 insertions(+), 19 deletions(-) create mode 100644 mysql-test/suite/innodb/include/crc32.pl diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index b677e9973b7..637acfd2e22 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -353,6 +353,27 @@ read_retry: && page_no >= FSP_EXTENT_SIZE && page_no < FSP_EXTENT_SIZE * 3) { /* We ignore the doublewrite buffer pages */ + } else if (mach_read_from_4(page + FIL_PAGE_OFFSET) != page_no + && space->id != TRX_SYS_SPACE) { + /* On pages that are not all zero, the + page number must match. + + There may be a mismatch on tablespace ID, + because files may be renamed during backup. + We disable the page number check + on the system tablespace, because it may consist + of multiple files, and here we count the pages + from the start of each file.) + + The first 38 and last 8 bytes are never encrypted. */ + const ulint* p = reinterpret_cast(page); + const ulint* const end = reinterpret_cast( + page + cursor->page_size); + do { + if (*p++) { + goto corrupted; + } + } while (p != end); } else if (mach_read_from_4( page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) @@ -361,9 +382,6 @@ read_retry: != CRYPT_SCHEME_UNENCRYPTED && fil_space_verify_crypt_checksum( page, cursor->zip_size)) { - ut_ad(mach_read_from_4(page + FIL_PAGE_SPACE_ID) - == space->id); - bool decrypted = false; memcpy(tmp_page, page, cursor->page_size); @@ -381,21 +399,25 @@ read_retry: true, tmp_page, cursor->zip_size, space)) { goto corrupted; } - } else if (page_type == FIL_PAGE_PAGE_COMPRESSED) { memcpy(tmp_page, page, cursor->page_size); page_decomp: ulint decomp = fil_page_decompress(tmp_frame, tmp_page); + page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE); if (!decomp || (decomp != srv_page_size && cursor->zip_size) - || buf_page_is_corrupted( - true, tmp_page, cursor->zip_size, space)) { + || page_type == FIL_PAGE_PAGE_COMPRESSED + || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED + || buf_page_is_corrupted(true, tmp_page, + cursor->zip_size, + space)) { goto corrupted; } - } else if (buf_page_is_corrupted(true, page, cursor->zip_size, - space)) { + } else if (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED + || buf_page_is_corrupted(true, page, + cursor->zip_size, space)) { corrupted: retry_count--; diff --git a/mysql-test/suite/innodb/include/crc32.pl b/mysql-test/suite/innodb/include/crc32.pl new file mode 100644 index 00000000000..c2bce09dd36 --- /dev/null +++ b/mysql-test/suite/innodb/include/crc32.pl @@ -0,0 +1,33 @@ +# The following is Public Domain / Creative Commons CC0 from +# http://billauer.co.il/blog/2011/05/perl-crc32-crc-xs-module/ + +sub mycrc32 { + my ($input, $init_value, $polynomial) = @_; + + $init_value = 0 unless (defined $init_value); + $polynomial = 0xedb88320 unless (defined $polynomial); + + my @lookup_table; + + for (my $i=0; $i<256; $i++) { + my $x = $i; + for (my $j=0; $j<8; $j++) { + if ($x & 1) { + $x = ($x >> 1) ^ $polynomial; + } else { + $x = $x >> 1; + } + } + push @lookup_table, $x; + } + + my $crc = $init_value ^ 0xffffffff; + + foreach my $x (unpack ('C*', $input)) { + $crc = (($crc >> 8) & 0xffffff) ^ $lookup_table[ ($crc ^ $x) & 0xff ]; + } + + $crc = $crc ^ 0xffffffff; + + return $crc; +} diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.result b/mysql-test/suite/mariabackup/encrypted_page_corruption.result index c985c48dbc0..0198cfb3dc0 100644 --- a/mysql-test/suite/mariabackup/encrypted_page_corruption.result +++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.result @@ -1,4 +1,4 @@ -call mtr.add_suppression("\\[ERROR\\] InnoDB: The page .* in file .* cannot be decrypted."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted."); CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes; insert into t1 select repeat('a',100); # Corrupt the table diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.test b/mysql-test/suite/mariabackup/encrypted_page_corruption.test index f8f7bdb6567..f87e12323da 100644 --- a/mysql-test/suite/mariabackup/encrypted_page_corruption.test +++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.test @@ -1,11 +1,22 @@ --source include/have_file_key_management.inc +--source include/innodb_page_size.inc -call mtr.add_suppression("\\[ERROR\\] InnoDB: The page .* in file .* cannot be decrypted."); +perl; +open(OUT, ">$ENV{MYSQLTEST_VARDIR}/log/check.txt") || die; +print OUT "--skip innodb_checksum_algorithm=crc32 needs little-endian\n" +unless unpack("L","macs")==unpack("N","scam"); +close(OUT); +EOF + +--source $MYSQLTEST_VARDIR/log/check.txt +--remove_file $MYSQLTEST_VARDIR/log/check.txt + +call mtr.add_suppression("\\[ERROR\\] InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted."); CREATE TABLE t1(c VARCHAR(128)) ENGINE INNODB, encrypted=yes; insert into t1 select repeat('a',100); -let $MYSQLD_DATADIR=`select @@datadir`; -let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd; +let MYSQLD_DATADIR=`select @@datadir`; +let INNODB_PAGE_SIZE=`select @@innodb_page_size`; --source include/shutdown_mysqld.inc @@ -15,17 +26,29 @@ perl; use strict; use warnings; use Fcntl qw(:DEFAULT :seek); +do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; -my $ibd_file = $ENV{'t1_IBD'}; +my $page_size = $ENV{INNODB_PAGE_SIZE}; -my $chunk; -my $len; +sysopen IBD_FILE, "$ENV{MYSQLD_DATADIR}/test/t1.ibd", O_RDWR +|| die "Cannot open t1.ibd\n"; +sysread(IBD_FILE, $_, 38) || die "Cannot read t1.ibd\n"; +my $space = unpack("x[34]N", $_); +sysseek(IBD_FILE, $page_size * 3, SEEK_SET) || die "Cannot seek t1.ibd\n"; -sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file"; -sysseek IBD_FILE, 16384 * 3, SEEK_CUR; -$chunk = '\xAA\xAA\xAA\xAA'; -syswrite IBD_FILE, $chunk, 4; +my $head = pack("Nx[18]", 3); # better to have a valid page number +my $body = chr(0) x ($page_size - 38 - 8); +# Calculate innodb_checksum_algorithm=crc32 for the unencrypted page. +# The following bytes are excluded: +# bytes 0..3 (the checksum is stored there) +# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id) +# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN) +my $polynomial = 0x82f63b78; # CRC-32C +my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); + +my $page= pack("N",$ck).$head.pack("NNN",1,$ck,$space).$body.pack("Nx[4]",$ck); +die unless syswrite(IBD_FILE, $page, $page_size) == $page_size; close IBD_FILE; EOF From f16d4d4c6ee81cfee3b0d1cb2f2219b1fa982e2e Mon Sep 17 00:00:00 2001 From: Sachin Date: Wed, 19 Dec 2018 16:33:00 +0530 Subject: [PATCH 17/58] MDEV-17720 slave_ddl_exec_mode=IDEMPOTENT does not handle DROP DATABASE Relevant if exists flag are added for create database and drop database. --- mysql-test/suite/rpl/r/rpl_idempotency.result | 12 +++++++++++ mysql-test/suite/rpl/t/rpl_idempotency.test | 21 +++++++++++++++++++ sql/sql_parse.cc | 6 ++++++ 3 files changed, 39 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_idempotency.result b/mysql-test/suite/rpl/r/rpl_idempotency.result index 38b955d7697..03482e6fefb 100644 --- a/mysql-test/suite/rpl/r/rpl_idempotency.result +++ b/mysql-test/suite/rpl/r/rpl_idempotency.result @@ -67,6 +67,18 @@ a -3 1 include/check_slave_no_error.inc +drop table t1, t2; DROP TABLE t1, t2; +include/check_slave_no_error.inc +create database d; +create database e; +create database d; +create database if not exists e; +include/check_slave_no_error.inc +drop database d; +drop database e; +drop database d; +drop database if exists e; +include/check_slave_no_error.inc SET @@global.slave_exec_mode= @old_slave_exec_mode; include/rpl_end.inc diff --git a/mysql-test/suite/rpl/t/rpl_idempotency.test b/mysql-test/suite/rpl/t/rpl_idempotency.test index 186c6260154..e801aac9b5e 100644 --- a/mysql-test/suite/rpl/t/rpl_idempotency.test +++ b/mysql-test/suite/rpl/t/rpl_idempotency.test @@ -75,9 +75,30 @@ SELECT * FROM t1 ORDER BY a; SELECT * FROM t2 ORDER BY a; --source include/check_slave_no_error.inc +connection slave; +drop table t1, t2; + connection master; DROP TABLE t1, t2; sync_slave_with_master; +--source include/check_slave_no_error.inc +create database d; +create database e; + +connection master; +create database d; +create database if not exists e; + +sync_slave_with_master; +--source include/check_slave_no_error.inc +drop database d; +drop database e; + +connection master; +drop database d; +drop database if exists e; +sync_slave_with_master; +--source include/check_slave_no_error.inc SET @@global.slave_exec_mode= @old_slave_exec_mode; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a9849c7248d..5ca22f0dedc 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3884,6 +3884,9 @@ end_with_restore_list: my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); break; } + if (slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT && + !(lex->create_info.options & HA_LEX_CREATE_IF_NOT_EXISTS)) + create_info.options|= HA_LEX_CREATE_IF_NOT_EXISTS; } #endif if (check_access(thd, CREATE_ACL, lex->name.str, NULL, NULL, 1, 0)) @@ -3915,6 +3918,9 @@ end_with_restore_list: my_message(ER_SLAVE_IGNORED_TABLE, ER(ER_SLAVE_IGNORED_TABLE), MYF(0)); break; } + if (!thd->slave_expected_error && + slave_ddl_exec_mode_options == SLAVE_EXEC_MODE_IDEMPOTENT) + lex->check_exists= 1; } #endif if (check_access(thd, DROP_ACL, lex->name.str, NULL, NULL, 1, 0)) From e765b47e41db54124c05732a903110eae08e1194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 14 Sep 2018 18:50:37 +0300 Subject: [PATCH 18/58] MDEV-17199 Assertion `pos < table->n_v_def' failed after upgrade to 10.2 Before MDEV-5800 in MariaDB 10.2.2, InnoDB knew nothing about virtual columns. But, they would be present in the TABLE_SHARE. It appears that the MDEV-12936 fix only worked in the special case when the virtual columns are the last columns in a table definition. mysql_fields(): Remove. build_template_needs_field(): Omit virtual columns if the InnoDB table definition is known to not contain them, based on the .frm file version. build_template_field(): Clean up some code. ha_innobase::build_template(): Remove redundant computations. Loop over all MariaDB columns. Skip virtual columns if InnoDB does not know about them. calc_row_difference(): Skip not-known-to-InnoDB virtual columns. wsrep_calc_row_hash(): Skip all virtual columns. This would fix an out-of-bounds access to dict_table_t::cols[]. Also, remove some redundant computations and variables. create_table_check_doc_id_col(): Assert that the .frm file for a newly created table will be in a format where InnoDB knows about virtual columns. --- storage/innobase/handler/ha_innodb.cc | 187 ++++++++++++-------------- 1 file changed, 84 insertions(+), 103 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 52940eb2f76..62924ab8fc5 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -275,10 +275,10 @@ void set_my_errno(int err) errno = err; } -static uint mysql_fields(const TABLE *table) +static uint omits_virtual_cols(const TABLE_SHARE &share) { - return table->s->frm_version < FRM_VER_EXPRESSSIONS - ? table->s->stored_fields : table->s->fields; + return share.frm_version < FRM_VER_EXPRESSSIONS && + share.virtual_fields; } /** Checks whether the file name belongs to a partition of a table. @@ -6247,12 +6247,13 @@ no_such_table: DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); } - uint n_fields = mysql_fields(table); + uint n_fields = omits_virtual_cols(*table_share) + ? table_share->stored_fields : table_share->fields; uint n_cols = dict_table_get_n_user_cols(ib_table) + dict_table_get_n_v_cols(ib_table) - !!DICT_TF2_FLAG_IS_SET(ib_table, DICT_TF2_FTS_HAS_DOC_ID); - if (n_cols != n_fields) { + if (UNIV_UNLIKELY(n_cols != n_fields)) { ib::warn() << "Table " << norm_name << " contains " << n_cols << " user" " defined columns in InnoDB, but " << n_fields @@ -7459,6 +7460,10 @@ build_template_needs_field( { const Field* field = table->field[i]; + if (innobase_is_v_fld(field) && omits_virtual_cols(*table->s)) { + return NULL; + } + if (!index_contains) { if (read_just_key) { /* If this is a 'key read', we do not need @@ -7483,7 +7488,6 @@ build_template_needs_field( if (fetch_primary_key_cols && dict_table_col_in_clustered_key(index->table, i - num_v)) { /* This field is needed in the query */ - return(field); } @@ -7536,17 +7540,11 @@ build_template_field( templ = prebuilt->mysql_template + prebuilt->n_template++; UNIV_MEM_INVALID(templ, sizeof *templ); - - if (innobase_is_v_fld(field)) { - templ->is_virtual = true; - col = &dict_table_get_nth_v_col(index->table, v_no)->m_col; - } else { - templ->is_virtual = false; - col = dict_table_get_nth_col(index->table, i); - } + templ->is_virtual = innobase_is_v_fld(field); if (!templ->is_virtual) { templ->col_no = i; + col = dict_table_get_nth_col(index->table, i); templ->clust_rec_field_no = dict_col_get_clust_pos( col, clust_index); /* If clustered index record field is not found, lets print out @@ -7585,7 +7583,7 @@ build_template_field( << table->field[j]->field_name; } - ib::error() << "Clustered record field for column " << i + ib::fatal() << "Clustered record field for column " << i << " not found table n_user_defined " << clust_index->n_user_defined_cols << " index n_user_defined " @@ -7602,8 +7600,6 @@ build_template_field( << table->s->stored_fields << " query " << innobase_get_stmt_unsafe(current_thd, &size); - - ut_a(templ->clust_rec_field_no != ULINT_UNDEFINED); } templ->rec_field_is_prefix = FALSE; templ->rec_prefix_field_no = ULINT_UNDEFINED; @@ -7621,6 +7617,8 @@ build_template_field( &templ->rec_prefix_field_no); } } else { + ut_ad(!omits_virtual_cols(*table->s)); + col = &dict_table_get_nth_v_col(index->table, v_no)->m_col; templ->clust_rec_field_no = v_no; templ->rec_prefix_field_no = ULINT_UNDEFINED; @@ -7704,10 +7702,8 @@ ha_innobase::build_template( { dict_index_t* index; dict_index_t* clust_index; - ulint n_fields; ibool fetch_all_in_key = FALSE; ibool fetch_primary_key_cols = FALSE; - ulint i; if (m_prebuilt->select_lock_type == LOCK_X) { /* We always retrieve the whole clustered index record if we @@ -7760,7 +7756,8 @@ ha_innobase::build_template( /* Below we check column by column if we need to access the clustered index. */ - n_fields = (ulint) mysql_fields(table); + const bool skip_virtual = omits_virtual_cols(*table_share); + const ulint n_fields = table_share->fields; if (!m_prebuilt->mysql_template) { m_prebuilt->mysql_template = (mysql_row_templ_t*) @@ -7780,25 +7777,25 @@ ha_innobase::build_template( /* Note that in InnoDB, i is the column number in the table. MySQL calls columns 'fields'. */ + ulint num_v = 0; + if (active_index != MAX_KEY && active_index == pushed_idx_cond_keyno) { - ulint num_v = 0; - /* Push down an index condition or an end_range check. */ - for (i = 0; i < n_fields; i++) { - ibool index_contains; - - if (innobase_is_v_fld(table->field[i])) { - index_contains = dict_index_contains_col_or_prefix( - index, num_v, true); - if (index_contains) - { - m_prebuilt->n_template = 0; - goto no_icp; - } - } else { - index_contains = dict_index_contains_col_or_prefix( - index, i - num_v, false); + for (ulint i = 0; i < n_fields; i++) { + const Field* field = table->field[i]; + const bool is_v = innobase_is_v_fld(field); + if (is_v && skip_virtual) { + num_v++; + continue; + } + ibool index_contains + = dict_index_contains_col_or_prefix( + index, is_v ? num_v : i - num_v, is_v); + if (is_v && index_contains) { + m_prebuilt->n_template = 0; + num_v = 0; + goto no_icp; } /* Test if an end_range or an index condition @@ -7816,17 +7813,10 @@ ha_innobase::build_template( the subset field->part_of_key.is_set(active_index) which would be acceptable if end_range==NULL. */ - bool is_v = innobase_is_v_fld(table->field[i]); if (build_template_needs_field_in_icp( index, m_prebuilt, index_contains, is_v ? num_v : i - num_v, is_v)) { - /* Needed in ICP */ - const Field* field; - mysql_row_templ_t* templ; - - if (whole_row) { - field = table->field[i]; - } else { + if (!whole_row) { field = build_template_needs_field( index_contains, m_prebuilt->read_just_key, @@ -7834,15 +7824,16 @@ ha_innobase::build_template( fetch_primary_key_cols, index, table, i, num_v); if (!field) { - if (innobase_is_v_fld( - table->field[i])) { + if (is_v) { num_v++; } continue; } } - templ = build_template_field( + ut_ad(!is_v); + + mysql_row_templ_t* templ= build_template_field( m_prebuilt, clust_index, index, table, field, i - num_v, 0); @@ -7917,7 +7908,8 @@ ha_innobase::build_template( < m_prebuilt->index->n_uniq); */ } - if (innobase_is_v_fld(table->field[i])) { + + if (is_v) { num_v++; } } @@ -7929,29 +7921,24 @@ ha_innobase::build_template( /* Include the fields that are not needed in index condition pushdown. */ - for (i = 0; i < n_fields; i++) { + for (ulint i = 0; i < n_fields; i++) { mysql_row_templ_t* templ; - ibool index_contains; - - if (innobase_is_v_fld(table->field[i])) { - index_contains = dict_index_contains_col_or_prefix( - index, num_v, true); - } else { - index_contains = dict_index_contains_col_or_prefix( - index, i - num_v, false); + const Field* field = table->field[i]; + const bool is_v = innobase_is_v_fld(field); + if (is_v && skip_virtual) { + num_v++; + continue; } - bool is_v = innobase_is_v_fld(table->field[i]); + ibool index_contains + = dict_index_contains_col_or_prefix( + index, is_v ? num_v : i - num_v, is_v); if (!build_template_needs_field_in_icp( index, m_prebuilt, index_contains, is_v ? num_v : i - num_v, is_v)) { /* Not needed in ICP */ - const Field* field; - - if (whole_row) { - field = table->field[i]; - } else { + if (!whole_row) { field = build_template_needs_field( index_contains, m_prebuilt->read_just_key, @@ -7959,7 +7946,7 @@ ha_innobase::build_template( fetch_primary_key_cols, index, table, i, num_v); if (!field) { - if (innobase_is_v_fld(table->field[i])) { + if (is_v) { num_v++; } continue; @@ -7969,8 +7956,9 @@ ha_innobase::build_template( templ = build_template_field( m_prebuilt, clust_index, index, table, field, i - num_v, num_v); + ut_ad(templ->is_virtual == is_v); - if (templ->is_virtual) { + if (is_v) { num_v++; } } @@ -7980,21 +7968,26 @@ ha_innobase::build_template( } else { no_icp: mysql_row_templ_t* templ; - ulint num_v = 0; /* No index condition pushdown */ m_prebuilt->idx_cond = NULL; + ut_ad(num_v == 0); - for (i = 0; i < n_fields; i++) { - const Field* field; + for (ulint i = 0; i < n_fields; i++) { + const Field* field = table->field[i]; + const bool is_v = innobase_is_v_fld(field); if (whole_row) { + if (is_v && skip_virtual) { + num_v++; + continue; + } /* Even this is whole_row, if the seach is on a virtual column, and read_just_key is set, and field is not in this index, we will not try to fill the value since they are not stored in such index nor in the cluster index. */ - if (innobase_is_v_fld(table->field[i]) + if (is_v && m_prebuilt->read_just_key && !dict_index_contains_col_or_prefix( m_prebuilt->index, num_v, true)) @@ -8005,12 +7998,10 @@ no_icp: num_v++; continue; } - - field = table->field[i]; } else { ibool contain; - if (!innobase_is_v_fld(table->field[i])) { + if (!is_v) { contain = dict_index_contains_col_or_prefix( index, i - num_v, false); @@ -8029,7 +8020,7 @@ no_icp: fetch_primary_key_cols, index, table, i, num_v); if (!field) { - if (innobase_is_v_fld(table->field[i])) { + if (is_v) { num_v++; } continue; @@ -8039,7 +8030,8 @@ no_icp: templ = build_template_field( m_prebuilt, clust_index, index, table, field, i - num_v, num_v); - if (templ->is_virtual) { + ut_ad(templ->is_virtual == is_v); + if (is_v) { num_v++; } } @@ -8048,8 +8040,7 @@ no_icp: if (index != clust_index && m_prebuilt->need_to_access_clustered) { /* Change rec_field_no's to correspond to the clustered index record */ - for (i = 0; i < m_prebuilt->n_template; i++) { - + for (ulint i = 0; i < m_prebuilt->n_template; i++) { mysql_row_templ_t* templ = &m_prebuilt->mysql_template[i]; @@ -8482,13 +8473,12 @@ calc_row_difference( ulint n_changed = 0; dfield_t dfield; dict_index_t* clust_index; - uint i; ibool changes_fts_column = FALSE; ibool changes_fts_doc_col = FALSE; trx_t* const trx = prebuilt->trx; doc_id_t doc_id = FTS_NULL_DOC_ID; ulint num_v = 0; - uint n_fields = mysql_fields(table); + const bool skip_virtual = omits_virtual_cols(*table->s); ut_ad(!srv_read_only_mode); @@ -8498,16 +8488,15 @@ calc_row_difference( /* We use upd_buff to convert changed fields */ buf = (byte*) upd_buff; - for (i = 0; i < n_fields; i++) { + for (uint i = 0; i < table->s->fields; i++) { field = table->field[i]; - bool is_virtual = innobase_is_v_fld(field); - dict_col_t* col; - - if (is_virtual) { - col = &prebuilt->table->v_cols[num_v].m_col; - } else { - col = &prebuilt->table->cols[i - num_v]; + const bool is_virtual = innobase_is_v_fld(field); + if (is_virtual && skip_virtual) { + continue; } + dict_col_t* col = is_virtual + ? &prebuilt->table->v_cols[num_v].m_col + : &prebuilt->table->cols[i - num_v]; o_ptr = (const byte*) old_row + get_field_offset(table, field); n_ptr = (const byte*) new_row + get_field_offset(table, field); @@ -8864,33 +8853,25 @@ wsrep_calc_row_hash( row_prebuilt_t* prebuilt, /*!< in: InnoDB prebuilt struct */ THD* thd) /*!< in: user thread */ { - Field* field; - enum_field_types field_mysql_type; - uint n_fields; ulint len; const byte* ptr; - ulint col_type; - uint i; void *ctx = alloca(my_md5_context_size()); my_md5_init(ctx); - n_fields = mysql_fields(table); - - for (i = 0; i < n_fields; i++) { + for (uint i = 0; i < table->s->fields; i++) { byte null_byte=0; byte true_byte=1; - field = table->field[i]; + const Field* field = table->field[i]; + if (innobase_is_v_fld(field)) { + continue; + } ptr = (const byte*) row + get_field_offset(table, field); len = field->pack_length(); - field_mysql_type = field->type(); - - col_type = prebuilt->table->cols[i].mtype; - - switch (col_type) { + switch (prebuilt->table->cols[i].mtype) { case DATA_BLOB: ptr = row_mysql_read_blob_ref(&len, ptr, len); @@ -8900,7 +8881,7 @@ wsrep_calc_row_hash( case DATA_VARCHAR: case DATA_BINARY: case DATA_VARMYSQL: - if (field_mysql_type == MYSQL_TYPE_VARCHAR) { + if (field->type() == MYSQL_TYPE_VARCHAR) { /* This is a >= 5.0.3 type true VARCHAR where the real payload data length is stored in 1 or 2 bytes */ @@ -10786,9 +10767,9 @@ create_table_check_doc_id_col( ULINT_UNDEFINED if column is of the wrong type/name/size */ { - uint n_fields = mysql_fields(form); + ut_ad(!omits_virtual_cols(*form->s)); - for (ulint i = 0; i < n_fields; i++) { + for (ulint i = 0; i < form->s->fields; i++) { const Field* field; ulint col_type; ulint col_len; From fca44b7c1ffe5e32a94e8d4449bd1d9f91492c3a Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 Dec 2018 23:12:14 +0100 Subject: [PATCH 19/58] MDEV-17909 Problem by MariaDB Update 10.1.32 -> 10.2.19 (Incorrect information in file: .frm) use frm_version, not mysql_version when parsing frm In particular, virtual columns are stored according to frm_version. And CHECK TABLE will overwrite mysql_version to the current server version, so it cannot correctly describe frm format. --- mysql-test/std_data/mdev17909#P#p20181029.MYD | 0 mysql-test/std_data/mdev17909#P#p20181029.MYI | Bin 0 -> 1024 bytes mysql-test/std_data/mdev17909#P#p20181128.MYD | 0 mysql-test/std_data/mdev17909#P#p20181128.MYI | Bin 0 -> 1024 bytes mysql-test/std_data/mdev17909.frm | Bin 0 -> 3284 bytes mysql-test/std_data/mdev17909.par | Bin 0 -> 48 bytes mysql-test/suite/vcol/r/upgrade.result | 16 ++++++++++++++++ mysql-test/suite/vcol/t/upgrade.test | 15 +++++++++++++++ sql/table.cc | 2 +- 9 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 mysql-test/std_data/mdev17909#P#p20181029.MYD create mode 100644 mysql-test/std_data/mdev17909#P#p20181029.MYI create mode 100644 mysql-test/std_data/mdev17909#P#p20181128.MYD create mode 100644 mysql-test/std_data/mdev17909#P#p20181128.MYI create mode 100644 mysql-test/std_data/mdev17909.frm create mode 100644 mysql-test/std_data/mdev17909.par diff --git a/mysql-test/std_data/mdev17909#P#p20181029.MYD b/mysql-test/std_data/mdev17909#P#p20181029.MYD new file mode 100644 index 00000000000..e69de29bb2d diff --git a/mysql-test/std_data/mdev17909#P#p20181029.MYI b/mysql-test/std_data/mdev17909#P#p20181029.MYI new file mode 100644 index 0000000000000000000000000000000000000000..dcdd088b4dc04a5413787cdb08d9a16b67d75c60 GIT binary patch literal 1024 zcmezOkDZZ$kujQK149bK5e7yEAmRX$K=2<-Vj=!R0Yr)giwayqAsomuFmqruOfH72 z`2my-b_o(6rUaRWxR!xfcd*}PU|_!kG=LdM-v`nn5H@U33dJ&}>kx6(7%(bu1wfq@aIoC~ZU$Y5Y>U}9jH0JPzMK#-@eV^HLO zuqmU&@C$+e4a3h*qdpo9fzc2c4S~@R7!85Z5TJDka55Am7L{a{Waj5B1=^($;20F* z8RF^hr{EN+5aj6R?y8^>;vetg7#XaQ;F4I9nxLu4rGZdYU}RuuVQ64vsSxJq6Y3hQ z;Nuz`tPtYi=%=7zZftIBW~iy)>gVq1=c-_<0BN!6a3R?O(QjyEfkVF~rhZKZhE~Q_ zP)m0N17@J#{eb-i2M#`XCoq?eNsQxQZ#eY!bf{4WbiT@cG`5B!3eL{Wx;@w?Cz!9IApkt`u7_8vz;TWW0 JXkehJ2>`7fTk)EMQ;)(wv+O3?e|fz{tSR!qC9T63Q|(vH*%g004Vp1s?za literal 0 HcmV?d00001 diff --git a/mysql-test/suite/vcol/r/upgrade.result b/mysql-test/suite/vcol/r/upgrade.result index 75684bf0e41..527bc5f3abf 100644 --- a/mysql-test/suite/vcol/r/upgrade.result +++ b/mysql-test/suite/vcol/r/upgrade.result @@ -16,3 +16,19 @@ select * from vcol_autoinc; pk v3 1 1 drop table vcol_autoinc; +check table t1 for upgrade; +Table Op Msg_type Msg_text +test.t1 check status OK +flush tables; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `Date` datetime(6) NOT NULL, + `Data` varbinary(2000) NOT NULL, + `a` varchar(100) GENERATED ALWAYS AS (column_get(`Data`,1 as char(100) charset latin1)) VIRTUAL, + PRIMARY KEY (`Date`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY RANGE (to_days(`Date`)) +(PARTITION `p20181029` VALUES LESS THAN (737361) ENGINE = MyISAM, + PARTITION `p20181128` VALUES LESS THAN (737391) ENGINE = MyISAM) +drop table t1; diff --git a/mysql-test/suite/vcol/t/upgrade.test b/mysql-test/suite/vcol/t/upgrade.test index 3e221747dfa..146495d8ed0 100644 --- a/mysql-test/suite/vcol/t/upgrade.test +++ b/mysql-test/suite/vcol/t/upgrade.test @@ -11,3 +11,18 @@ select * from vcol_autoinc; insert vcol_autoinc (pk) values (1); select * from vcol_autoinc; drop table vcol_autoinc; + +# +# MDEV-17909 Problem by MariaDB Update 10.1.32 -> 10.2.19 (Incorrect information in file: .frm) +# +source include/have_partition.inc; +copy_file std_data/mdev17909#P#p20181029.MYD $datadir/test/t1#P#p20181029.MYD; +copy_file std_data/mdev17909#P#p20181029.MYI $datadir/test/t1#P#p20181029.MYI; +copy_file std_data/mdev17909#P#p20181128.MYD $datadir/test/t1#P#p20181128.MYD; +copy_file std_data/mdev17909#P#p20181128.MYI $datadir/test/t1#P#p20181128.MYI; +copy_file std_data/mdev17909.frm $datadir/test/t1.frm; +copy_file std_data/mdev17909.par $datadir/test/t1.par; +check table t1 for upgrade; +flush tables; +show create table t1; +drop table t1; diff --git a/sql/table.cc b/sql/table.cc index 0cf88aed4f6..dbf10bc8293 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1027,7 +1027,7 @@ bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, while (pos < end) { uint type, expr_length; - if (table->s->mysql_version >= 100202) + if (table->s->frm_version >= FRM_VER_EXPRESSSIONS) { uint field_nr, name_length; /* see pack_expression() for how data is stored */ From a79183b01e4e1f3af55abd102715560cecbbddae Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 19 Dec 2018 02:30:22 +0100 Subject: [PATCH 20/58] correct table name in CHECK failures during ALTER TABLE --- mysql-test/r/partition_alter.result | 4 ++-- mysql-test/t/partition_alter.test | 2 -- sql/table.cc | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/partition_alter.result b/mysql-test/r/partition_alter.result index 6aa0039c8d2..d272381bc08 100644 --- a/mysql-test/r/partition_alter.result +++ b/mysql-test/r/partition_alter.result @@ -59,7 +59,7 @@ partition p2 values less than ('2020-10-19')); insert t1 values (0, '2000-01-02', 0); insert t1 values (1, '2020-01-02', 10); alter table t1 add check (b in (0, 1)); -ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`#sql-temporary` +ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` alter table t1 add check (b in (0, 10)); show create table t1; Table Create Table @@ -83,7 +83,7 @@ partition p2 values less than ('2020-10-19')); insert t1 values (0, '2000-01-02', 0); insert t1 values (1, '2020-01-02', 10); alter table t1 add check (b in (0, 1)); -ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`#sql-temporary` +ERROR 23000: CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` alter table t1 add check (b in (0, 10)); show create table t1; Table Create Table diff --git a/mysql-test/t/partition_alter.test b/mysql-test/t/partition_alter.test index ce6672c4b9d..1235e5b8dc2 100644 --- a/mysql-test/t/partition_alter.test +++ b/mysql-test/t/partition_alter.test @@ -79,7 +79,6 @@ partition p1 values less than ('2016-10-18'), partition p2 values less than ('2020-10-19')); insert t1 values (0, '2000-01-02', 0); insert t1 values (1, '2020-01-02', 10); ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ --error ER_CONSTRAINT_FAILED alter table t1 add check (b in (0, 1)); alter table t1 add check (b in (0, 10)); @@ -96,7 +95,6 @@ partition p1 values less than ('2016-10-18'), partition p2 values less than ('2020-10-19')); insert t1 values (0, '2000-01-02', 0); insert t1 values (1, '2020-01-02', 10); ---replace_regex /#sql-[0-9a-f_]*/#sql-temporary/ --error ER_CONSTRAINT_FAILED alter table t1 add check (b in (0, 1)); alter table t1 add check (b in (0, 10)); diff --git a/sql/table.cc b/sql/table.cc index dbf10bc8293..7c53246a7d3 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -5178,7 +5178,7 @@ int TABLE::verify_constraints(bool ignore_failure) field_error.append((*chk)->name.str); my_error(ER_CONSTRAINT_FAILED, MYF(ignore_failure ? ME_JUST_WARNING : 0), field_error.c_ptr(), - s->db.str, s->table_name.str); + s->db.str, s->error_table_name()); return ignore_failure ? VIEW_CHECK_SKIP : VIEW_CHECK_ERROR; } } From 7b2e2288e9f784ea12f85dc005503511fe99f796 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 14 Dec 2018 14:28:30 +0100 Subject: [PATCH 21/58] MDEV-16903 Assertion `!auto_increment_field_not_null' failed in TABLE::init after unsuccessful attempt to add CHECK constraint on temporary table if the CHECK constraint failed in copy_data_between_tables(), the loop was aborted prematurely and to->auto_increment_field_not_null wasn't reset. --- mysql-test/r/check.result | 10 ++++++++++ mysql-test/t/check.test | 12 ++++++++++++ sql/sql_table.cc | 16 ++++++++-------- sql/temporary_tables.cc | 11 ++++------- 4 files changed, 34 insertions(+), 15 deletions(-) diff --git a/mysql-test/r/check.result b/mysql-test/r/check.result index e3dcda773f4..e882a4cdbe6 100644 --- a/mysql-test/r/check.result +++ b/mysql-test/r/check.result @@ -85,3 +85,13 @@ t1 CREATE TABLE `t1` ( `c` int(11) DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 DROP TABLE t1; +create temporary table t1 ( +id int not null auto_increment primary key, +f int not null default 0 +); +insert into t1 () values (); +alter ignore table t1 add constraint check (f > 0); +Warnings: +Warning 4025 CONSTRAINT `CONSTRAINT_1` failed for `test`.`t1` +alter table t1; +drop table t1; diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test index cce8fd34c9c..475a7996a09 100644 --- a/mysql-test/t/check.test +++ b/mysql-test/t/check.test @@ -103,3 +103,15 @@ CREATE OR REPLACE TABLE t1 (a INT, b INT, c INT, CHECK (a+b>0)) ENGINE=MyISAM; ALTER TABLE t1 DROP COLUMN b, DROP CONSTRAINT `CONSTRAINT_1`; SHOW CREATE TABLE t1; DROP TABLE t1; + +# +# MDEV-16903 Assertion `!auto_increment_field_not_null' failed in TABLE::init after unsuccessful attempt to add CHECK constraint on temporary table +# +create temporary table t1 ( + id int not null auto_increment primary key, + f int not null default 0 +); +insert into t1 () values (); +alter ignore table t1 add constraint check (f > 0); +alter table t1; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1765e352b88..9e72278db8d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10065,14 +10065,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, error= 1; break; } - if (to->next_number_field) - { - if (auto_increment_field_copied) - to->auto_increment_field_not_null= TRUE; - else - to->next_number_field->reset(); - } - + for (Copy_field *copy_ptr=copy ; copy_ptr != copy_end ; copy_ptr++) { copy_ptr->do_copy(copy_ptr); @@ -10091,6 +10084,13 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, error= 1; break; } + if (to->next_number_field) + { + if (auto_increment_field_copied) + to->auto_increment_field_not_null= TRUE; + else + to->next_number_field->reset(); + } error=to->file->ha_write_row(to->record[0]); to->auto_increment_field_not_null= FALSE; if (error) diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 3201b306fad..87c4671ada4 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1140,8 +1140,7 @@ TABLE *THD::open_temporary_table(TMP_TABLE_SHARE *share, @return Success false Failure true */ -bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, - TABLE **out_table) +bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, TABLE **out_table) { DBUG_ENTER("THD::find_and_use_tmp_table"); @@ -1151,11 +1150,9 @@ bool THD::find_and_use_tmp_table(const TABLE_LIST *tl, key_length= create_tmp_table_def_key(key, tl->get_db_name(), tl->get_table_name()); - result= - use_temporary_table(find_temporary_table(key, key_length, - TMP_TABLE_NOT_IN_USE), - out_table); - + result= use_temporary_table(find_temporary_table(key, key_length, + TMP_TABLE_NOT_IN_USE), + out_table); DBUG_RETURN(result); } From 6a73569f12fe4883937a669c262716c11d1f9238 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Thu, 21 Jun 2018 16:46:11 +1000 Subject: [PATCH 22/58] MDEV-16429: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' fails upon attempt to update virtual column on partitioned versioned table When using buffered sort in `UPDATE`, keyread is used. In this case, `TABLE::update_virtual_field` should be aborted, but it actually isn't, because it is called not with a top-level handler, but with the one that is actually going to access the disk. Here the problemm is issued with partitioning, so the solution is to recursively mark for keyread all the underlying partition handlers. * ha_partition: update keyread state for child partitions Closes #800 --- sql/ha_partition.cc | 104 +++++++++++++++++++++++++++++--------------- sql/ha_partition.h | 6 ++- sql/handler.h | 4 +- 3 files changed, 75 insertions(+), 39 deletions(-) diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index 090102266f0..3eabc698fed 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -401,7 +401,7 @@ const char *ha_partition::table_type() const ha_partition::~ha_partition() { - DBUG_ENTER("ha_partition::~ha_partition()"); + DBUG_ENTER("ha_partition::~ha_partition"); if (m_new_partitions_share_refs.elements) m_new_partitions_share_refs.delete_elements(); if (m_file != NULL) @@ -616,7 +616,7 @@ int ha_partition::create_partitioning_metadata(const char *path, const char *old_path, int action_flag) { - DBUG_ENTER("ha_partition::create_partitioning_metadata()"); + DBUG_ENTER("ha_partition::create_partitioning_metadata"); /* We need to update total number of parts since we might write the handler @@ -6811,6 +6811,24 @@ void ha_partition::get_dynamic_partition_info(PARTITION_STATS *stat_info, } +static int extra_cb(handler *h, void *operation) +{ + return h->extra(*(enum ha_extra_function*)operation); +} + + +static int start_keyread_cb(handler* h, void *p) +{ + return h->ha_start_keyread(*(uint*)p); +} + + +static int end_keyread_cb(handler* h, void *unused) +{ + return h->ha_end_keyread(); +} + + /** General function to prepare handler for certain behavior. @@ -7131,11 +7149,12 @@ int ha_partition::extra(enum ha_extra_function operation) switch (operation) { /* Category 1), used by most handlers */ - case HA_EXTRA_KEYREAD: case HA_EXTRA_NO_KEYREAD: + DBUG_RETURN(loop_partitions(end_keyread_cb, NULL)); + case HA_EXTRA_KEYREAD: case HA_EXTRA_FLUSH: case HA_EXTRA_PREPARE_FOR_FORCED_CLOSE: - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_partitions(extra_cb, &operation)); case HA_EXTRA_PREPARE_FOR_RENAME: case HA_EXTRA_FORCE_REOPEN: DBUG_RETURN(loop_extra_alter(operation)); @@ -7147,7 +7166,7 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_KEYREAD_PRESERVE_FIELDS: { if (!m_myisam) - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_partitions(extra_cb, &operation)); break; } @@ -7171,7 +7190,7 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_PREPARE_FOR_DROP: case HA_EXTRA_FLUSH_CACHE: { - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_partitions(extra_cb, &operation)); } case HA_EXTRA_NO_READCHECK: { @@ -7203,7 +7222,7 @@ int ha_partition::extra(enum ha_extra_function operation) m_extra_cache_size= 0; m_extra_prepare_for_update= FALSE; m_extra_cache_part_id= NO_CURRENT_PART_ID; - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_partitions(extra_cb, &operation)); } case HA_EXTRA_IGNORE_NO_KEY: case HA_EXTRA_NO_IGNORE_NO_KEY: @@ -7237,7 +7256,7 @@ int ha_partition::extra(enum ha_extra_function operation) } /* Category 7), used by federated handlers */ case HA_EXTRA_INSERT_WITH_UPDATE: - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_partitions(extra_cb, &operation)); /* Category 8) Operations only used by NDB */ case HA_EXTRA_DELETE_CANNOT_BATCH: case HA_EXTRA_UPDATE_CANNOT_BATCH: @@ -7264,7 +7283,7 @@ int ha_partition::extra(enum ha_extra_function operation) case HA_EXTRA_BEGIN_ALTER_COPY: case HA_EXTRA_END_ALTER_COPY: case HA_EXTRA_FAKE_START_STMT: - DBUG_RETURN(loop_extra(operation)); + DBUG_RETURN(loop_partitions(extra_cb, &operation)); default: { /* Temporary crash to discover what is wrong */ @@ -7309,24 +7328,40 @@ int ha_partition::reset(void) } /* - Special extra method for HA_EXTRA_CACHE with cachesize as extra parameter + Special extra method with additional parameter + See @ref ha_partition::extra - SYNOPSIS - extra_opt() - operation Must be HA_EXTRA_CACHE - cachesize Size of cache in full table scan + @param[in] operation operation to execute + @param[in] arg extra argument - RETURN VALUE - >0 Error code - 0 Success + @return status + @retval 0 success + @retval >0 error code + + @detail + Operations supported by extra_opt: + HA_EXTRA_KEYREAD: + arg is interpreted as key index + HA_EXTRA_CACHE: + arg is interpreted as size of cache in full table scan + + For detailed description refer to @ref ha_partition::extra */ -int ha_partition::extra_opt(enum ha_extra_function operation, ulong cachesize) +int ha_partition::extra_opt(enum ha_extra_function operation, ulong arg) { - DBUG_ENTER("ha_partition::extra_opt()"); + DBUG_ENTER("ha_partition::extra_opt"); - DBUG_ASSERT(HA_EXTRA_CACHE == operation); - prepare_extra_cache(cachesize); + switch (operation) + { + case HA_EXTRA_KEYREAD: + DBUG_RETURN(loop_partitions(start_keyread_cb, &arg)); + case HA_EXTRA_CACHE: + prepare_extra_cache(arg); + DBUG_RETURN(0); + default: + DBUG_ASSERT(0); + } DBUG_RETURN(0); } @@ -7344,7 +7379,7 @@ int ha_partition::extra_opt(enum ha_extra_function operation, ulong cachesize) void ha_partition::prepare_extra_cache(uint cachesize) { - DBUG_ENTER("ha_partition::prepare_extra_cache()"); + DBUG_ENTER("ha_partition::prepare_extra_cache"); DBUG_PRINT("info", ("cachesize %u", cachesize)); m_extra_cache= TRUE; @@ -7374,7 +7409,7 @@ int ha_partition::loop_extra_alter(enum ha_extra_function operation) { int result= 0, tmp; handler **file; - DBUG_ENTER("ha_partition::loop_extra_alter()"); + DBUG_ENTER("ha_partition::loop_extra_alter"); DBUG_ASSERT(operation == HA_EXTRA_PREPARE_FOR_RENAME || operation == HA_EXTRA_FORCE_REOPEN); @@ -7390,34 +7425,33 @@ int ha_partition::loop_extra_alter(enum ha_extra_function operation) if ((tmp= (*file)->extra(operation))) result= tmp; } - if ((tmp= loop_extra(operation))) + if ((tmp= loop_partitions(extra_cb, &operation))) result= tmp; DBUG_RETURN(result); } -/* - Call extra on all partitions +/** + Call callback(part, param) on all partitions - SYNOPSIS - loop_extra() - operation extra operation type + @param callback a callback to call for each partition + @param param a void*-parameter passed to callback - RETURN VALUE - >0 Error code - 0 Success + @return Operation status + @retval >0 Error code + @retval 0 Success */ -int ha_partition::loop_extra(enum ha_extra_function operation) +int ha_partition::loop_partitions(handler_callback callback, void *param) { int result= 0, tmp; uint i; - DBUG_ENTER("ha_partition::loop_extra()"); + DBUG_ENTER("ha_partition::loop_partitions"); for (i= bitmap_get_first_set(&m_part_info->lock_partitions); i < m_tot_parts; i= bitmap_get_next_set(&m_part_info->lock_partitions, i)) { - if ((tmp= m_file[i]->extra(operation))) + if ((tmp= callback(m_file[i], param))) result= tmp; } /* Add all used partitions to be called in reset(). */ diff --git a/sql/ha_partition.h b/sql/ha_partition.h index e348da08443..9a73eeff817 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -649,7 +649,7 @@ public: void get_dynamic_partition_info(PARTITION_STATS *stat_info, uint part_id); virtual int extra(enum ha_extra_function operation); - virtual int extra_opt(enum ha_extra_function operation, ulong cachesize); + virtual int extra_opt(enum ha_extra_function operation, ulong arg); virtual int reset(void); virtual uint count_query_cache_dependant_tables(uint8 *tables_type); virtual my_bool @@ -659,6 +659,8 @@ public: uint *n); private: + typedef int handler_callback(handler *, void *); + my_bool reg_query_cache_dependant_table(THD *thd, char *engine_key, uint engine_key_len, @@ -669,7 +671,7 @@ private: **block_table, handler *file, uint *n); static const uint NO_CURRENT_PART_ID; - int loop_extra(enum ha_extra_function operation); + int loop_partitions(handler_callback callback, void *param); int loop_extra_alter(enum ha_extra_function operations); void late_extra_cache(uint partition_id); void late_extra_no_cache(uint partition_id); diff --git a/sql/handler.h b/sql/handler.h index ed2ef822c88..d34064811f0 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2874,7 +2874,7 @@ public: bool keyread_enabled() { return keyread < MAX_KEY; } int ha_start_keyread(uint idx) { - int res= keyread_enabled() ? 0 : extra(HA_EXTRA_KEYREAD); + int res= keyread_enabled() ? 0 : extra_opt(HA_EXTRA_KEYREAD, idx); keyread= idx; return res; } @@ -3278,7 +3278,7 @@ public: uint part_id); virtual int extra(enum ha_extra_function operation) { return 0; } - virtual int extra_opt(enum ha_extra_function operation, ulong cache_size) + virtual int extra_opt(enum ha_extra_function operation, ulong arg) { return extra(operation); } /** From f04bbed220215a0e5a5b1be9f3af5e442abe033b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 14 Dec 2018 16:14:30 +0100 Subject: [PATCH 23/58] MDEV-17755 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' failed in Field_bit::val_int upon SELECT with JOIN, partitions, indexed virtual column add a test case --- mysql-test/r/partition_innodb.result | 17 +++++++++++++++++ mysql-test/t/partition_innodb.test | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result index ec99d2879b0..0a58883bb34 100644 --- a/mysql-test/r/partition_innodb.result +++ b/mysql-test/r/partition_innodb.result @@ -956,3 +956,20 @@ test_jfg test_jfg11 test_jfg test_jfg12#P#p1000 test_jfg test_jfg12#P#pmax DROP DATABASE test_jfg; +create table t1 (a int) engine=innodb; +create table t2 ( +b int, +c int, +d bit not null default 0, +v bit as (d) virtual, +key (b,v) +) engine=innodb partition by hash (b); +insert into t1 values (1),(2); +insert into t2 (b,c,d) values (1,1,0),(2,2,0); +explain select t1.* from t1 join t2 on (v = a); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 +1 SIMPLE t2 index NULL b 7 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +select t1.* from t1 join t2 on (v = a); +a +drop table t1, t2; diff --git a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test index 5dcb83b5737..590e2fc7f07 100644 --- a/mysql-test/t/partition_innodb.test +++ b/mysql-test/t/partition_innodb.test @@ -1051,3 +1051,20 @@ SELECT database_name, table_name FROM mysql.innodb_table_stats WHERE database_name = 'test_jfg'; DROP DATABASE test_jfg; + +# +# MDEV-17755 Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index) || (!(ptr >= table->record[0] && ptr < table->record[0] + table->s->reclength)))' failed in Field_bit::val_int upon SELECT with JOIN, partitions, indexed virtual column +# +create table t1 (a int) engine=innodb; +create table t2 ( + b int, + c int, + d bit not null default 0, + v bit as (d) virtual, + key (b,v) +) engine=innodb partition by hash (b); +insert into t1 values (1),(2); +insert into t2 (b,c,d) values (1,1,0),(2,2,0); +explain select t1.* from t1 join t2 on (v = a); +select t1.* from t1 join t2 on (v = a); +drop table t1, t2; From 2ec018b281a801089afde96ec0f5968c8ed89858 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 14 Dec 2018 23:07:32 +0100 Subject: [PATCH 24/58] MDEV-17953 MariaDB 10.2.19 with TokuDB incompatible with Jemalloc 5+ Simplify the check, remove redundant code. Add a safety check to avoid linking with static jemalloc_pic.a if jemalloc version is 5+. This doesn't fix the issue on Gentoo, it should be fixed in the ebuild. --- storage/tokudb/CMakeLists.txt | 48 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index 86463c2997e..f3166ca8c0b 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -49,33 +49,41 @@ CHECK_JEMALLOC() IF(NOT LIBJEMALLOC) MESSAGE(WARNING "TokuDB is enabled, but jemalloc is not. This configuration is not supported") +ELSEIF(LIBJEMALLOC STREQUAL jemalloc_pic) + CHECK_CXX_SOURCE_COMPILES( +" +#include +#if JEMALLOC_VERSION_MAJOR < 5 +int main() { return 0; } +#else +#error +#endif +" JEMALLOC_OK) + IF (NOT JEMALLOC_OK) + MESSAGE(FATAL_ERROR "static jemalloc_pic.a can only be used up to jemalloc 4") + ENDIF() ELSEIF(LIBJEMALLOC STREQUAL jemalloc) FIND_LIBRARY(LIBJEMALLOC_SO jemalloc) IF(NOT LIBJEMALLOC_SO) MESSAGE(FATAL_ERROR "jemalloc is present, but cannot be found?") ENDIF() GET_FILENAME_COMPONENT(LIBJEMALLOC_PATH ${LIBJEMALLOC_SO} REALPATH CACHE) -ENDIF() -IF(LIBJEMALLOC_PATH AND (RPM OR DEB)) - UNSET(LIBJEMALLOC) - GET_DIRECTORY_PROPERTY(V DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITION CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES) - SET(CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES "${V} jemalloc" PARENT_SCOPE) - SET(systemd_env "Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"") #" - SET(cnf_malloc_lib "malloc-lib=${LIBJEMALLOC_PATH}") -ELSEIF(LIBJEMALLOC_PATH) - SET(systemd_env "#Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"") #" - SET(cnf_malloc_lib "#malloc-lib=${LIBJEMALLOC_PATH}") -ELSE() - SET(systemd_env "#Environment=\"LD_PRELOAD=/path/to/libjemalloc.so\"") #" - SET(cnf_malloc_lib "#malloc-lib=/path/to/libjemalloc.so") -ENDIF() -CONFIGURE_FILE(tokudb.cnf.in tokudb.cnf @ONLY) -CONFIGURE_FILE(tokudb.conf.in tokudb.conf @ONLY) -IF(INSTALL_SYSCONFDIR) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tokudb.conf - DESTINATION ${INSTALL_SYSCONFDIR}/systemd/system/mariadb.service.d/ - COMPONENT tokudb-engine) + IF(RPM OR DEB) + UNSET(LIBJEMALLOC) + GET_DIRECTORY_PROPERTY(V DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITION CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES) + SET(CPACK_RPM_tokudb-engine_PACKAGE_REQUIRES "${V} jemalloc" PARENT_SCOPE) + ENDIF() + + IF(INSTALL_SYSCONFDIR) + SET(systemd_env "Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"") + SET(cnf_malloc_lib "malloc-lib=${LIBJEMALLOC_PATH}") + CONFIGURE_FILE(tokudb.cnf.in tokudb.cnf @ONLY) + CONFIGURE_FILE(tokudb.conf.in tokudb.conf @ONLY) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tokudb.conf + DESTINATION ${INSTALL_SYSCONFDIR}/systemd/system/mariadb.service.d/ + COMPONENT tokudb-engine) + ENDIF() ENDIF() MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow") From d13302ff6013acee9ac5fb6946d0c91e2f303224 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 16 Dec 2018 18:22:35 +0100 Subject: [PATCH 25/58] cleanup: small simplification --- sql/temporary_tables.cc | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index 87c4671ada4..a4ece127f96 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1032,39 +1032,21 @@ TABLE *THD::find_temporary_table(const char *key, uint key_length, /* A matching TMP_TABLE_SHARE is found. */ All_share_tables_list::Iterator tables_it(share->all_tmp_tables); - while ((table= tables_it++)) + bool found= false; + while (!found && (table= tables_it++)) { switch (state) { - case TMP_TABLE_IN_USE: - if (table->query_id > 0) - { - result= table; - goto done; - } - break; - case TMP_TABLE_NOT_IN_USE: - if (table->query_id == 0) - { - result= table; - goto done; - } - break; - case TMP_TABLE_ANY: - { - result= table; - goto done; - } - break; - default: /* Invalid */ - DBUG_ASSERT(0); - goto done; + case TMP_TABLE_IN_USE: found= table->query_id > 0; break; + case TMP_TABLE_NOT_IN_USE: found= table->query_id == 0; break; + case TMP_TABLE_ANY: found= true; break; } } + result= table; + break; } } -done: if (locked) { DBUG_ASSERT(m_tmp_tables_locked); From 2027841d5bc7e22ebb24a5a7538d0fd057dd8352 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 16 Dec 2018 18:32:05 +0100 Subject: [PATCH 26/58] MDEV-16110 ALTER with ALGORITHM=INPLACE breaks temporary table with virtual columns Part two, temporary tables. Make temporary tables respect TABLE::m_needs_reopen. See also 77cd754229b --- mysql-test/r/alter_table_errors.result | 19 +++++++++++++++++++ mysql-test/t/alter_table_errors.test | 11 +++++++++++ sql/temporary_tables.cc | 7 +++++++ 3 files changed, 37 insertions(+) diff --git a/mysql-test/r/alter_table_errors.result b/mysql-test/r/alter_table_errors.result index 020a30304d0..b26409e3d05 100644 --- a/mysql-test/r/alter_table_errors.result +++ b/mysql-test/r/alter_table_errors.result @@ -8,3 +8,22 @@ t CREATE TABLE `t` ( `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t; +create temporary table t1 (a int, v int as (a)); +alter table t1 change column a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create temporary table t2 (a int, v int as (a)); +lock table t2 write; +alter table t2 change column a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +show create table t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 diff --git a/mysql-test/t/alter_table_errors.test b/mysql-test/t/alter_table_errors.test index d9982ac26f4..8fa65b0f330 100644 --- a/mysql-test/t/alter_table_errors.test +++ b/mysql-test/t/alter_table_errors.test @@ -8,3 +8,14 @@ create table t (a int, v int as (a)) engine=innodb; alter table t change column a b tinyint, algorithm=inplace; show create table t; drop table t; + +create temporary table t1 (a int, v int as (a)); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 change column a b int, algorithm=inplace; +show create table t1; + +create temporary table t2 (a int, v int as (a)); +lock table t2 write; +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t2 change column a b int, algorithm=inplace; +show create table t2; diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index a4ece127f96..29c9910f332 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1042,6 +1042,13 @@ TABLE *THD::find_temporary_table(const char *key, uint key_length, case TMP_TABLE_ANY: found= true; break; } } + if (table && unlikely(table->m_needs_reopen)) + { + share->all_tmp_tables.remove(table); + free_temporary_table(table); + it.rewind(); + continue; + } result= table; break; } From 24763451fe811bc4683bfe32f77cbe9bf0c6db6c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 17 Dec 2018 15:58:32 +0100 Subject: [PATCH 27/58] update C/C to v3.0.8 --- libmariadb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libmariadb b/libmariadb index 334964f0711..34f8887af03 160000 --- a/libmariadb +++ b/libmariadb @@ -1 +1 @@ -Subproject commit 334964f0711c3fd027f634a239eee57bc912f7ff +Subproject commit 34f8887af03d022416dd6593de91d0706e57f46b From cb4c2a98b56b836ba19f822b52ea24337cd34370 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 18 Dec 2018 15:20:37 +0100 Subject: [PATCH 28/58] always link C/C with external (to C/C) zlib it'll be either system zlib.so or bundled with the server (but still external to C/C) zlib.a --- cmake/mariadb_connector_c.cmake | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index c36087cb862..368a6cc8da5 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -6,10 +6,7 @@ ENDIF() SET(CONC_WITH_SIGNCODE ${SIGNCODE}) SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS}) - -IF(NOT TARGET zlib) - SET(CONC_WITH_EXTERNAL_ZLIB ON) -ENDIF() +SET(CONC_WITH_EXTERNAL_ZLIB ON) IF(SSL_DEFINES MATCHES "YASSL") IF(WIN32) From 8ede9b3ae542068cc02ca27ab32eb76fcfab942f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 19 Dec 2018 15:23:54 +0100 Subject: [PATCH 29/58] MDEV-17975 Assertion `! is_set()' or `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon REVOKE under LOCK TABLE open_grant_tables() returns -1/0/1, where -1 is an error, while 1 is not. Don't store it's return value in bool --- mysql-test/r/grant5.result | 7 +++++++ mysql-test/t/grant5.test | 10 ++++++++++ sql/sql_acl.cc | 9 +++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/grant5.result b/mysql-test/r/grant5.result index d7f3b6812bb..8c32d90a640 100644 --- a/mysql-test/r/grant5.result +++ b/mysql-test/r/grant5.result @@ -16,3 +16,10 @@ show grants for foo@'%'; ERROR 42000: Access denied for user 'test'@'%' to database 'mysql' drop user test, foo; drop role foo; +CREATE TABLE t1 (a INT); +LOCK TABLE t1 WRITE; +REVOKE EXECUTE ON PROCEDURE sp FROM u; +ERROR HY000: Table 'user' was not locked with LOCK TABLES +REVOKE PROCESS ON *.* FROM u; +ERROR HY000: Table 'user' was not locked with LOCK TABLES +DROP TABLE t1; diff --git a/mysql-test/t/grant5.test b/mysql-test/t/grant5.test index 14f2fd65020..649bba7d1ca 100644 --- a/mysql-test/t/grant5.test +++ b/mysql-test/t/grant5.test @@ -23,3 +23,13 @@ show grants for foo@'%'; # user drop user test, foo; drop role foo; +# +# MDEV-17975 Assertion `! is_set()' or `!is_set() || (m_status == DA_OK_BULK && is_bulk_op())' failed upon REVOKE under LOCK TABLE +# +CREATE TABLE t1 (a INT); +LOCK TABLE t1 WRITE; +--error ER_TABLE_NOT_LOCKED +REVOKE EXECUTE ON PROCEDURE sp FROM u; +--error ER_TABLE_NOT_LOCKED +REVOKE PROCESS ON *.* FROM u; +DROP TABLE t1; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 0f21a6bc134..784f2338a55 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -786,8 +786,7 @@ static const int Table_procs_priv= 1 << PROCS_PRIV_TABLE; static const int Table_proxies_priv= 1 << PROXIES_PRIV_TABLE; static const int Table_roles_mapping= 1 << ROLES_MAPPING_TABLE; -static int open_grant_tables(THD *thd, TABLE_LIST *tables, - enum thr_lock_type lock_type, int tables_to_open); +static int open_grant_tables(THD *, TABLE_LIST *, enum thr_lock_type, int); const LEX_STRING acl_table_names[]= // matches enum_acl_tables { @@ -6030,7 +6029,8 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, List_iterator str_list (user_list); LEX_USER *Str, *tmp_Str; TABLE_LIST tables[TABLES_MAX]; - bool create_new_users= 0, result; + bool create_new_users= 0; + int result; char *db_name, *table_name; DBUG_ENTER("mysql_routine_grant"); @@ -6465,7 +6465,8 @@ bool mysql_grant(THD *thd, const char *db, List &list, List_iterator str_list (list); LEX_USER *Str, *tmp_Str, *proxied_user= NULL; char tmp_db[SAFE_NAME_LEN+1]; - bool create_new_users=0, result; + bool create_new_users=0; + int result; TABLE_LIST tables[TABLES_MAX]; DBUG_ENTER("mysql_grant"); From ed36fc353f374892c225d191f5525f439031d939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 20 Dec 2018 13:33:09 +0200 Subject: [PATCH 30/58] MDEV-18025: Detect corrupted innodb_page_compression=zlib pages In MDEV-13103, I made a mistake in the error handling of page_compressed=1 decryption when the default innodb_compression_algorithm=zlib is used. Due to this mistake, with certain versions of zlib, MariaDB would fail to detect a corrupted page. The problem was uncovered by the following tests: mariabackup.unencrypted_page_compressed mariabackup.encrypted_page_compressed --- storage/innobase/fil/fil0pagecompress.cc | 8 ++++---- storage/xtradb/fil/fil0pagecompress.cc | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/innobase/fil/fil0pagecompress.cc b/storage/innobase/fil/fil0pagecompress.cc index 25cd8e28a91..101f8fb0f31 100644 --- a/storage/innobase/fil/fil0pagecompress.cc +++ b/storage/innobase/fil/fil0pagecompress.cc @@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) case PAGE_ZLIB_ALGORITHM: { uLong len = srv_page_size; - if (Z_OK != uncompress(tmp_buf, &len, + if (Z_OK == uncompress(tmp_buf, &len, buf + header_len, uLong(actual_size)) - && len != srv_page_size) { - return 0; + && len == srv_page_size) { + break; } } - break; + return 0; #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: if (LZ4_decompress_safe(reinterpret_cast(buf) diff --git a/storage/xtradb/fil/fil0pagecompress.cc b/storage/xtradb/fil/fil0pagecompress.cc index 25cd8e28a91..101f8fb0f31 100644 --- a/storage/xtradb/fil/fil0pagecompress.cc +++ b/storage/xtradb/fil/fil0pagecompress.cc @@ -341,14 +341,14 @@ UNIV_INTERN ulint fil_page_decompress(byte* tmp_buf, byte* buf) case PAGE_ZLIB_ALGORITHM: { uLong len = srv_page_size; - if (Z_OK != uncompress(tmp_buf, &len, + if (Z_OK == uncompress(tmp_buf, &len, buf + header_len, uLong(actual_size)) - && len != srv_page_size) { - return 0; + && len == srv_page_size) { + break; } } - break; + return 0; #ifdef HAVE_LZ4 case PAGE_LZ4_ALGORITHM: if (LZ4_decompress_safe(reinterpret_cast(buf) From 9f4a4cb401980e2bd321c0680595e81087ad60d5 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 20 Dec 2018 14:31:18 +0100 Subject: [PATCH 31/58] Cleanup recent mariabackup validation patches. - Refactor code to isolate page validation in page_is_corrupted() function. - Introduce --extended-validation parameter(default OFF) for mariabackup --backup to enable decryption of encrypted uncompressed pages during backup. - mariabackup would still always check checksum on encrypted data, it is needed to detect partially written pages. --- extra/mariabackup/fil_cur.cc | 155 +++++++++--------- extra/mariabackup/xtrabackup.cc | 10 ++ extra/mariabackup/xtrabackup.h | 1 + .../encrypted_page_corruption.test | 8 +- 4 files changed, 100 insertions(+), 74 deletions(-) diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index 637acfd2e22..b4393f7ffdd 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -265,6 +265,87 @@ xb_fil_cur_open( return(XB_FIL_CUR_SUCCESS); } +static bool page_is_corrupted(byte *page, ulint page_no, xb_fil_cur_t *cursor, fil_space_t *space) +{ + byte tmp_frame[UNIV_PAGE_SIZE_MAX]; + byte tmp_page[UNIV_PAGE_SIZE_MAX]; + + ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); + + /* We ignore the doublewrite buffer pages.*/ + if (cursor->space_id == TRX_SYS_SPACE + && page_no >= FSP_EXTENT_SIZE + && page_no < FSP_EXTENT_SIZE * 3) { + return false; + } + + /* Validate page number. */ + if (mach_read_from_4(page + FIL_PAGE_OFFSET) != page_no + && space->id != TRX_SYS_SPACE) { + /* On pages that are not all zero, the + page number must match. + + There may be a mismatch on tablespace ID, + because files may be renamed during backup. + We disable the page number check + on the system tablespace, because it may consist + of multiple files, and here we count the pages + from the start of each file.) + + The first 38 and last 8 bytes are never encrypted. */ + const ulint* p = reinterpret_cast(page); + const ulint* const end = reinterpret_cast( + page + cursor->page_size); + do { + if (*p++) { + return true; + } + } while (p != end); + + /* Whole zero page is valid. */ + return false; + } + + /* Validate encrypted pages. */ + if (mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) && + (space->crypt_data && space->crypt_data->type!= CRYPT_SCHEME_UNENCRYPTED)) { + + if (!fil_space_verify_crypt_checksum(page, cursor->zip_size)) + return true; + + /* Compressed encrypted need to be unencryped and uncompressed for verification. */ + if (page_type != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED && !opt_extended_validation) + return false; + + memcpy(tmp_page, page, cursor->page_size); + + bool decrypted = false; + if (!fil_space_decrypt(space, tmp_frame,tmp_page, &decrypted)) { + return true; + } + + if (page_type != FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { + return buf_page_is_corrupted(true, tmp_page, cursor->zip_size, space); + } + } + + if (page_type == FIL_PAGE_PAGE_COMPRESSED) { + memcpy(tmp_page, page, cursor->page_size); + } + + if (page_type == FIL_PAGE_PAGE_COMPRESSED || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { + ulint decomp = fil_page_decompress(tmp_frame, tmp_page); + page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE); + + return (!decomp + || (decomp != srv_page_size && cursor->zip_size) + || page_type == FIL_PAGE_PAGE_COMPRESSED + || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED + || buf_page_is_corrupted(true, tmp_page, cursor->zip_size, space)); + } + + return buf_page_is_corrupted(true, page, cursor->zip_size, space); +} /************************************************************************ Reads and verifies the next block of pages from the source file. Positions the cursor after the last read non-corrupted page. @@ -284,8 +365,6 @@ xb_fil_cur_read( xb_fil_cur_result_t ret; ib_int64_t offset; ib_int64_t to_read; - byte tmp_frame[UNIV_PAGE_SIZE_MAX]; - byte tmp_page[UNIV_PAGE_SIZE_MAX]; cursor->read_filter->get_next_batch(&cursor->read_filter_ctxt, &offset, &to_read); @@ -347,78 +426,8 @@ read_retry: for (page = cursor->buf, i = 0; i < npages; page += cursor->page_size, i++) { ulint page_no = cursor->buf_page_no + i; - ulint page_type = mach_read_from_2(page + FIL_PAGE_TYPE); - if (cursor->space_id == TRX_SYS_SPACE - && page_no >= FSP_EXTENT_SIZE - && page_no < FSP_EXTENT_SIZE * 3) { - /* We ignore the doublewrite buffer pages */ - } else if (mach_read_from_4(page + FIL_PAGE_OFFSET) != page_no - && space->id != TRX_SYS_SPACE) { - /* On pages that are not all zero, the - page number must match. - - There may be a mismatch on tablespace ID, - because files may be renamed during backup. - We disable the page number check - on the system tablespace, because it may consist - of multiple files, and here we count the pages - from the start of each file.) - - The first 38 and last 8 bytes are never encrypted. */ - const ulint* p = reinterpret_cast(page); - const ulint* const end = reinterpret_cast( - page + cursor->page_size); - do { - if (*p++) { - goto corrupted; - } - } while (p != end); - } else if (mach_read_from_4( - page - + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) - && space->crypt_data - && space->crypt_data->type - != CRYPT_SCHEME_UNENCRYPTED - && fil_space_verify_crypt_checksum( - page, cursor->zip_size)) { - bool decrypted = false; - - memcpy(tmp_page, page, cursor->page_size); - - if (!fil_space_decrypt(space, tmp_frame, - tmp_page, &decrypted)) { - goto corrupted; - } - - if (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED) { - goto page_decomp; - } - - if (buf_page_is_corrupted( - true, tmp_page, cursor->zip_size, space)) { - goto corrupted; - } - } else if (page_type == FIL_PAGE_PAGE_COMPRESSED) { - memcpy(tmp_page, page, cursor->page_size); -page_decomp: - ulint decomp = fil_page_decompress(tmp_frame, tmp_page); - page_type = mach_read_from_2(tmp_page + FIL_PAGE_TYPE); - - if (!decomp - || (decomp != srv_page_size && cursor->zip_size) - || page_type == FIL_PAGE_PAGE_COMPRESSED - || page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED - || buf_page_is_corrupted(true, tmp_page, - cursor->zip_size, - space)) { - goto corrupted; - } - - } else if (page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED - || buf_page_is_corrupted(true, page, - cursor->zip_size, space)) { -corrupted: + if (page_is_corrupted(page, page_no, cursor, space)){ retry_count--; if (retry_count == 0) { diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index be022f7afa2..d2b241a28f5 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -206,6 +206,7 @@ char* log_ignored_opt = NULL; extern my_bool opt_use_ssl; my_bool opt_ssl_verify_server_cert; +my_bool opt_extended_validation; /* === metadata of backup === */ #define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints" @@ -510,6 +511,7 @@ enum options_xtrabackup OPT_XTRA_DATABASES_FILE, OPT_XTRA_CREATE_IB_LOGFILE, OPT_XTRA_PARALLEL, + OPT_XTRA_EXTENDED_VALIDATION, OPT_XTRA_STREAM, OPT_XTRA_COMPRESS, OPT_XTRA_COMPRESS_THREADS, @@ -976,6 +978,14 @@ struct my_option xb_server_options[] = (G_PTR*) &xtrabackup_parallel, (G_PTR*) &xtrabackup_parallel, 0, GET_INT, REQUIRED_ARG, 1, 1, INT_MAX, 0, 0, 0}, + {"extended_validation", OPT_XTRA_EXTENDED_VALIDATION, + "Enable extended validation for Innodb data pages during backup phase." + "Will slow down backup considerably, in case encryption is used.", + (G_PTR*)&opt_extended_validation, + (G_PTR*)&opt_extended_validation, + 0, GET_BOOL, NO_ARG, FALSE, 0, 0, 0, 0, 0}, + + {"log", OPT_LOG, "Ignored option for MySQL option compatibility", (G_PTR*) &log_ignored_opt, (G_PTR*) &log_ignored_opt, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/mariabackup/xtrabackup.h b/extra/mariabackup/xtrabackup.h index 9af7c861dd7..2af5396fa06 100644 --- a/extra/mariabackup/xtrabackup.h +++ b/extra/mariabackup/xtrabackup.h @@ -128,6 +128,7 @@ extern my_bool opt_noversioncheck; extern my_bool opt_no_backup_locks; extern my_bool opt_decompress; extern my_bool opt_remove_original; +extern my_bool opt_extended_validation; extern char *opt_incremental_history_name; extern char *opt_incremental_history_uuid; diff --git a/mysql-test/suite/mariabackup/encrypted_page_corruption.test b/mysql-test/suite/mariabackup/encrypted_page_corruption.test index f87e12323da..7ee4e8c5d58 100644 --- a/mysql-test/suite/mariabackup/encrypted_page_corruption.test +++ b/mysql-test/suite/mariabackup/encrypted_page_corruption.test @@ -60,7 +60,7 @@ let $backuplog=$MYSQLTEST_VARDIR/tmp/backup.log; --disable_result_log --error 1 -exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir > $backuplog; +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --extended-validation --target-dir=$targetdir > $backuplog; --enable_result_log @@ -68,6 +68,12 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir= --let SEARCH_FILE=$backuplog --source include/search_pattern_in_file.inc remove_file $backuplog; +rmdir $targetdir; + +# Due to very constructed nature of the "corruption" (faking checksums), the "corruption" won't be found without --extended-validation +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$targetdir; +--enable_result_log drop table t1; rmdir $targetdir; From e631ea4a7c597557f2be6b9cd1118f4f3a71dccd Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 21 Dec 2018 09:41:23 +0400 Subject: [PATCH 32/58] MDEV-17738 Server crashes in Item::delete_self on closing connection after unsuccessful PS Also fixes: MDEV-17741 Assertion `thd->Item_change_list::is_empty()' failed in mysql_parse after unsuccessful PS The problem was introduced by: commit f033fbd9f2366619c52186a1a902066495539141 Changed the test case for MDEV-15571 It was later fixed, but in 10.3 only: commit ce2cf855bfc0d9c8adb64f02a7b32ddd81f9948a MDEV-16043 Assertion thd->Item_change_list::is_empty() failed in mysql_parse upon SELECT from a view reading from a versioned table This patch is a backport of ce2cf855bfc0d9c8adb64f02a7b32ddd81f9948a to 10.2 --- mysql-test/r/ps_error.result | 73 ++++++++++++++++++++++++++++++++++++ mysql-test/t/ps_error.test | 66 ++++++++++++++++++++++++++++++++ sql/sql_select.cc | 8 ++-- 3 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 mysql-test/r/ps_error.result create mode 100644 mysql-test/t/ps_error.test diff --git a/mysql-test/r/ps_error.result b/mysql-test/r/ps_error.result new file mode 100644 index 00000000000..c3c312e82f5 --- /dev/null +++ b/mysql-test/r/ps_error.result @@ -0,0 +1,73 @@ +# +# MDEV-17741 Assertion `thd->Item_change_list::is_empty()' failed in mysql_parse after unsuccessful PS +# +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +EXECUTE stmt; +ERROR 22007: Truncated incorrect INTEGER value: 'foo' +SELECT a FROM t1 GROUP BY NULL WITH ROLLUP; +a +DROP TABLE t1; +SET sql_mode=DEFAULT; +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +EXECUTE stmt; +ERROR 22007: Truncated incorrect INTEGER value: 'foo' +SET @a = REPLACE( @@global.optimizer_switch, '=on', '=off' ) ; +DROP TABLE t1; +SET sql_mode=DEFAULT; +# +# MDEV-17738 Server crashes in Item::delete_self on closing connection after unsuccessful PS +# +SET SQL_MODE='STRICT_ALL_TABLES'; +PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0"; +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +EXECUTE stmt; +ERROR 22007: Truncated incorrect INTEGER value: 'foo' +SELECT 'All done'; +All done +All done +SET SQL_MODE=DEFAULT; +SET SQL_MODE='STRICT_ALL_TABLES'; +PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0"; +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +EXECUTE stmt; +ERROR 22007: Truncated incorrect INTEGER value: 'foo' +DEALLOCATE PREPARE stmt; +SELECT 'All done'; +All done +All done +SET SQL_MODE=DEFAULT; +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +EXECUTE stmt; +ERROR 22007: Truncated incorrect INTEGER value: 'foo' +SELECT a FROM t1 GROUP BY a; +a +SELECT * FROM t1; +a +DROP TABLE t1; +SET SQL_MODE=DEFAULT; +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +Warnings: +Warning 1292 Truncated incorrect INTEGER value: 'foo' +EXECUTE stmt; +ERROR 22007: Truncated incorrect INTEGER value: 'foo' +SELECT a FROM t1 GROUP BY a; +a +INSERT t1 SELECT * FROM ( SELECT * FROM t1 ) sq; +DROP TABLE t1; +SET SQL_MODE=DEFAULT; diff --git a/mysql-test/t/ps_error.test b/mysql-test/t/ps_error.test new file mode 100644 index 00000000000..5efb5d36137 --- /dev/null +++ b/mysql-test/t/ps_error.test @@ -0,0 +1,66 @@ +# +# Tests related to PS returning errors rather than doing successfull execution +# + +--echo # +--echo # MDEV-17741 Assertion `thd->Item_change_list::is_empty()' failed in mysql_parse after unsuccessful PS +--echo # + +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +--error ER_TRUNCATED_WRONG_VALUE +EXECUTE stmt; +SELECT a FROM t1 GROUP BY NULL WITH ROLLUP; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +--error ER_TRUNCATED_WRONG_VALUE +EXECUTE stmt; +SET @a = REPLACE( @@global.optimizer_switch, '=on', '=off' ) ; +DROP TABLE t1; +SET sql_mode=DEFAULT; + + +--echo # +--echo # MDEV-17738 Server crashes in Item::delete_self on closing connection after unsuccessful PS +--echo # + +SET SQL_MODE='STRICT_ALL_TABLES'; +PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0"; +--error ER_TRUNCATED_WRONG_VALUE +EXECUTE stmt; +--source include/restart_mysqld.inc +SELECT 'All done'; +SET SQL_MODE=DEFAULT; + +SET SQL_MODE='STRICT_ALL_TABLES'; +PREPARE stmt FROM "CREATE TABLE ps AS SELECT 1 FROM DUAL WHERE 'foo' && 0"; +--error ER_TRUNCATED_WRONG_VALUE +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +SELECT 'All done'; +SET SQL_MODE=DEFAULT; + +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +--error ER_TRUNCATED_WRONG_VALUE +EXECUTE stmt; +SELECT a FROM t1 GROUP BY a; +SELECT * FROM t1; +DROP TABLE t1; +SET SQL_MODE=DEFAULT; + +SET SQL_MODE= 'STRICT_ALL_TABLES'; +CREATE TABLE t1 (a INT); +PREPARE stmt FROM "CREATE TABLE tmp AS SELECT * FROM t1 WHERE 'foo' && 0"; +--error ER_TRUNCATED_WRONG_VALUE +EXECUTE stmt; +SELECT a FROM t1 GROUP BY a; +INSERT t1 SELECT * FROM ( SELECT * FROM t1 ) sq; +DROP TABLE t1; +SET SQL_MODE=DEFAULT; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index dc948ff676a..221bdc9480c 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1318,10 +1318,12 @@ JOIN::optimize_inner() /* Convert all outer joins to inner joins if possible */ conds= simplify_joins(this, join_list, conds, TRUE, FALSE); - if (thd->is_error()) - DBUG_RETURN(1); - if (select_lex->save_leaf_tables(thd)) + if (thd->is_error() || select_lex->save_leaf_tables(thd)) + { + if (arena) + thd->restore_active_arena(arena, &backup); DBUG_RETURN(1); + } build_bitmap_for_nested_joins(join_list, 0); sel->prep_where= conds ? conds->copy_andor_structure(thd) : 0; From 40a094e4a8fdea2f07231faa0d5911ed023a320b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Dec 2018 09:40:36 +0200 Subject: [PATCH 33/58] Relax a too tight suppression When using a wrong key, all encrypted pages will look corrupted, and occasionally the test may access other pages than the clustered index root page. --- mysql-test/suite/encryption/r/innodb-missing-key.result | 2 +- mysql-test/suite/encryption/t/innodb-missing-key.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/encryption/r/innodb-missing-key.result b/mysql-test/suite/encryption/r/innodb-missing-key.result index 45a01f03c2b..da19f65dfb5 100644 --- a/mysql-test/suite/encryption/r/innodb-missing-key.result +++ b/mysql-test/suite/encryption/r/innodb-missing-key.result @@ -1,5 +1,5 @@ call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); -call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t[12].ibd looks corrupted; key_version=1"); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:[1-9][0-9]* in file .*test.t[12].ibd looks corrupted; key_version=1"); # Start server with keys2.txt CREATE TABLE t1(a int not null primary key auto_increment, b varchar(128)) engine=innodb ENCRYPTED=YES ENCRYPTION_KEY_ID=19; diff --git a/mysql-test/suite/encryption/t/innodb-missing-key.test b/mysql-test/suite/encryption/t/innodb-missing-key.test index c68604fdcf5..72c24802ce9 100644 --- a/mysql-test/suite/encryption/t/innodb-missing-key.test +++ b/mysql-test/suite/encryption/t/innodb-missing-key.test @@ -8,7 +8,7 @@ # call mtr.add_suppression("InnoDB: The page \\[page id: space=[1-9][0-9]*, page number=[1-9][0-9]*\\] in file '.*test.t[123]\\.ibd' cannot be decrypted\\."); -call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:3 in file .*test.t[12].ibd looks corrupted; key_version=1"); +call mtr.add_suppression("InnoDB: Encrypted page [1-9][0-9]*:[1-9][0-9]* in file .*test.t[12].ibd looks corrupted; key_version=1"); --echo --echo # Start server with keys2.txt From ed166f53fa6fb6911b7d1cc5bfdccd91563929b4 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 20 Dec 2018 17:42:16 +0300 Subject: [PATCH 34/58] MDEV-18043 data race in os_event os_event::is_set(): protect os_event::m_set with os_event::mutex --- storage/innobase/os/os0event.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/storage/innobase/os/os0event.cc b/storage/innobase/os/os0event.cc index 71b86df24a4..f2931239c3a 100644 --- a/storage/innobase/os/os0event.cc +++ b/storage/innobase/os/os0event.cc @@ -126,7 +126,10 @@ struct os_event { /** @return true if the event is in the signalled state. */ bool is_set() const UNIV_NOTHROW { - return(m_set); + mutex.enter(); + bool is_set = m_set; + mutex.exit(); + return is_set; } private: @@ -224,7 +227,7 @@ private: int64_t signal_count; /*!< this is incremented each time the event becomes signaled */ - EventMutex mutex; /*!< this mutex protects + mutable EventMutex mutex; /*!< this mutex protects the next fields */ From 0dafcf529c14b42e2e63d1634da79e0700be16a1 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Thu, 20 Dec 2018 17:58:50 +0300 Subject: [PATCH 35/58] cleanup os_event --- storage/innobase/os/os0event.cc | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/storage/innobase/os/os0event.cc b/storage/innobase/os/os0event.cc index f2931239c3a..4e18a48332e 100644 --- a/storage/innobase/os/os0event.cc +++ b/storage/innobase/os/os0event.cc @@ -31,8 +31,6 @@ Created 2012-09-23 Sunny Bains #include #endif /* _WIN32 */ -#include - /** The number of microsecnds in a second. */ static const ulint MICROSECS_IN_A_SECOND = 1000000; @@ -44,9 +42,6 @@ typedef CONDITION_VARIABLE os_cond_t; typedef pthread_cond_t os_cond_t; #endif /* _WIN32 */ -typedef std::list > os_event_list_t; -typedef os_event_list_t::iterator event_iter_t; - /** InnoDB condition variable. */ struct os_event { os_event(const char* name) UNIV_NOTHROW; @@ -234,9 +229,6 @@ private: os_cond_t cond_var; /*!< condition variable is used in waiting for the event */ -public: - event_iter_t event_iter; /*!< For O(1) removal from - list */ protected: // Disable copying os_event(const os_event&); @@ -544,8 +536,6 @@ os_event_destroy( os_event_t& event) /*!< in/own: event to free */ { - if (event != NULL) { - UT_DELETE(event); - event = NULL; - } + UT_DELETE(event); + event = NULL; } From c5bb6024a78ac5cea6a4e4d7767946e7f01e880a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 21 Dec 2018 11:54:53 +0200 Subject: [PATCH 36/58] MDEV-18039 Assertion failed in btr_node_ptr_max_size for VARCHAR(0) btr_node_ptr_max_size(): Do not reserve extra space for indexed VARCHAR(0) columns. --- mysql-test/suite/innodb/r/data_types.result | 12 +++++++++++- mysql-test/suite/innodb/t/data_types.test | 11 ++++++++++- storage/innobase/btr/btr0cur.cc | 15 ++++++++++++++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/data_types.result b/mysql-test/suite/innodb/r/data_types.result index 4e919e37cee..1394431b09d 100644 --- a/mysql-test/suite/innodb/r/data_types.result +++ b/mysql-test/suite/innodb/r/data_types.result @@ -77,7 +77,9 @@ t1_VARCHAR_500_BINARY VARCHAR(500) BINARY, t1_YEAR_2 YEAR(2), t1_YEAR_4 YEAR(4), t1_CHAR_0 CHAR(0), -t1_MYSQL_0 CHAR(0) CHARACTER SET utf8 +t1_MYSQL_0 CHAR(0) CHARACTER SET utf8, +t1_VARCHAR_0 VARCHAR(0), +t1_VARMYSQL_0 VARCHAR(0) CHARACTER SET utf8 ) ENGINE=InnoDB; Warnings: Note 1287 'YEAR(2)' is deprecated and will be removed in a future release. Please use YEAR(4) instead @@ -151,10 +153,12 @@ t1_TINYINT DATA_INT t1_TINYINT_UNSIGNED DATA_INT UNSIGNED t1_TINYTEXT DATA_BLOB t1_VARBINARY_100 DATA_BINARY +t1_VARCHAR_0 DATA_VARCHAR t1_VARCHAR_10 DATA_VARCHAR t1_VARCHAR_10_BINARY DATA_VARMYSQL t1_VARCHAR_500 DATA_VARCHAR t1_VARCHAR_500_BINARY DATA_VARMYSQL +t1_VARMYSQL_0 DATA_VARMYSQL t1_YEAR_2 DATA_INT UNSIGNED t1_YEAR_4 DATA_INT UNSIGNED DROP TABLE t1; @@ -164,3 +168,9 @@ DROP TABLE t1; CREATE TABLE t1 (c CHAR(0), KEY(c)) ENGINE=InnoDB; INSERT INTO t1 VALUES (''); DROP TABLE t1; +# +# MDEV-18039 Assertion failed in btr_node_ptr_max_size for VARCHAR(0) +# +CREATE TABLE t1 (c VARCHAR(0), KEY(c)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (''); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/data_types.test b/mysql-test/suite/innodb/t/data_types.test index c8e80c9db27..cfdd5201af2 100644 --- a/mysql-test/suite/innodb/t/data_types.test +++ b/mysql-test/suite/innodb/t/data_types.test @@ -90,7 +90,9 @@ CREATE TABLE t1 t1_YEAR_2 YEAR(2), t1_YEAR_4 YEAR(4), t1_CHAR_0 CHAR(0), - t1_MYSQL_0 CHAR(0) CHARACTER SET utf8 + t1_MYSQL_0 CHAR(0) CHARACTER SET utf8, + t1_VARCHAR_0 VARCHAR(0), + t1_VARMYSQL_0 VARCHAR(0) CHARACTER SET utf8 ) ENGINE=InnoDB; INSERT INTO t1 () VALUES (); @@ -127,3 +129,10 @@ DROP TABLE t1; CREATE TABLE t1 (c CHAR(0), KEY(c)) ENGINE=InnoDB; INSERT INTO t1 VALUES (''); DROP TABLE t1; + +--echo # +--echo # MDEV-18039 Assertion failed in btr_node_ptr_max_size for VARCHAR(0) +--echo # +CREATE TABLE t1 (c VARCHAR(0), KEY(c)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (''); +DROP TABLE t1; diff --git a/storage/innobase/btr/btr0cur.cc b/storage/innobase/btr/btr0cur.cc index 3f26803d14b..9cf42a93800 100644 --- a/storage/innobase/btr/btr0cur.cc +++ b/storage/innobase/btr/btr0cur.cc @@ -754,9 +754,20 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index) field_max_size = dict_col_get_max_size(col); if (UNIV_UNLIKELY(!field_max_size)) { switch (col->mtype) { + case DATA_VARCHAR: + if (!comp + && (!strcmp(index->table->name.m_name, + "SYS_FOREIGN") + || !strcmp(index->table->name.m_name, + "SYS_FOREIGN_COLS"))) { + break; + } + /* fall through */ + case DATA_VARMYSQL: case DATA_CHAR: case DATA_MYSQL: - /* CHAR(0) is a possible data type. + /* CHAR(0) and VARCHAR(0) are possible + data type definitions in MariaDB. The InnoDB internal SQL parser maps CHAR to DATA_VARCHAR, so DATA_CHAR (or DATA_MYSQL) is only coming from the @@ -772,6 +783,7 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index) } continue; } + /* SYS_FOREIGN.ID is defined as CHAR in the InnoDB internal SQL parser, which translates into the incorrect VARCHAR(0). InnoDB does @@ -788,6 +800,7 @@ static ulint btr_node_ptr_max_size(const dict_index_t* index) || !strcmp(index->table->name.m_name, "SYS_FOREIGN_COLS")); ut_ad(!comp); + ut_ad(col->mtype == DATA_VARCHAR); rec_max_size += (srv_page_size == UNIV_PAGE_SIZE_MAX) ? REDUNDANT_REC_MAX_DATA_SIZE From 37b1b065f448db90fecc8e7a51cf52d22f3b4369 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 21 Dec 2018 11:29:25 +0100 Subject: [PATCH 37/58] TokuDB: generate tokudb.cnf unconditionally it's listed in MYSQL_ADD_PLUGIN() declaration, so it must always exist, jemalloc or not. --- storage/tokudb/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/storage/tokudb/CMakeLists.txt b/storage/tokudb/CMakeLists.txt index f3166ca8c0b..3b4e4fb967e 100644 --- a/storage/tokudb/CMakeLists.txt +++ b/storage/tokudb/CMakeLists.txt @@ -78,7 +78,6 @@ ELSEIF(LIBJEMALLOC STREQUAL jemalloc) IF(INSTALL_SYSCONFDIR) SET(systemd_env "Environment=\"LD_PRELOAD=${LIBJEMALLOC_PATH}\"") SET(cnf_malloc_lib "malloc-lib=${LIBJEMALLOC_PATH}") - CONFIGURE_FILE(tokudb.cnf.in tokudb.cnf @ONLY) CONFIGURE_FILE(tokudb.conf.in tokudb.conf @ONLY) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tokudb.conf DESTINATION ${INSTALL_SYSCONFDIR}/systemd/system/mariadb.service.d/ @@ -86,6 +85,8 @@ ELSEIF(LIBJEMALLOC STREQUAL jemalloc) ENDIF() ENDIF() +CONFIGURE_FILE(tokudb.cnf.in tokudb.cnf @ONLY) + MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-shadow") MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-vla" DEBUG) MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough") From 2cf30866d7482d83b398e103b444b00661c306c7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 21 Dec 2018 13:29:36 +0100 Subject: [PATCH 38/58] MDEV-14576 Include full name of object in message about incorrect value for column update engines/ suites followup for c4ab352b670 --- .../funcs/r/in_number_boundary_error.result | 12 +- .../r/in_number_decimal_boundary_error.result | 8 +- .../engines/iuds/r/insert_decimal.result | 12 +- .../suite/engines/iuds/r/insert_number.result | 204 +++++++++--------- .../suite/engines/iuds/r/insert_year.result | 16 +- .../engines/iuds/r/update_decimal.result | 4 +- storage/tokudb/mysql-test/tokudb/disabled.def | 4 +- 7 files changed, 130 insertions(+), 130 deletions(-) diff --git a/mysql-test/suite/engines/funcs/r/in_number_boundary_error.result b/mysql-test/suite/engines/funcs/r/in_number_boundary_error.result index 53964697506..b1c46a3a398 100644 --- a/mysql-test/suite/engines/funcs/r/in_number_boundary_error.result +++ b/mysql-test/suite/engines/funcs/r/in_number_boundary_error.result @@ -7,7 +7,7 @@ INSERT INTO t4 (c1) VALUES(0); INSERT INTO t4 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t4 (c1) VALUES('x'); -ERROR 22007: Incorrect integer value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect integer value: 'x' for column `test`.`t4`.`c1` at row 1 INSERT INTO t4 (c1) VALUES('9'); SELECT COUNT(c1) AS total_rows FROM t4; total_rows @@ -26,7 +26,7 @@ INSERT INTO t4 (c1) VALUES(0); INSERT INTO t4 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t4 (c1) VALUES('x'); -ERROR 22007: Incorrect integer value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect integer value: 'x' for column `test`.`t4`.`c1` at row 1 INSERT INTO t4 (c1) VALUES('9'); SELECT COUNT(c1) AS total_rows FROM t4; total_rows @@ -45,7 +45,7 @@ INSERT INTO t4 (c1) VALUES(0); INSERT INTO t4 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t4 (c1) VALUES('x'); -ERROR 22007: Incorrect integer value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect integer value: 'x' for column `test`.`t4`.`c1` at row 1 INSERT INTO t4 (c1) VALUES('9'); SELECT COUNT(c1) AS total_rows FROM t4; total_rows @@ -64,7 +64,7 @@ INSERT INTO t4 (c1) VALUES(0); INSERT INTO t4 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t4 (c1) VALUES('x'); -ERROR 22007: Incorrect integer value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect integer value: 'x' for column `test`.`t4`.`c1` at row 1 INSERT INTO t4 (c1) VALUES('9'); SELECT COUNT(c1) AS total_rows FROM t4; total_rows @@ -83,7 +83,7 @@ INSERT INTO t4 (c1) VALUES(0); INSERT INTO t4 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t4 (c1) VALUES('x'); -ERROR 22007: Incorrect integer value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect integer value: 'x' for column `test`.`t4`.`c1` at row 1 INSERT INTO t4 (c1) VALUES('9'); SELECT COUNT(c1) AS total_rows FROM t4; total_rows @@ -102,7 +102,7 @@ INSERT INTO t4 (c1) VALUES(0); INSERT INTO t4 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t4 (c1) VALUES('x'); -ERROR 22007: Incorrect integer value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect integer value: 'x' for column `test`.`t4`.`c1` at row 1 INSERT INTO t4 (c1) VALUES('9'); SELECT COUNT(c1) AS total_rows FROM t4; total_rows diff --git a/mysql-test/suite/engines/funcs/r/in_number_decimal_boundary_error.result b/mysql-test/suite/engines/funcs/r/in_number_decimal_boundary_error.result index 62ad9a568f9..0c9ae5453e3 100644 --- a/mysql-test/suite/engines/funcs/r/in_number_decimal_boundary_error.result +++ b/mysql-test/suite/engines/funcs/r/in_number_decimal_boundary_error.result @@ -7,7 +7,7 @@ INSERT INTO t5 (c1) VALUES(0); INSERT INTO t5 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t5 (c1) VALUES('x'); -ERROR 22007: Incorrect decimal value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect decimal value: 'x' for column `test`.`t5`.`c1` at row 1 INSERT INTO t5 (c1) VALUES(999999); ERROR 22003: Out of range value for column 'c1' at row 1 SELECT COUNT(c1) AS total_rows FROM t5; @@ -27,7 +27,7 @@ INSERT INTO t5 (c1) VALUES(0); INSERT INTO t5 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t5 (c1) VALUES('x'); -ERROR 22007: Incorrect decimal value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect decimal value: 'x' for column `test`.`t5`.`c1` at row 1 INSERT INTO t5 (c1) VALUES(999999); ERROR 22003: Out of range value for column 'c1' at row 1 SELECT COUNT(c1) AS total_rows FROM t5; @@ -47,7 +47,7 @@ INSERT INTO t5 (c1) VALUES(0); INSERT INTO t5 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t5 (c1) VALUES('x'); -ERROR 22007: Incorrect decimal value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect decimal value: 'x' for column `test`.`t5`.`c1` at row 1 INSERT INTO t5 (c1) VALUES(999999); ERROR 22003: Out of range value for column 'c1' at row 1 SELECT COUNT(c1) AS total_rows FROM t5; @@ -67,7 +67,7 @@ INSERT INTO t5 (c1) VALUES(0); INSERT INTO t5 (c1) VALUES(-1); ERROR 22003: Out of range value for column 'c1' at row 1 INSERT INTO t5 (c1) VALUES('x'); -ERROR 22007: Incorrect decimal value: 'x' for column 'c1' at row 1 +ERROR 22007: Incorrect decimal value: 'x' for column `test`.`t5`.`c1` at row 1 INSERT INTO t5 (c1) VALUES(999999); ERROR 22003: Out of range value for column 'c1' at row 1 SELECT COUNT(c1) AS total_rows FROM t5; diff --git a/mysql-test/suite/engines/iuds/r/insert_decimal.result b/mysql-test/suite/engines/iuds/r/insert_decimal.result index a341de58946..860fa8a2c4c 100644 --- a/mysql-test/suite/engines/iuds/r/insert_decimal.result +++ b/mysql-test/suite/engines/iuds/r/insert_decimal.result @@ -110,15 +110,15 @@ Warnings: Warning 1264 Out of range value for column 'c1' at row 1 Warning 1264 Out of range value for column 'c2' at row 1 Warning 1264 Out of range value for column 'c3' at row 1 -Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column 'c1' at row 2 -Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column 'c2' at row 2 -Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column 'c3' at row 2 +Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column `test`.`t2`.`c1` at row 2 +Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column `test`.`t2`.`c2` at row 2 +Warning 1366 Incorrect decimal value: '1e+18446744073709551616' for column `test`.`t2`.`c3` at row 2 Note 1265 Data truncated for column 'c1' at row 3 Note 1265 Data truncated for column 'c2' at row 3 Note 1265 Data truncated for column 'c3' at row 3 -Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column 'c1' at row 4 -Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column 'c2' at row 4 -Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column 'c3' at row 4 +Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column `test`.`t2`.`c1` at row 4 +Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column `test`.`t2`.`c2` at row 4 +Warning 1366 Incorrect decimal value: '1e-9223372036854775809' for column `test`.`t2`.`c3` at row 4 SELECT * FROM t1; c1 c2 c3 c4 0.00000 -0.10000 0 13 diff --git a/mysql-test/suite/engines/iuds/r/insert_number.result b/mysql-test/suite/engines/iuds/r/insert_number.result index d3d96082566..1355812649a 100644 --- a/mysql-test/suite/engines/iuds/r/insert_number.result +++ b/mysql-test/suite/engines/iuds/r/insert_number.result @@ -12,16 +12,16 @@ INSERT INTO t2 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t3 VALUES(105,NULL,102,103,104,105,106); INSERT IGNORE INTO t1 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT IGNORE INTO t2 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c2` at row 1 INSERT IGNORE INTO t3 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c2` at row 1 INSERT IGNORE INTO t1 VALUES(-1,124,22,23,24,25,26); Warnings: Warning 1264 Out of range value for column 'c1' at row 1 @@ -40,15 +40,15 @@ INSERT INTO t3 VALUES(0,0,32,32,34,35,36); INSERT IGNORE INTO t1 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`c2` at row 1 INSERT IGNORE INTO t2 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t2`.`c2` at row 1 INSERT IGNORE INTO t3 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t3`.`c2` at row 1 SELECT * FROM t1; c1 c2 c3 c4 c5 c6 c7 0 0 17 18 19 20 21 @@ -1378,22 +1378,22 @@ Warnings: Warning 1364 Field 'c2' doesn't have a default value INSERT IGNORE INTO t4 VALUES('','',17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c2` at row 1 INSERT IGNORE INTO t5 VALUES('','',-17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c2` at row 1 INSERT IGNORE INTO t4 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c3` at row 1 INSERT IGNORE INTO t5 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c3` at row 1 INSERT INTO t4 VALUES(4,7,8,9,10,11,12,13); INSERT IGNORE INTO t5 VALUES(-1,-1,-1,8,9,10,11,12); Warnings: @@ -5621,16 +5621,16 @@ INSERT INTO t2 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t3 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t1 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c2` at row 1 INSERT INTO t1 VALUES(-1,124,22,23,24,25,26); Warnings: Warning 1264 Out of range value for column 'c1' at row 1 @@ -5649,15 +5649,15 @@ INSERT INTO t3 VALUES(0,0,32,32,34,35,36); INSERT INTO t1 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t3`.`c2` at row 1 SELECT * FROM t1; c1 c2 c3 c4 c5 c6 c7 0 0 17 18 19 20 21 @@ -6987,22 +6987,22 @@ Warnings: Warning 1364 Field 'c2' doesn't have a default value INSERT INTO t4 VALUES('','',17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c2` at row 1 INSERT INTO t5 VALUES('','',-17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c2` at row 1 INSERT INTO t4 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c3` at row 1 INSERT INTO t5 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c3` at row 1 INSERT INTO t4 VALUES(4,7,8,9,10,11,12,13); INSERT INTO t5 VALUES(-1,-1,-1,8,9,10,11,12); Warnings: @@ -11321,16 +11321,16 @@ INSERT INTO t2 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t3 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t1 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c2` at row 1 INSERT INTO t1 VALUES(-1,124,22,23,24,25,26); Warnings: Warning 1264 Out of range value for column 'c1' at row 1 @@ -11349,15 +11349,15 @@ INSERT INTO t3 VALUES(0,0,32,32,34,35,36); INSERT INTO t1 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t3`.`c2` at row 1 SELECT * FROM t1; c1 c2 c3 c4 c5 c6 c7 0 0 17 18 19 20 21 @@ -12687,22 +12687,22 @@ Warnings: Warning 1364 Field 'c2' doesn't have a default value INSERT INTO t4 VALUES('','',17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c2` at row 1 INSERT INTO t5 VALUES('','',-17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c2` at row 1 INSERT INTO t4 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c3` at row 1 INSERT INTO t5 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c3` at row 1 INSERT INTO t4 VALUES(4,7,8,9,10,11,12,13); INSERT INTO t5 VALUES(-1,-1,-1,8,9,10,11,12); Warnings: @@ -17126,16 +17126,16 @@ INSERT INTO t2 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t3 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t1 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c2` at row 1 INSERT INTO t1 VALUES(-1,124,22,23,24,25,26); Warnings: Warning 1264 Out of range value for column 'c1' at row 1 @@ -17154,15 +17154,15 @@ INSERT INTO t3 VALUES(0,0,32,32,34,35,36); INSERT INTO t1 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t3`.`c2` at row 1 SELECT * FROM t1; c1 c2 c3 c4 c5 c6 c7 0 0 17 18 19 20 21 @@ -18492,22 +18492,22 @@ Warnings: Warning 1364 Field 'c2' doesn't have a default value INSERT INTO t4 VALUES('','',17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c2` at row 1 INSERT INTO t5 VALUES('','',-17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c2` at row 1 INSERT INTO t4 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c3` at row 1 INSERT INTO t5 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c3` at row 1 INSERT INTO t4 VALUES(4,7,8,9,10,11,12,13); INSERT INTO t5 VALUES(-1,-1,-1,8,9,10,11,12); Warnings: @@ -23036,16 +23036,16 @@ INSERT INTO t2 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t3 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t1 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c2` at row 1 INSERT INTO t1 VALUES(-1,124,22,23,24,25,26); Warnings: Warning 1264 Out of range value for column 'c1' at row 1 @@ -23064,15 +23064,15 @@ INSERT INTO t3 VALUES(0,0,32,32,34,35,36); INSERT INTO t1 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t3`.`c2` at row 1 SELECT * FROM t1; c1 c2 c3 c4 c5 c6 c7 0 0 17 18 19 20 21 @@ -24402,22 +24402,22 @@ Warnings: Warning 1364 Field 'c2' doesn't have a default value INSERT INTO t4 VALUES('','',17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c2` at row 1 INSERT INTO t5 VALUES('','',-17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c2` at row 1 INSERT INTO t4 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c3` at row 1 INSERT INTO t5 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c3` at row 1 INSERT INTO t4 VALUES(4,7,8,9,10,11,12,13); INSERT INTO t5 VALUES(-1,-1,-1,8,9,10,11,12); Warnings: @@ -28946,16 +28946,16 @@ INSERT INTO t2 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t3 VALUES(105,NULL,102,103,104,105,106); INSERT INTO t1 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('','',17,18,19,20,21); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t3`.`c2` at row 1 INSERT INTO t1 VALUES(-1,124,22,23,24,25,26); Warnings: Warning 1264 Out of range value for column 'c1' at row 1 @@ -28974,15 +28974,15 @@ INSERT INTO t3 VALUES(0,0,32,32,34,35,36); INSERT INTO t1 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`c2` at row 1 INSERT INTO t2 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t2`.`c2` at row 1 INSERT INTO t3 VALUES('101.34 a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t3`.`c2` at row 1 SELECT * FROM t1; c1 c2 c3 c4 c5 c6 c7 0 0 17 18 19 20 21 @@ -30312,22 +30312,22 @@ Warnings: Warning 1364 Field 'c2' doesn't have a default value INSERT INTO t4 VALUES('','',17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t4`.`c2` at row 1 INSERT INTO t5 VALUES('','',-17,18,19,20,21,22); Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t5`.`c2` at row 1 INSERT INTO t4 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t4`.`c3` at row 1 INSERT INTO t5 VALUES('102.34 a','a','a',37,38,39,40,41); Warnings: Warning 1265 Data truncated for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c2' at row 1 -Warning 1366 Incorrect integer value: 'a' for column 'c3' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c2` at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t5`.`c3` at row 1 INSERT INTO t4 VALUES(4,7,8,9,10,11,12,13); INSERT INTO t5 VALUES(-1,-1,-1,8,9,10,11,12); Warnings: diff --git a/mysql-test/suite/engines/iuds/r/insert_year.result b/mysql-test/suite/engines/iuds/r/insert_year.result index ea6e10d130b..c7a0dbcba86 100644 --- a/mysql-test/suite/engines/iuds/r/insert_year.result +++ b/mysql-test/suite/engines/iuds/r/insert_year.result @@ -60,12 +60,12 @@ Warning 1264 Out of range value for column 'c1' at row 6 Warning 1264 Out of range value for column 'c2' at row 6 INSERT IGNORE INTO t1 VALUES('','','08-01-04','08/01/05') /* Inserts zero dates for '' strings */; Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT IGNORE INTO t4 VALUES('abcd','abcd','08-01-10','08/01/11'),(1234,1234,'08-01-12','08/01/13') /* Inserts zero dates for absurd dates */; Warnings: -Warning 1366 Incorrect integer value: 'abcd' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'abcd' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'abcd' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: 'abcd' for column `test`.`t4`.`c2` at row 1 Warning 1264 Out of range value for column 'c1' at row 2 Warning 1264 Out of range value for column 'c2' at row 2 INSERT INTO t2 VALUES('20','30','98-12-16','98.12.16 11:30:45'),('40','20','98-12-15','98.12.15 11:30:45'); @@ -3319,12 +3319,12 @@ Warning 1264 Out of range value for column 'c1' at row 6 Warning 1264 Out of range value for column 'c2' at row 6 INSERT IGNORE INTO t1 VALUES('','','08-01-04','08/01/05') /* Inserts zero dates for '' strings */; Warnings: -Warning 1366 Incorrect integer value: '' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: '' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c1` at row 1 +Warning 1366 Incorrect integer value: '' for column `test`.`t1`.`c2` at row 1 INSERT IGNORE INTO t4 VALUES('abcd','abcd','08-01-10','08/01/11'),(1234,1234,'08-01-12','08/01/13') /* Inserts zero dates for absurd dates */; Warnings: -Warning 1366 Incorrect integer value: 'abcd' for column 'c1' at row 1 -Warning 1366 Incorrect integer value: 'abcd' for column 'c2' at row 1 +Warning 1366 Incorrect integer value: 'abcd' for column `test`.`t4`.`c1` at row 1 +Warning 1366 Incorrect integer value: 'abcd' for column `test`.`t4`.`c2` at row 1 Warning 1264 Out of range value for column 'c1' at row 2 Warning 1264 Out of range value for column 'c2' at row 2 INSERT INTO t2 VALUES('20','30','98-12-16','98.12.16 11:30:45'),('40','20','98-12-15','98.12.15 11:30:45'); diff --git a/mysql-test/suite/engines/iuds/r/update_decimal.result b/mysql-test/suite/engines/iuds/r/update_decimal.result index 7b4a3ea9079..8bedcf8ab51 100644 --- a/mysql-test/suite/engines/iuds/r/update_decimal.result +++ b/mysql-test/suite/engines/iuds/r/update_decimal.result @@ -334,7 +334,7 @@ INSERT INTO t3 VALUES ('11111.11111','4444444444',1),('55555.55555','5555555555' UPDATE t2,t3 SET t3.c1='22222.22222' WHERE t2.c1=t3.c1 AND t2.c3=t3.c3; UPDATE IGNORE t1 SET c3='asdf' WHERE c1='11111.11111'; Warnings: -Warning 1366 Incorrect decimal value: 'asdf' for column 'c3' at row 1 +Warning 1366 Incorrect decimal value: 'asdf' for column `test`.`t1`.`c3` at row 1 SELECT c3 FROM t1; c3 0 @@ -1099,7 +1099,7 @@ INSERT INTO t3 VALUES ('11111.11111','4444444444',1),('55555.55555','5555555555' UPDATE t2,t3 SET t3.c1='22222.22222' WHERE t2.c1=t3.c1 AND t2.c3=t3.c3; UPDATE IGNORE t1 SET c3='asdf' WHERE c1='11111.11111'; Warnings: -Warning 1366 Incorrect double value: 'asdf' for column 'c3' at row 1 +Warning 1366 Incorrect double value: 'asdf' for column `test`.`t1`.`c3` at row 1 SELECT c3 FROM t1; c3 0 diff --git a/storage/tokudb/mysql-test/tokudb/disabled.def b/storage/tokudb/mysql-test/tokudb/disabled.def index 89f6992d26d..4f759001151 100644 --- a/storage/tokudb/mysql-test/tokudb/disabled.def +++ b/storage/tokudb/mysql-test/tokudb/disabled.def @@ -30,5 +30,5 @@ i_s_tokudb_lock_waits_released: unstable, race conditions i_s_tokudb_locks_released: unstable, race conditions row_format: n/a nonflushing_analyze_debug: Freezes in MariaDB 10.0 -tokudb.change_column_all_1000_1: We are too lazy to fix this properly -tokudb.change_column_all_1000_10: We are too lazy to fix this properly +change_column_all_1000_1: We are too lazy to fix this properly +change_column_all_1000_10: We are too lazy to fix this properly From 773479f5b305cea938b3b5835923ca3e46454a44 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 21 Dec 2018 11:18:53 +0100 Subject: [PATCH 39/58] Add test for partial backup for partitioned table. --- extra/mariabackup/xtrabackup.cc | 23 ++++++---- .../mariabackup/partition_partial.result | 31 +++++++++++++ .../suite/mariabackup/partition_partial.test | 44 +++++++++++++++++++ 3 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 mysql-test/suite/mariabackup/partition_partial.result create mode 100644 mysql-test/suite/mariabackup/partition_partial.test diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 9769c875fe3..9646e0eac03 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -1469,7 +1469,7 @@ debug_sync_point(const char *name) } -static std::vector tables_for_export; +static std::set tables_for_export; static void append_export_table(const char *dbname, const char *tablename, bool is_remote) { @@ -1481,7 +1481,15 @@ static void append_export_table(const char *dbname, const char *tablename, bool char *p=strrchr(buf, '.'); if (p) *p=0; - tables_for_export.push_back(ut_get_name(0,buf)); + std::string name=ut_get_name(0, buf); + /* Strip partition name comment from table name, if any */ + if (ends_with(name.c_str(), "*/")) + { + size_t pos= name.rfind("/*"); + if (pos != std::string::npos) + name.resize(pos); + } + tables_for_export.insert(name); } } @@ -1496,9 +1504,10 @@ static int create_bootstrap_file() fputs("SET NAMES UTF8;\n",f); enumerate_ibd_files(append_export_table); - for (size_t i= 0; i < tables_for_export.size(); i++) + for (std::set::iterator it = tables_for_export.begin(); + it != tables_for_export.end(); it++) { - const char *tab = tables_for_export[i].c_str(); + const char *tab = it->c_str(); fprintf(f, "BEGIN NOT ATOMIC " "DECLARE CONTINUE HANDLER FOR NOT FOUND,SQLEXCEPTION BEGIN END;" @@ -1528,7 +1537,7 @@ static int prepare_export() snprintf(cmdline, sizeof cmdline, IF_WIN("\"","") "\"%s\" --mysqld \"%s\" " " --defaults-extra-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=." - " --innodb --innodb-fast-shutdown=0" + " --innodb --innodb-fast-shutdown=0 --loose-partition" " --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu" " --console --skip-log-error --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""), mariabackup_exe, @@ -1540,7 +1549,7 @@ static int prepare_export() sprintf(cmdline, IF_WIN("\"","") "\"%s\" --mysqld" " --defaults-file=./backup-my.cnf --defaults-group-suffix=%s --datadir=." - " --innodb --innodb-fast-shutdown=0" + " --innodb --innodb-fast-shutdown=0 --loose-partition" " --innodb_purge_rseg_truncate_frequency=1 --innodb-buffer-pool-size=%llu" " --console --log-error= --bootstrap < " BOOTSTRAP_FILENAME IF_WIN("\"",""), mariabackup_exe, @@ -5851,7 +5860,6 @@ check_all_privileges() mysql_free_result(result); int check_result = PRIVILEGE_OK; - bool reload_checked = false; /* FLUSH TABLES WITH READ LOCK */ if (!opt_no_lock) @@ -5859,7 +5867,6 @@ check_all_privileges() check_result |= check_privilege( granted_privileges, "RELOAD", "*", "*"); - reload_checked = true; } if (!opt_no_lock) diff --git a/mysql-test/suite/mariabackup/partition_partial.result b/mysql-test/suite/mariabackup/partition_partial.result new file mode 100644 index 00000000000..62b7adf75f8 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_partial.result @@ -0,0 +1,31 @@ +CREATE TABLE t1(i INT) ENGINE INNODB +PARTITION BY RANGE (i) +(PARTITION p1 VALUES LESS THAN (100), +PARTITION p2 VALUES LESS THAN (200), +PARTITION p3 VALUES LESS THAN (300), +PARTITION p4 VALUES LESS THAN (400)); +INSERT INTO t1 VALUES (1), (101), (201), (301); +# xtrabackup backup +INSERT INTO t1 VALUES (1), (101), (201), (301); +# xtrabackup prepare +CREATE TABLE t1_placeholder (i INT) ENGINE INNODB; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p4 WITH TABLE t1_placeholder; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p3 WITH TABLE t1_placeholder; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p2 WITH TABLE t1_placeholder; +ALTER TABLE t1_placeholder DISCARD TABLESPACE; +ALTER TABLE t1_placeholder IMPORT TABLESPACE; +ALTER TABLE t1 EXCHANGE PARTITION p1 WITH TABLE t1_placeholder; +SELECT * FROM t1; +i +1 +101 +201 +301 +DROP TABLE t1; +DROP TABLE t1_placeholder; diff --git a/mysql-test/suite/mariabackup/partition_partial.test b/mysql-test/suite/mariabackup/partition_partial.test new file mode 100644 index 00000000000..8e288ec997f --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_partial.test @@ -0,0 +1,44 @@ +#--source include/innodb_page_size.inc + +# import partitioned table from table from partial backup + +CREATE TABLE t1(i INT) ENGINE INNODB +PARTITION BY RANGE (i) +(PARTITION p1 VALUES LESS THAN (100), + PARTITION p2 VALUES LESS THAN (200), + PARTITION p3 VALUES LESS THAN (300), + PARTITION p4 VALUES LESS THAN (400)); + +INSERT INTO t1 VALUES (1), (101), (201), (301); + +echo # xtrabackup backup; + +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup "--tables=test.t1" --target-dir=$targetdir; +--enable_result_log +INSERT INTO t1 VALUES (1), (101), (201), (301); + + +echo # xtrabackup prepare; +--disable_result_log +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.1 --prepare --export --target-dir=$targetdir; +--enable_result_log + + +let $MYSQLD_DATADIR= `select @@datadir`; +CREATE TABLE t1_placeholder (i INT) ENGINE INNODB; +let $i=4; +while($i) +{ + eval ALTER TABLE t1_placeholder DISCARD TABLESPACE; + copy_file $targetdir/test/t1#P#p$i.cfg $MYSQLD_DATADIR/test/t1_placeholder.cfg; + copy_file $targetdir/test/t1#P#p$i.ibd $MYSQLD_DATADIR/test/t1_placeholder.ibd; + eval ALTER TABLE t1_placeholder IMPORT TABLESPACE; + eval ALTER TABLE t1 EXCHANGE PARTITION p$i WITH TABLE t1_placeholder; + dec $i; +} +SELECT * FROM t1; +DROP TABLE t1; +DROP TABLE t1_placeholder; +rmdir $targetdir; From 242fedf595387db6566af56658e4c6c9a1b205e7 Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Fri, 21 Dec 2018 18:58:23 +0200 Subject: [PATCH 40/58] Follow-up for MDEV-14576 - updated test result --- mysql-test/suite/storage_engine/type_bool.result | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/storage_engine/type_bool.result b/mysql-test/suite/storage_engine/type_bool.result index 87308ed63fc..10cfc08102f 100644 --- a/mysql-test/suite/storage_engine/type_bool.result +++ b/mysql-test/suite/storage_engine/type_bool.result @@ -42,8 +42,8 @@ b1 b2 0 0 INSERT INTO t1 (b1,b2) VALUES ('a','b'); Warnings: -Warning 1366 Incorrect integer value: 'a' for column 'b1' at row 1 -Warning 1366 Incorrect integer value: 'b' for column 'b2' at row 1 +Warning 1366 Incorrect integer value: 'a' for column `test`.`t1`.`b1` at row 1 +Warning 1366 Incorrect integer value: 'b' for column `test`.`t1`.`b2` at row 1 SELECT b1,b2 FROM t1; b1 b2 -1 -2 From b82df7117426ec35a34569994a4a6544dde78efc Mon Sep 17 00:00:00 2001 From: Elena Stepanova Date: Fri, 21 Dec 2018 18:59:11 +0200 Subject: [PATCH 41/58] Updated list of unstable tests for 10.2.20 --- mysql-test/unstable-tests | 114 ++++++++++++++++---------------------- 1 file changed, 49 insertions(+), 65 deletions(-) diff --git a/mysql-test/unstable-tests b/mysql-test/unstable-tests index 2e517228bfd..59a287547d4 100644 --- a/mysql-test/unstable-tests +++ b/mysql-test/unstable-tests @@ -23,21 +23,24 @@ # ############################################################################## -# Based on 10.2 85baa03c60d5e9da4890344f10fa0437337cb265 +# Based on 10.2 2cf30866d7482d83b398e103b444b00661c306c7 main.alter_table : Modified in 10.2.19 +main.alter_table_errors : Modified in 10.2.20 main.alter_table_trans : MDEV-12084 - timeout main.analyze_stmt_slow_query_log : MDEV-12237 - Wrong result main.auth_named_pipe : MDEV-14724 - System error 2 main.auto_increment_ranges_innodb : Modified in 10.2.19 -main.connect : MDEV-17282 - Wrong result +main.bigint : Modified in 10.2.20 +main.check : Modified in 10.2.20 +main.connect : MDEV-17282 - Wrong result; modified in 10.2.20 main.connect2 : MDEV-13885 - Server crash -main.constraints : Modified in 10.2.18 main.count_distinct2 : MDEV-11768 - timeout main.create_delayed : MDEV-10605 - failed with timeout +main.create_drop_event : MDEV-16271 - Wrong result main.create_or_replace : Modified in 10.2.19 main.cte_nonrecursive : Modified in 10.2.19 -main.cte_recursive : Modified in 10.2.19 +main.cte_recursive : Modified in 10.2.20 main.ctype_latin1 : Modified in 10.2.19 main.ctype_uca : Modified in 10.2.19 main.ctype_ucs : MDEV-17681 - Data too long for column @@ -54,20 +57,18 @@ main.events_restart : MDEV-12236 - Server shutdown problem main.events_slowlog : MDEV-12821 - Wrong result main.flush : Modified in 10.2.19 main.func_concat : Modified in 10.2.19 -main.func_isnull : Modified in 10.2.18 +main.func_default : Modified in 10.2.20 main.func_json : Modified in 10.2.19 -main.func_time : Modified in 10.2.18 -main.gis : MDEV-13411 - wrong result on P8; modified in 10.2.18 -main.gis-precise : Modified in 10.2.18 -main.grant : Modified in 10.2.18 +main.func_time : Modified in 10.2.20 +main.gis : MDEV-13411 - wrong result on P8 +main.grant5 : Modified in 10.2.20 main.group_by : Modified in 10.2.19 -main.group_min_max : Modified in 10.2.18 main.host_cache_size_functionality : MDEV-10606 - sporadic failure on shutdown main.index_intersect_innodb : MDEV-10643 - failed with timeout main.index_merge_innodb : MDEV-7142 - Plan mismatch main.index_merge_myisam : Modified in 10.2.19 +main.information_schema : Modified in 10.2.20 main.innodb_mysql_lock : MDEV-7861 - Wrong result -main.join : Modified in 10.2.18 main.kill-2 : MDEV-13257 - Wrong result main.kill_processlist-6619 : MDEV-10793 - Wrong result main.lock : Modified in 10.2.19 @@ -78,10 +79,8 @@ main.lowercase_fs_off : Modified in 10.2.19 main.mdev-504 : MDEV-15171 - warning main.mdev375 : MDEV-10607 - sporadic "can't connect" main.merge : MDEV-10607 - sporadic "can't connect" -main.mysql : Modified in 10.2.18 main.mysql_client_test_comp : MDEV-16641 - Error in exec main.mysql_client_test_nonblock : CONC-208 - Error on Power; MDEV-15096 - exec failed -main.mysql_not_windows : Modified in 10.2.18 main.mysql_upgrade_noengine : MDEV-14355 - Wrong result main.mysql_upgrade_ssl : MDEV-13492 - Unknown SSL error main.mysqldump : MDEV-14800 - Stack smashing detected @@ -93,43 +92,43 @@ main.openssl_1 : MDEV-13492 - Unknown SSL error main.openssl_6975 : MDEV-17184 - Failures with OpenSSL 1.1.1 main.order_by_optimizer_innodb : MDEV-10683 - Wrong result main.order_by_zerolength-4285 : Modified in 10.2.19 +main.partition : Modified in 10.2.20 +main.partition_alter : Modified in 10.2.20 main.partition_debug_sync : MDEV-15669 - Deadlock found when trying to get lock main.partition_explicit_prune : Modified in 10.2.19 +main.partition_innodb : Modified in 10.2.20 main.partition_innodb_plugin : MDEV-12901 - Valgrind warnings -main.ps : MDEV-11017 - Wrong result; modified in 10.2.18 +main.ps : MDEV-11017 - Wrong result +main.ps_error : Added in 10.2.20 main.query_cache : MDEV-16180 - Wrong result main.query_cache_debug : MDEV-15281 - Query cache is disabled -main.range : Modified in 10.2.18 main.range_vs_index_merge_innodb : MDEV-15283 - Server has gone away -main.selectivity : Modified in 10.2.18 main.set_statement : MDEV-13183 - Wrong result main.shm : MDEV-12727 - Mismatch, ERROR 2013 main.show_explain : MDEV-10674 - Wrong result code -main.sp : MDEV-7866 - Mismatch; modified in 10.2.18 +main.sp : MDEV-7866 - Mismatch main.sp_notembedded : MDEV-10607 - internal error -main.sp-security : MDEV-10607 - sporadic "can't connect"; modified in 10.2.18 +main.sp-security : MDEV-10607 - sporadic "can't connect" main.ssl : MDEV-17184 - Failures with OpenSSL 1.1.1 main.ssl_ca : MDEV-10895 - SSL connection error on Power main.ssl_cert_verify : MDEV-13735 - Server crash main.ssl_cipher : MDEV-17184 - Failures with OpenSSL 1.1.1 main.ssl_connect : MDEV-13492 - Unknown SSL error main.ssl_timeout : MDEV-11244 - Crash -main.stat_tables : Modified in 10.2.18 +main.stat_tables : Modified in 10.2.20 main.stat_tables_par : MDEV-13266 - Wrong result main.stat_tables_par_innodb : MDEV-14155 - Wrong rounding main.status : MDEV-13255 - Wrong result -main.subselect_extra_no_semijoin : Modified in 10.2.18 main.subselect_innodb : MDEV-10614 - Sporadic wrong results main.tc_heuristic_recover : MDEV-14189 - Wrong result main.type_blob : MDEV-15195 - Wrong result main.type_datetime : Modified in 10.2.19 main.type_datetime_hires : MDEV-10687 - Timeout -main.type_float : Modified in 10.2.18 -main.type_newdecimal : Modified in 10.2.19 +main.type_newdecimal : Modified in 10.2.20 main.type_year : Modified in 10.2.19 +main.udf : Modified in 10.2.20 main.userstat : MDEV-12904 - SSL errors -main.win : Modified in 10.2.19 -main.win_lead_lag : Modified in 10.2.18 +main.win : Modified in 10.2.20 main.win_percent_cume : Modified in 10.2.19 main.win_rank : Modified in 10.2.19 main.win_std : Modified in 10.2.19 @@ -179,7 +178,6 @@ binlog_encryption.rpl_typeconv : MDEV-14362 - Lost connection to MySQL serv connect.pivot : MDEV-14803 - Failed to discover table connect.vcol : MDEV-12374 - Fails on Windows -connect.xml2 : Modified in 10.2.18 connect.zip : MDEV-13884 - Wrong result #---------------------------------------------------------------- @@ -188,7 +186,7 @@ encryption.create_or_replace : MDEV-12694 - Timeout; MDEV-16 encryption.debug_key_management : MDEV-13841 - Timeout encryption.encrypt_and_grep : MDEV-13765 - Wrong result encryption.innochecksum : MDEV-13644 - Assertion failure -encryption.innodb-checksum-algorithm : MDEV-12898 - Deadlock of threads; MDEV-16896 - Server crash +encryption.innodb-checksum-algorithm : MDEV-12898 - Deadlock of threads; MDEV-16896 - Server crash; modified in 10.2.20 encryption.innodb-compressed-blob : MDEV-14728 - Unable to get certificate encryption.innodb_encrypt_log : MDEV-13725 - Wrong result encryption.innodb_encryption : MDEV-15675 - Timeout @@ -198,7 +196,7 @@ encryption.innodb_encryption-page-compression : MDEV-12630 - crash or asserti encryption.innodb_encryption_row_compressed : MDEV-16113 - Crash encryption.innodb_first_page : MDEV-10689 - Crash encryption.innodb-first-page-read : MDEV-14356 - Timeout in wait condition -encryption.innodb-force-corrupt : MDEV-17286 - SSL error +encryption.innodb-force-corrupt : MDEV-17286 - SSL error; modified in 10.2.20 encryption.innodb_lotoftables : MDEV-16111 - Wrong result encryption.innodb_onlinealter_encryption : MDEV-17287 - SIGABRT on server restart encryption.innodb-page_encryption : MDEV-10641 - mutex problem @@ -258,14 +256,15 @@ heap.heap_btree : Modified in 10.2.19 innodb.101_compatibility : MDEV-13891 - Wrong result innodb.alter_copy : MDEV-16181 - Assertion failure; modified in 10.2.19 innodb.alter_crash : MDEV-16944 - The process cannot access the file; modified in 10.2.19 -innodb.alter_inplace_perfschema : Added in 10.2.19 +innodb.alter_inplace_perfschema : MDEV-17748 - Wrong result; added in 10.2.19 innodb.alter_kill : Modified in 10.2.19 innodb.auto_increment_dup : Modified in 10.2.19 innodb.autoinc_persist : MDEV-15282 - Assertion failure innodb.binlog_consistent : MDEV-10618 - Server fails to start +innodb.data_types : Modified in 10.2.20 +innodb.default_row_format_create : Modified in 10.2.20 innodb.doublewrite : MDEV-12905 - Server crash innodb.drop_table_background : Modified in 10.2.19 -innodb.foreign-keys : Modified in 10.2.18 innodb.foreign_key : Modified in 10.2.19 innodb.group_commit_crash : MDEV-14191 - InnoDB registration failed innodb.group_commit_crash_no_optimize_thread : MDEV-13830 - Assertion failure @@ -285,10 +284,9 @@ innodb.innodb_bulk_create_index_replication : MDEV-15273 - Slave failed to start innodb.innodb_defrag_stats_many_tables : MDEV-14198 - Table is full innodb.innodb-fk : MDEV-13832 - Assertion failure on shutdown innodb.innodb-get-fk : MDEV-13276 - Server crash -innodb.innodb-index : Modified in 10.2.19 +innodb.innodb-index : Modified in 10.2.20 innodb.innodb-index-online : MDEV-14809 - Cannot save statistics innodb.innodb_information_schema : MDEV-8851 - Wrong result -innodb.innodb-lock : Modified in 10.2.18 innodb.innodb_max_recordsize_32k : MDEV-14801 - Operation failed innodb.innodb_max_recordsize_64k : MDEV-15203 - Wrong result innodb.innodb_monitor : MDEV-10939 - Testcase timeout @@ -300,8 +298,6 @@ innodb.innodb_stats_persistent_debug : MDEV-14801 - Operation failed innodb.innodb-table-online : MDEV-13894 - Wrong result innodb.innodb_sys_semaphore_waits : MDEV-10331 - Semaphore wait innodb.innodb-wl5522-debug : MDEV-14200 - Wrong errno -innodb.innodb_zip_innochecksum2 : MDEV-13882 - Extra warnings -innodb.innodb_zip_innochecksum3 : MDEV-14486 - Resource temporarily unavailable innodb.log_corruption : MDEV-13251 - Wrong result innodb.log_data_file_size : MDEV-14204 - Server failed to start innodb.log_file_name : MDEV-14193 - Exception @@ -315,10 +311,10 @@ innodb.recovery_shutdown : MDEV-15671 - Checksum mismatch in datafi innodb.rename_table_debug : Added in 10.2.19 innodb.row_format_redundant : MDEV-15192 - Trying to access missing tablespace innodb.table_definition_cache_debug : MDEV-14206 - Extra warning -innodb.table_flags : MDEV-13572 - Wrong result; modified in 10.2.19 +innodb.table_flags : MDEV-13572 - Wrong result; modified in 10.2.20 innodb.temp_table_savepoint : MDEV-16182 - Wrong result innodb.temporary_table : MDEV-13265 - Wrong result -innodb.truncate : Added in 10.2.19 +innodb.truncate : Modified in 10.2.20 innodb.truncate_crash : Added in 10.2.19 innodb.truncate_debug : Opt file added in 10.2.19 innodb.truncate_foreign : Added in 10.2.19 @@ -332,7 +328,7 @@ innodb.undo_truncate_recover : MDEV-17679 - MySQL server has gone away; innodb.xa_recovery : MDEV-15279 - mysqld got exception innodb_fts.crash_recovery : Modified in 10.2.19 -innodb_fts.fts_kill_query : Modified in 10.0.37 +innodb_fts.create : Modified in 10.2.20 innodb_fts.innodb-fts-fic : MDEV-14154 - Assertion failure innodb_fts.innodb_fts_misc_debug : MDEV-14156 - Unexpected warning innodb_fts.innodb_fts_plugin : MDEV-13888 - Errors in server log @@ -348,6 +344,7 @@ innodb_gis.rtree_undo : MDEV-14456 - Timeout in include file innodb_gis.types : MDEV-15679 - Table is marked as crashed innodb_zip.cmp_per_index : MDEV-14490 - Table is marked as crashed +innodb_zip.innochecksum : Modified in 10.2.20 innodb_zip.innochecksum_3 : MDEV-13279 - Extra warnings innodb_zip.restart : Opt file modified in 10.2.19 innodb_zip.wl6470_1 : MDEV-14240 - Assertion failure @@ -361,39 +358,30 @@ innodb_zip.wl6501_scale_1 : MDEV-13254 - Timeout, MDEV-14104 - Error #---------------------------------------------------------------- -maria.concurrent : Added in 10.2.18 -maria.create : Added in 10.2.18 maria.fulltext2 : Added in 10.2.19 maria.insert_select : MDEV-12757 - Timeout maria.insert_select-7314 : MDEV-16492 - Timeout -maria.maria : MDEV-14430 - Extra warning; modified in 10.2.18 +maria.maria : MDEV-14430 - Extra warning #---------------------------------------------------------------- -mariabackup.absolute_ibdata_paths : Opt file modified in 10.2.18 +mariabackup.absolute_ibdata_paths : MDEV-14192 - Assertion failure mariabackup.apply-log-only : MDEV-14192 - Assertion failure mariabackup.apply-log-only-incr : MDEV-14192 - Assertion failure +mariabackup.backup_grants : Added in 10.2.20 mariabackup.backup_ssl : MDEV-14192 - Assertion failure -mariabackup.create_during_backup : Added in 10.2.18 -mariabackup.create_with_data_directory_during_backup : Added in 10.2.18 mariabackup.data_directory : MDEV-15270 - Error on exec -mariabackup.drop_table_during_backup : Added in 10.2.18 +mariabackup.encrypted_page_compressed : Added in 10.2.20 +mariabackup.encrypted_page_corruption : Added in 10.2.20 +mariabackup.unencrypted_page_compressed : Added in 10.2.20 mariabackup.full_backup : MDEV-16571 - Wrong result mariabackup.huge_lsn : MDEV-15662 - Sequence number is in the future mariabackup.incremental_backup : MDEV-14192 - Assertion failure -mariabackup.incremental_ddl_during_backup : Added in 10.2.18 mariabackup.incremental_encrypted : MDEV-15667 - Timeout; MDEV-14192 - Assertion failure mariabackup.mdev-14447 : MDEV-15201 - Timeout -mariabackup.mlog_index_load : Added in 10.2.18 -mariabackup.nolock_ddl_during_backup_end : Added in 10.2.18 mariabackup.partial_exclude : MDEV-15270 - Error on exec -mariabackup.recreate_table_during_backup : Added in 10.2.18 -mariabackup.rename_during_backup : MDEV-14192 - Assertion failure; Added in 10.2.18 -mariabackup.rename_during_mdl_lock : Modified in 10.2.18 -mariabackup.skip_innodb : Added in 10.2.18 +mariabackup.rename_during_backup : MDEV-14192 - Assertion failure mariabackup.truncate_during_backup : Modified in 10.2.19 -mariabackup.undo_space_id : Opt file modified in 10.2.18 -mariabackup.unsupported_redo : Modified in 10.2.18 mariabackup.xbstream : MDEV-14192 - Crash mariabackup.xb_page_compress : MDEV-14810 - status: 1, errno: 11 mariabackup.xb_partition : MDEV-14192 - Assertion failure; MDEV-17584 - Crash on shutdown @@ -430,8 +418,6 @@ parts.partition_debug_innodb : MDEV-10891 - Can't create UNIX socket; MD parts.partition_exch_qa_10 : MDEV-11765 - wrong result parts.partition_innodb_status_file : MDEV-12901 - Valgrind parts.partition_special_innodb : MDEV-16942 - Timeout -parts.show_create : Modified in 10.2.18 -parts.update_and_cache : Added in 10.2.18 #---------------------------------------------------------------- @@ -444,6 +430,7 @@ perfschema.bad_option_3 : MDEV-12728 - Timeout on Power perfschema.bad_option_5 : MDEV-14197 - Timeout perfschema.connect_attrs : MDEV-17283 - Wrong result perfschema.dml_file_instances : MDEV-15179 - Wrong result +perfschema.dml_threads : MDEV-17746 - Wrong errno perfschema.func_file_io : MDEV-5708 - fails for s390x perfschema.func_mutex : MDEV-5708 - fails for s390x perfschema.hostcache_ipv4_addrinfo_again_allow : MDEV-12759 - Crash @@ -452,7 +439,7 @@ perfschema.hostcache_ipv6_addrinfo_bad_allow : MDEV-13260 - Crash perfschema.hostcache_ipv6_ssl : MDEV-10696 - Crash perfschema.privilege_table_io : MDEV-13184 - Extra lines perfschema.rpl_gtid_func : MDEV-16897 - Wrong result -perfschema.socket_connect : MDEV-15677 - Wrong result +perfschema.socket_connect : Modified in 10.2.20 perfschema.socket_summary_by_event_name_func : MDEV-10622 - Wrong result perfschema.stage_mdl_global : MDEV-11803 - wrong result on slow builders perfschema.stage_mdl_procedure : MDEV-11545 - Missing row @@ -498,6 +485,7 @@ rocksdb.ttl_secondary_read_filtering : MDEV-16560 - Wrong result rocksdb.unique_check : MDEV-16576 - Wrong errno rocksdb.use_direct_reads_writes : MDEV-16646 - Server crash rocksdb.write_sync : MDEV-16965 - WRong result +rocksdb.xa : Added in 10.2.20 rocksdb_rpl.mdev12179 : MDEV-16632 - Server crash rocksdb_rpl.rpl_binlog_xid_count : MDEV-16644 - Server crash @@ -508,6 +496,7 @@ rocksdb_sys_vars.rocksdb_update_cf_options : MDEV-16955 - Bytes lost #---------------------------------------------------------------- roles.create_and_grant_role : MDEV-11772 - wrong result +roles.flush_roles-17898 : Added in 10.2.20 #---------------------------------------------------------------- @@ -526,7 +515,6 @@ rpl.rpl_domain_id_filter_restart : MDEV-10684 - Wrong result rpl.rpl_drop_db_fail : MDEV-16898 - Slave fails to start rpl.rpl_extra_col_master_innodb : MDEV-16570 - Extra warning rpl.rpl_extra_col_master_myisam : MDEV-14203 - Extra warning -rpl.rpl_foreign_key_innodb : Modified in 10.2.18 rpl.rpl_gtid_basic : MDEV-10681 - server startup problem rpl.rpl_gtid_crash : MDEV-9501 - Failed registering on master, MDEV-13643 - Lost connection rpl.rpl_gtid_delete_domain : MDEV-14463 - Timeout @@ -570,7 +558,6 @@ rpl.rpl_row_img_eng_noblob : MDEV-13875 - command "diff_files" failed rpl.rpl_row_index_choice : MDEV-15196 - Slave crash rpl.rpl_row_lcase_tblnames : Added in 10.2.19 rpl.rpl_row_sp001 : MDEV-9329 - Fails on Ubuntu/s390x -rpl.rpl_row_spatial : Added in 10.2.18 rpl.rpl_semi_sync : MDEV-11220 - Wrong result rpl.rpl_semi_sync_after_sync : MDEV-14366 - Wrong result rpl.rpl_semi_sync_after_sync_row : MDEV-14366 - Wrong result @@ -593,6 +580,7 @@ rpl.rpl_stm_stop_middle_group : MDEV-13791 - Server crash rpl.rpl_sync : MDEV-13830 - Assertion failure rpl.rpl_temporal_mysql56_to_mariadb53 : MDEV-9501 - Failed registering on master rpl.rpl_temporary_error2 : MDEV-10634 - Wrong number of retries +rpl.rpl_trigger : MDEV-18055 - Wrong result rpl.rpl_typeconv : Include file modified in 10.2.19 rpl.sec_behind_master-5114 : MDEV-13878 - Wrong result @@ -629,6 +617,7 @@ stress.ddl_innodb : MDEV-10635 - Testcase timeout #---------------------------------------------------------------- +sys_vars.aria_used_for_temp_tables_basic : Modified in 10.2.20 sys_vars.autocommit_func2 : MDEV-9329 - Fails on Ubuntu/s390x sys_vars.delayed_insert_limit_func : MDEV-17683 - Wrong result; modified in 10.2.19 sys_vars.innodb_buffer_pool_dump_at_shutdown_basic : MDEV-14280 - Unexpected error @@ -640,14 +629,13 @@ sys_vars.log_slow_admin_statements_func : MDEV-12235 - Server crash sys_vars.rpl_init_slave_func : MDEV-10149 - Test assertion sys_vars.slow_query_log_func : MDEV-14273 - Wrong result sys_vars.sql_low_priority_updates_func : Modified in 10.2.19 +sys_vars.sysvars_aria : Modified in 10.2.20 sys_vars.thread_cache_size_func : MDEV-11775 - Wrong result +sys_vars.tmp_disk_table_size_func : Modified in 10.2.20 sys_vars.wait_timeout_func : MDEV-12896 - Wrong result -sys_vars.wsrep_start_position_basic : Modified in 10.2.18 #---------------------------------------------------------------- -tokudb.* : suite.pm and multiple modifications in 10.2.18 - tokudb.change_column_all_1000_10 : MDEV-12640 - Lost connection tokudb.change_column_bin : MDEV-12640 - Lost connection tokudb.change_column_char : MDEV-12822 - Lost connection @@ -672,8 +660,6 @@ tokudb.type_datetime : MDEV-15193 - Wrong result tokudb_alter_table.hcad_all_add2 : MDEV-15269 - Timeout -tokudb_bugs.PS-3773 : Added in 10.0.37 -tokudb_bugs.alter_table_comment_rebuild_data : Added in 10.0.37 tokudb_bugs.checkpoint_lock : MDEV-10637 - Wrong processlist output tokudb_bugs.checkpoint_lock_3 : MDEV-10637 - Wrong processlist output tokudb_bugs.frm_store : MDEV-12823 - Valgrind @@ -695,15 +681,13 @@ rpl-tokudb.* : MDEV-14354 - Tests fail with tcmalloc unit.conc_basic-t : MDEV-15286 - not ok 7 - test_reconnect_maxpackage unit.conc_misc : MDEV-14811 - not ok 12 - test_conc49 unit.conc_ps_bugs : MDEV-13252 - not ok 44 test_bug4236 -unit.lf : MDEV-12897 - Unexpected return code unit.ma_test_loghandler : MDEV-10638 - record read not ok -unit.my_atomic : MDEV-15670 - Signal 11 thrown #---------------------------------------------------------------- -vcol.index : Modified in 10.2.18 vcol.not_supported : MDEV-10639 - Testcase timeout vcol.races : Added in 10.2.19 +vcol.upgrade : Modified in 10.2.20 vcol.vcol_keys_innodb : MDEV-10639 - Testcase timeout vcol.vcol_misc : MDEV-16651 - Wrong error message From 975f4a1295f2b678c5ecea2cf4cfc69e177d88f5 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 21 Dec 2018 19:44:43 +0100 Subject: [PATCH 42/58] Add forgotten .opt file. --- mysql-test/suite/mariabackup/partition_partial.opt | 1 + 1 file changed, 1 insertion(+) create mode 100644 mysql-test/suite/mariabackup/partition_partial.opt diff --git a/mysql-test/suite/mariabackup/partition_partial.opt b/mysql-test/suite/mariabackup/partition_partial.opt new file mode 100644 index 00000000000..508cf185695 --- /dev/null +++ b/mysql-test/suite/mariabackup/partition_partial.opt @@ -0,0 +1 @@ +--innodb --loose-partition From 9ad1663f785d28a731ab8212ea62b8125282a27f Mon Sep 17 00:00:00 2001 From: Rakshit Kumar <32777813+rakshitkumarcse@users.noreply.github.com> Date: Sat, 22 Dec 2018 15:04:50 +0530 Subject: [PATCH 43/58] Grammatical errors of README-wsrep fixed. (#915) Docs grammar fixed --- Docs/README-wsrep | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Docs/README-wsrep b/Docs/README-wsrep index 422ec52f48a..2058e1eb14d 100644 --- a/Docs/README-wsrep +++ b/Docs/README-wsrep @@ -60,7 +60,7 @@ CONTENTS: Wsrep API developed by Codership Oy is a modern generic (database-agnostic) replication API for transactional databases with a goal to make database replication/logging subsystem completely modular and pluggable. It is developed -with flexibility and completeness in mind to satisfy broad range of modern +with flexibility and completeness in mind to satisfy a broad range of modern replication scenarios. It is equally suitable for synchronous and asynchronous, master-slave and multi-master replication. @@ -87,7 +87,7 @@ Upgrade from mysql-server-5.0 to mysql-wsrep is not supported yet, please upgrade to mysql-server-5.1 first. If you're installing over an existing mysql installation, mysql-server-wsrep -will conflict with mysql-server-5.1 package, so remove it first: +will conflict with the mysql-server-5.1 package, so remove it first: $ sudo apt-get remove mysql-server-5.1 mysql-server-core-5.1 @@ -105,7 +105,7 @@ For example, installation of required packages on Debian Lenny: $ sudo apt-get install psmisc $ sudo apt-get -t lenny-backports install mysql-client-5.1 -Now you should be able to install mysql-wsrep package: +Now you should be able to install the mysql-wsrep package: $ sudo dpkg -i @@ -150,7 +150,7 @@ and can be ignored unless specific functionality is needed. 3. FIRST TIME SETUP Unless you're upgrading an already installed mysql-wsrep package, you will need -to set up a few things to prepare server for operation. +to set up a few things to prepare the server for operation. 3.1 CONFIGURATION FILES @@ -162,7 +162,7 @@ to set up a few things to prepare server for operation. * Make sure system-wide my.cnf contains "!includedir /etc/mysql/conf.d/" line. * Edit /etc/mysql/conf.d/wsrep.cnf and set wsrep_provider option by specifying - a path to provider library. If you don't have a provider, leave it as it is. + a path to the provider library. If you don't have a provider, leave it as it is. * When a new node joins the cluster it'll have to receive a state snapshot from one of the peers. This requires a privileged MySQL account with access from @@ -267,7 +267,7 @@ innodb_autoinc_lock_mode=2 This is a required parameter. Without it INSERTs into tables with AUTO_INCREMENT column may fail. autoinc lock modes 0 and 1 can cause unresolved deadlock, and make - system unresponsive. + the system unresponsive. innodb_locks_unsafe_for_binlog=1 This option is required for parallel applying. @@ -299,14 +299,14 @@ wsrep_node_address= results (multiple network interfaces, NAT, etc.) If not explicitly overridden by wsrep_sst_receive_address, the
part will be used to listen for SST (see below). And the whole
[:port] - will be passed to wsrep provider to be used as a base address in its + will be passed to the wsrep provider to be used as a base address in its communications. wsrep_node_name= Human readable node name (for easier log reading only). Defaults to hostname. wsrep_slave_threads=1 - Number of threads dedicated to processing of writesets from other nodes. + The number of threads dedicated to the processing of writesets from other nodes. For best performance should be few per CPU core. wsrep_dbug_option @@ -326,7 +326,7 @@ wsrep_convert_LOCK_to_trx=0 wsrep_retry_autocommit=1 Retry autocommit queries and single statement transactions should they fail certification test. This is analogous to rescheduling an autocommit query - should it go into deadlock with other transactions in the database lock + should it go into a deadlock with other transactions in the database lock manager. wsrep_auto_increment_control=1 @@ -357,7 +357,7 @@ wsrep_OSU_method=TOI is not replicating and may be unable to process replication events (due to table lock). Once DDL operation is complete, the node will catch up and sync with the cluster to become fully operational again. The DDL statement or - its effects are not replicated, so it is user's responsibility to manually + its effects are not replicated, so it is the user's responsibility to manually perform this operation on each of the nodes. wsrep_forced_binlog_format=none @@ -366,7 +366,7 @@ wsrep_forced_binlog_format=none format, regardless of what the client session has specified in binlog_format. Valid choices for wsrep_forced_binlog_format are: ROW, STATEMENT, MIXED and special value NONE, meaning that there is no forced binlog format in effect. - This variable was intruduced to support STATEMENT format replication during + This variable was introduced to support STATEMENT format replication during rolling schema upgrade processing. However, in most cases ROW replication is valid for asymmetrict schema replication. @@ -412,8 +412,8 @@ wsrep_sst_auth= wsrep_sst_donor= A name of the node which should serve as state snapshot donor. This allows - to control which node will serve state snapshot request. By default the - most suitable node is chosen by wsrep provider. This is the same as given in + controlling which node will serve the state snapshot request. By default the + most suitable node is chosen by the wsrep provider. This is the same as given in wsrep_node_name. @@ -423,7 +423,7 @@ wsrep_sst_donor= for the database. They change the database structure and are non- transactional. - Release 22.3 brings a new method for performing schema upgrades. User can + Release 22.3 brings a new method for performing schema upgrades. A user can now choose whether to use the traditional total order isolation or new rolling schema upgrade method. The OSU method choice is done by global parameter: 'wsrep_OSU_method'. @@ -439,7 +439,7 @@ wsrep_sst_donor= 6.2 Rolling Schema Upgrade (RSU) - Rolling schema upgrade is new DDL processing method, where DDL will be + Rolling schema upgrade is a new DDL processing method, where DDL will be processed locally for the node. The node is disconnected of the replication for the duration of the DDL processing, so that there is only DDL statement processing in the node and it does not block the rest of the cluster. When @@ -468,7 +468,7 @@ wsrep_sst_donor= * LOCK/UNLOCK TABLES cannot be supported in multi-master setups. * lock functions (GET_LOCK(), RELEASE_LOCK()... ) -4) Query log cannot be directed to table. If you enable query logging, +4) Query log cannot be directed to a table. If you enable query logging, you must forward the log to a file: log_output = FILE Use general_log and general_log_file to choose query logging and the @@ -480,7 +480,7 @@ wsrep_sst_donor= 6) Due to cluster level optimistic concurrency control, transaction issuing COMMIT may still be aborted at that stage. There can be two transactions. writing to same rows and committing in separate cluster nodes, and only one - of the them can successfully commit. The failing one will be aborted. + of them can successfully commit. The failing one will be aborted. For cluster level aborts, MySQL/galera cluster gives back deadlock error. code (Error: 1213 SQLSTATE: 40001 (ER_LOCK_DEADLOCK)). From 835f49d9ce11ba5166da15409f7f75dcf7b5252d Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Mon, 24 Dec 2018 09:22:55 -0500 Subject: [PATCH 44/58] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0ecdac30b5d..c7d57913442 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=2 -MYSQL_VERSION_PATCH=20 +MYSQL_VERSION_PATCH=21 From 734029fa7960d54d9c50adfca4ac6739a4ea0347 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Wed, 26 Dec 2018 00:00:49 +0300 Subject: [PATCH 45/58] Fix a trivial (and harmless) merge error --- storage/rocksdb/ha_rocksdb.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc index 4a1f19f45de..a6689f7707f 100644 --- a/storage/rocksdb/ha_rocksdb.cc +++ b/storage/rocksdb/ha_rocksdb.cc @@ -3770,7 +3770,6 @@ static int rocksdb_commit(handlerton* hton, THD* thd, bool commit_tx) We get here when committing a statement within a transaction. */ tx->make_stmt_savepoint_permanent(); - tx->make_stmt_savepoint_permanent(); } if (my_core::thd_tx_isolation(thd) <= ISO_READ_COMMITTED) { From b74eb5a5feb41164f7e5cab986cf203537c2128a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Dec 2018 12:28:16 +0200 Subject: [PATCH 46/58] row_drop_table_for_mysql(): Correct a parameter to innobase_format_name() This fixes a regression that was introduced in MySQL 5.6.6 in an error handling code path, in the following change: commit 024f363d6b5f09b20d1bba411af55be95c7398d3 Author: kevin.lewis@oracle.com <> Date: Fri Jun 15 09:01:42 2012 -0500 Bug #14169459 INNODB; DROP TABLE DOES NOT DELETE THE IBD FILE FOR A TEMPORARY TABLE. --- storage/innobase/row/row0mysql.cc | 3 ++- storage/xtradb/row/row0mysql.cc | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index d9e18a99201..68329658618 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4323,7 +4323,8 @@ do_drop: char msg_tablename[MAX_FULL_NAME_LEN + 1]; innobase_format_name( - msg_tablename, sizeof(tablename), + msg_tablename, + sizeof msg_tablename, tablename, FALSE); ib_logf(IB_LOG_LEVEL_INFO, diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index cb6e6bbcb1f..e828d8a8611 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -4347,7 +4347,8 @@ do_drop: char msg_tablename[MAX_FULL_NAME_LEN + 1]; innobase_format_name( - msg_tablename, sizeof(tablename), + msg_tablename, + sizeof msg_tablename, tablename, FALSE); ib_logf(IB_LOG_LEVEL_INFO, From c5a5eaa9a996015517c1ebbce19551c6e650cba1 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Fri, 14 Dec 2018 01:28:55 +0300 Subject: [PATCH 47/58] MDEV-17470 Orphan temporary files after interrupted ALTER cause InnoDB: Operating system error number 17 and eventual fatal error 71 Orphan #sql* tables may remain after ALTER TABLE was interrupted by timeout or KILL or client disconnect. This is a regression caused by MDEV-16515. Similar to temporary tables (MDEV-16647), we had better ignore the KILL when dropping the original table in the final part of ALTER TABLE. Closes #1020 --- .../suite/innodb/r/innodb-alter-debug.result | 21 ++++++++++++++ .../suite/innodb/t/innodb-alter-debug.test | 28 +++++++++++++++++++ storage/innobase/row/row0mysql.cc | 5 ++-- storage/xtradb/row/row0mysql.cc | 5 ++-- 4 files changed, 55 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result index d888fb5b034..5ce93b96c77 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-debug.result +++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result @@ -68,3 +68,24 @@ SET DEBUG_SYNC = 'now SIGNAL S2'; ERROR 23000: Duplicate entry '1' for key 'a' SET DEBUG_SYNC='RESET'; DROP TABLE t1; +# +# MDEV-17470 Orphan temporary files after interrupted ALTER +# cause InnoDB: Operating system error number 17 and eventual +# fatal error 71 +# +CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8); +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +LOCK TABLE t1 READ; +SET max_statement_time= 1; +ALTER TABLE t1 FORCE, ALGORITHM=COPY; +ERROR 70100: Query execution was interrupted (max_statement_time exceeded) +SET DEBUG_SYNC = 'now SIGNAL stop_waining'; +SET DEBUG_SYNC = 'now WAIT_FOR stop_waining'; +UNLOCK TABLES; +DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test index bc4b2ad8e56..d32faf39aad 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-debug.test +++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test @@ -100,3 +100,31 @@ DROP TABLE t1; # Wait till all disconnects are completed --source include/wait_until_count_sessions.inc + +--echo # +--echo # MDEV-17470 Orphan temporary files after interrupted ALTER +--echo # cause InnoDB: Operating system error number 17 and eventual +--echo # fatal error 71 +--echo # +CREATE TABLE t1 (pk INT AUTO_INCREMENT PRIMARY KEY, i INT) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL,1),(NULL,2),(NULL,3),(NULL,4),(NULL,5),(NULL,6),(NULL,7),(NULL,8); +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; +INSERT INTO t1 SELECT NULL, i FROM t1; + +LOCK TABLE t1 READ; + +--connect (con1,localhost,root,,test) +SET max_statement_time= 1; +--error ER_STATEMENT_TIMEOUT +ALTER TABLE t1 FORCE, ALGORITHM=COPY; +SET DEBUG_SYNC = 'now SIGNAL stop_waining'; +--disconnect con1 + +--connection default +SET DEBUG_SYNC = 'now WAIT_FOR stop_waining'; +UNLOCK TABLES; +DROP TABLE t1; +SET DEBUG_SYNC = 'RESET'; diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index bb815de3138..6ec45c591eb 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4224,9 +4224,10 @@ row_drop_table_for_mysql( calling btr_search_drop_page_hash_index() while we hold the InnoDB dictionary lock, we will drop any adaptive hash index entries upfront. */ + const bool is_temp = dict_table_is_temporary(table) + || strstr(tablename_minus_db, tmp_file_prefix); while (buf_LRU_drop_page_hash_for_tablespace(table)) { - if ((!dict_table_is_temporary(table) - && trx_is_interrupted(trx)) + if ((!is_temp && trx_is_interrupted(trx)) || srv_shutdown_state != SRV_SHUTDOWN_NONE) { err = DB_INTERRUPTED; goto funct_exit; diff --git a/storage/xtradb/row/row0mysql.cc b/storage/xtradb/row/row0mysql.cc index 88ebe24f3bb..a5381df1995 100644 --- a/storage/xtradb/row/row0mysql.cc +++ b/storage/xtradb/row/row0mysql.cc @@ -4234,9 +4234,10 @@ row_drop_table_for_mysql( calling btr_search_drop_page_hash_index() while we hold the InnoDB dictionary lock, we will drop any adaptive hash index entries upfront. */ + const bool is_temp = dict_table_is_temporary(table) + || strstr(tablename_minus_db, tmp_file_prefix); while (buf_LRU_drop_page_hash_for_tablespace(table)) { - if ((!dict_table_is_temporary(table) - && trx_is_interrupted(trx)) + if ((!is_temp && trx_is_interrupted(trx)) || srv_shutdown_state != SRV_SHUTDOWN_NONE) { err = DB_INTERRUPTED; goto funct_exit; From ed66acb291eb698530b20e82667e1b6c450c7cfc Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Sat, 29 Dec 2018 02:06:19 +0100 Subject: [PATCH 48/58] Silence LeakSanitizer by default in mariabackup, so that phanthom "leaks" would not hide more interesting information, like invalid memory accesses. some "leaks" are expected - partly this is due to weird options parsing, that runs twice, and does not free memory after the first run. - also we do not mind to exit() whenever it makes sense, without full cleanup. --- extra/mariabackup/xtrabackup.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index d2b241a28f5..df8e1e245fc 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -6844,3 +6844,12 @@ int main(int argc, char **argv) exit(EXIT_SUCCESS); } + + +#if defined (__SANITIZE_ADDRESS__) && defined (__linux__) +/* Avoid LeakSanitizer's false positives. */ +const char* __asan_default_options() +{ + return "detect_leaks=0"; +} +#endif From 68143c8905352361c30595864a90f494d9a3d99f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 29 Dec 2018 10:57:26 +0200 Subject: [PATCH 49/58] MDEV-17470: Fix the test for --embedded --- .../suite/innodb/r/innodb-alter-debug.result | 7 ++---- .../suite/innodb/t/innodb-alter-debug.test | 24 +++++++++++-------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-debug.result b/mysql-test/suite/innodb/r/innodb-alter-debug.result index 5ce93b96c77..fa6670e6fb3 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-debug.result +++ b/mysql-test/suite/innodb/r/innodb-alter-debug.result @@ -81,11 +81,8 @@ INSERT INTO t1 SELECT NULL, i FROM t1; INSERT INTO t1 SELECT NULL, i FROM t1; INSERT INTO t1 SELECT NULL, i FROM t1; LOCK TABLE t1 READ; -SET max_statement_time= 1; ALTER TABLE t1 FORCE, ALGORITHM=COPY; -ERROR 70100: Query execution was interrupted (max_statement_time exceeded) -SET DEBUG_SYNC = 'now SIGNAL stop_waining'; -SET DEBUG_SYNC = 'now WAIT_FOR stop_waining'; +kill query @id; +ERROR 70100: Query execution was interrupted UNLOCK TABLES; DROP TABLE t1; -SET DEBUG_SYNC = 'RESET'; diff --git a/mysql-test/suite/innodb/t/innodb-alter-debug.test b/mysql-test/suite/innodb/t/innodb-alter-debug.test index d32faf39aad..3c457294884 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-debug.test +++ b/mysql-test/suite/innodb/t/innodb-alter-debug.test @@ -98,9 +98,6 @@ SET DEBUG_SYNC='RESET'; DROP TABLE t1; -# Wait till all disconnects are completed ---source include/wait_until_count_sessions.inc - --echo # --echo # MDEV-17470 Orphan temporary files after interrupted ALTER --echo # cause InnoDB: Operating system error number 17 and eventual @@ -117,14 +114,21 @@ INSERT INTO t1 SELECT NULL, i FROM t1; LOCK TABLE t1 READ; --connect (con1,localhost,root,,test) -SET max_statement_time= 1; ---error ER_STATEMENT_TIMEOUT -ALTER TABLE t1 FORCE, ALGORITHM=COPY; -SET DEBUG_SYNC = 'now SIGNAL stop_waining'; ---disconnect con1 +let $ID= `SELECT @id := CONNECTION_ID()`; +send ALTER TABLE t1 FORCE, ALGORITHM=COPY; --connection default -SET DEBUG_SYNC = 'now WAIT_FOR stop_waining'; +let $wait_condition= select 1 from information_schema.processlist where state='Waiting for table metadata lock'; +source include/wait_condition.inc; +let $ignore= `SELECT @id := $ID`; +kill query @id; +--connection con1 +--error ER_QUERY_INTERRUPTED +reap; +--disconnect con1 +--connection default UNLOCK TABLES; DROP TABLE t1; -SET DEBUG_SYNC = 'RESET'; + +# Wait till all disconnects are completed +--source include/wait_until_count_sessions.inc From 802ce9672ff630bbef08235e0e39bf599075f985 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Sat, 29 Dec 2018 20:44:40 +0300 Subject: [PATCH 50/58] MDEV-18041 Database corruption after renaming a prefix-indexed column This is a regression after MDEV-13671. The bug is related to key part prefix lengths wich are stored in SYS_FIELDS. Storage format is not obvious and was handled incorrectly which led to data dictionary corruption. SYS_FIELDS.POS actually contains prefix length too in case if any key part has prefix length. innobase_rename_column_try(): fixed prefixes handling Tests for prefixed indexes added too. Closes #1063 --- mysql-test/suite/innodb/r/innodb-alter.result | 21 ++++++++++++ mysql-test/suite/innodb/t/innodb-alter.test | 13 ++++++++ storage/innobase/handler/handler0alter.cc | 32 +++++++++++-------- storage/xtradb/handler/handler0alter.cc | 32 +++++++++++-------- 4 files changed, 70 insertions(+), 28 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter.result b/mysql-test/suite/innodb/r/innodb-alter.result index 2f9b832328b..57638a84517 100644 --- a/mysql-test/suite/innodb/r/innodb-alter.result +++ b/mysql-test/suite/innodb/r/innodb-alter.result @@ -865,6 +865,27 @@ WHERE T.NAME='test/t1'; NAME a DROP TABLE t1; +# and an MDEV-18041 regression related to indexes prefixes +create table `test` ( +`test_old` varchar(255) NOT NULL, +`other` varchar(255) NOT NULL, +PRIMARY KEY (`test_old`,`other`), +UNIQUE KEY uk (`test_old`(100), `other`) +) ENGINE=InnoDB; +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +name pos +test_old 0 +other 1 +test_old 0 +other 1 +alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL; +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +name pos +test_new 0 +other 1 +test_new 0 +other 1 +drop table `test`; # # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN # DICT_MEM_TABLE_COL_RENAME_LOW diff --git a/mysql-test/suite/innodb/t/innodb-alter.test b/mysql-test/suite/innodb/t/innodb-alter.test index 30e3292ec10..a47573626aa 100644 --- a/mysql-test/suite/innodb/t/innodb-alter.test +++ b/mysql-test/suite/innodb/t/innodb-alter.test @@ -522,6 +522,19 @@ SELECT C.NAME FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS C INNER JOIN WHERE T.NAME='test/t1'; DROP TABLE t1; +--echo # and an MDEV-18041 regression related to indexes prefixes +create table `test` ( + `test_old` varchar(255) NOT NULL, + `other` varchar(255) NOT NULL, + PRIMARY KEY (`test_old`,`other`), + UNIQUE KEY uk (`test_old`(100), `other`) +) ENGINE=InnoDB; + +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +alter table `test` CHANGE COLUMN `test_old` `test_new` varchar(255) NOT NULL; +select name, pos from information_schema.innodb_SYS_FIELDS where name in ('test_old', 'other', 'test_new'); +drop table `test`; + --echo # --echo # BUG 20029625 - HANDLE_FATAL_SIGNAL (SIG=11) IN diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 6d9255a628e..8fbdf6c6884 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4533,36 +4533,40 @@ err_exit: index != NULL; index = dict_table_get_next_index(index)) { + bool has_prefixes = false; + for (size_t i = 0; i < dict_index_get_n_fields(index); i++) { + if (dict_index_get_nth_field(index, i)->prefix_len) { + has_prefixes = true; + break; + } + } + for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (my_strcasecmp( - system_charset_info, - dict_index_get_nth_field(index, i)->name, - from)) { + const dict_field_t* field + = dict_index_get_nth_field(index, i); + if (my_strcasecmp(system_charset_info, field->name, + from)) { continue; } info = pars_info_create(); + int pos = i; + if (has_prefixes) { + pos = (pos << 16) + field->prefix_len; + } + pars_info_add_ull_literal(info, "indexid", index->id); - pars_info_add_int4_literal(info, "nth", i); + pars_info_add_int4_literal(info, "nth", pos); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( info, "PROCEDURE RENAME_SYS_FIELDS_PROC () IS\n" "BEGIN\n" - "UPDATE SYS_FIELDS SET COL_NAME=:new\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\n" - "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" - "END;\n", FALSE, trx); diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index 9508adbbd12..bdec9a076ac 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -4547,36 +4547,40 @@ err_exit: index != NULL; index = dict_table_get_next_index(index)) { + bool has_prefixes = false; + for (size_t i = 0; i < dict_index_get_n_fields(index); i++) { + if (dict_index_get_nth_field(index, i)->prefix_len) { + has_prefixes = true; + break; + } + } + for (ulint i = 0; i < dict_index_get_n_fields(index); i++) { - if (my_strcasecmp( - system_charset_info, - dict_index_get_nth_field(index, i)->name, - from)) { + const dict_field_t* field + = dict_index_get_nth_field(index, i); + if (my_strcasecmp(system_charset_info, field->name, + from)) { continue; } info = pars_info_create(); + int pos = i; + if (has_prefixes) { + pos = (pos << 16) + field->prefix_len; + } + pars_info_add_ull_literal(info, "indexid", index->id); - pars_info_add_int4_literal(info, "nth", i); + pars_info_add_int4_literal(info, "nth", pos); pars_info_add_str_literal(info, "new", to); error = que_eval_sql( info, "PROCEDURE RENAME_SYS_FIELDS_PROC () IS\n" "BEGIN\n" - "UPDATE SYS_FIELDS SET COL_NAME=:new\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\n" - "AND POS>=65536*:nth AND POS<65536*(:nth+1);\n" - "END;\n", FALSE, trx); From 50c9469be821e1942a8a9c5f37132e1855c40c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 29 Dec 2018 22:59:20 +0200 Subject: [PATCH 51/58] MDEV-18105 Mariabackup fails to copy encrypted InnoDB system tablespace if LSN>4G This is a regression caused by commit 8c43f963882a9d5ac4e4289c8dd3dbcaeb40a0ce that was part of the MDEV-12112 fixes. page_is_corrupted(): Never interpret page_no=0 as encrypted. --- extra/mariabackup/fil_cur.cc | 13 ++++++++++--- mysql-test/suite/mariabackup/huge_lsn.opt | 4 ++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/extra/mariabackup/fil_cur.cc b/extra/mariabackup/fil_cur.cc index b4393f7ffdd..c370d521947 100644 --- a/extra/mariabackup/fil_cur.cc +++ b/extra/mariabackup/fil_cur.cc @@ -306,9 +306,16 @@ static bool page_is_corrupted(byte *page, ulint page_no, xb_fil_cur_t *cursor, f return false; } - /* Validate encrypted pages. */ - if (mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) && - (space->crypt_data && space->crypt_data->type!= CRYPT_SCHEME_UNENCRYPTED)) { + /* Validate encrypted pages. The first page is never encrypted. + In the system tablespace, the first page would be written with + FIL_PAGE_FILE_FLUSH_LSN at shutdown, and if the LSN exceeds + 4,294,967,295, the mach_read_from_4() below would wrongly + interpret the page as encrypted. We prevent that by checking + page_no first. */ + if (page_no + && mach_read_from_4(page + FIL_PAGE_FILE_FLUSH_LSN_OR_KEY_VERSION) + && space->crypt_data + && space->crypt_data->type != CRYPT_SCHEME_UNENCRYPTED) { if (!fil_space_verify_crypt_checksum(page, cursor->zip_size)) return true; diff --git a/mysql-test/suite/mariabackup/huge_lsn.opt b/mysql-test/suite/mariabackup/huge_lsn.opt index 74a6450a1ef..c65b76fb7d2 100644 --- a/mysql-test/suite/mariabackup/huge_lsn.opt +++ b/mysql-test/suite/mariabackup/huge_lsn.opt @@ -1,4 +1,8 @@ --innodb-encrypt-log=ON +--innodb-tablespaces-encryption +--innodb-encrypt-tables=ON +--innodb-encryption-rotate-key-age=1 +--innodb-encryption-threads=4 --plugin-load-add=$FILE_KEY_MANAGEMENT_SO --loose-file-key-management --loose-file-key-management-filekey=FILE:$MTR_SUITE_DIR/filekeys-data.key From 2450fd67ed403bb8a154925dd1ca500b23f5b3cc Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jan 2019 12:03:15 +0100 Subject: [PATCH 52/58] fix the test for 2019 --- mysql-test/r/mysqldump.result | 6 +++--- mysql-test/t/mysqldump.test | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/mysqldump.result b/mysql-test/r/mysqldump.result index 99b14189282..bb9bba01fdf 100644 --- a/mysql-test/r/mysqldump.result +++ b/mysql-test/r/mysqldump.result @@ -4317,12 +4317,12 @@ second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL E show create event ee1; Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation ee1 UTC CREATE DEFINER=`root`@`localhost` EVENT `ee1` ON SCHEDULE AT '2035-12-31 20:01:23' ON COMPLETION NOT PRESERVE ENABLE DO set @a=5 latin1 latin1_swedish_ci latin1_swedish_ci -create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5; +create event ee2 on schedule at '2030-12-31 21:01:22' do set @a=5; create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5; show events; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation second ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -second ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +second ee2 root@localhost UTC ONE TIME 2030-12-31 21:01:22 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci second ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci drop database second; create database third; @@ -4330,7 +4330,7 @@ use third; show events; Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation third ee1 root@localhost UTC ONE TIME 2035-12-31 20:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -third ee2 root@localhost UTC ONE TIME 2018-12-31 21:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci +third ee2 root@localhost UTC ONE TIME 2030-12-31 21:01:22 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci third ee3 root@localhost UTC ONE TIME 2030-12-31 22:01:23 NULL NULL NULL NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci drop database third; set time_zone = 'SYSTEM'; diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index cb12919a823..a8820f42541 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -1803,7 +1803,7 @@ show create event ee1; ## prove three works (with spaces and tabs on the end) # start with one from the previous restore -create event ee2 on schedule at '2018-12-31 21:01:23' do set @a=5; +create event ee2 on schedule at '2030-12-31 21:01:22' do set @a=5; create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5; show events; --exec $MYSQL_DUMP --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql From 32150d2513b2de1ff5b4ac3f4d9aa3470ae1c333 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jan 2019 19:28:48 +0100 Subject: [PATCH 53/58] compilation warning on Windows --- storage/innobase/handler/handler0alter.cc | 2 +- storage/xtradb/handler/handler0alter.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8fbdf6c6884..25019b8f964 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4551,7 +4551,7 @@ err_exit: info = pars_info_create(); - int pos = i; + ulint pos = i; if (has_prefixes) { pos = (pos << 16) + field->prefix_len; } diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc index bdec9a076ac..e932e2cbbdb 100644 --- a/storage/xtradb/handler/handler0alter.cc +++ b/storage/xtradb/handler/handler0alter.cc @@ -4565,7 +4565,7 @@ err_exit: info = pars_info_create(); - int pos = i; + ulint pos = i; if (has_prefixes) { pos = (pos << 16) + field->prefix_len; } From 884caeafbaea50f5380c21c844b4a65323b5eb11 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jan 2019 19:32:05 +0100 Subject: [PATCH 54/58] fix RHEL8 "ambiguous python shebang" build failures --- storage/tokudb/mysql-test/tokudb/t/change_column_bin.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_char.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py | 0 .../tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_int.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py | 0 .../tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py | 0 storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py | 0 10 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_bin.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_char.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_int.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py mode change 100755 => 100644 storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py b/storage/tokudb/mysql-test/tokudb/t/change_column_bin.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_bin_rename.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_binary.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_charbinary.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_char_rename.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_key.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_not_supported.py old mode 100755 new mode 100644 diff --git a/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py b/storage/tokudb/mysql-test/tokudb/t/change_column_int_rename.py old mode 100755 new mode 100644 From 099186d09eae20e6d656f556b90dc245d64013b0 Mon Sep 17 00:00:00 2001 From: Daniel Bartholomew Date: Wed, 2 Jan 2019 13:42:11 -0500 Subject: [PATCH 55/58] bump the VERSION --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index c7d57913442..976b857053d 100644 --- a/VERSION +++ b/VERSION @@ -1,3 +1,3 @@ MYSQL_VERSION_MAJOR=10 MYSQL_VERSION_MINOR=2 -MYSQL_VERSION_PATCH=21 +MYSQL_VERSION_PATCH=22 From 1f9f72b13e17a42540fd8ee7892faa52d6308a33 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jan 2019 16:34:15 +0100 Subject: [PATCH 56/58] fix debian builds for cosmic --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 47dd568e06d..edd11a99373 100644 --- a/debian/control +++ b/debian/control @@ -479,7 +479,7 @@ Description: OQGraph storage engine for MariaDB Package: mariadb-plugin-tokudb Architecture: any Depends: mariadb-server-10.2 (= ${binary:Version}), - libjemalloc1 (>= 3.0.0~), + libjemalloc1 (>= 3.0.0~) | libjemalloc2, ${misc:Depends}, ${shlibs:Depends} Breaks: mariadb-server-10.0, From cf8a564686666d9f69dc101fecba85a4ef6b0342 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jan 2019 19:29:58 +0100 Subject: [PATCH 57/58] compilation warning on windows --- storage/innobase/handler/ha_innodb.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 62924ab8fc5..611387d749b 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -7956,7 +7956,7 @@ ha_innobase::build_template( templ = build_template_field( m_prebuilt, clust_index, index, table, field, i - num_v, num_v); - ut_ad(templ->is_virtual == is_v); + ut_ad(templ->is_virtual == (ulint)is_v); if (is_v) { num_v++; @@ -8030,7 +8030,7 @@ no_icp: templ = build_template_field( m_prebuilt, clust_index, index, table, field, i - num_v, num_v); - ut_ad(templ->is_virtual == is_v); + ut_ad(templ->is_virtual == (ulint)is_v); if (is_v) { num_v++; } From 2f368bb967795de5b96f21ff9d12c847df86029f Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 2 Jan 2019 19:33:52 +0100 Subject: [PATCH 58/58] fix RHEL8 "ambiguous python shebang" build failures --- CMakeLists.txt | 1 + cmake/cpack_rpm.cmake | 2 ++ storage/rocksdb/CMakeLists.txt | 4 +++- storage/rocksdb/{myrocks_hotbackup => myrocks_hotbackup.py} | 2 +- 4 files changed, 7 insertions(+), 2 deletions(-) rename storage/rocksdb/{myrocks_hotbackup => myrocks_hotbackup.py} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 90fadcec839..d1d12869a70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -330,6 +330,7 @@ MYSQL_CHECK_SSL() MYSQL_CHECK_READLINE() SET(MALLOC_LIBRARY "system") +SET(PYTHON_SHEBANG "/usr/bin/env python") CHECK_PCRE() diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index b88d5634483..6bc0cc81ada 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -219,6 +219,8 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7") ALTERNATIVE_NAME("server" "mariadb-server") ALTERNATIVE_NAME("server" "mysql-compat-server") ALTERNATIVE_NAME("test" "mariadb-test") +ELSEIF(RPM MATCHES "(rhel|centos)8") + SET(PYTHON_SHEBANG "/usr/bin/python3") ENDIF() # workaround for lots of perl dependencies added by rpmbuild diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 2689dc7151c..acbab49c586 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -217,7 +217,9 @@ TARGET_LINK_LIBRARIES(sst_dump rocksdblib) MYSQL_ADD_EXECUTABLE(mysql_ldb tools/mysql_ldb.cc COMPONENT rocksdb-engine) TARGET_LINK_LIBRARIES(mysql_ldb rocksdb_tools rocksdb_aux_lib) -INSTALL_SCRIPT(myrocks_hotbackup COMPONENT rocksdb-engine) +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/myrocks_hotbackup.py + ${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup @ONLY) +INSTALL_SCRIPT(${CMAKE_CURRENT_BINARY_DIR}/myrocks_hotbackup COMPONENT rocksdb-engine) IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") SET_TARGET_PROPERTIES(rocksdb_tools sst_dump mysql_ldb PROPERTIES COMPILE_FLAGS -frtti) diff --git a/storage/rocksdb/myrocks_hotbackup b/storage/rocksdb/myrocks_hotbackup.py similarity index 99% rename from storage/rocksdb/myrocks_hotbackup rename to storage/rocksdb/myrocks_hotbackup.py index ef1e934f3fd..69c75b7cbfd 100755 --- a/storage/rocksdb/myrocks_hotbackup +++ b/storage/rocksdb/myrocks_hotbackup.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!@PYTHON_SHEBANG@ from __future__ import division from optparse import OptionParser