diff options
Diffstat (limited to 'storage')
38 files changed, 262 insertions, 219 deletions
diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index 44383d584a8..5690062be47 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -79,7 +79,8 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp) if (trace(2)) htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); - if (tdbp) { + if (tdbp) + { // Attach the new column to the table block if (!tdbp->GetColumns()) { tdbp->SetColumns(this); diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index e7681c3bdab..60c10527fe9 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -645,7 +645,8 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted) // This is a pseudo indexed sorted block optimized column // return 0; - if (tdbp->GetKindex()) { + if (tdbp->GetKindex()) + { if (((XXBASE*)tdbp->GetKindex())->GetID() == id) { tdbp->GetKindex()->Reset(); // Same index return (tdbp->GetKindex()->IsMul()) ? 2 : 1; diff --git a/storage/connect/filamap.cpp b/storage/connect/filamap.cpp index 6e71e1bf2cd..53150f9d8ae 100644 --- a/storage/connect/filamap.cpp +++ b/storage/connect/filamap.cpp @@ -349,7 +349,8 @@ int MAPFAM::ReadBuffer(PGLOBAL g) if ((rc = GetNext(g)) != RC_OK) return rc; - case RC_NF: + /* falls through */ + case RC_NF: // Skip this record if ((rc = SkipRecord(g, false)) != RC_OK) return rc; diff --git a/storage/connect/filamdbf.cpp b/storage/connect/filamdbf.cpp index 253ed96a044..e48e40601e3 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -840,7 +840,8 @@ int DBFFAM::DeleteRecords(PGLOBAL g, int irc) { if (irc == RC_OK) { // T_Stream is the temporary stream or the table file stream itself - if (!T_Stream) { + if (!T_Stream) + { if (UseTemp) { if (OpenTempFile(g)) return RC_FX; @@ -851,7 +852,6 @@ int DBFFAM::DeleteRecords(PGLOBAL g, int irc) } else T_Stream = Stream; } - *Tdbp->GetLine() = '*'; Modif++; // Modified line in Delete mode } // endif irc diff --git a/storage/connect/filamgz.cpp b/storage/connect/filamgz.cpp index f7517b53b8f..d694eab3845 100644 --- a/storage/connect/filamgz.cpp +++ b/storage/connect/filamgz.cpp @@ -1021,6 +1021,7 @@ bool ZLBFAM::AllocateBuffer(PGLOBAL g) #else sprintf(g->Message, MSG(READ_ERROR), To_File, _strerror(NULL)); #endif + /* falls through */ case RC_NF: return TRUE; } // endswitch diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index f8ae5930a60..20205e0a8cf 100644 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -301,7 +301,8 @@ int VCTFAM::Cardinality(PGLOBAL g) if (!g) return 1; - if (Block < 0) { + if (Block < 0) + { if (Split) { // Separate column files and no pre setting of Block and Last // This allows to see a table modified externally, but Block @@ -348,7 +349,6 @@ int VCTFAM::Cardinality(PGLOBAL g) } // endif split } - return (Block) ? ((Block - 1) * Nrec + Last) : 0; } // end of Cardinality diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index e1f18b61ce1..fd1cf0ceff9 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -91,6 +91,7 @@ static bool ZipFile(PGLOBAL g, ZIPUTIL *zutp, PCSZ fn, PCSZ entry, char *buf) static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf) { char filename[_MAX_PATH]; + /*********************************************************************/ /* pat is a multiple file name with wildcard characters */ /*********************************************************************/ @@ -98,9 +99,9 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf) #if defined(__WIN__) char drive[_MAX_DRIVE], direc[_MAX_DIR]; - int rc; WIN32_FIND_DATA FileData; HANDLE hSearch; + int rc; _splitpath(filename, drive, direc, NULL, NULL); diff --git a/storage/connect/filter.cpp b/storage/connect/filter.cpp index 5bd9fc08ac4..d776b403917 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -1220,7 +1220,7 @@ bool FILTER::Eval(PGLOBAL g) int i; // n = 0; //PSUBQ subp = NULL; PARRAY ap = NULL; - PDBUSER dup = PlgGetUser(g); + PDBUSER dup __attribute__((unused)) = PlgGetUser(g); if (Opc <= OP_XX) { diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 2a1bd53f51b..28b71b95e4d 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -240,9 +240,11 @@ YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +#ifdef NOT_USED static int yy_start_stack_ptr = 0; static int yy_start_stack_depth = 0; static int *yy_start_stack = 0; +#endif static void *yy_flex_alloc YY_PROTO(( unsigned int )); static void *yy_flex_realloc YY_PROTO(( void *, unsigned int )); @@ -264,11 +266,13 @@ extern char *yytext; static void yy_flex_strncpy YY_PROTO(( char *, const char *, int )); #endif +#ifdef NOT_USED #ifdef __cplusplus static int yyinput YY_PROTO(( void )); #else static int input YY_PROTO(( void )); #endif +#endif static yy_state_type yy_get_previous_state YY_PROTO(( void )); static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); @@ -1057,6 +1061,8 @@ register char *yy_bp; } +#ifdef NOT_USED + #ifdef __cplusplus static int yyinput() #else @@ -1123,7 +1129,7 @@ static int input() return c; } - +#endif /* NOT_USED */ #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index 98a4659cea8..5d7d08285cf 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -154,7 +154,7 @@ PJSON ParseJson(PGLOBAL g, char *s, int len, int *ptyp, bool *comma) b = false; break; } // endif b - + /* falls through */ default: if (jsp) goto tryit; diff --git a/storage/connect/jsonudf.cpp b/storage/connect/jsonudf.cpp index b1e32394de0..edd596ea02e 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -379,6 +379,7 @@ void JSNX::SetJsonValue(PGLOBAL g, PVAL vp, PJVAL val, int n) case TYPE_NULL: vp->SetNull(true); + /* falls through */ default: vp->Reset(); } // endswitch Type @@ -1772,7 +1773,7 @@ static char *GetJsonFile(PGLOBAL g, char *fn) #endif if (h == -1) { - sprintf(g->Message, "Error %d opening %s", errno, fn); + sprintf(g->Message, "Error %d opening %-.1024s", errno, fn); return NULL; } // endif h @@ -1784,7 +1785,7 @@ static char *GetJsonFile(PGLOBAL g, char *fn) if ((str = (char*)PlgDBSubAlloc(g, NULL, len + 1))) { if ((n = read(h, str, len)) < 0) { - sprintf(g->Message, "Error %d reading %d bytes from %s", errno, len, fn); + sprintf(g->Message, "Error %d reading %d bytes from %-.1024s", errno, len, fn); return NULL; } // endif n @@ -3479,7 +3480,7 @@ char *jsonget_string(UDF_INIT *initid, UDF_ARGS *args, char *result, } catch (int n) { if (trace(1)) - htrc("Exception %d: %s\n", n, g->Message); + htrc("Exception %d: %-.256s\n", n, g->Message); PUSH_WARNING(g->Message); str = NULL; @@ -3761,7 +3762,6 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message) } else more += (ulong)*(longlong*)args->args[2]; } - CalcLen(args, false, reslen, memlen); // TODO: calculate this @@ -3839,7 +3839,7 @@ char *jsonlocate(UDF_INIT *initid, UDF_ARGS *args, char *result, } catch (int n) { if (trace(1)) - htrc("Exception %d: %s\n", n, g->Message); + htrc("Exception %d: %-.256s\n", n, g->Message); PUSH_WARNING(g->Message); *error = 1; @@ -3883,12 +3883,13 @@ my_bool json_locate_all_init(UDF_INIT *initid, UDF_ARGS *args, char *message) strcpy(message, "Third argument is not an integer (Depth)"); return true; } else if (args->arg_count > 3) + { if (args->arg_type[3] != INT_RESULT) { strcpy(message, "Fourth argument is not an integer (memory)"); return true; } else more += (ulong)*(longlong*)args->args[2]; - + } CalcLen(args, false, reslen, memlen); // TODO: calculate this @@ -3964,7 +3965,7 @@ char *json_locate_all(UDF_INIT *initid, UDF_ARGS *args, char *result, } catch (int n) { if (trace(1)) - htrc("Exception %d: %s\n", n, g->Message); + htrc("Exception %d: %-.256s\n", n, g->Message); PUSH_WARNING(g->Message); *error = 1; @@ -4244,7 +4245,7 @@ char *handle_item(UDF_INIT *initid, UDF_ARGS *args, char *result, } catch (int n) { if (trace(1)) - htrc("Exception %d: %s\n", n, g->Message); + htrc("Exception %d: %-.256s\n", n, g->Message); PUSH_WARNING(g->Message); str = NULL; diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index c1eaa6766cc..3b2696b066d 100644 --- a/storage/connect/libdoc.cpp +++ b/storage/connect/libdoc.cpp @@ -211,7 +211,7 @@ static xmlStrdupFunc Strdup; void xmlMyFree(void *mem) { if (trace(1)) { - htrc("%.4d Freeing at %p %s\n", ++m, mem, s); + htrc("%.4d Freeing at %p %-.256s\n", ++m, mem, s); *s = 0; } // endif trace Free(mem); @@ -221,7 +221,7 @@ void *xmlMyMalloc(size_t size) { void *p = Malloc(size); if (trace(1)) { - htrc("%.4d Allocating %.5d at %p %s\n", ++m, size, p, s); + htrc("%.4d Allocating %.5d at %p %-.256s\n", ++m, size, p, s); *s = 0; } // endif trace return p; @@ -231,7 +231,7 @@ void *xmlMyMallocAtomic(size_t size) { void *p = MallocA(size); if (trace(1)) { - htrc("%.4d Atom alloc %.5d at %p %s\n", ++m, size, p, s); + htrc("%.4d Atom alloc %.5d at %p %-.256s\n", ++m, size, p, s); *s = 0; } // endif trace return p; @@ -241,7 +241,7 @@ void *xmlMyRealloc(void *mem, size_t size) { void *p = Realloc(mem, size); if (trace(1)) { - htrc("%.4d ReAlloc %.5d to %p from %p %s\n", ++m, size, p, mem, s); + htrc("%.4d ReAlloc %.5d to %p from %p %-.256s\n", ++m, size, p, mem, s); *s = 0; } // endif trace return p; @@ -251,7 +251,7 @@ char *xmlMyStrdup(const char *str) { char *p = Strdup(str); if (trace(1)) { - htrc("%.4d Duplicating to %p from %p %s %s\n", ++m, p, str, str, s); + htrc("%.4d Duplicating to %p from %p %-.256s %-.256s\n", ++m, p, str, str, s); *s = 0; } // endif trace return p; @@ -448,7 +448,7 @@ bool LIBXMLDOC::NewDoc(PGLOBAL g, PCSZ ver) void LIBXMLDOC::AddComment(PGLOBAL g, char *txtp) { if (trace(1)) - htrc("AddComment: %s\n", txtp); + htrc("AddComment: %-.256s\n", txtp); xmlNodePtr cp = xmlNewDocComment(Docp, BAD_CAST txtp); xmlAddChild((xmlNodePtr)Docp, cp); @@ -476,7 +476,7 @@ PXNODE LIBXMLDOC::GetRoot(PGLOBAL g) PXNODE LIBXMLDOC::NewRoot(PGLOBAL g, char *name) { if (trace(1)) - htrc("NewRoot: %s\n", name); + htrc("NewRoot: %-.256s\n", name); xmlNodePtr root = xmlNewDocNode(Docp, NULL, BAD_CAST name, NULL); @@ -494,7 +494,7 @@ PXNODE LIBXMLDOC::NewRoot(PGLOBAL g, char *name) PXNODE LIBXMLDOC::NewPnode(PGLOBAL g, char *name) { if (trace(1)) - htrc("NewNode: %s\n", name); + htrc("NewNode: %-.256s\n", name); xmlNodePtr nop; @@ -535,7 +535,7 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) FILE *of; if (trace(1)) - htrc("DumpDoc: %s\n", ofn); + htrc("DumpDoc: %-.256s\n", ofn); if (!(of= global_fopen(g, MSGID_CANNOT_OPEN, ofn, "w"))) return -1; @@ -554,8 +554,8 @@ int LIBXMLDOC::DumpDoc(PGLOBAL g, char *ofn) xmlNodePtr Rootp; // Save the modified document - fprintf(of, "<?xml version=\"1.0\" encoding=\"%s\"?>\n", Encoding); - fprintf(of, "<!-- Created by CONNECT %s -->\n", version); + fprintf(of, "<?xml version=\"1.0\" encoding=\"%-.256s\"?>\n", Encoding); + fprintf(of, "<!-- Created by CONNECT %-.256s -->\n", version); if (!(Rootp = xmlDocGetRootElement(Docp))) return 1; @@ -631,7 +631,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) xmlNodeSetPtr nl; if (trace(1)) - htrc("GetNodeList: %s np=%p\n", xp, np); + htrc("GetNodeList: %-.256s np=%p\n", xp, np); if (!Ctxp) { // Init Xpath @@ -648,7 +648,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) strcpy(g->Message, MSG(XPATH_CNTX_ERR)); if (trace(1)) - htrc("Context error: %s\n", g->Message); + htrc("Context error: %-.256s\n", g->Message); return NULL; } // endif xpathCtx @@ -656,7 +656,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) // Register namespaces from list (if any) for (PNS nsp = Namespaces; nsp; nsp = nsp->Next) { if (trace(1)) - htrc("Calling xmlXPathRegisterNs Prefix=%s Uri=%s\n", + htrc("Calling xmlXPathRegisterNs Prefix=%-.256s Uri=%-.512s\n", nsp->Prefix, nsp->Uri); if (xmlXPathRegisterNs(Ctxp, BAD_CAST nsp->Prefix, @@ -664,7 +664,7 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) sprintf(g->Message, MSG(REGISTER_ERR), nsp->Prefix, nsp->Uri); if (trace(1)) - htrc("Ns error: %s\n", g->Message); + htrc("Ns error: %-.256s\n", g->Message); return NULL; } // endif Registering @@ -699,14 +699,14 @@ xmlNodeSetPtr LIBXMLDOC::GetNodeList(PGLOBAL g, xmlNodePtr np, char *xp) Ctxp->node = np; if (trace(1)) - htrc("Calling xmlXPathEval %s Ctxp=%p\n", xp, Ctxp); + htrc("Calling xmlXPathEval %-.256s Ctxp=%p\n", xp, Ctxp); // Evaluate table xpath if (!(Xop = xmlXPathEval(BAD_CAST xp, Ctxp))) { sprintf(g->Message, MSG(XPATH_EVAL_ERR), xp); if (trace(1)) - htrc("Path error: %s\n", g->Message); + htrc("Path error: %-.256s\n", g->Message); return NULL; } else @@ -882,14 +882,14 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) } // endif p1 } else { - sprintf(g->Message, "Truncated %s content", Nodep->name); + sprintf(g->Message, "Truncated %-.256s content", Nodep->name); rc = RC_INFO; } // endif len *p2 = 0; if (trace(1)) - htrc("GetText buf='%s' len=%d\n", buf, len); + htrc("GetText buf='%-.256s' len=%d\n", buf, len); xmlFree(Content); Content = NULL; @@ -897,7 +897,7 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) *buf = '\0'; if (trace(1)) - htrc("GetContent: %s\n", buf); + htrc("GetContent: %-.256s\n", buf); return rc; } // end of GetContent @@ -908,12 +908,12 @@ RCODE XML2NODE::GetContent(PGLOBAL g, char *buf, int len) bool XML2NODE::SetContent(PGLOBAL g, char *txtp, int len) { if (trace(1)) - htrc("SetContent: %s\n", txtp); + htrc("SetContent: %-.256s\n", txtp); xmlChar *buf = xmlEncodeEntitiesReentrant(Docp, BAD_CAST txtp); if (trace(1)) - htrc("SetContent: %s -> %s\n", txtp, buf); + htrc("SetContent: %-.256s -> %-.256s\n", txtp, buf); xmlNodeSetContent(Nodep, buf); xmlFree(buf); @@ -942,7 +942,7 @@ PXNODE XML2NODE::Clone(PGLOBAL g, PXNODE np) PXLIST XML2NODE::GetChildElements(PGLOBAL g, char *xp, PXLIST lp) { if (trace(1)) - htrc("GetChildElements: %s\n", xp); + htrc("GetChildElements: %-.256s\n", xp); return SelectNodes(g, (xp) ? xp : (char*)"*", lp); } // end of GetChildElements @@ -953,7 +953,7 @@ PXLIST XML2NODE::GetChildElements(PGLOBAL g, char *xp, PXLIST lp) PXLIST XML2NODE::SelectNodes(PGLOBAL g, char *xp, PXLIST lp) { if (trace(1)) - htrc("SelectNodes: %s\n", xp); + htrc("SelectNodes: %-.256s\n", xp); xmlNodeSetPtr nl = ((PXDOC2)Doc)->GetNodeList(g, Nodep, xp); @@ -971,7 +971,7 @@ PXLIST XML2NODE::SelectNodes(PGLOBAL g, char *xp, PXLIST lp) PXNODE XML2NODE::SelectSingleNode(PGLOBAL g, char *xp, PXNODE np) { if (trace(1)) - htrc("SelectSingleNode: %s\n", xp); + htrc("SelectSingleNode: %-.256s\n", xp); xmlNodeSetPtr nl = ((PXDOC2)Doc)->GetNodeList(g, Nodep, xp); @@ -995,7 +995,7 @@ PXATTR XML2NODE::GetAttribute(PGLOBAL g, char *name, PXATTR ap) xmlAttrPtr atp; if (trace(1)) - htrc("GetAttribute: %s\n", SVP(name)); + htrc("GetAttribute: %-.256s\n", SVP(name)); if (name) atp = xmlHasProp(Nodep, BAD_CAST name); @@ -1024,7 +1024,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np) char *p, *pn, *pf = NULL, *nmp = PlugDup(g, name); if (trace(1)) - htrc("AddChildNode: %s\n", name); + htrc("AddChildNode: %-.256s\n", name); // Is a prefix specified if ((pn = strchr(nmp, ':'))) { @@ -1075,7 +1075,7 @@ PXNODE XML2NODE::AddChildNode(PGLOBAL g, PCSZ name, PXNODE np) PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) { if (trace(1)) - htrc("AddProperty: %s\n", name); + htrc("AddProperty: %-.256s\n", name); xmlAttrPtr atp = xmlNewProp(Nodep, BAD_CAST name, NULL); @@ -1098,7 +1098,7 @@ PXATTR XML2NODE::AddProperty(PGLOBAL g, char *name, PXATTR ap) void XML2NODE::AddText(PGLOBAL g, PCSZ txtp) { if (trace(1)) - htrc("AddText: %s\n", txtp); + htrc("AddText: %-.256s\n", txtp); // This is to avoid a blank line when inserting a new line xmlNodePtr np = xmlGetLastChild(Nodep); @@ -1158,7 +1158,7 @@ void XML2NODE::DeleteChild(PGLOBAL g, PXNODE dnp) err: if (trace(1)) - htrc("DeleteChild: errmsg=%s\n", xerr->message); + htrc("DeleteChild: errmsg=%-.256s\n", xerr->message); xmlResetError(xerr); } // end of DeleteChild @@ -1260,7 +1260,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len) if (strlen((char*)txt) >= (unsigned)len) { memcpy(buf, txt, len - 1); buf[len - 1] = 0; - sprintf(g->Message, "Truncated %s content", Atrp->name); + sprintf(g->Message, "Truncated %-.256s content", Atrp->name); rc = RC_INFO; } else strcpy(buf, (const char*)txt); @@ -1270,7 +1270,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len) *buf = '\0'; if (trace(1)) - htrc("GetText: %s\n", buf); + htrc("GetText: %-.256s\n", buf); return rc; } // end of GetText @@ -1281,7 +1281,7 @@ RCODE XML2ATTR::GetText(PGLOBAL g, char *buf, int len) bool XML2ATTR::SetText(PGLOBAL g, char *txtp, int len) { if (trace(1)) - htrc("SetText: %s %d\n", txtp, len); + htrc("SetText: %-.256s %d\n", txtp, len); xmlSetProp(Parent, Atrp->name, BAD_CAST txtp); return false; diff --git a/storage/connect/myutil.cpp b/storage/connect/myutil.cpp index 338a79d9455..89b18f86323 100644 --- a/storage/connect/myutil.cpp +++ b/storage/connect/myutil.cpp @@ -66,6 +66,7 @@ int MYSQLtoPLG(char *typname, char *var) break; case TPC_SKIP: *var = 'K'; + /* falls through */ default: // TPC_NO type = TYPE_ERROR; } // endswitch xconv @@ -237,13 +238,14 @@ int MYSQLtoPLG(int mytype, char *var) break; case TPC_SKIP: *var = 'K'; // Skip + /* falls through */ default: // TPC_NO type = TYPE_ERROR; } // endswitch xconv return type; } // endif var - + /* falls through */ default: type = TYPE_ERROR; } // endswitch mytype diff --git a/storage/connect/plugutil.cpp b/storage/connect/plugutil.cpp index e74937b942a..3899379ade2 100644 --- a/storage/connect/plugutil.cpp +++ b/storage/connect/plugutil.cpp @@ -147,7 +147,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize) PGLOBAL g; if (trace(2)) - htrc("PlugInit: Language='%s'\n", + htrc("PlugInit: Language='%-.256s'\n", ((!Language) ? "Null" : (char*)Language)); try { @@ -216,15 +216,15 @@ LPSTR PlugRemoveType(LPSTR pBuff, LPCSTR FileName) _splitpath(FileName, drive, direc, fname, ftype); if (trace(2)) { - htrc("after _splitpath: FileName=%s\n", FileName); - htrc("drive=%s dir=%s fname=%s ext=%s\n", + htrc("after _splitpath: FileName=%-.256s\n", FileName); + htrc("drive=%-.256s dir=%-.256s fname=%-.256s ext=%-.256s\n", SVP(drive), direc, fname, ftype); } // endif trace _makepath(pBuff, drive, direc, fname, ""); if (trace(2)) - htrc("buff='%s'\n", pBuff); + htrc("buff='%-.256s'\n", pBuff); return pBuff; } // end of PlugRemoveType @@ -257,7 +257,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) #endif if (trace(2)) - htrc("prefix=%s fn=%s path=%s\n", prefix, FileName, defpath); + htrc("prefix=%-.256s fn=%-.256s path=%-.256s\n", prefix, FileName, defpath); if (!strncmp(FileName, "//", 2) || !strncmp(FileName, "\\\\", 2)) { strcpy(pBuff, FileName); // Remote file @@ -274,7 +274,7 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) if (*FileName == '~') { if (_fullpath(pBuff, FileName, _MAX_PATH)) { if (trace(2)) - htrc("pbuff='%s'\n", pBuff); + htrc("pbuff='%-.256s'\n", pBuff); return pBuff; } else @@ -309,12 +309,12 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) _splitpath(tmpdir, defdrv, defdir, NULL, NULL); if (trace(2)) { - htrc("after _splitpath: FileName=%s\n", FileName); + htrc("after _splitpath: FileName=%-.256s\n", FileName); #if defined(__WIN__) - htrc("drive=%s dir=%s fname=%s ext=%s\n", drive, direc, fname, ftype); - htrc("defdrv=%s defdir=%s\n", defdrv, defdir); + htrc("drive=%-.256s dir=%-.256s fname=%-.256s ext=%-.256s\n", drive, direc, fname, ftype); + htrc("defdrv=%-.256s defdir=%-.256s\n", defdrv, defdir); #else - htrc("dir=%s fname=%s ext=%s\n", direc, fname, ftype); + htrc("dir=%-.256s fname=%-.256s ext=%-.256s\n", direc, fname, ftype); #endif } // endif trace @@ -336,11 +336,11 @@ LPCSTR PlugSetPath(LPSTR pBuff, LPCSTR prefix, LPCSTR FileName, LPCSTR defpath) _makepath(newname, drive, direc, fname, ftype); if (trace(2)) - htrc("newname='%s'\n", newname); + htrc("newname='%-.256s'\n", newname); if (_fullpath(pBuff, newname, _MAX_PATH)) { if (trace(2)) - htrc("pbuff='%s'\n", pBuff); + htrc("pbuff='%-.256s'\n", pBuff); return pBuff; } else @@ -365,22 +365,22 @@ 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 %s", msgfile); + sprintf(stmsg, "Fail to open message file %-.256s", msgfile); goto err; } // endif mfile for (;;) if (!fgets(buff, 256, mfile)) { - sprintf(stmsg, "Cannot get message %d %s", mid, SVP(m)); + sprintf(stmsg, "Cannot get message %d %-.256s", mid, SVP(m)); goto fin; } else if (atoi(buff) == mid) break; - if (sscanf(buff, " %*d %s \"%[^\"]", msgid, stmsg) < 2) { + if (sscanf(buff, " %*d %-.256s \"%[^\"]", msgid, stmsg) < 2) { // Old message file if (!sscanf(buff, " %*d \"%[^\"]", stmsg)) { - sprintf(stmsg, "Bad message file for %d %s", mid, SVP(m)); + sprintf(stmsg, "Bad message file for %d %-.256s", mid, SVP(m)); goto fin; } else m = NULL; @@ -485,7 +485,7 @@ bool AllocSarea(PGLOBAL g, uint size) if (g->Sarea) htrc("Work area of %u allocated at %p\n", size, g->Sarea); else - htrc("SareaAlloc: %s\n", g->Message); + htrc("SareaAlloc: %-.256s\n", g->Message); } // endif trace @@ -567,11 +567,11 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size) PCSZ pname = "Work"; sprintf(g->Message, - "Not enough memory in %s area for request of %u (used=%d free=%d)", + "Not enough memory in %-.256s area for request of %u (used=%d free=%d)", pname, (uint)size, pph->To_Free, pph->FreeBlk); if (trace(1)) - htrc("PlugSubAlloc: %s\n", g->Message); + htrc("PlugSubAlloc: %-.256s\n", g->Message); DoThrow(1234); } /* endif size OS32 code */ diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp index 2d3c6a6aacd..5b97377db97 100644 --- a/storage/connect/reldef.cpp +++ b/storage/connect/reldef.cpp @@ -350,8 +350,6 @@ RECFM TABDEF::GetTableFormat(const char* type) bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR schema, LPCSTR am) { - int poff = 0; - Hc = ((MYCAT*)cat)->GetHandler(); Name = (PSZ)name; Schema = (PSZ)Hc->GetDBName(schema); @@ -430,6 +428,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g) case RECFM_CSV: case RECFM_FMT: nlg+= nof; + /* falls through */ case RECFM_DIR: case RECFM_XML: poff= loff + (pcf->Flags & U_VIRTUAL ? 0 : 1); @@ -472,6 +471,7 @@ int TABDEF::GetColCatInfo(PGLOBAL g) switch (trf ) { case RECFM_VCT: cdp->SetOffset(0); // Not to have shift + /* falls through */ case RECFM_BIN: // BIN/VEC are packed by default if (nof) { diff --git a/storage/connect/tabdos.cpp b/storage/connect/tabdos.cpp index c979d86e9ae..32f549b0f79 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -1424,9 +1424,7 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv) bool conv = false, xdb2 = false; PXOB xp[2]; PCOL colp; -//LSTVAL *vlp = NULL; -//SFROW *sfr[2]; - PBF bfp = NULL; + PBF bfp = NULL; for (i = 0; i < 2; i++) { switch (arg[i]->GetType()) { diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index 432e297e59a..759f84594b8 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -350,7 +350,6 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) } else goto skip; } - // isdigit cannot be used here because of debug assert if (!strchr("0123456789", *p)) { if (!digit && *p == dechar) @@ -373,7 +372,6 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) } else goto skip; } - if (n) { len[i] = MY_MAX(len[i], n); type = (digit || n == 0 || (dec && n == 1)) ? TYPE_STRING @@ -761,7 +759,6 @@ bool TDBCSV::OpenDB(PGLOBAL g) if (!cdp->IsSpecial() && !cdp->IsVirtual()) Fields++; } - Offset = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields); Fldlen = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields); diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index ca126d8c488..a8e96e2fe8d 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -1429,6 +1429,7 @@ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj) return NULL; for (p1 = p2 = mgopath; *p1; p1++) + { if (i) { // Inside [] if (isdigit(*p1)) { if (!proj) @@ -1466,12 +1467,12 @@ PSZ JSONCOL::GetJpath(PGLOBAL g, bool proj) p2--; // Suppress last :* break; } // endif p2 - + /* falls through */ default: *p2++ = *p1; break; } // endswitch p1; - + } *p2 = 0; return mgopath; } else @@ -2128,7 +2129,6 @@ int TDBJSON::Cardinality(PGLOBAL g) } else return 10; } - return Cardinal; } // end of Cardinality diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 4bec25eeebc..20d4c0cb032 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -450,9 +450,8 @@ bool TDBOCCUR::OpenDB(PGLOBAL g) N = M = 0; RowFlag = 0; - if (Xcolp) { - Xcolp->Xreset(); - } + if (Xcolp) + Xcolp->Xreset(); return Tdbp->OpenDB(g); } // endif use diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 8aee9fbb10d..1ba36864005 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -747,7 +747,9 @@ int TDBPIVOT::ReadDB(PGLOBAL g) colp->ReadColumn(g); for (colp = Columns; colp; colp = colp->GetNext()) - if (colp->GetAmType() == TYPE_AM_SRC) { + { + if (colp->GetAmType() == TYPE_AM_SRC) + { if (FileStatus) { if (((PSRCCOL)colp)->CompareLast()) { newrow = (RowFlag) ? TRUE : FALSE; @@ -757,7 +759,7 @@ int TDBPIVOT::ReadDB(PGLOBAL g) } else ((PSRCCOL)colp)->SetColumn(); } - + } FileStatus = 1; } // endif RowFlag diff --git a/storage/connect/tabvir.cpp b/storage/connect/tabvir.cpp index c78a8f531f6..76d52e198e3 100644 --- a/storage/connect/tabvir.cpp +++ b/storage/connect/tabvir.cpp @@ -168,16 +168,17 @@ int TDBVIR::TestFilter(PFIL filp, bool nop) } // endswitch op if (!nop) switch (op) { - case OP_LT: l1--; - case OP_LE: limit = l1; break; - default: ok = false; - } // endswitch op - + case OP_LT: l1--; + /* falls through */ + case OP_LE: limit = l1; break; + default: ok = false; + } // endswitch op else switch (op) { - case OP_GE: l1--; - case OP_GT: limit = l1; break; - default: ok = false; - } // endswitch op + case OP_GE: l1--; + /* falls through */ + case OP_GT: limit = l1; break; + default: ok = false; + } // endswitch op limit = MY_MIN(MY_MAX(0, limit), Size); diff --git a/storage/connect/tabxml.cpp b/storage/connect/tabxml.cpp index 062d52679f6..cc67f825b87 100644 --- a/storage/connect/tabxml.cpp +++ b/storage/connect/tabxml.cpp @@ -218,8 +218,10 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) while (true) { if (!vp->atp && - !(node = (vp->nl) ? vp->nl->GetItem(g, vp->k++, tdp->Usedom ? node : NULL) - : NULL)) { + !(node = (vp->nl) ? vp->nl->GetItem(g, vp->k++, tdp->Usedom ? + node : NULL) + : NULL)) + { if (j) { vp = lvlp[--j]; @@ -235,7 +237,6 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) } else break; } - xcol->Name[vp->n] = 0; fmt[vp->m] = 0; @@ -249,6 +250,7 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) switch (vp->atp->GetText(g, buf, sizeof(buf))) { case RC_INFO: PushWarning(g, txmp); + /* falls through */ case RC_OK: strncat(fmt, "@", XLEN(fmt)); break; @@ -309,6 +311,7 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) switch (node->GetContent(g, buf, sizeof(buf))) { case RC_INFO: PushWarning(g, txmp); + /* falls through */ case RC_OK: xcol->Cbn = !strlen(buf); break; @@ -1271,7 +1274,8 @@ int TDBXML::ReadDB(PGLOBAL g) /***********************************************************************/ bool TDBXML::CheckRow(PGLOBAL g, bool b) { - if (NewRow && Mode == MODE_INSERT) { + if (NewRow && Mode == MODE_INSERT) + { if (Rowname) { TabNode->AddText(g, "\n\t"); RowNode = TabNode->AddChildNode(g, Rowname, RowNode); @@ -1526,7 +1530,8 @@ bool XMLCOL::ParseXpath(PGLOBAL g, bool mode) // Analyze the Xpath for this column for (i = 0, p = pbuf; (p2 = strchr(p, '/')); i++, p = p2 + 1) { - if (Tdbp->Mulnode && !strncmp(p, Tdbp->Mulnode, p2 - p)) { + if (Tdbp->Mulnode && !strncmp(p, Tdbp->Mulnode, p2 - p)) + { if (!Tdbp->Xpand && mode) { strcpy(g->Message, MSG(CONCAT_SUBNODE)); return true; @@ -1778,7 +1783,8 @@ void XMLCOL::WriteColumn(PGLOBAL g) else break; - if (ColNode) { + if (ColNode) + { if (Type) ValNode = ColNode->SelectSingleNode(g, Xname, Vxnp); else @@ -1796,7 +1802,8 @@ void XMLCOL::WriteColumn(PGLOBAL g) /* Create missing nodes. */ /*********************************************************************/ if (ColNode == NULL) { - if (TopNode == NULL) { + if (TopNode == NULL) + { if (Tdbp->Clist) { Tdbp->RowNode->AddText(g, "\n\t\t"); ColNode = Tdbp->RowNode->AddChildNode(g, Tdbp->Colname); @@ -2018,7 +2025,8 @@ void XMULCOL::WriteColumn(PGLOBAL g) TopNode = ColNode; } // endfor k - if (ColNode) { + if (ColNode) + { if (Inod == Nod) { /***************************************************************/ /* The node value can be multiple. */ @@ -2036,10 +2044,12 @@ void XMULCOL::WriteColumn(PGLOBAL g) ValNode = Nlx->GetItem(g, Tdbp->Nsub, Vxnp); } else // Inod != Nod + { if (Type) ValNode = ColNode->SelectSingleNode(g, Xname, Vxnp); else AttNode = ColNode->GetAttribute(g, Xname, Vxap); + } } if (TopNode || ValNode || AttNode) break; // We found the good column @@ -2052,7 +2062,8 @@ void XMULCOL::WriteColumn(PGLOBAL g) /* Create missing nodes. */ /*********************************************************************/ if (ColNode == NULL) { - if (TopNode == NULL) { + if (TopNode == NULL) + { if (Tdbp->Clist) { Tdbp->RowNode->AddText(g, "\n\t\t"); ColNode = Tdbp->RowNode->AddChildNode(g, Tdbp->Colname); @@ -2061,6 +2072,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) } else TopNode = Tdbp->RowNode; } + for (; k < Nod && TopNode; k++) { if (!done) { TopNode->AddText(g, "\n\t\t"); diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 2421aec9f67..1b3534b4f1b 100644 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -558,7 +558,8 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) Nk, n, Num_K, Ndif, addcolp, Tdbp->To_BlkFil, X); // Check whether the unique index is unique indeed - if (!Mul) { + if (!Mul) + { if (Ndif < Num_K) { strcpy(g->Message, MSG(INDEX_NOT_UNIQ)); brc = true; @@ -2042,7 +2043,8 @@ int XINDXS::Range(PGLOBAL g, int limit, bool incl) kp->Valp->SetValue_pval(xp->GetValue(), !kp->Prefix); k = FastFind(); - if (k < Num_K || Op != OP_EQ) { + if (k < Num_K || Op != OP_EQ) + { if (limit) n = (Mul) ? k : kp->Val_K; else diff --git a/storage/connect/zip.c b/storage/connect/zip.c index 18614576ef4..52d63e108e7 100644 --- a/storage/connect/zip.c +++ b/storage/connect/zip.c @@ -28,6 +28,7 @@ #include <time.h> #include "zlib.h" #include "zip.h" +#include "my_attribute.h" #ifdef STDC # include <stddef.h> @@ -1057,7 +1058,7 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, const void* extrafield_global, uInt size_extrafield_global, const char* comment, int method, int level, int raw, int windowBits,int memLevel, int strategy, - const char* password, uLong crcForCrypting, + const char* password, uLong crcForCrypting __attribute__((unused)), uLong versionMadeBy, uLong flagBase, int zip64) { zip64_internal* zi; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index e7f25a0063c..3634e372bd9 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -11083,7 +11083,10 @@ foreign_fail: /* MDEV-17468: Avoid this at least when ctx->is_instant(). Currently dict_load_column_low() is the only place where num_base for virtual columns is assigned to nonzero. */ - if (ctx0->num_to_drop_vcol || ctx0->num_to_add_vcol) { + if (ctx0->num_to_drop_vcol || ctx0->num_to_add_vcol + || (ctx0->is_instant() + && m_prebuilt->table->n_v_cols + && ha_alter_info->handler_flags & ALTER_STORED_COLUMN_ORDER)) { DBUG_ASSERT(ctx0->old_table->get_ref_count() == 1); trx_commit_for_mysql(m_prebuilt->trx); diff --git a/storage/innobase/include/ib0mutex.h b/storage/innobase/include/ib0mutex.h index 960cafe5cdb..ce0e911dbb4 100644 --- a/storage/innobase/include/ib0mutex.h +++ b/storage/innobase/include/ib0mutex.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2019, MariaDB Corporation. +Copyright (c) 2017, 2020, 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 @@ -29,7 +29,6 @@ Created 2013-03-26 Sunny Bains. #ifndef ib0mutex_h #define ib0mutex_h -#include "my_atomic.h" #include "my_cpu.h" #include "os0event.h" #include "sync0arr.h" diff --git a/storage/innobase/include/ut0rnd.h b/storage/innobase/include/ut0rnd.h index 9af8687bfd0..5b1ae5bc0da 100644 --- a/storage/innobase/include/ut0rnd.h +++ b/storage/innobase/include/ut0rnd.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2019, MariaDB Corporation. +Copyright (c) 2019, 2020, 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 @@ -32,7 +32,7 @@ Created 1/20/1994 Heikki Tuuri #ifndef UNIV_INNOCHECKSUM /** Seed value of ut_rnd_gen() */ -extern int32 ut_rnd_current; +extern std::atomic<uint32_t> ut_rnd_current; /** @return a pseudo-random 32-bit number */ inline uint32_t ut_rnd_gen() @@ -45,8 +45,7 @@ inline uint32_t ut_rnd_gen() x^19+x^18+x^14+x^13+x^11+x^10+x^9+x^8+x^6+1 */ const uint32_t crc32c= 0x1edc6f41; - uint32_t rnd= my_atomic_load32_explicit(&ut_rnd_current, - MY_MEMORY_ORDER_RELAXED); + uint32_t rnd= ut_rnd_current.load(std::memory_order_relaxed); if (UNIV_UNLIKELY(rnd == 0)) { @@ -61,7 +60,7 @@ inline uint32_t ut_rnd_gen() rnd^= crc32c; } - my_atomic_store32_explicit(&ut_rnd_current, rnd, MY_MEMORY_ORDER_RELAXED); + ut_rnd_current.store(rnd, std::memory_order_relaxed); return rnd; } diff --git a/storage/innobase/row/row0log.cc b/storage/innobase/row/row0log.cc index 91879068c17..0fd3f840fcf 100644 --- a/storage/innobase/row/row0log.cc +++ b/storage/innobase/row/row0log.cc @@ -1137,6 +1137,7 @@ row_log_table_get_pk_old_col( /** Maps an old table column of a PRIMARY KEY column. @param[in] ifield clustered index field in the new table (after ALTER TABLE) +@param[in] index the clustered index of ifield @param[in,out] dfield clustered index tuple field in the new table @param[in,out] heap memory heap for allocating dfield contents @param[in] rec clustered index leaf page record in the old @@ -1152,6 +1153,7 @@ static dberr_t row_log_table_get_pk_col( const dict_field_t* ifield, + const dict_index_t* index, dfield_t* dfield, mem_heap_t* heap, const rec_t* rec, @@ -1175,14 +1177,19 @@ row_log_table_get_pk_col( return(DB_INVALID_NULL); } - ulint n_default_cols = i - DATA_N_SYS_COLS; + ulint new_i = dict_col_get_clust_pos(ifield->col, index); + + if (UNIV_UNLIKELY(new_i >= log->defaults->n_fields)) { + ut_ad(0); + return DB_INVALID_NULL; + } field = static_cast<const byte*>( - log->defaults->fields[n_default_cols].data); + log->defaults->fields[new_i].data); if (!field) { return(DB_INVALID_NULL); } - len = log->defaults->fields[i - DATA_N_SYS_COLS].len; + len = log->defaults->fields[new_i].len; } if (rec_offs_nth_extern(offsets, i)) { @@ -1341,7 +1348,7 @@ row_log_table_get_pk( } log->error = row_log_table_get_pk_col( - ifield, dfield, *heap, + ifield, new_index, dfield, *heap, rec, offsets, i, zip_size, max_len, log); diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index cbf3a9d1726..29ced04359f 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -458,6 +458,21 @@ row_undo_mod_clust( 2 columns so that we can access DB_TRX_ID, DB_ROLL_PTR. */ offset_t offsets_[REC_OFFS_HEADER_SIZE + MAX_REF_PARTS + 2]; if (trx_id_offset) { +#ifdef UNIV_DEBUG + ut_ad(rec_offs_validate(NULL, index, offsets)); + if (buf_block_get_page_zip( + btr_pcur_get_block(&node->pcur))) { + /* Below, page_zip_write_trx_id_and_roll_ptr() + needs offsets to access DB_TRX_ID,DB_ROLL_PTR. + We already computed offsets for possibly + another record in the clustered index. + Because the PRIMARY KEY is fixed-length, + the offsets for the PRIMARY KEY and + DB_TRX_ID,DB_ROLL_PTR are still valid. + Silence the rec_offs_validate() assertion. */ + rec_offs_make_valid(rec, index, true, offsets); + } +#endif } else if (rec_is_metadata(rec, *index)) { ut_ad(!buf_block_get_page_zip(btr_pcur_get_block( pcur))); diff --git a/storage/innobase/ut/ut0rnd.cc b/storage/innobase/ut/ut0rnd.cc index 8265121ef2e..a2e569514cb 100644 --- a/storage/innobase/ut/ut0rnd.cc +++ b/storage/innobase/ut/ut0rnd.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1994, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2019, MariaDB Corporation. +Copyright (c) 2019, 2020, 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 @@ -27,7 +27,7 @@ Created 5/11/1994 Heikki Tuuri #include "ut0rnd.h" /** Seed value of ut_rnd_gen() */ -int32 ut_rnd_current; +std::atomic<uint32_t> ut_rnd_current; /** These random numbers are used in ut_find_prime */ /*@{*/ diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index d4153dd8ead..5351f6ea673 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -554,6 +554,11 @@ static int table2maria(TABLE *table_arg, data_file_type row_type, if (!table_arg->field[field->field_index]->stored_in_db()) { my_free(*recinfo_out); + if (table_arg->s->long_unique_table) + { + my_error(ER_TOO_LONG_KEY, MYF(0), table_arg->file->max_key_length()); + DBUG_RETURN(HA_ERR_INDEX_COL_TOO_LONG); + } my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN, MYF(0)); DBUG_RETURN(HA_ERR_UNSUPPORTED); } @@ -2150,7 +2155,32 @@ void ha_maria::start_bulk_insert(ha_rows rows, uint flags) else { my_bool all_keys= MY_TEST(flags & HA_CREATE_UNIQUE_INDEX_BY_SORT); - maria_disable_indexes_for_rebuild(file, rows, all_keys); + /* + Deactivate all indexes that can be recreated fast. + These include packed keys on which sorting will use more temporary + space than the max allowed file length or for which the unpacked keys + will take much more space than packed keys. + Note that 'rows' may be zero for the case when we don't know how many + rows we will put into the file. + */ + MARIA_SHARE *share= file->s; + MARIA_KEYDEF *key=share->keyinfo; + uint i; + + DBUG_ASSERT(share->state.state.records == 0 && + (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES)); + for (i=0 ; i < share->base.keys ; i++,key++) + { + if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY | HA_RTREE_INDEX)) && + ! maria_too_big_key_for_sort(key,rows) && share->base.auto_key != i+1 && + (all_keys || !(key->flag & HA_NOSAME)) && + table->key_info[i].algorithm != HA_KEY_ALG_LONG_HASH) + { + maria_clear_key_active(share->state.key_map, i); + file->update|= HA_STATE_CHANGED; + file->create_unique_index_by_sort= all_keys; + } + } } if (share->now_transactional) { diff --git a/storage/maria/ma_check.c b/storage/maria/ma_check.c index 79c78628065..8b4e34816d5 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -6447,7 +6447,7 @@ static ha_checksum maria_byte_checksum(const uchar *buf, uint length) return crc; } -static my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows) +my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows) { uint key_maxlength=key->maxlength; if (key->flag & HA_FULLTEXT) @@ -6463,38 +6463,6 @@ static my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows) } /* - Deactivate all indexes that can be recreated fast. - These include packed keys on which sorting will use more temporary - space than the max allowed file length or for which the unpacked keys - will take much more space than packed keys. - Note that 'rows' may be zero for the case when we don't know how many - rows we will put into the file. - */ - -void maria_disable_indexes_for_rebuild(MARIA_HA *info, ha_rows rows, - my_bool all_keys) -{ - MARIA_SHARE *share= info->s; - MARIA_KEYDEF *key=share->keyinfo; - uint i; - - DBUG_ASSERT(share->state.state.records == 0 && - (!rows || rows >= MARIA_MIN_ROWS_TO_DISABLE_INDEXES)); - for (i=0 ; i < share->base.keys ; i++,key++) - { - if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY | HA_RTREE_INDEX)) && - ! maria_too_big_key_for_sort(key,rows) && share->base.auto_key != i+1 && - (all_keys || !(key->flag & HA_NOSAME))) - { - maria_clear_key_active(share->state.key_map, i); - info->update|= HA_STATE_CHANGED; - info->create_unique_index_by_sort= all_keys; - } - } -} - - -/* Return TRUE if we can use repair by sorting One can set the force argument to force to use sorting even if the temporary file would be quite big! diff --git a/storage/mroonga/vendor/groonga/lib/ii.c b/storage/mroonga/vendor/groonga/lib/ii.c index cd5559e6958..2abd074796c 100644 --- a/storage/mroonga/vendor/groonga/lib/ii.c +++ b/storage/mroonga/vendor/groonga/lib/ii.c @@ -4315,7 +4315,7 @@ grn_ii_remove(grn_ctx *ctx, const char *path) if (!path || strlen(path) > PATH_MAX - 4) { return GRN_INVALID_ARGUMENT; } if ((rc = grn_io_remove(ctx, path))) { goto exit; } grn_snprintf(buffer, PATH_MAX, PATH_MAX, - "%s.c", path); + "%-.256s.c", path); rc = grn_io_remove(ctx, buffer); exit : return rc; @@ -4331,12 +4331,12 @@ grn_ii_truncate(grn_ctx *ctx, grn_ii *ii) uint32_t flags; if ((io_segpath = grn_io_path(ii->seg)) && *io_segpath != '\0') { if (!(segpath = GRN_STRDUP(io_segpath))) { - ERR(GRN_NO_MEMORY_AVAILABLE, "cannot duplicate path: <%s>", io_segpath); + ERR(GRN_NO_MEMORY_AVAILABLE, "cannot duplicate path: <%-.256s>", io_segpath); return GRN_NO_MEMORY_AVAILABLE; } if ((io_chunkpath = grn_io_path(ii->chunk)) && *io_chunkpath != '\0') { if (!(chunkpath = GRN_STRDUP(io_chunkpath))) { - ERR(GRN_NO_MEMORY_AVAILABLE, "cannot duplicate path: <%s>", io_chunkpath); + ERR(GRN_NO_MEMORY_AVAILABLE, "cannot duplicate path: <%-.256s>", io_chunkpath); return GRN_NO_MEMORY_AVAILABLE; } } else { @@ -5144,7 +5144,7 @@ grn_ii_cursor_set_min(grn_ctx *ctx, grn_ii_cursor *c, grn_id min) c->stat |= CHUNK_USED; GRN_LOG(ctx, GRN_LOG_DEBUG, "[ii][cursor][min] skip: %p: min(%u->%u): chunk(%u->%u): " - "chunk-used(%s->%s)", + "chunk-used(%-.256s->%-.256s)", c, old_min, min, old_chunk, c->curr_chunk, @@ -5205,7 +5205,7 @@ grn_ii_cursor_next_internal(grn_ctx *ctx, grn_ii_cursor *c, } GRN_TEXT_PUTC(ctx, &buf, ')'); GRN_TEXT_PUTC(ctx, &buf, '\0'); - GRN_LOG(ctx, GRN_LOG_DEBUG, "posting(%d):%s", count, GRN_TEXT_VALUE(&buf)); + GRN_LOG(ctx, GRN_LOG_DEBUG, "posting(%d):%-.256s", count, GRN_TEXT_VALUE(&buf)); GRN_OBJ_FIN(ctx, &buf); } */ @@ -6451,7 +6451,7 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, ERR(GRN_INVALID_ARGUMENT, "[ii][column][update][new] invalid object: " "<%.*s>: " - "<%s>(%#x)", + "<%-.256s>(%#x)", name_size, name, grn_obj_type_to_string(type), type); @@ -6564,7 +6564,7 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section, ERR(GRN_INVALID_ARGUMENT, "[ii][column][update][old] invalid object: " "<%.*s>: " - "<%s>(%#x)", + "<%-.256s>(%#x)", name_size, name, grn_obj_type_to_string(type), type); @@ -7833,7 +7833,7 @@ grn_ii_select_cursor_open(grn_ctx *ctx, default : ERR(GRN_INVALID_ARGUMENT, "[ii][select][cursor][open] " - "EXACT, FUZZY, NEAR and NEAR2 are only supported mode: %s", + "EXACT, FUZZY, NEAR and NEAR2 are only supported mode: %-.256s", grn_operator_to_string(mode)); break; } @@ -7841,7 +7841,7 @@ grn_ii_select_cursor_open(grn_ctx *ctx, cursor = GRN_CALLOC(sizeof(grn_ii_select_cursor)); if (!cursor) { ERR(ctx->rc, - "[ii][select][cursor][open] failed to allocate cursor: %s", + "[ii][select][cursor][open] failed to allocate cursor: %-.256s", ctx->errbuf); return NULL; } @@ -7851,7 +7851,7 @@ grn_ii_select_cursor_open(grn_ctx *ctx, if (!(cursor->tis = GRN_MALLOC(sizeof(token_info *) * string_len * 2))) { ERR(ctx->rc, - "[ii][select][cursor][open] failed to allocate token info container: %s", + "[ii][select][cursor][open] failed to allocate token info container: %-.256s", ctx->errbuf); GRN_FREE(cursor); return NULL; @@ -7891,7 +7891,7 @@ grn_ii_select_cursor_open(grn_ctx *ctx, case GRN_OP_NEAR : if (!(cursor->bt = bt_open(ctx, cursor->n_tis))) { ERR(ctx->rc, - "[ii][select][cursor][open] failed to allocate btree: %s", + "[ii][select][cursor][open] failed to allocate btree: %-.256s", ctx->errbuf); grn_ii_select_cursor_close(ctx, cursor); return NULL; @@ -8114,7 +8114,7 @@ grn_ii_parse_regexp_query(grn_ctx *ctx, if (char_len == 0) { GRN_OBJ_FIN(ctx, &buffer); ERR(GRN_INVALID_ARGUMENT, - "%s invalid encoding character: <%.*s|%#x|>", + "%-.256s invalid encoding character: <%.*s|%#x|>", log_tag, (int)(current - string), string, *current); @@ -8515,7 +8515,7 @@ grn_ii_select_sequential_search(grn_ctx *ctx, onig_error_code_to_str(message, onig_result, error_info); GRN_LOG(ctx, GRN_LOG_WARNING, "[ii][select][sequential] " - "failed to create regular expression object: %s", + "failed to create regular expression object: %-.256s", message); processed = GRN_FALSE; } @@ -10148,7 +10148,7 @@ grn_ii_buffer_open(grn_ctx *ctx, grn_ii *ii, ii_buffer->block_buf = GRN_MALLOCN(grn_id, II_BUFFER_BLOCK_SIZE); if (ii_buffer->block_buf) { grn_snprintf(ii_buffer->tmpfpath, PATH_MAX, PATH_MAX, - "%sXXXXXX", grn_io_path(ii->seg)); + "%-.256sXXXXXX", grn_io_path(ii->seg)); ii_buffer->block_buf_size = II_BUFFER_BLOCK_SIZE; ii_buffer->tmpfd = grn_mkstemp(ii_buffer->tmpfpath); if (ii_buffer->tmpfd != -1) { @@ -10161,7 +10161,7 @@ grn_ii_buffer_open(grn_ctx *ctx, grn_ii *ii, } return ii_buffer; } else { - SERR("failed grn_mkstemp(%s)", + SERR("failed grn_mkstemp(%-.256s)", ii_buffer->tmpfpath); } GRN_FREE(ii_buffer->block_buf); @@ -10308,7 +10308,7 @@ grn_ii_buffer_commit(grn_ctx *ctx, grn_ii_buffer *ii_buffer) ii_buffer->tmpfpath, O_RDONLY | GRN_OPEN_FLAG_BINARY); if (ii_buffer->tmpfd == -1) { - ERRNO_ERR("failed to open path: <%s>", ii_buffer->tmpfpath); + ERRNO_ERR("failed to open path: <%-.256s>", ii_buffer->tmpfpath); return ctx->rc; } { @@ -10358,10 +10358,10 @@ grn_ii_buffer_commit(grn_ctx *ctx, grn_ii_buffer *ii_buffer) grn_close(ii_buffer->tmpfd); if (grn_unlink(ii_buffer->tmpfpath) == 0) { GRN_LOG(ctx, GRN_LOG_INFO, - "[ii][buffer][commit] removed temporary path: <%s>", + "[ii][buffer][commit] removed temporary path: <%-.256s>", ii_buffer->tmpfpath); } else { - ERRNO_ERR("[ii][buffer][commit] failed to remove temporary path: <%s>", + ERRNO_ERR("[ii][buffer][commit] failed to remove temporary path: <%-.256s>", ii_buffer->tmpfpath); } ii_buffer->tmpfd = -1; @@ -10385,10 +10385,10 @@ grn_ii_buffer_close(grn_ctx *ctx, grn_ii_buffer *ii_buffer) grn_close(ii_buffer->tmpfd); if (grn_unlink(ii_buffer->tmpfpath) == 0) { GRN_LOG(ctx, GRN_LOG_INFO, - "[ii][buffer][close] removed temporary path: <%s>", + "[ii][buffer][close] removed temporary path: <%-.256s>", ii_buffer->tmpfpath); } else { - ERRNO_ERR("[ii][buffer][close] failed to remove temporary path: <%s>", + ERRNO_ERR("[ii][buffer][close] failed to remove temporary path: <%-.256s>", ii_buffer->tmpfpath); } } @@ -11468,10 +11468,10 @@ grn_ii_builder_fin(grn_ctx *ctx, grn_ii_builder *builder) grn_close(builder->fd); if (grn_unlink(builder->path) == 0) { GRN_LOG(ctx, GRN_LOG_INFO, - "[ii][builder][fin] removed path: <%s>", + "[ii][builder][fin] removed path: <%-.256s>", builder->path); } else { - ERRNO_ERR("[ii][builder][fin] failed to remove path: <%s>", + ERRNO_ERR("[ii][builder][fin] failed to remove path: <%-.256s>", builder->path); } } @@ -11779,10 +11779,10 @@ static grn_rc grn_ii_builder_create_file(grn_ctx *ctx, grn_ii_builder *builder) { grn_snprintf(builder->path, PATH_MAX, PATH_MAX, - "%sXXXXXX", grn_io_path(builder->ii->seg)); + "%-.256sXXXXXX", grn_io_path(builder->ii->seg)); builder->fd = grn_mkstemp(builder->path); if (builder->fd == -1) { - SERR("failed to create a temporary file: path = \"%s\"", + SERR("failed to create a temporary file: path = \"%-.256s\"", builder->path); return ctx->rc; } diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 2b78efe2920..38091dae0ba 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1751,7 +1751,35 @@ void ha_myisam::start_bulk_insert(ha_rows rows, uint flags) else { my_bool all_keys= MY_TEST(flags & HA_CREATE_UNIQUE_INDEX_BY_SORT); - mi_disable_indexes_for_rebuild(file, rows, all_keys); + MYISAM_SHARE *share=file->s; + MI_KEYDEF *key=share->keyinfo; + uint i; + /* + Deactivate all indexes that can be recreated fast. + These include packed keys on which sorting will use more temporary + space than the max allowed file length or for which the unpacked keys + will take much more space than packed keys. + Note that 'rows' may be zero for the case when we don't know how many + rows we will put into the file. + Long Unique Index (HA_KEY_ALG_LONG_HASH) will not be disabled because + there unique property is enforced at the time of ha_write_row + (check_duplicate_long_entries). So we need active index at the time of + insert. + */ + DBUG_ASSERT(file->state->records == 0 && + (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES)); + for (i=0 ; i < share->base.keys ; i++,key++) + { + if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY)) && + ! mi_too_big_key_for_sort(key,rows) && file->s->base.auto_key != i+1 && + (all_keys || !(key->flag & HA_NOSAME)) && + table->key_info[i].algorithm != HA_KEY_ALG_LONG_HASH) + { + mi_clear_key_active(share->state.key_map, i); + file->update|= HA_STATE_CHANGED; + file->create_unique_index_by_sort= all_keys; + } + } } } else diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index f377028be52..3f3c60a4249 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -4667,7 +4667,7 @@ static ha_checksum mi_byte_checksum(const uchar *buf, uint length) return crc; } -static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) +my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) { uint key_maxlength=key->maxlength; if (key->flag & HA_FULLTEXT) @@ -4682,38 +4682,6 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) } /* - Deactivate all indexes that can be recreated fast. - These include packed keys on which sorting will use more temporary - space than the max allowed file length or for which the unpacked keys - will take much more space than packed keys. - Note that 'rows' may be zero for the case when we don't know how many - rows we will put into the file. - */ - -void mi_disable_indexes_for_rebuild(MI_INFO *info, ha_rows rows, - my_bool all_keys) -{ - MYISAM_SHARE *share=info->s; - MI_KEYDEF *key=share->keyinfo; - uint i; - - DBUG_ASSERT(info->state->records == 0 && - (!rows || rows >= MI_MIN_ROWS_TO_DISABLE_INDEXES)); - for (i=0 ; i < share->base.keys ; i++,key++) - { - if (!(key->flag & (HA_SPATIAL | HA_AUTO_KEY)) && - ! mi_too_big_key_for_sort(key,rows) && info->s->base.auto_key != i+1 && - (all_keys || !(key->flag & HA_NOSAME))) - { - mi_clear_key_active(share->state.key_map, i); - info->update|= HA_STATE_CHANGED; - info->create_unique_index_by_sort= all_keys; - } - } -} - - -/* Return TRUE if we can use repair by sorting One can set the force argument to force to use sorting even if the temporary file would be quite big! diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index 3b036b5f4a4..b92c012e5f4 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -732,8 +732,6 @@ void mi_restore_status(void *param); void mi_copy_status(void *to, void *from); my_bool mi_check_status(void *param); void mi_fix_status(MI_INFO *org_table, MI_INFO *new_table); -void mi_disable_indexes_for_rebuild(MI_INFO *info, ha_rows rows, - my_bool all_keys); extern MI_INFO *test_if_reopen(char *filename); my_bool check_table_is_closed(const char *name, const char *where); int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share); diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 8e8b75817c0..9bef2be929f 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -750,7 +750,8 @@ static int test_when_accessed (struct file_info *key, } -static int file_info_free(void* arg, TREE_FREE mode, void *unused) +static int file_info_free(void* arg, TREE_FREE mode __attribute__((unused)), + void *unused __attribute__((unused))) { struct file_info *fileinfo= arg; DBUG_ENTER("file_info_free"); diff --git a/storage/rocksdb/rdb_datadic.cc b/storage/rocksdb/rdb_datadic.cc index d8b5b50b4c4..00e6b95a748 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -267,8 +267,9 @@ int Rdb_key_field_iterator::next() { bool covered_column = true; if (m_covered_bitmap != nullptr && m_field->real_type() == MYSQL_TYPE_VARCHAR && !m_fpi->m_covered) { + uint tmp= m_curr_bitmap_pos++; covered_column = m_curr_bitmap_pos < MAX_REF_PARTS && - bitmap_is_set(m_covered_bitmap, m_curr_bitmap_pos++); + bitmap_is_set(m_covered_bitmap, tmp); } if (m_fpi->m_unpack_func && covered_column) { |