diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-10-02 14:38:13 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2022-10-02 14:38:13 +0200 |
commit | 3a2116241b128b811ee2455845ff9710da3115ac (patch) | |
tree | 7de53fc50126f7a19251303bd1d2a0f6cdb42069 /storage | |
parent | e29fb956145cfa1f4f8c41cafcddea36a20b23aa (diff) | |
parent | d4f6d2f08f228778fd7744554d8b12be05b6a114 (diff) | |
download | mariadb-git-3a2116241b128b811ee2455845ff9710da3115ac.tar.gz |
Merge branch '10.4' into 10.5
Diffstat (limited to 'storage')
25 files changed, 200 insertions, 88 deletions
diff --git a/storage/connect/bsonudf.cpp b/storage/connect/bsonudf.cpp index 531894a68cc..f5fe6475639 100644 --- a/storage/connect/bsonudf.cpp +++ b/storage/connect/bsonudf.cpp @@ -1146,7 +1146,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; @@ -1440,7 +1440,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 1064b14113f..a8a0658f0db 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -3076,6 +3076,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]; @@ -3101,8 +3103,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); + strColumn.append(STRING_WITH_LEN("`")); + } if (h && i && !ishav) return NULL; // Having should be col VOP arg @@ -3116,9 +3124,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 f79b2ffac03..fa3937a5d80 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 1ae722a2fc5..0baaa70b496 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -908,7 +908,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; @@ -1189,7 +1189,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 3d695391439..cfb8918ed11 100644 --- a/storage/federatedx/ha_federatedx.cc +++ b/storage/federatedx/ha_federatedx.cc @@ -2641,7 +2641,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; @@ -3367,7 +3367,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/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 23a0adcaf2a..4e4eaceeb56 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) && + !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/rocksdb/CMakeLists.txt b/storage/rocksdb/CMakeLists.txt index 3a7922515a7..7d8ab0ddba8 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/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)); diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_5_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_5_tokudb.result index 2e31fc57dd4..aa35364b811 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_5_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_5_tokudb.result @@ -13,7 +13,7 @@ Grants for test1@localhost GRANT USAGE ON *.* TO `test1`@`localhost` GRANT SELECT, INSERT, CREATE, DROP ON `test`.* TO `test1`@`localhost` ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; -ERROR 42000: ALTER command denied to user 'test1'@'localhost' for table 'tp' +ERROR 42000: ALTER command denied to user 'test1'@'localhost' for table `test`.`tp` disconnect test1; connect test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK; USE test; @@ -83,7 +83,7 @@ Grants for test2@localhost GRANT USAGE ON *.* TO `test2`@`localhost` GRANT SELECT, INSERT, UPDATE, CREATE, DROP ON `test`.* TO `test2`@`localhost` ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; -ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp' +ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table `test`.`tp` SELECT * FROM tp WHERE a BETWEEN 0 AND 10; a b 2 Two @@ -91,11 +91,11 @@ a b 6 Six 8 Eight ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE t_10; -ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tp' +ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table `test`.`tp` ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00; -ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp' +ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table `test`.`tsp` ALTER TABLE tsp EXCHANGE PARTITION sp00 WITH TABLE tsp_00; -ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table 'tsp' +ERROR 42000: ALTER command denied to user 'test2'@'localhost' for table `test`.`tsp` connection default; disconnect test2; DROP TABLE IF EXISTS t_10; diff --git a/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_8_tokudb.result b/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_8_tokudb.result index 2fd45be9261..842c93ac403 100644 --- a/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_8_tokudb.result +++ b/storage/tokudb/mysql-test/tokudb_parts/r/partition_exch_qa_8_tokudb.result @@ -62,9 +62,9 @@ connection default; REVOKE INSERT ON testdb.* FROM test2@localhost; connect test2,localhost,test2,,test,$MASTER_MYPORT,$MASTER_MYSOCK; ALTER TABLE tp EXCHANGE PARTITION p0 WITH TABLE testdb.t_10; -ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 't_10' +ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table `testdb`.`t_10` ALTER TABLE testdb.tp EXCHANGE PARTITION p0 WITH TABLE t_10; -ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table 'tp' +ERROR 42000: INSERT command denied to user 'test2'@'localhost' for table `testdb`.`tp` disconnect test2; connection default; DROP TABLE IF EXISTS t_10; |