diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-10-04 07:41:35 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-10-04 07:41:35 +0200 |
commit | b6ebadaa66ee68b1880c0e10669543d1ba058c18 (patch) | |
tree | 75506bd02a8186a013b5eb16a425de0c1d96bc71 /storage | |
parent | 7d4b2b984779e695d0c233d11173b2965d25ef27 (diff) | |
parent | fe449affcf99fcf63f620994b544eb96d2504cda (diff) | |
download | mariadb-git-b6ebadaa66ee68b1880c0e10669543d1ba058c18.tar.gz |
Merge branch '10.6' into 10.7
Diffstat (limited to 'storage')
44 files changed, 315 insertions, 186 deletions
diff --git a/storage/connect/bsonudf.cpp b/storage/connect/bsonudf.cpp index acf723c3e22..1519ed473df 100644 --- a/storage/connect/bsonudf.cpp +++ b/storage/connect/bsonudf.cpp @@ -1147,7 +1147,7 @@ my_bool BJNX::LocateArray(PGLOBAL g, PBVAL jarp) for (int i = 0; i < n && !Found; i++) { Jp->N = m; - sprintf(s, "[%d]", i + B); + snprintf(s, sizeof(s), "[%d]", i + B); if (Jp->WriteStr(s)) return true; @@ -1441,7 +1441,7 @@ my_bool BJNX::AddPath(void) for (int i = 0; i <= I; i++) { if (Jpnp[i].Type == TYPE_JAR) { - sprintf(s, "[%d]", Jpnp[i].N + B); + snprintf(s, sizeof(s), "[%d]", Jpnp[i].N + B); if (Jp->WriteStr(s)) return true; diff --git a/storage/connect/global.h b/storage/connect/global.h index eb3d4106477..bc1585eba41 100644 --- a/storage/connect/global.h +++ b/storage/connect/global.h @@ -14,6 +14,8 @@ #include <time.h> /* time_t type declaration */ #include <setjmp.h> /* Long jump declarations */ +#define ROUNDUP_TO_8(num) (((num + 7) / 8) * 8) + #if defined(_WIN32) && !defined(NOEX) #define DllExport __declspec( dllexport ) #else // !_WIN32 diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 5ba64f3aa1f..6d180ac5441 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3070,6 +3070,8 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) if ((iscol= args[i]->type() == COND::FIELD_ITEM)) { const char *fnm; + char buf[MAX_FIELD_WIDTH]; + String strColumn(buf, sizeof(buf), system_charset_info); ha_field_option_struct *fop; Item_field *pField= (Item_field *)args[i]; @@ -3095,8 +3097,14 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) return NULL; } else { bool h; - fnm= filp->Chk(pField->field->field_name.str, &h); + if (tty == TYPE_AM_MYSQL && !(x || ismul)) + { + strColumn.length(0); + strColumn.qs_append(STRING_WITH_LEN("`")); + strColumn.qs_append(fnm, strlen(fnm)); + strColumn.append(STRING_WITH_LEN("`")); + } if (h && i && !ishav) return NULL; // Having should be col VOP arg @@ -3110,9 +3118,11 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond) htrc("Field name=%s\n", pField->field->field_name.str); htrc("Field type=%d\n", pField->field->type()); htrc("Field_type=%d\n", args[i]->field_type()); - } // endif trace - - strcat((ishav ? havg : body), fnm); + } // endif trace + if (tty == TYPE_AM_MYSQL && !(x || ismul)) + strcat((ishav ? havg : body), strColumn.ptr()); + else + strcat((ishav ? havg : body), fnm); } else if (args[i]->type() == COND::FUNC_ITEM) { if (tty == TYPE_AM_MYSQL) { if (!CheckCond(g, filp, args[i])) diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index 090f8343e1e..71ceb7974ba 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -555,3 +555,25 @@ public: #if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT) bool MongoEnabled(void); #endif // JAVA_SUPPORT || CMGO_SUPPORT + +/* This is a hack for ASAN + * Libraries such as libxml2 and libodbc do not like being unloaded before + * exit and will show as a leak in ASAN with no stack trace (as the plugin + * has been unloaded from memory). + * + * The below is designed to trick the compiler into adding a "UNIQUE" symbol + * which can be seen using: + * readelf -s storage/connect/ha_connect.so | grep UNIQUE + * + * Having this symbol means that the plugin remains in memory after dlclose() + * has been called. Thereby letting the libraries clean up properly. + */ +#if defined(__SANITIZE_ADDRESS__) +__attribute__((__used__)) +inline int dummy(void) +{ + static int d; + d++; + return d; +} +#endif diff --git a/storage/connect/jdbconn.cpp b/storage/connect/jdbconn.cpp index fc22b7033be..0ba1f56aa50 100644 --- a/storage/connect/jdbconn.cpp +++ b/storage/connect/jdbconn.cpp @@ -451,8 +451,14 @@ PQRYRES JDBCSrcCols(PGLOBAL g, PCSZ src, PJPARM sjp) if (strstr(src, "%s")) { // Place holder for an eventual where clause - sqry = (char*)PlugSubAlloc(g, NULL, strlen(src) + 2); - sprintf(sqry, src, "1=1"); // dummy where clause + size_t sqry_size = strlen(src) + 2; + sqry = (char*)PlugSubAlloc(g, NULL, sqry_size); + // Function PlugSubAlloc(...) recalculate string size + // while allocate memory - it rounds size up size to multiple of 8 + // we need to know the real allocated size + // to use it in sprintf(...) + const int sqry_real_allocated_size = ROUNDUP_TO_8(sqry_size); + snprintf(sqry, sqry_real_allocated_size, src, "1=1"); // dummy where clause } else sqry = (char*)src; diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index f27f5a9d55b..4078a03830a 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -1023,13 +1023,13 @@ bool JDOC::SerializeValue(PJVAL jvp) case TYPE_DTM: return js->Escape(jvp->Strp); case TYPE_INTG: - sprintf(buf, "%d", jvp->N); + snprintf(buf, sizeof(buf), "%d", jvp->N); return js->WriteStr(buf); case TYPE_BINT: - sprintf(buf, "%lld", jvp->LLn); + snprintf(buf, sizeof(buf), "%lld", jvp->LLn); return js->WriteStr(buf); case TYPE_DBL: // dfp to limit to the default number of decimals - sprintf(buf, "%.*f", MY_MIN(jvp->Nd, dfp), jvp->F); + snprintf(buf, sizeof(buf), "%.*f", MY_MIN(jvp->Nd, dfp), jvp->F); return js->WriteStr(buf); case TYPE_NULL: return js->WriteStr("null"); diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index f6325c89c5a..6f5b0883fe1 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -909,7 +909,7 @@ my_bool JSNX::LocateArray(PGLOBAL g, PJAR jarp) for (int i = 0; i < jarp->size() && !Found; i++) { Jp->N = m; - sprintf(s, "[%d]", i + B); + snprintf(s, sizeof(s), "[%d]", i + B); if (Jp->WriteStr(s)) return true; @@ -1190,7 +1190,7 @@ my_bool JSNX::AddPath(void) { for (int i = 0; i <= I; i++) { if (Jpnp[i].Type == TYPE_JAR) { - sprintf(s, "[%d]", Jpnp[i].N + B); + snprintf(s, sizeof(s), "[%d]", Jpnp[i].N + B); if (Jp->WriteStr(s)) return true; diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 60e24841a94..14e1e44895c 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -290,46 +290,8 @@ if (!rc) /******************************************************************/ /* XML library cleanup function. */ /******************************************************************/ -/* - This is a copy of xmlCleanupParser() from the libxml2 sources - with xmlResetLastError() commented. - - xmlResetLastError() called from the original xmlCleanupParser() causes - valgrind to report memory leaks. This happens because - ha_initialize_handlerton() is called from the main thread in mysqld.cc, - while ha_finalize_handlerton() is called from a non-main thread. - libxml2 gets confused because of xmlInitParser() and xmlCleanupParser() - being called from the different threads. - - Perhaps the code in mysqld.cc should eventually be modified - to shutdown plugins from the main thread. -*/ -static void -xmlCleanupParser_replacement(void) - { - xmlCleanupCharEncodingHandlers(); -#ifdef LIBXML_CATALOG_ENABLED - xmlCatalogCleanup(); -#endif - xmlDictCleanup(); - xmlCleanupInputCallbacks(); -#ifdef LIBXML_OUTPUT_ENABLED - xmlCleanupOutputCallbacks(); -#endif -#ifdef LIBXML_SCHEMAS_ENABLED - xmlSchemaCleanupTypes(); - xmlRelaxNGCleanupTypes(); -#endif - //xmlResetLastError(); - xmlCleanupGlobals(); - xmlCleanupThreads(); /* must be last if called not from the main thread */ - xmlCleanupMemory(); - } - - void XmlCleanupParserLib(void) { - xmlCleanupParser_replacement(); } // end of XmlCleanupParserLib /******************************************************************/ diff --git a/storage/connect/mysql-test/connect/r/mysql.result b/storage/connect/mysql-test/connect/r/mysql.result index 83c2bc0abb5..918256ac395 100644 --- a/storage/connect/mysql-test/connect/r/mysql.result +++ b/storage/connect/mysql-test/connect/r/mysql.result @@ -304,5 +304,27 @@ INSERT INTO t2 VALUES (10),(20),(30),(40); DROP TABLE t2; DROP TABLE t1; # +# MDEV-28533 CONNECT engine does not quote columns involved in WHERE clause +# +CREATE TABLE t1 (id int, `spaced col` varchar(10),`nospace` varchar(10)); +insert into t1 values (1,1,'x1'),(2,'C-003','x2'); +SELECT * from t1; +id spaced col nospace +1 1 x1 +2 C-003 x2 +CREATE TABLE t2 (id int, `spaced col` varchar(10), `nospace` varchar(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=PORT'; +SELECT * from t2; +id spaced col nospace +1 1 x1 +2 C-003 x2 +SELECT `id` FROM t2 WHERE t2.`nospace` = 'x1'; +id +1 +SELECT `id` FROM t2 WHERE t2.`spaced col` = 'C-003'; +id +2 +DROP TABLE t1; +DROP TABLE t2; +# # End of 10.3 tests # diff --git a/storage/connect/mysql-test/connect/r/odbc_postgresql.result b/storage/connect/mysql-test/connect/r/odbc_postgresql.result index dc23dbdb990..fd23197c37f 100644 --- a/storage/connect/mysql-test/connect/r/odbc_postgresql.result +++ b/storage/connect/mysql-test/connect/r/odbc_postgresql.result @@ -17,6 +17,7 @@ mtr public t2 TABLE mtr public v1 VIEW mtr schema1 t1 TABLE mtr schema1 t2 TABLE +mtr schema1 t3 TABLE mtr schema1 v1 VIEW DROP TABLE t1; # All tables in all schemas @@ -28,6 +29,7 @@ mtr public t2 TABLE mtr public v1 VIEW mtr schema1 t1 TABLE mtr schema1 t2 TABLE +mtr schema1 t3 TABLE mtr schema1 v1 VIEW DROP TABLE t1; # All tables in all schemas @@ -39,6 +41,7 @@ mtr public t2 TABLE mtr public v1 VIEW mtr schema1 t1 TABLE mtr schema1 t2 TABLE +mtr schema1 t3 TABLE mtr schema1 v1 VIEW DROP TABLE t1; # All tables in the default schema ("public") @@ -101,6 +104,8 @@ mtr public t2 a 4 int4 10 4 0 10 0 mtr public v1 a 4 int4 10 4 0 10 1 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t3 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t3 b 1 bpchar 10 40 NULL NULL 0 mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1 DROP TABLE t1; # All columns in the schemas "public" and "schema1" @@ -112,6 +117,8 @@ mtr public t2 a 4 int4 10 4 0 10 0 mtr public v1 a 4 int4 10 4 0 10 1 mtr schema1 t1 a 1 bpchar 10 40 NULL NULL 0 mtr schema1 t2 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t3 a 1 bpchar 10 40 NULL NULL 0 +mtr schema1 t3 b 1 bpchar 10 40 NULL NULL 0 mtr schema1 v1 a 1 bpchar 10 40 NULL NULL 1 DROP TABLE t1; # All tables "t1" in all schemas @@ -195,7 +202,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` char(10) NOT NULL -) ENGINE=CONNECT DEFAULT CHARSET=utf8 CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' `TABLE_TYPE`='ODBC' `TABNAME`='schema1.t1' `DATA_CHARSET`='utf8' +) ENGINE=CONNECT DEFAULT CHARSET=utf8mb3 CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' `TABLE_TYPE`='ODBC' `TABNAME`='schema1.t1' `DATA_CHARSET`='utf8' SELECT * FROM t1; a aaa @@ -206,7 +213,7 @@ CREATE TABLE t2 AS SELECT * FROM t1; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` char(10) CHARACTER SET utf8 NOT NULL + `a` char(10) CHARACTER SET utf8mb3 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * FROM t2; a @@ -230,7 +237,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` char(10) DEFAULT NULL -) ENGINE=CONNECT DEFAULT CHARSET=utf8 CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' `TABLE_TYPE`='ODBC' `TABNAME`='schema1.v1' `DATA_CHARSET`='utf8' +) ENGINE=CONNECT DEFAULT CHARSET=utf8mb3 CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' `TABLE_TYPE`='ODBC' `TABNAME`='schema1.v1' `DATA_CHARSET`='utf8' SELECT * FROM t1; a aaa @@ -241,7 +248,7 @@ CREATE TABLE t2 AS SELECT * FROM t1; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` char(10) CHARACTER SET utf8 DEFAULT NULL + `a` char(10) CHARACTER SET utf8mb3 DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * FROM t2; a @@ -265,7 +272,7 @@ SHOW CREATE TABLE t1; Table Create Table t1 CREATE TABLE `t1` ( `a` char(10) NOT NULL -) ENGINE=CONNECT DEFAULT CHARSET=utf8 CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' `TABLE_TYPE`='ODBC' `TABNAME`='schema1.t2' `DATA_CHARSET`='utf8' +) ENGINE=CONNECT DEFAULT CHARSET=utf8mb3 CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr' `TABLE_TYPE`='ODBC' `TABNAME`='schema1.t2' `DATA_CHARSET`='utf8' SELECT * FROM t1; a xxx @@ -276,7 +283,7 @@ CREATE TABLE t2 AS SELECT * FROM t1; SHOW CREATE TABLE t2; Table Create Table t2 CREATE TABLE `t2` ( - `a` char(10) CHARACTER SET utf8 NOT NULL + `a` char(10) CHARACTER SET utf8mb3 NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 SELECT * FROM t2; a @@ -294,3 +301,8 @@ zzz ÄÖÜ DROP VIEW v1; DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(6), b VARCHAR(6), PRIMARY KEY(a, b)) ENGINE=CONNECT TABNAME='schema1.t3' CHARSET=utf8 DATA_CHARSET=utf8 TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr'; +DELETE FROM t1 WHERE a='20'; +Warnings: +Note 1105 schema1.t3: 0 affected rows +DROP TABLE t1; diff --git a/storage/connect/mysql-test/connect/t/mysql.test b/storage/connect/mysql-test/connect/t/mysql.test index 451de29c0b0..ce76a4665d5 100644 --- a/storage/connect/mysql-test/connect/t/mysql.test +++ b/storage/connect/mysql-test/connect/t/mysql.test @@ -484,5 +484,25 @@ DROP TABLE t2; DROP TABLE t1; --echo # +--echo # MDEV-28533 CONNECT engine does not quote columns involved in WHERE clause +--echo # + +CREATE TABLE t1 (id int, `spaced col` varchar(10),`nospace` varchar(10)); +insert into t1 values (1,1,'x1'),(2,'C-003','x2'); + +SELECT * from t1; + +--replace_result $PORT PORT +--eval CREATE TABLE t2 (id int, `spaced col` varchar(10), `nospace` varchar(10)) ENGINE=CONNECT TABLE_TYPE=MYSQL DBNAME='test' TABNAME='t1' OPTION_LIST='host=localhost,user=root,port=$PORT' + +SELECT * from t2; +SELECT `id` FROM t2 WHERE t2.`nospace` = 'x1'; +SELECT `id` FROM t2 WHERE t2.`spaced col` = 'C-003'; + + +DROP TABLE t1; +DROP TABLE t2; + +--echo # --echo # End of 10.3 tests --echo # diff --git a/storage/connect/mysql-test/connect/t/odbc_postgresql.sql b/storage/connect/mysql-test/connect/t/odbc_postgresql.sql index 1c302294393..a795817a4d3 100644 --- a/storage/connect/mysql-test/connect/t/odbc_postgresql.sql +++ b/storage/connect/mysql-test/connect/t/odbc_postgresql.sql @@ -25,3 +25,6 @@ INSERT INTO schema1.t1 VALUES ('aaa'),('bbb'),('ccc'),('яяя'); CREATE VIEW schema1.v1 AS SELECT * FROM schema1.t1; CREATE TABLE schema1.t2 (a CHAR(10) NOT NULL); INSERT INTO schema1.t2 VALUES ('xxx'),('yyy'),('zzz'),('ÄÖÜ'); +CREATE TABLE schema1.t3 (a CHAR(10) NOT NULL, b CHAR(10) NOT NULL); +INSERT INTO schema1.t3 VALUES ('xxx', 'aaa'),('yyy', 'bbb'),('zzz', 'ccc'),('ÄÖÜ', 'яяя'); + diff --git a/storage/connect/mysql-test/connect/t/odbc_postgresql.test b/storage/connect/mysql-test/connect/t/odbc_postgresql.test index 7fc16130713..86597423d04 100644 --- a/storage/connect/mysql-test/connect/t/odbc_postgresql.test +++ b/storage/connect/mysql-test/connect/t/odbc_postgresql.test @@ -205,3 +205,9 @@ CREATE VIEW v1 AS SELECT * FROM t1; SELECT * FROM v1; DROP VIEW v1; DROP TABLE t1; + +# MDEV-25767 DELETE with WHERE condition crashes when two columns used for +# pkey +CREATE TABLE t1 (a VARCHAR(6), b VARCHAR(6), PRIMARY KEY(a, b)) ENGINE=CONNECT TABNAME='schema1.t3' CHARSET=utf8 DATA_CHARSET=utf8 TABLE_TYPE=ODBC CONNECTION='DSN=ConnectEnginePostgresql;UID=mtr;PWD=mtr'; +DELETE FROM t1 WHERE a='20'; +DROP TABLE t1; diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp index d131482ef94..6fb40c92a1b 100644 --- a/storage/connect/plugutil.cpp +++ b/storage/connect/plugutil.cpp @@ -371,13 +371,13 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m) PlugSetPath(msgfile, NULL, buff, msg_path); if (!(mfile = fopen(msgfile, "rt"))) { - sprintf(stmsg, "Fail to open message file %-.256s", msgfile); + snprintf(stmsg, sizeof(stmsg), "Fail to open message file %s", msgfile); goto err; } // endif mfile for (;;) if (!fgets(buff, 256, mfile)) { - sprintf(stmsg, "Cannot get message %d %-.256s", mid, SVP(m)); + snprintf(stmsg, sizeof(stmsg), "Cannot get message %d %s", mid, SVP(m)); goto fin; } else if (atoi(buff) == mid) @@ -386,7 +386,7 @@ char *PlugReadMessage(PGLOBAL g, int mid, char *m) if (sscanf(buff, " %*d %.31s \"%.255[^\"]", msgid, stmsg) < 2) { // Old message file if (!sscanf(buff, " %*d \"%.255[^\"]", stmsg)) { - sprintf(stmsg, "Bad message file for %d %-.256s", mid, SVP(m)); + snprintf(stmsg, sizeof(stmsg), "Bad message file for %d %s", mid, SVP(m)); goto fin; } else m = NULL; @@ -425,17 +425,18 @@ char *PlugGetMessage(PGLOBAL g, int mid) if (n == 0) { DWORD rc = GetLastError(); - msg = (char*)PlugSubAlloc(g, NULL, 512); // Extend buf allocation - n = sprintf(msg, "Message %d, rc=%d: ", mid, rc); + const int BUF_SIZE= 512; + msg = (char*)PlugSubAlloc(g, NULL, BUF_SIZE); // Extend buf allocation + n = snprintf(msg, BUF_SIZE, "Message %d, rc=%d: ", mid, rc); FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, rc, 0, - (LPTSTR)(msg + n), 512 - n, NULL); + (LPTSTR)(msg + n), BUF_SIZE - n, NULL); return msg; } // endif n #else // ALL if (!GetRcString(mid, stmsg, 200)) - sprintf(stmsg, "Message %d not found", mid); + snprintf(stmsg, sizeof(stmsg) "Message %d not found", mid); #endif // ALL if (g) { @@ -564,7 +565,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) /*******************************************************************/ memp = g->Sarea; - size = ((size + 7) / 8) * 8; /* Round up size to multiple of 8 */ + size = ROUNDUP_TO_8(size); /* Round up size to multiple of 8 */ pph = (PPOOLHEADER)memp; if (trace(16)) diff --git a/storage/connect/tabbson.cpp b/storage/connect/tabbson.cpp index b69618a60cb..4cbb0e44e19 100644 --- a/storage/connect/tabbson.cpp +++ b/storage/connect/tabbson.cpp @@ -477,7 +477,7 @@ bool BSONDISC::Find(PGLOBAL g, PBVAL jvp, PCSZ key, int j) n = sizeof(fmt) - (strlen(fmt) + 1); if (!tdp->Xcol || stricmp(tdp->Xcol, key)) { - sprintf(buf, "%d", k); + snprintf(buf, sizeof(buf), "%d", k); if (tdp->Uri) { strncat(strncat(fmt, sep, n), buf, n - strlen(sep)); @@ -798,7 +798,7 @@ void BCUTIL::SetJsonValue(PGLOBAL g, PVAL vp, PBVAL jvp) break; default: - sprintf(G->Message, "Unsupported column type %d", vp->GetType()); + snprintf(G->Message, sizeof(G->Message), "Unsupported column type %d", vp->GetType()); throw 888; } // endswitch Type diff --git a/storage/connect/tabodbc.cpp b/storage/connect/tabodbc.cpp index fb9168f3b88..d60cd039951 100644 --- a/storage/connect/tabodbc.cpp +++ b/storage/connect/tabodbc.cpp @@ -553,7 +553,7 @@ bool TDBODBC::OpenDB(PGLOBAL g) if (Memory < 3) { // Method will depend on cursor type - if ((Rbuf = Ocp->Rewind(Query->GetStr(), (PODBCCOL)Columns)) < 0) { + if (Query && (Rbuf = Ocp->Rewind(Query->GetStr(), (PODBCCOL)Columns)) < 0) { if (Mode != MODE_READX) { Ocp->Close(); return true; diff --git a/storage/connect/tabwmi.cpp b/storage/connect/tabwmi.cpp index f90ff98ca35..935d21c59c9 100644 --- a/storage/connect/tabwmi.cpp +++ b/storage/connect/tabwmi.cpp @@ -810,7 +810,7 @@ void WMICOL::ReadColumn(PGLOBAL g) char buf[24]; int rc = VariantTimeToSystemTime(Prop.date, &stm); - sprintf(buf, "%02d/%02d/%d %02d:%02d:%02d", + snprintf(buf, sizeof(buf), "%02d/%02d/%d %02d:%02d:%02d", stm.wDay, stm.wMonth, stm.wYear, stm.wHour, stm.wMinute, stm.wSecond); Value->SetValue_psz(buf); diff --git a/storage/connect/valblk.cpp b/storage/connect/valblk.cpp index 7d7da5b6252..528c4abf3db 100644 --- a/storage/connect/valblk.cpp +++ b/storage/connect/valblk.cpp @@ -604,7 +604,7 @@ int TYPBLK<TYPE>::GetMaxLength(void) int i, n, m; for (i = n = 0; i < Nval; i++) { - m = sprintf(buf, Fmt, UnalignedRead(i)); + m = snprintf(buf, sizeof(buf), Fmt, UnalignedRead(i)); n = MY_MAX(n, m); } // endfor i diff --git a/storage/federatedx/federatedx_txn.cc b/storage/federatedx/federatedx_txn.cc index 220896cc2a4..c434a00805c 100644 --- a/storage/federatedx/federatedx_txn.cc +++ b/storage/federatedx/federatedx_txn.cc @@ -57,10 +57,12 @@ federatedx_txn::~federatedx_txn() void federatedx_txn::close(FEDERATEDX_SERVER *server) { +#ifdef DBUG_TRACE uint count= 0; +#endif federatedx_io *io, **iop; DBUG_ENTER("federatedx_txn::close"); - + DBUG_ASSERT(!server->use_count); DBUG_PRINT("info",("use count: %u connections: %u", server->use_count, server->io_count)); @@ -84,9 +86,11 @@ void federatedx_txn::close(FEDERATEDX_SERVER *server) { server->idle_list= io->idle_next; delete io; +#ifdef DBUG_TRACE count++; +#endif } - + DBUG_PRINT("info",("closed %u connections, txn_list: %s", count, txn_list ? "active": "empty")); DBUG_VOID_RETURN; @@ -172,12 +176,14 @@ void federatedx_txn::release(federatedx_io **ioptr) void federatedx_txn::release_scan() { +#ifdef DBUG_TRACE uint count= 0, returned= 0; +#endif federatedx_io *io, **pio; DBUG_ENTER("federatedx_txn::release_scan"); - /* return any inactive and idle connections to the server */ - for (pio= &txn_list; (io= *pio); count++) + /* return any inactive and idle connections to the server */ + for (pio= &txn_list; (io= *pio);) { if (io->active || io->busy) pio= &io->txn_next; @@ -196,8 +202,13 @@ void federatedx_txn::release_scan() io->idle_next= server->idle_list; server->idle_list= io; mysql_mutex_unlock(&server->mutex); +#ifdef DBUG_TRACE returned++; +#endif } +#ifdef DBUG_TRACE + count++; +#endif } DBUG_PRINT("info",("returned %u of %u connections(s)", returned, count)); diff --git a/storage/federatedx/ha_federatedx.cc b/storage/federatedx/ha_federatedx.cc index 20a78b8e3ce..dbf83aec127 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -2650,7 +2650,7 @@ int ha_federatedx::index_read_idx_with_result_set(uchar *buf, uint index, if (io->query(sql_query.ptr(), sql_query.length())) { - sprintf(error_buffer, "error: %d '%s'", + snprintf(error_buffer, sizeof(error_buffer), "error: %d '%s'", io->error_code(), io->error_str()); retval= ER_QUERY_ON_FOREIGN_DATA_SOURCE; goto error; @@ -3375,7 +3375,7 @@ static int test_connection(MYSQL_THD thd, federatedx_io *io, if ((retval= io->query(str.ptr(), str.length()))) { - sprintf(buffer, "database: '%s' username: '%s' hostname: '%s'", + snprintf(buffer, sizeof(buffer), "database: '%s' username: '%s' hostname: '%s'", share->database, share->username, share->hostname); DBUG_PRINT("info", ("error-code: %d", io->error_code())); my_error(ER_CANT_CREATE_FEDERATED_TABLE, MYF(0), buffer); diff --git a/storage/innobase/btr/btr0defragment.cc b/storage/innobase/btr/btr0defragment.cc index 0c1959bb554..37219210883 100644 --- a/storage/innobase/btr/btr0defragment.cc +++ b/storage/innobase/btr/btr0defragment.cc @@ -656,7 +656,7 @@ release_and_exit: mysql_mutex_unlock(&btr_defragment_mutex); func_exit: set_current_thd(nullptr); - innobase_destroy_background_thd(thd); + destroy_background_thd(thd); return; } item = *btr_defragment_wq.begin(); diff --git a/storage/innobase/dict/dict0stats_bg.cc b/storage/innobase/dict/dict0stats_bg.cc index 10c7426103c..833d99cdaee 100644 --- a/storage/innobase/dict/dict0stats_bg.cc +++ b/storage/innobase/dict/dict0stats_bg.cc @@ -381,7 +381,7 @@ static void dict_stats_func(void*) while (dict_stats_process_entry_from_recalc_pool(thd)) {} dict_defrag_process_entries_from_defrag_pool(thd); set_current_thd(nullptr); - innobase_destroy_background_thd(thd); + destroy_background_thd(thd); } diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index faf598ddd72..df60a2aadd1 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -3960,6 +3960,43 @@ fts_sync_index( return(fts_sync_write_words(trx, index_cache)); } +/** Rollback a sync operation +@param[in,out] sync sync state */ +static +void +fts_sync_rollback( + fts_sync_t* sync) +{ + trx_t* trx = sync->trx; + fts_cache_t* cache = sync->table->fts->cache; + + for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) { + ulint j; + fts_index_cache_t* index_cache; + + index_cache = static_cast<fts_index_cache_t*>( + ib_vector_get(cache->indexes, i)); + + for (j = 0; fts_index_selector[j].value; ++j) { + + if (index_cache->ins_graph[j] != NULL) { + + que_graph_free(index_cache->ins_graph[j]); + + index_cache->ins_graph[j] = NULL; + } + } + } + + mysql_mutex_unlock(&cache->lock); + + fts_sql_rollback(trx); + + /* Avoid assertion in trx_t::free(). */ + trx->dict_operation_lock_mode = false; + trx->free(); +} + /** Commit the SYNC, change state of processed doc ids etc. @param[in,out] sync sync state @return DB_SUCCESS if all OK */ @@ -4000,10 +4037,10 @@ fts_sync_commit( mysql_mutex_unlock(&cache->lock); fts_sql_commit(trx); } else { - mysql_mutex_unlock(&cache->lock); - fts_sql_rollback(trx); ib::error() << "(" << error << ") during SYNC of " "table " << sync->table->name; + fts_sync_rollback(sync); + return error; } if (UNIV_UNLIKELY(fts_enable_diag_print) && elapsed_time) { @@ -4023,43 +4060,6 @@ fts_sync_commit( return(error); } -/** Rollback a sync operation -@param[in,out] sync sync state */ -static -void -fts_sync_rollback( - fts_sync_t* sync) -{ - trx_t* trx = sync->trx; - fts_cache_t* cache = sync->table->fts->cache; - - for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) { - ulint j; - fts_index_cache_t* index_cache; - - index_cache = static_cast<fts_index_cache_t*>( - ib_vector_get(cache->indexes, i)); - - for (j = 0; fts_index_selector[j].value; ++j) { - - if (index_cache->ins_graph[j] != NULL) { - - que_graph_free(index_cache->ins_graph[j]); - - index_cache->ins_graph[j] = NULL; - } - } - } - - mysql_mutex_unlock(&cache->lock); - - fts_sql_rollback(trx); - - /* Avoid assertion in trx_t::free(). */ - trx->dict_operation_lock_mode = false; - trx->free(); -} - /** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. @param[in,out] sync sync state diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 9cc56f184fd..7c40a25e6e7 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -2974,7 +2974,7 @@ fts_optimize_shutdown() &fts_optimize_wq->mutex.m_mutex); } - innobase_destroy_background_thd(fts_opt_thd); + destroy_background_thd(fts_opt_thd); fts_opt_thd = NULL; pthread_cond_destroy(&fts_opt_shutdown_cond); mysql_mutex_unlock(&fts_optimize_wq->mutex); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index ea521fb7798..d070dbea66f 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -130,7 +130,6 @@ void thd_clear_error(MYSQL_THD thd); TABLE *find_fk_open_table(THD *thd, const char *db, size_t db_len, const char *table, size_t table_len); MYSQL_THD create_background_thd(); -void destroy_background_thd(MYSQL_THD thd); void reset_thd(MYSQL_THD thd); TABLE *get_purge_table(THD *thd); TABLE *open_purge_table(THD *thd, const char *db, size_t dblen, @@ -1829,20 +1828,6 @@ THD *innodb_thd_increment_pending_ops(THD *thd) return thd; } -/** Destroy a background purge thread THD. -@param[in] thd MYSQL_THD to destroy */ -void -innobase_destroy_background_thd( -/*============================*/ - MYSQL_THD thd) -{ - /* need to close the connection explicitly, the server won't do it - if innodb is in the PLUGIN_IS_DYING state */ - innobase_close_connection(innodb_hton_ptr, thd); - thd_set_ha_data(thd, innodb_hton_ptr, NULL); - destroy_background_thd(thd); -} - /** Close opened tables, free memory, delete items for a MYSQL_THD. @param[in] thd MYSQL_THD to reset */ void @@ -5016,6 +5001,7 @@ static int innobase_close_connection(handlerton *hton, THD *thd) DBUG_ASSERT(hton == innodb_hton_ptr); if (auto trx= thd_to_trx(thd)) { + thd_set_ha_data(thd, innodb_hton_ptr, NULL); if (trx->state == TRX_STATE_PREPARED && trx->has_logged_persistent()) { trx_disconnect_prepared(trx); @@ -5023,6 +5009,7 @@ static int innobase_close_connection(handlerton *hton, THD *thd) } innobase_rollback_trx(trx); trx->free(); + DEBUG_SYNC(thd, "innobase_connection_closed"); } return 0; } diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 3d217dc3243..d9a26226e98 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2006, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2021, MariaDB Corporation. +Copyright (c) 2017, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -460,10 +460,9 @@ normalize_table_name_c_low( @return new MYSQL_THD */ MYSQL_THD innobase_create_background_thd(const char* name); -/** Destroy a background purge thread THD. +/** Destroy a THD object associated with a background task. @param[in] thd MYSQL_THD to destroy */ -void -innobase_destroy_background_thd(MYSQL_THD); +void destroy_background_thd(MYSQL_THD thd); /** Close opened tables, free memory, delete items for a MYSQL_THD. @param[in] thd MYSQL_THD to reset */ diff --git a/storage/innobase/include/srv0start.h b/storage/innobase/include/srv0start.h index 9033cd916c3..44b19aa666b 100644 --- a/storage/innobase/include/srv0start.h +++ b/storage/innobase/include/srv0start.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2020, MariaDB Corporation. +Copyright (c) 2017, 2022, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -52,9 +52,6 @@ void innodb_preshutdown(); /** Shut down InnoDB. */ void innodb_shutdown(); -/** Shut down background threads that can generate undo log. */ -void srv_shutdown_bg_undo_sources(); - /*************************************************************//** Copy the file path component of the physical file to parameter. It will copy up to and including the terminating path separator. diff --git a/storage/innobase/que/que0que.cc b/storage/innobase/que/que0que.cc index 642a852b473..3ea5c15bccc 100644 --- a/storage/innobase/que/que0que.cc +++ b/storage/innobase/que/que0que.cc @@ -507,7 +507,7 @@ que_node_get_containing_loop_node( return(node); } -#ifndef DBUG_OFF +#ifdef DBUG_TRACE /** Gets information of an SQL query graph node. @return type description */ static MY_ATTRIBUTE((warn_unused_result, nonnull)) @@ -564,7 +564,7 @@ que_node_type_string( return("UNKNOWN NODE TYPE"); } } -#endif /* !DBUG_OFF */ +#endif /* DBUG_TRACE */ /**********************************************************************//** Performs an execution step on a query thread. diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index eeac4b1712e..15835ff4afd 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1922,6 +1922,7 @@ func_exit: mtr.commit(); func_exit_committed: ut_ad(mtr.has_committed()); + ut_free(pcur.old_rec_buf); if (error != DB_SUCCESS) { /* Report the erroneous row using the new @@ -2082,7 +2083,8 @@ func_exit_committed: entry = row_build_index_entry(old_row, old_ext, index, heap); if (!entry) { ut_ad(0); - return(DB_CORRUPTION); + error = DB_CORRUPTION; + goto func_exit_committed; } mtr.start(); diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 156df2edc70..10b22c9de7d 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -1926,7 +1926,7 @@ static void srv_shutdown_purge_tasks() std::unique_lock<std::mutex> lk(purge_thd_mutex); while (!purge_thds.empty()) { - innobase_destroy_background_thd(purge_thds.front()); + destroy_background_thd(purge_thds.front()); purge_thds.pop_front(); } n_purge_thds= 0; diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index f2285bfa404..e3dfc75ec7e 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -837,6 +837,21 @@ static void srv_shutdown_threads() } } + +/** Shut down background threads that can generate undo log. */ +static void srv_shutdown_bg_undo_sources() +{ + srv_shutdown_state= SRV_SHUTDOWN_INITIATED; + + if (srv_undo_sources) + { + ut_ad(!srv_read_only_mode); + fts_optimize_shutdown(); + dict_stats_shutdown(); + srv_undo_sources= false; + } +} + #ifdef UNIV_DEBUG # define srv_init_abort(_db_err) \ srv_init_abort_low(create_new_db, __FILE__, __LINE__, _db_err) @@ -1913,19 +1928,6 @@ skip_monitors: return(DB_SUCCESS); } -/** Shut down background threads that can generate undo log. */ -void srv_shutdown_bg_undo_sources() -{ - srv_shutdown_state = SRV_SHUTDOWN_INITIATED; - - if (srv_undo_sources) { - ut_ad(!srv_read_only_mode); - fts_optimize_shutdown(); - dict_stats_shutdown(); - srv_undo_sources = false; - } -} - /** Shutdown purge to make sure that there is no possibility that we call any plugin code (e.g., audit) inside virtual column computation. diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index f66b6ae6186..f470d3691c1 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -1070,7 +1070,7 @@ static int chk_index(HA_CHECK *param, MARIA_HA *info, MARIA_KEYDEF *keyinfo, share->state.state.data_file_length) || (share->data_file_type == NO_RECORD && record != 0)) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char llbuff2[22], llbuff3[22]; #endif _ma_check_print_error(param, diff --git a/storage/maria/ma_loghandler.c b/storage/maria/ma_loghandler.c index fc46022f5b1..6572ff8e140 100644 --- a/storage/maria/ma_loghandler.c +++ b/storage/maria/ma_loghandler.c @@ -2661,7 +2661,7 @@ static my_bool translog_buffer_flush(struct st_translog_buffer *buffer) i < buffer->size; i+= TRANSLOG_PAGE_SIZE, pg++) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE TRANSLOG_ADDRESS addr= (buffer->offset + i); #endif DBUG_PRINT("info", ("send log form %lu till %lu address: " LSN_FMT " " @@ -2908,7 +2908,7 @@ static my_bool translog_page_validator(int res, PAGECACHE_IO_HOOK_ARGS *args) uint flags; uchar *page_pos; TRANSLOG_FILE *data= (TRANSLOG_FILE *) args->data; -#ifndef DBUG_OFF +#ifdef DBUG_TRACE pgcache_page_no_t offset= page_no * TRANSLOG_PAGE_SIZE; #endif DBUG_ENTER("translog_page_validator"); @@ -3268,7 +3268,7 @@ static my_bool translog_get_last_page_addr(TRANSLOG_ADDRESS *addr, my_off_t file_size; uint32 file_no= LSN_FILE_NO(*addr); TRANSLOG_FILE *file; -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char buff[21]; #endif DBUG_ENTER("translog_get_last_page_addr"); diff --git a/storage/maria/ma_pagecache.c b/storage/maria/ma_pagecache.c index de85ec51deb..144b10a86da 100644 --- a/storage/maria/ma_pagecache.c +++ b/storage/maria/ma_pagecache.c @@ -190,7 +190,7 @@ struct st_pagecache_hash_link enum PCBLOCK_TEMPERATURE { PCBLOCK_COLD /*free*/ , PCBLOCK_WARM , PCBLOCK_HOT }; /* debug info */ -#ifndef DBUG_OFF +#ifdef DBUG_TRACE static const char *page_cache_page_type_str[]= { /* used only for control page type changing during debugging */ @@ -225,8 +225,9 @@ static const char *page_cache_page_pin_str[]= "unpinned -> pinned", "pinned -> unpinned" }; +#endif /* DBUG_TRACE */ - +#ifndef DBUG_OFF typedef struct st_pagecache_pin_info { struct st_pagecache_pin_info *next, **prev; @@ -563,7 +564,7 @@ static void pagecache_debug_print _VARARGS((const char *fmt, ...)); #define KEYCACHE_DBUG_ASSERT(a) DBUG_ASSERT(a) #endif /* defined(PAGECACHE_DEBUG) */ -#if defined(PAGECACHE_DEBUG) || !defined(DBUG_OFF) +#if defined(PAGECACHE_DEBUG) || defined(DBUG_TRACE) static my_thread_id pagecache_thread_id; #define KEYCACHE_THREAD_TRACE(l) \ KEYCACHE_DBUG_PRINT(l,("|thread %lld",pagecache_thread_id)) @@ -581,7 +582,7 @@ static my_thread_id pagecache_thread_id; #define KEYCACHE_THREAD_TRACE_BEGIN(l) #define KEYCACHE_THREAD_TRACE_END(l) #define KEYCACHE_THREAD_TRACE(l) -#endif /* defined(PAGECACHE_DEBUG) || !defined(DBUG_OFF) */ +#endif /* defined(PAGECACHE_DEBUG) || defined(DBUG_TRACE) */ #define PCBLOCK_NUMBER(p, b) \ ((uint) (((char*)(b)-(char *) p->block_root)/sizeof(PAGECACHE_BLOCK_LINK))) @@ -3714,8 +3715,9 @@ uchar *pagecache_read(PAGECACHE *pagecache, unlock_pin= lock_to_pin[buff==0][lock].unlock_pin; PAGECACHE_BLOCK_LINK *fake_link; my_bool reg_request; -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char llbuf[22]; +#endif DBUG_ENTER("pagecache_read"); DBUG_PRINT("enter", ("fd: %u page: %s buffer: %p level: %u " "t:%s (%d)%s->%s %s->%s big block: %d", @@ -3731,7 +3733,6 @@ uchar *pagecache_read(PAGECACHE *pagecache, DBUG_ASSERT(buff != 0 || (buff == 0 && (unlock_pin == PAGECACHE_PIN || unlock_pin == PAGECACHE_PIN_LEFT_PINNED))); DBUG_ASSERT(pageno < ((1ULL) << 40)); -#endif if (!page_link) page_link= &fake_link; @@ -4375,8 +4376,9 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, my_bool error= 0; int need_lock_change= write_lock_change_table[lock].need_lock_change; my_bool reg_request; -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char llbuf[22]; +#endif DBUG_ENTER("pagecache_write_part"); DBUG_PRINT("enter", ("fd: %u page: %s level: %u type: %s lock: %s " "pin: %s mode: %s offset: %u size %u", @@ -4392,7 +4394,6 @@ my_bool pagecache_write_part(PAGECACHE *pagecache, DBUG_ASSERT(offset + size <= pagecache->block_size); DBUG_ASSERT(pageno < ((1ULL) << 40)); DBUG_ASSERT(pagecache->big_block_read == 0); -#endif if (!page_link) page_link= &fake_link; diff --git a/storage/maria/unittest/ma_pagecache_single.c b/storage/maria/unittest/ma_pagecache_single.c index c4e2c53d235..de2ecaecfc4 100644 --- a/storage/maria/unittest/ma_pagecache_single.c +++ b/storage/maria/unittest/ma_pagecache_single.c @@ -661,14 +661,10 @@ err: static void *test_thread(void *arg) { -#ifndef DBUG_OFF - int param= *((int*) arg); -#endif - my_thread_init(); { DBUG_ENTER("test_thread"); - DBUG_PRINT("enter", ("param: %d", param)); + DBUG_PRINT("enter", ("param: %d", *(int*) arg)); if (!simple_read_write_test() || !simple_read_change_write_read_test() || diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 2a49971f6db..f89f5d4ab5b 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -33,6 +33,7 @@ #include "sql_table.h" // tablename_to_filename #include "sql_class.h" // THD #include "debug_sync.h" +#include "sql_debug.h" ulonglong myisam_recover_options; static ulong opt_myisam_block_size; @@ -121,6 +122,28 @@ static void debug_wait_for_kill(const char *info) thd_proc_info(thd, prev_info); DBUG_VOID_RETURN; } + + +class Debug_key_myisam: public Debug_key +{ +public: + Debug_key_myisam() { } + + static void print_keys_myisam(THD *thd, const char *where, + const TABLE *table, + const MI_KEYDEF *keydef, uint count) + { + for (uint i= 0; i < count; i++) + { + Debug_key_myisam tmp; + if (!tmp.append(where, strlen(where)) && + !tmp.append_key(table->s->key_info[i].name, keydef[i].flag)) + tmp.print(thd); + print_keysegs(thd, keydef[i].seg, keydef[i].keysegs); + } + } +}; + #endif /***************************************************************************** @@ -2234,6 +2257,15 @@ int ha_myisam::create(const char *name, TABLE *table_arg, if ((error= table2myisam(table_arg, &keydef, &recinfo, &record_count))) DBUG_RETURN(error); /* purecov: inspected */ + +#ifndef DBUG_OFF + DBUG_EXECUTE_IF("key", + Debug_key_myisam::print_keys_myisam(table_arg->in_use, + "ha_myisam::create: ", + table_arg, keydef, share->keys); + ); +#endif + bzero((char*) &create_info, sizeof(create_info)); create_info.max_rows= share->max_rows; create_info.reloc_rows= share->min_rows; diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index 16184a1b166..b4187ffc7dc 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -858,7 +858,7 @@ static int chk_index(HA_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, } if (record >= info->state->data_file_length) { -#ifndef DBUG_OFF +#ifdef DBUG_TRACE char llbuff2[22], llbuff3[22]; #endif mi_check_print_error(param,"Found key at page %s that points to record outside datafile",llstr(page,llbuff)); diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index c006cc0b9a7..63950a3fc1d 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -704,7 +704,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (mi_state_info_write(file, &share.state, 2) || mi_base_info_write(file, &share.base)) goto err; -#ifndef DBUG_OFF +#ifdef DBUG_TRACE if ((uint) mysql_file_tell(file, MYF(0)) != base_pos + MI_BASE_INFO_SIZE) { uint pos=(uint) mysql_file_tell(file, MYF(0)); @@ -804,12 +804,12 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, if (mi_recinfo_write(file, &recinfo[i])) goto err; -#ifndef DBUG_OFF - if ((uint) mysql_file_tell(file, MYF(0)) != info_length) +#ifdef DBUG_TRACE { uint pos= (uint) mysql_file_tell(file, MYF(0)); - DBUG_PRINT("warning",("info_length: %d != used_length: %d", - info_length, pos)); + if (pos != info_length) + DBUG_PRINT("warning",("info_length: %d != used_length: %d", + info_length, pos)); } #endif diff --git a/storage/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index f76f91c66bf..0478a7dd01a 100644 --- a/storage/rocksdb/CMakeLists.txt +++ b/storage/rocksdb/CMakeLists.txt @@ -4,6 +4,8 @@ SET(CPACK_RPM_rocksdb-engine_PACKAGE_SUMMARY "RocksDB storage engine for MariaDB SET(CPACK_RPM_rocksdb-engine_PACKAGE_DESCRIPTION "The RocksDB storage engine is a high performance storage engine, aimed at maximising storage efficiency while maintaining InnoDB-like performance." PARENT_SCOPE) +MY_CHECK_AND_SET_COMPILER_FLAG(-Wno-range-loop-construct) + MACRO(SKIP_ROCKSDB_PLUGIN msg) MESSAGE_ONCE(SKIP_ROCKSDB_PLUGIN "Can't build rocksdb engine - ${msg}") ADD_FEATURE_INFO(ROCKSDB "OFF" "Storage Engine") diff --git a/storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc b/storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc new file mode 100644 index 00000000000..a5446a6188d --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/include/restart_spider.inc @@ -0,0 +1,8 @@ +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect + +--exec echo "wait" > $_expect_file_name +--shutdown_server +--source include/wait_until_disconnected.inc +--exec echo "restart" > $_expect_file_name +--enable_reconnect +--source include/wait_until_connected_again.inc diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result new file mode 100644 index 00000000000..5715edf2bd6 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_29352.result @@ -0,0 +1,12 @@ +CREATE TABLE t (c INT); +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `c` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +FLUSH TABLES WITH READ LOCK; +CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; +ERROR HY000: Can't execute the query because you have a conflicting read lock +SELECT * FROM t; +c +DROP TABLE t; diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test new file mode 100644 index 00000000000..00d8ee73ebc --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_29352.test @@ -0,0 +1,11 @@ +CREATE TABLE t (c INT); +SHOW CREATE TABLE t; +FLUSH TABLES WITH READ LOCK; + +--error ER_CANT_UPDATE_WITH_READLOCK +CREATE FUNCTION spider_bg_direct_sql RETURNS INT SONAME 'ha_spider.so'; +SELECT * FROM t; + +--source include/restart_spider.inc + +DROP TABLE t; diff --git a/storage/spider/spd_group_by_handler.cc b/storage/spider/spd_group_by_handler.cc index 7f26f91cc70..f2722c85ccc 100644 --- a/storage/spider/spd_group_by_handler.cc +++ b/storage/spider/spd_group_by_handler.cc @@ -1858,6 +1858,8 @@ group_by_handler *spider_create_group_by_handler( { for (order = query->order_by; order; order = order->next) { + if ((*order->item)->type() == Item::SUM_FUNC_ITEM) + continue; if (spider_db_print_item_type((*order->item), NULL, spider, NULL, NULL, 0, roop_count, TRUE, fields_arg)) { diff --git a/storage/spider/spd_ping_table.cc b/storage/spider/spd_ping_table.cc index f220a9d97c2..8c2c8d2ce9e 100644 --- a/storage/spider/spd_ping_table.cc +++ b/storage/spider/spd_ping_table.cc @@ -1005,12 +1005,13 @@ int spider_ping_table_cache_compare( char *db_name, *table_name, *link_id; DBUG_ENTER("spider_ping_table_cache_compare"); - if ( - !(db_name = get_field(mem_root, table->field[0])) || - !(table_name = get_field(mem_root, table->field[1])) || - !(link_id = get_field(mem_root, table->field[2])) - ) + if (!(db_name = get_field(mem_root, table->field[0]))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!(table_name = get_field(mem_root, table->field[1]))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); + if (!(link_id = get_field(mem_root, table->field[2]))) + DBUG_RETURN(HA_ERR_OUT_OF_MEM); + DBUG_PRINT("info", ("spider db_name=%s", db_name)); DBUG_PRINT("info", ("spider table_name=%s", table_name)); DBUG_PRINT("info", ("spider link_id=%s", link_id)); |