From cd2c0e013ccb5f9b009743dfd7188585a539d9b5 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 29 Jan 2020 17:31:08 +0200 Subject: [PATCH 01/16] Added error output wsrep_print_version This helps to determinate why galera library doesn't load --- .../lib/My/SafeProcess/wsrep_check_version.c | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c index 616548d4f2d..52dfbe6d2df 100644 --- a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c +++ b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c @@ -1,5 +1,4 @@ -/* Copyright (c) 2009, 2019, MariaDB - +/* 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 Foundation; version 2 of the License. @@ -86,12 +85,24 @@ int main(int argc, char **argv) int rc = EINVAL; void *dlh; wsrep_loader_fun dlfun; + const char *provider= getenv("WSREP_PROVIDER"); - if (!(dlh = dlopen(getenv("WSREP_PROVIDER"), RTLD_NOW | RTLD_LOCAL))) { - goto err; + if (!provider) + { + fprintf(stderr, "WSREP_PROVIDER is not set\n"); + goto err; + } + if (!(dlh = dlopen(provider, RTLD_NOW | RTLD_LOCAL))) + { + fprintf(stderr, "Can't open WSREP_PROVIDER (%s) library, error: %s\n", + provider, dlerror()); + goto err; } - if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader"))) { + if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader"))) + { + fprintf(stderr, "Can't find 'wsrep_loader' symbol in %s\n", + provider); goto err; } From 4d61f1247a1b6a86570cb03d3450930a78d689b3 Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 29 Jan 2020 16:41:04 +0200 Subject: [PATCH 02/16] Fixed compiler warnings from gcc 7.4.1 - Fixed possible error in rocksdb/rdb_datadic.cc --- plugin/auth_pam/auth_pam_tool.c | 6 +- plugin/auth_pam/testing/pam_mariadb_mtr.c | 8 ++- sql/sql_class.cc | 2 +- storage/connect/colblk.cpp | 3 +- storage/connect/connect.cc | 2 + storage/connect/filamap.cpp | 3 +- storage/connect/filamdbf.cpp | 3 +- storage/connect/filamfix.cpp | 2 +- storage/connect/filamgz.cpp | 7 ++- storage/connect/filamtxt.cpp | 3 +- storage/connect/filamvct.cpp | 5 +- storage/connect/filamzip.cpp | 2 +- storage/connect/filter.cpp | 6 +- storage/connect/fmdlex.c | 14 +++-- storage/connect/ha_connect.cc | 2 +- storage/connect/inihandl.cpp | 3 +- storage/connect/json.cpp | 2 +- storage/connect/jsonudf.cpp | 32 ++++++----- storage/connect/libdoc.cpp | 68 +++++++++++------------ storage/connect/maputil.cpp | 2 +- storage/connect/myconn.cpp | 2 +- storage/connect/myutil.cpp | 4 +- storage/connect/plgdbutl.cpp | 2 + storage/connect/plugutil.cpp | 38 ++++++------- storage/connect/reldef.cpp | 4 +- storage/connect/tabdos.cpp | 28 +++++----- storage/connect/tabfmt.cpp | 21 ++++--- storage/connect/tabjson.cpp | 13 +++-- storage/connect/tabmul.cpp | 10 ++-- storage/connect/taboccur.cpp | 6 +- storage/connect/tabpivot.cpp | 9 ++- storage/connect/tabvir.cpp | 19 ++++--- storage/connect/tabxml.cpp | 26 +++++++-- storage/connect/user_connect.cc | 2 +- storage/connect/user_connect.h | 2 +- storage/connect/xindex.cpp | 7 ++- storage/connect/zip.c | 16 +++--- storage/mroonga/vendor/groonga/lib/ii.c | 48 ++++++++-------- storage/myisam/myisamlog.c | 3 +- storage/rocksdb/rdb_datadic.cc | 3 +- strings/ctype-bin.c | 2 +- strings/ctype-simple.c | 4 +- strings/json_lib.c | 10 +++- strings/strcoll.ic | 4 +- unittest/mysys/byte_order-t.c | 2 +- zlib/infback.c | 1 + zlib/inflate.c | 18 ++++++ 47 files changed, 282 insertions(+), 197 deletions(-) diff --git a/plugin/auth_pam/auth_pam_tool.c b/plugin/auth_pam/auth_pam_tool.c index 624b6880933..225f35a6624 100644 --- a/plugin/auth_pam/auth_pam_tool.c +++ b/plugin/auth_pam/auth_pam_tool.c @@ -16,6 +16,7 @@ #include #include +#include #include struct param { @@ -62,7 +63,7 @@ typedef struct st_mysql_server_auth_info #include "auth_pam_base.c" -int main(int argc, char **argv) +int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) { struct param param; MYSQL_SERVER_AUTH_INFO info; @@ -70,7 +71,8 @@ int main(int argc, char **argv) int res; char a_buf[MYSQL_USERNAME_LENGTH + 1 + 1024]; - (void) setreuid(0, 0); + if ((res= setreuid(0, 0))) + fprintf(stderr, "Got error %d from setreuid()\n", (int) errno); if (read(0, &field, 1) < 1) return -1; diff --git a/plugin/auth_pam/testing/pam_mariadb_mtr.c b/plugin/auth_pam/testing/pam_mariadb_mtr.c index c0e07232027..2075d5fdbf3 100644 --- a/plugin/auth_pam/testing/pam_mariadb_mtr.c +++ b/plugin/auth_pam/testing/pam_mariadb_mtr.c @@ -15,7 +15,7 @@ #define N 3 -int pam_sm_authenticate(pam_handle_t *pamh, int flags, +int pam_sm_authenticate(pam_handle_t *pamh, int flags __attribute__((unused)), int argc, const char *argv[]) { struct pam_conv *conv; @@ -72,8 +72,10 @@ ret: return retval; } -int pam_sm_setcred(pam_handle_t *pamh, int flags, - int argc, const char *argv[]) +int pam_sm_setcred(pam_handle_t *pamh __attribute__((unused)), + int flags __attribute__((unused)), + int argc __attribute__((unused)), + const char *argv[] __attribute__((unused))) { return PAM_SUCCESS; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 1e276d257da..d8d4b9a8d64 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -6115,7 +6115,7 @@ int THD::decide_logging_format(TABLE_LIST *tables) /* As all updated tables are temporary, nothing will be logged */ set_current_stmt_binlog_format_row(); } - else if (IF_WSREP((!WSREP(this) || + else if (IF_WSREP((!WSREP_NNULL(this) || wsrep_cs().mode() == wsrep::client_state::m_local),1)) { diff --git a/storage/connect/colblk.cpp b/storage/connect/colblk.cpp index a9cf43f3d96..242e68b5905 100644 --- a/storage/connect/colblk.cpp +++ b/storage/connect/colblk.cpp @@ -80,6 +80,7 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp) htrc(" copying COLBLK %s from %p to %p\n", Name, col1, this); if (tdbp) + { // Attach the new column to the table block if (!tdbp->GetColumns()) tdbp->SetColumns(this); @@ -88,7 +89,7 @@ COLBLK::COLBLK(PCOL col1, PTDB tdbp) colp->Next = this; } // endelse - + } } // end of COLBLK copy constructor /***********************************************************************/ diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc index dfc619cf4af..60c10527fe9 100644 --- a/storage/connect/connect.cc +++ b/storage/connect/connect.cc @@ -646,6 +646,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted) // return 0; if (tdbp->GetKindex()) + { if (((XXBASE*)tdbp->GetKindex())->GetID() == id) { tdbp->GetKindex()->Reset(); // Same index return (tdbp->GetKindex()->IsMul()) ? 2 : 1; @@ -653,6 +654,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted) tdbp->GetKindex()->Close(); tdbp->SetKindex(NULL); } // endif colp + } for (xdp= dfp->GetIndx(); xdp; xdp= xdp->GetNext()) if (xdp->GetID() == id) 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 c8bab2b53a4..43b3e461cd1 100644 --- a/storage/connect/filamdbf.cpp +++ b/storage/connect/filamdbf.cpp @@ -841,6 +841,7 @@ 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 (UseTemp) { if (OpenTempFile(g)) return RC_FX; @@ -850,7 +851,7 @@ 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/filamfix.cpp b/storage/connect/filamfix.cpp index 0a98ec5b54a..433dd71cd0c 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -135,7 +135,7 @@ bool FIXFAM::AllocateBuffer(PGLOBAL g) // The buffer must be prepared depending on column types int n = 0; bool b = false; - PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); + PDOSDEF defp __attribute__((unused))= (PDOSDEF)Tdbp->GetDef(); // PCOLDEF cdp; PBINCOL colp; diff --git a/storage/connect/filamgz.cpp b/storage/connect/filamgz.cpp index 880db54c91d..6c960ab86de 100644 --- a/storage/connect/filamgz.cpp +++ b/storage/connect/filamgz.cpp @@ -647,7 +647,7 @@ int ZBKFAM::WriteBuffer(PGLOBAL g) int ZBKFAM::DeleteRecords(PGLOBAL g, int irc) { if (irc == RC_EF) { - LPCSTR name = Tdbp->GetName(); + LPCSTR name __attribute__((unused)) = Tdbp->GetName(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); defp->SetBlock(0); @@ -673,7 +673,7 @@ void ZBKFAM::CloseTableFile(PGLOBAL g, bool) int rc = RC_OK; if (Tdbp->GetMode() == MODE_INSERT) { - LPCSTR name = Tdbp->GetName(); + LPCSTR name __attribute__((unused))= Tdbp->GetName(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); if (CurNum && !Closing) { @@ -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 @@ -1355,7 +1356,7 @@ void ZLBFAM::CloseTableFile(PGLOBAL g, bool) int rc = RC_OK; if (Tdbp->GetMode() == MODE_INSERT) { - LPCSTR name = Tdbp->GetName(); + LPCSTR name __attribute__((unused))= Tdbp->GetName(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); // Closing is True if last Write was in error diff --git a/storage/connect/filamtxt.cpp b/storage/connect/filamtxt.cpp index ca48fc765a1..67ab120c499 100644 --- a/storage/connect/filamtxt.cpp +++ b/storage/connect/filamtxt.cpp @@ -1547,13 +1547,14 @@ int BLKFAM::WriteBuffer(PGLOBAL g) // T_Stream is the temporary stream or the table file stream itself if (!T_Stream) + { if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) { if (OpenTempFile(g)) return RC_FX; } else T_Stream = Stream; - + } if (UseTemp) { /*****************************************************************/ /* We are using a temporary file. Before writing the updated */ diff --git a/storage/connect/filamvct.cpp b/storage/connect/filamvct.cpp index 6d0779b150a..49283f8c0c7 100644 --- a/storage/connect/filamvct.cpp +++ b/storage/connect/filamvct.cpp @@ -302,6 +302,7 @@ int VCTFAM::Cardinality(PGLOBAL g) return 1; 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 @@ -347,7 +348,7 @@ int VCTFAM::Cardinality(PGLOBAL g) return -1; // Error } // endif split - + } return (Block) ? ((Block - 1) * Nrec + Last) : 0; } // end of Cardinality @@ -1163,7 +1164,7 @@ bool VCTFAM::ResetTableSize(PGLOBAL g, int block, int last) if (!Header) { // Update catalog values for Block and Last PVCTDEF defp = (PVCTDEF)Tdbp->GetDef(); - LPCSTR name = Tdbp->GetName(); + LPCSTR name __attribute__((unused))= Tdbp->GetName(); defp->SetBlock(Block); defp->SetLast(Last); diff --git a/storage/connect/filamzip.cpp b/storage/connect/filamzip.cpp index f7866b9dae1..fd1cf0ceff9 100644 --- a/storage/connect/filamzip.cpp +++ b/storage/connect/filamzip.cpp @@ -91,7 +91,6 @@ 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]; - int rc; /*********************************************************************/ /* pat is a multiple file name with wildcard characters */ @@ -102,6 +101,7 @@ static bool ZipFiles(PGLOBAL g, ZIPUTIL *zutp, PCSZ pat, char *buf) char drive[_MAX_DRIVE], direc[_MAX_DIR]; 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 7082b082c67..d776b403917 100644 --- a/storage/connect/filter.cpp +++ b/storage/connect/filter.cpp @@ -1220,15 +1220,19 @@ 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) + { for (i = 0; i < 2; i++) + { // Evaluate the object and eventually convert it. if (Arg(i)->Eval(g)) return TRUE; else if (Test[i].Conv) Val(i)->SetValue_pval(Arg(i)->GetValue()); + } + } if (trace(1)) htrc(" Filter: op=%d type=%d %d B_T=%d %d val=%p %p\n", diff --git a/storage/connect/fmdlex.c b/storage/connect/fmdlex.c index 729b1b883c1..28b71b95e4d 100644 --- a/storage/connect/fmdlex.c +++ b/storage/connect/fmdlex.c @@ -240,12 +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; -static void yy_push_state YY_PROTO(( int new_state )); -static void yy_pop_state YY_PROTO(( void )); -static int yy_top_state YY_PROTO(( void )); +#endif static void *yy_flex_alloc YY_PROTO(( unsigned int )); static void *yy_flex_realloc YY_PROTO(( void *, unsigned int )); @@ -267,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 )); @@ -1060,6 +1061,8 @@ register char *yy_bp; } +#ifdef NOT_USED + #ifdef __cplusplus static int yyinput() #else @@ -1126,7 +1129,7 @@ static int input() return c; } - +#endif /* NOT_USED */ #ifdef YY_USE_PROTOS void yyrestart( FILE *input_file ) @@ -1266,6 +1269,7 @@ FILE *file; } +#ifdef NOT_USED #ifdef YY_USE_PROTOS static void yy_push_state( int new_state ) #else @@ -1297,7 +1301,6 @@ int new_state; BEGIN(new_state); } - static void yy_pop_state() { if ( --yy_start_stack_ptr < 0 ) @@ -1311,6 +1314,7 @@ static int yy_top_state() { return yy_start_stack[yy_start_stack_ptr - 1]; } +#endif /* NOT_USED */ #ifdef YY_USE_PROTOS diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 1b583dad76e..8b9a1ae5c8d 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -790,7 +790,7 @@ static int connect_init_func(void *p) @brief Plugin clean up */ -static int connect_done_func(void *) +int connect_done_func(void *) { int error= 0; PCONNECT pc, pn; diff --git a/storage/connect/inihandl.cpp b/storage/connect/inihandl.cpp index 8e79aeac7ef..95cb3a1227d 100644 --- a/storage/connect/inihandl.cpp +++ b/storage/connect/inihandl.cpp @@ -1340,6 +1340,7 @@ BOOL WritePrivateProfileSection(LPCSTR section, * Note that when the buffer is big enough then the return value may be any * value between 1 and len-1 (or len in Win95), including len-2. */ +#ifdef NOT_USED static DWORD GetPrivateProfileSectionNames(LPSTR buffer, DWORD size, LPCSTR filename) { @@ -1356,7 +1357,7 @@ GetPrivateProfileSectionNames(LPSTR buffer, DWORD size, LPCSTR filename) LeaveCriticalSection(&PROFILE_CritSect); return ret; } // end of GetPrivateProfileSectionNames - +#endif /************************************************************************ * Program to test the above 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 d5bd1215e77..940e7e678fd 100644 --- a/storage/connect/jsonudf.cpp +++ b/storage/connect/jsonudf.cpp @@ -247,7 +247,7 @@ my_bool JSNX::ParseJpath(PGLOBAL g) { char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; int i; - my_bool a, mul = false; + my_bool a; if (Parsed) return false; // Already done @@ -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 @@ -424,7 +425,6 @@ PVAL JSNX::GetColumnValue(PGLOBAL g, PJSON row, int i) /*********************************************************************************/ PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b) { - my_bool expd = false; PJAR arp; PJVAL val = NULL; @@ -763,7 +763,7 @@ my_bool JSNX::WriteValue(PGLOBAL g, PJVAL jvalp) PSZ JSNX::Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k) { PSZ str = NULL; - my_bool b = false, err = true; + my_bool err = true; g->Message[0] = 0; @@ -885,7 +885,7 @@ my_bool JSNX::LocateValue(PJVAL jvp) PSZ JSNX::LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx) { PSZ str = NULL; - my_bool b = false, err = true; + my_bool err = true; PJPN jnp; if (!jsp) { @@ -1352,7 +1352,7 @@ static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int bsnp->Pretty = pretty; - if (bsnp->Filename = (char*)args->args[0]) { + if ((bsnp->Filename = (char*)args->args[0])) { bsnp->Filename = MakePSZ(g, args, 0); strncpy(bsnp->Msg, bsnp->Filename, BMX); } else @@ -1773,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 @@ -1785,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 @@ -3480,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; @@ -3755,12 +3755,13 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message) strcpy(message, "Third argument is not an integer (rank)"); 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 @@ -3838,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; @@ -3882,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 @@ -3963,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; @@ -4243,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; @@ -5178,7 +5180,7 @@ char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result, PCSZ key; PJOB jobp; PJVAL jvp = MakeValue(g, args, 0, &top); - PJSON jsp = jvp->GetJson(); + PJSON jsp __attribute__((unused)) = jvp->GetJson(); if (CheckPath(g, args, top, jvp, 2)) PUSH_WARNING(g->Message); @@ -5889,7 +5891,7 @@ long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result, memcpy(str2, args->args[1], lg); str2[lg] = 0; - while (s = strstr(s, str2)) { + while ((s = strstr(s, str2))) { n++; s += lg; } // endwhile diff --git a/storage/connect/libdoc.cpp b/storage/connect/libdoc.cpp index 58b0267bd6d..69bbe980eba 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; @@ -378,7 +378,7 @@ bool LIBXMLDOC::Initialize(PGLOBAL g, PCSZ entry, bool zipped) if (zipped && InitZip(g, entry)) return true; - int n = xmlKeepBlanksDefault(1); + int n __attribute__((unused))= xmlKeepBlanksDefault(1); return MakeNSlist(g); } // end of Initialize @@ -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, "\n", Encoding); - fprintf(of, "\n", version); + fprintf(of, "\n", Encoding); + fprintf(of, "\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/maputil.cpp b/storage/connect/maputil.cpp index 87263b3adf6..9dcc564a86b 100644 --- a/storage/connect/maputil.cpp +++ b/storage/connect/maputil.cpp @@ -190,7 +190,7 @@ bool CloseMemMap(void *memory, size_t dwSize) { if (memory) { // All this must be redesigned - int rc = msync((char*)memory, dwSize, MS_SYNC); + int rc __attribute__((unused))= msync((char*)memory, dwSize, MS_SYNC); return (munmap((char*)memory, dwSize) < 0) ? true : false; } else return false; diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 4303a9e191b..e07270aff8a 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -140,7 +140,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db, PCSZ fmt; char *fld, *colname, *chset, v, buf[128], uns[16], zero[16]; int i, n, nf = 0, ncol = sizeof(buftyp) / sizeof(int); - int len, type, prec, rc, k = 0; + int len, type, prec, rc; bool b; PQRYRES qrp; PCOLRES crp; 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/plgdbutl.cpp b/storage/connect/plgdbutl.cpp index e296553d8e2..d51d52a2678 100644 --- a/storage/connect/plgdbutl.cpp +++ b/storage/connect/plgdbutl.cpp @@ -430,6 +430,7 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op) /* Because this function is only used for catalog name checking, */ /* it must be case insensitive. */ /***********************************************************************/ +#ifdef NOT_USED static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat) { if (pat && strlen(pat)) { @@ -443,6 +444,7 @@ static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat) return true; } // end of PlugCheckPattern +#endif /***********************************************************************/ /* PlugEvalLike: evaluates a LIKE clause. */ 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 8efe2aad702..3d8e89f3f3c 100644 --- a/storage/connect/tabdos.cpp +++ b/storage/connect/tabdos.cpp @@ -569,8 +569,6 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dop, bool dox) MaxSize = -1; // Size must be recalculated Cardinal = -1; // as well as Cardinality - PTXF xp = Txfp; - To_Filter = NULL; // Disable filtering //To_BlkIdx = NULL; // and index filtering To_BlkFil = NULL; // and block filtering @@ -642,7 +640,7 @@ int TDBDOS::MakeBlockValues(PGLOBAL g) PDOSDEF defp = (PDOSDEF)To_Def; PDOSCOL colp = NULL; PDBUSER dup = PlgGetUser(g); - PCATLG cat = defp->GetCat(); + PCATLG cat __attribute__((unused))= defp->GetCat(); //void *memp = cat->GetDescp(); if ((nrec = defp->GetElemt()) < 2) { @@ -1005,14 +1003,14 @@ bool TDBDOS::GetBlockValues(PGLOBAL g) { char filename[_MAX_PATH]; int i, lg, n[NZ]; - int nrec, block = 0, last = 0, allocblk = 0; + int nrec, block = 0, last = 0; int len; bool newblk = false; size_t ndv, nbm, nbk, blk; FILE *opfile; PCOLDEF cdp; PDOSDEF defp = (PDOSDEF)To_Def; - PCATLG cat = defp->GetCat(); + PCATLG cat __attribute__((unused))= defp->GetCat(); PDBUSER dup = PlgGetUser(g); #if 0 @@ -1294,7 +1292,7 @@ PBF TDBDOS::InitBlockFilter(PGLOBAL g, PFIL filp) } // endif blk - int i, op = filp->GetOpc(), opm = filp->GetOpm(), n = 0; + int i, op = filp->GetOpc(), opm = filp->GetOpm(); bool cnv[2]; PCOL colp; PXOB arg[2] = {NULL,NULL}; @@ -1337,13 +1335,14 @@ PBF TDBDOS::InitBlockFilter(PGLOBAL g, PFIL filp) bfp = new(g) BLKSPCIN(g, this, op, opm, arg, Txfp->Nrec); } else if (blk && Txfp->Nrec > 1 && colp->IsClustered()) + { // Clustered column and constant array if (colp->GetClustered() == 2) bfp = new(g) BLKFILIN2(g, this, op, opm, arg); else bfp = new(g) BLKFILIN(g, this, op, opm, arg); - - } // endif this + } + } // endif this #if 0 } else if (filp->GetArgType(0) == TYPE_SCALF && @@ -1419,12 +1418,10 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv) //bool conv = false, xdb2 = false, ok = false, b[2]; //PXOB *xarg1, *xarg2 = NULL, xp[2]; int i, n = 0, type[2] = {0,0}; - bool conv = false, xdb2 = false, ok = false; - PXOB *xarg2 = NULL, xp[2]; + bool conv = false, xdb2 = false; + PXOB xp[2]; PCOL colp; -//LSTVAL *vlp = NULL; -//SFROW *sfr[2]; - PBF *fp = NULL, bfp = NULL; + PBF bfp = NULL; for (i = 0; i < 2; i++) { switch (arg[i]->GetType()) { @@ -1655,7 +1652,7 @@ int TDBDOS::TestBlock(PGLOBAL g) int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) { int k, n, rc = RC_OK; - bool fixed, doit, sep, b = (pxdf != NULL); + bool fixed, doit, sep; PCOL *keycols, colp; PIXDEF xdp, sxp = NULL; PKPDEF kdp; @@ -2831,6 +2828,7 @@ bool DOSCOL::SetBitMap(PGLOBAL g) bool DOSCOL::CheckSorted(PGLOBAL g) { if (Sorted) + { if (OldVal) { // Verify whether this column is sorted all right if (OldVal->CompareValue(Value) > 0) { @@ -2843,7 +2841,7 @@ bool DOSCOL::CheckSorted(PGLOBAL g) } else OldVal = AllocateValue(g, Value); - + } return false; } // end of CheckSorted diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index b395c49c95d..eed67525f78 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -312,12 +312,13 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) } else if (*p == q) { if (phase == 0) { if (blank) + { if (++nerr > mxr) { sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); goto err; } else goto skip; - + } n = 0; phase = digit = 1; } else if (phase == 1) { @@ -342,12 +343,13 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) } else { if (phase == 2) + { if (++nerr > mxr) { sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); goto err; } else goto skip; - + } // isdigit cannot be used here because of debug assert if (!strchr("0123456789", *p)) { if (!digit && *p == dechar) @@ -363,12 +365,13 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) } // endif's *p if (phase == 1) + { if (++nerr > mxr) { sprintf(g->Message, MSG(UNBALANCE_QUOTE), num_read); goto err; } else goto skip; - + } if (n) { len[i] = MY_MAX(len[i], n); type = (digit || n == 0 || (dec && n == 1)) ? TYPE_STRING @@ -742,6 +745,7 @@ bool TDBCSV::OpenDB(PGLOBAL g) PCSVCOL colp; if (!Fields) // May have been set in TABFMT::OpenDB + { if (Mode != MODE_UPDATE && Mode != MODE_INSERT) { for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next) if (!colp->IsSpecial() && !colp->IsVirtual()) @@ -754,7 +758,7 @@ bool TDBCSV::OpenDB(PGLOBAL g) for (cdp = tdp->GetCols(); cdp; cdp = cdp->GetNext()) if (!cdp->IsSpecial() && !cdp->IsVirtual()) Fields++; - + } Offset = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields); Fldlen = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields); @@ -775,6 +779,7 @@ bool TDBCSV::OpenDB(PGLOBAL g) } // endfor i if (Field) + { // Prepare writing fields if (Mode != MODE_UPDATE) { for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next) @@ -797,7 +802,7 @@ bool TDBCSV::OpenDB(PGLOBAL g) Fldlen[i] = len; Fldtyp[i] = IsTypeNum(cdp->GetType()); } // endif cdp - + } } // endif Use if (Header) { @@ -1047,6 +1052,7 @@ bool TDBCSV::PrepareWriting(PGLOBAL g) strcat(To_Line, sep); if (Field[i]) + { if (!strlen(Field[i])) { // Generally null fields are not quoted if (Quoted > 2) @@ -1075,7 +1081,7 @@ bool TDBCSV::PrepareWriting(PGLOBAL g) else strcat(To_Line, Field[i]); - + } } // endfor i #if defined(_DEBUG) @@ -1135,6 +1141,7 @@ int TDBCSV::CheckWrite(PGLOBAL g) n += (Quoted > 2 ? 2 : 0); else if (strchr(Field[i], Sep) || (Qot && *Field[i] == Qot) || Quoted > 1 || (Quoted == 1 && !Fldtyp[i])) + { if (!Qot) { sprintf(g->Message, MSG(SEP_IN_FIELD), i + 1); return -1; @@ -1147,7 +1154,7 @@ int TDBCSV::CheckWrite(PGLOBAL g) n += 2; // Outside quotes } // endif - + } if ((nlen += n) > maxlen) { strcpy(g->Message, MSG(LINE_TOO_LONG)); return -1; diff --git a/storage/connect/tabjson.cpp b/storage/connect/tabjson.cpp index 7e8d6c8d9f0..a8e96e2fe8d 100644 --- a/storage/connect/tabjson.cpp +++ b/storage/connect/tabjson.cpp @@ -255,11 +255,13 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt) jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; } else { if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) + { if (!mgo) { sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); return 0; } else tdp->Lrecl = 8192; // Should be enough + } tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); @@ -1328,7 +1330,7 @@ bool JSONCOL::ParseJpath(PGLOBAL g) { char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; int i; - bool a, mul = false; + bool a; if (Parsed) return false; // Already done @@ -1427,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) @@ -1464,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 @@ -1558,7 +1561,6 @@ void JSONCOL::ReadColumn(PGLOBAL g) PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i) { int n = Nod - 1; - bool expd = false; PJAR arp; PJVAL val = NULL; @@ -2119,13 +2121,14 @@ int TDBJSON::Cardinality(PGLOBAL g) if (!g) return (Xcol || Multiple) ? 0 : 1; else if (Cardinal < 0) + { if (!Multiple) { if (MakeDocument(g) == RC_OK) Cardinal = Doc->size(); } else return 10; - + } return Cardinal; } // end of Cardinality diff --git a/storage/connect/tabmul.cpp b/storage/connect/tabmul.cpp index 649fc6706c6..7997a999b56 100644 --- a/storage/connect/tabmul.cpp +++ b/storage/connect/tabmul.cpp @@ -671,8 +671,8 @@ TDBDIR::TDBDIR(PSZ fpat) : TDBASE((PTABDEF)NULL) /***********************************************************************/ char* TDBDIR::Path(PGLOBAL g) { - PCATLG cat = PlgGetCatalog(g); - PTABDEF defp = (PTABDEF)To_Def; + PCATLG cat __attribute__((unused))= PlgGetCatalog(g); + PTABDEF defp = (PTABDEF)To_Def; #if defined(__WIN__) if (!*Drive) { @@ -708,8 +708,9 @@ PCOL TDBDIR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n) int TDBDIR::GetMaxSize(PGLOBAL g) { if (MaxSize < 0) { - int rc, n = -1; + int n = -1; #if defined(__WIN__) + int rc; // Start searching files in the target directory. hSearch = FindFirstFile(Path(g), &FileData); @@ -1041,12 +1042,13 @@ int TDBSDR::GetMaxSize(PGLOBAL g) /***********************************************************************/ int TDBSDR::FindInDir(PGLOBAL g) { - int rc, n = 0; + int n = 0; size_t m = strlen(Direc); // Start searching files in the target directory. #if defined(__WIN__) HANDLE h; + int rc; #if defined(PATHMATCHSPEC) if (!*Drive) diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 07272d1b298..20d4c0cb032 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -202,7 +202,7 @@ bool OcrSrcCols(PGLOBAL g, PQRYRES qrp, const char *col, /**********************************************************************/ /* Replace the columns of the colist by the rank and occur columns. */ /**********************************************************************/ - for (i = 0, pcrp = &qrp->Colresp; crp = *pcrp; ) { + for (i = 0, pcrp = &qrp->Colresp; (crp = *pcrp); ) { for (k = 0, pn = colist; k < m; k++, pn += (strlen(pn) + 1)) if (!stricmp(pn, crp->Name)) break; @@ -450,8 +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 9121a0453e5..b8e61f259e4 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -187,7 +187,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) } // endif picol // Prepare the column list - for (pcrp = &Qryp->Colresp; crp = *pcrp; ) + for (pcrp = &Qryp->Colresp; (crp = *pcrp); ) if (SkipColumn(crp, skc)) { // Ignore this column *pcrp = crp->Next; @@ -340,7 +340,7 @@ int PIVAID::Qcompare(int *i1, int *i2) bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff) { char *p1, *p2; - PHC hc = ((MYCAT*)Cat)->GetHandler(); + PHC hc __attribute__((unused))= ((MYCAT*)Cat)->GetHandler(); if (PRXDEF::DefineAM(g, am, poff)) return TRUE; @@ -748,7 +748,9 @@ int TDBPIVOT::ReadDB(PGLOBAL g) colp->ReadColumn(g); for (colp = Columns; colp; colp = colp->GetNext()) + { if (colp->GetAmType() == TYPE_AM_SRC) + { if (FileStatus) { if (((PSRCCOL)colp)->CompareLast()) { newrow = (RowFlag) ? TRUE : FALSE; @@ -757,7 +759,8 @@ 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 717090e9c5a..a46aa8635aa 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]; @@ -234,7 +236,7 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info) continue; } else break; - + } xcol->Name[vp->n] = 0; fmt[vp->m] = 0; @@ -248,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; @@ -308,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,6 +1275,7 @@ int TDBXML::ReadDB(PGLOBAL g) bool TDBXML::CheckRow(PGLOBAL g, bool b) { if (NewRow && Mode == MODE_INSERT) + { if (Rowname) { TabNode->AddText(g, "\n\t"); RowNode = TabNode->AddChildNode(g, Rowname, RowNode); @@ -1278,6 +1283,7 @@ bool TDBXML::CheckRow(PGLOBAL g, bool b) strcpy(g->Message, MSG(NO_ROW_NODE)); return true; } // endif Rowname + } if (Colname && (NewRow || b)) Clist = RowNode->SelectNodes(g, Colname, Clist); @@ -1525,11 +1531,13 @@ 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->Xpand && mode) { strcpy(g->Message, MSG(CONCAT_SUBNODE)); return true; } else Inod = i; // Index of multiple node + } if (mode) { // For Update or Insert the Xpath must be explicit @@ -1776,10 +1784,12 @@ void XMLCOL::WriteColumn(PGLOBAL g) break; if (ColNode) + { 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 @@ -1793,6 +1803,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) /*********************************************************************/ if (ColNode == NULL) { if (TopNode == NULL) + { if (Tdbp->Clist) { Tdbp->RowNode->AddText(g, "\n\t\t"); ColNode = Tdbp->RowNode->AddChildNode(g, Tdbp->Colname); @@ -1800,7 +1811,7 @@ void XMLCOL::WriteColumn(PGLOBAL g) TopNode = ColNode; } else TopNode = Tdbp->RowNode; - + } for (; k < Nod && TopNode; k++) { if (!done) { TopNode->AddText(g, "\n\t\t"); @@ -2015,6 +2026,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) } // endfor k if (ColNode) + { if (Inod == Nod) { /***************************************************************/ /* The node value can be multiple. */ @@ -2032,11 +2044,13 @@ 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 else if (Tdbp->Clist) @@ -2049,6 +2063,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) /*********************************************************************/ if (ColNode == NULL) { if (TopNode == NULL) + { if (Tdbp->Clist) { Tdbp->RowNode->AddText(g, "\n\t\t"); ColNode = Tdbp->RowNode->AddChildNode(g, Tdbp->Colname); @@ -2056,6 +2071,7 @@ void XMULCOL::WriteColumn(PGLOBAL g) TopNode = ColNode; } else TopNode = Tdbp->RowNode; + } for (; k < Nod && TopNode; k++) { if (!done) { diff --git a/storage/connect/user_connect.cc b/storage/connect/user_connect.cc index c25443ef7ef..55597c426eb 100644 --- a/storage/connect/user_connect.cc +++ b/storage/connect/user_connect.cc @@ -112,7 +112,7 @@ bool user_connect::user_init() if (g) printf("%s\n", g->Message); - int rc= PlugExit(g); + int rc __attribute__((unused))= PlugExit(g); g= NULL; if (dup) diff --git a/storage/connect/user_connect.h b/storage/connect/user_connect.h index 2670c5bcebc..53064e620f2 100644 --- a/storage/connect/user_connect.h +++ b/storage/connect/user_connect.h @@ -35,7 +35,7 @@ //typedef struct _global *PGLOBAL; typedef class user_connect *PCONNECT; typedef class ha_connect *PHC; -static int connect_done_func(void *); +int connect_done_func(void *); /*****************************************************************************/ /* The CONNECT users. There should be one by connected users. */ diff --git a/storage/connect/xindex.cpp b/storage/connect/xindex.cpp index 95f038d494c..8dcaa186bc9 100644 --- a/storage/connect/xindex.cpp +++ b/storage/connect/xindex.cpp @@ -559,12 +559,14 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp) // Check whether the unique index is unique indeed if (!Mul) + { if (Ndif < Num_K) { strcpy(g->Message, MSG(INDEX_NOT_UNIQ)); brc = true; goto err; } else PlgDBfree(Offset); // Not used anymore + } // Restore kcp list To_LastCol->Next = addcolp; @@ -1209,7 +1211,7 @@ bool XINDEX::MapInit(PGLOBAL g) PCOL colp; PXCOL prev = NULL, kcp = NULL; PDOSDEF defp = (PDOSDEF)Tdbp->To_Def; - PDBUSER dup = PlgGetUser(g); + PDBUSER dup __attribute__((unused))= PlgGetUser(g); /*********************************************************************/ /* Get the estimated table size. */ @@ -2043,11 +2045,12 @@ int XINDXS::Range(PGLOBAL g, int limit, bool incl) k = FastFind(); if (k < Num_K || Op != OP_EQ) + { if (limit) n = (Mul) ? k : kp->Val_K; else n = (Mul) ? Pof[kp->Val_K + 1] - k : 1; - + } } else { strcpy(g->Message, MSG(RANGE_NO_JOIN)); n = -1; // Logical error diff --git a/storage/connect/zip.c b/storage/connect/zip.c index 4bbe31ab7dd..52d63e108e7 100644 --- a/storage/connect/zip.c +++ b/storage/connect/zip.c @@ -28,6 +28,7 @@ #include #include "zlib.h" #include "zip.h" +#include "my_attribute.h" #ifdef STDC # include @@ -518,16 +519,16 @@ local ZPOS64_T zip64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_f if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) break; - for (i=(int)uReadSize-3; (i--)>0;) + for (i=(int)uReadSize-3; (i--)>0;) { if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) { uPosFound = uReadPos+i; break; } - - if (uPosFound!=0) - break; + } + if (uPosFound!=0) + break; } TRYFREE(buf); return uPosFound; @@ -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; @@ -1066,11 +1067,10 @@ extern int ZEXPORT zipOpenNewFileInZip4_64 (zipFile file, const char* filename, uInt i; int err = ZIP_OK; -# ifdef NOCRYPT - (crcForCrypting); +#ifdef NOCRYPT if (password != NULL) return ZIP_PARAMERROR; -# endif +#endif if (file == NULL) return ZIP_PARAMERROR; 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/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 0d43d4da5c4..f0bc8a49761 100644 --- a/storage/rocksdb/rdb_datadic.cc +++ b/storage/rocksdb/rdb_datadic.cc @@ -266,8 +266,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) { diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index e4bd6d2b5c2..0324c0665e2 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -219,7 +219,7 @@ static size_t my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), static size_t my_case_bin(CHARSET_INFO *cs __attribute__((unused)), const char *src, size_t srclen, - char *dst, size_t dstlen) + char *dst, size_t dstlen __attribute__((unused))) { DBUG_ASSERT(srclen <= dstlen); memcpy(dst, src, srclen); diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index 17cb51ff8cb..1ce180e30e4 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -237,7 +237,7 @@ size_t my_casedn_str_8bit(CHARSET_INFO * cs,char *str) size_t my_caseup_8bit(CHARSET_INFO * cs, const char *src, size_t srclen, - char *dst, size_t dstlen) + char *dst, size_t dstlen __attribute__((unused))) { const char *end= src + srclen; register const uchar *map= cs->to_upper; @@ -249,7 +249,7 @@ size_t my_caseup_8bit(CHARSET_INFO * cs, const char *src, size_t srclen, size_t my_casedn_8bit(CHARSET_INFO * cs, const char *src, size_t srclen, - char *dst, size_t dstlen) + char *dst, size_t dstlen __attribute__((unused))) { const char *end= src + srclen; register const uchar *map=cs->to_lower; diff --git a/strings/json_lib.c b/strings/json_lib.c index bb8c15ee0c1..8a77c41d015 100644 --- a/strings/json_lib.c +++ b/strings/json_lib.c @@ -1995,9 +1995,13 @@ err_return: } -enum json_types json_get_object_nkey(const char *js,const char *js_end, int nkey, - const char **keyname, const char **keyname_end, - const char **value, int *value_len) +enum json_types json_get_object_nkey(const char *js __attribute__((unused)), + const char *js_end __attribute__((unused)), + int nkey __attribute__((unused)), + const char **keyname __attribute__((unused)), + const char **keyname_end __attribute__((unused)), + const char **value __attribute__((unused)), + int *value_len __attribute__((unused))) { return JSV_NOTHING; } diff --git a/strings/strcoll.ic b/strings/strcoll.ic index 50278135dd4..86789fc4189 100644 --- a/strings/strcoll.ic +++ b/strings/strcoll.ic @@ -367,7 +367,7 @@ MY_FUNCTION_NAME(strnxfrm)(CHARSET_INFO *cs, static size_t -MY_FUNCTION_NAME(strnxfrm_internal)(CHARSET_INFO *cs, +MY_FUNCTION_NAME(strnxfrm_internal)(CHARSET_INFO *cs __attribute__((unused)), uchar *dst, uchar *de, uint *nweights, const uchar *src, const uchar *se) @@ -489,7 +489,7 @@ MY_FUNCTION_NAME(strnxfrm_nopad)(CHARSET_INFO *cs, static size_t -MY_FUNCTION_NAME(strnxfrm_internal)(CHARSET_INFO *cs, +MY_FUNCTION_NAME(strnxfrm_internal)(CHARSET_INFO *cs __attribute__((unused)), uchar *dst, uchar *de, uint *nweights, const uchar *src, diff --git a/unittest/mysys/byte_order-t.c b/unittest/mysys/byte_order-t.c index e276e597fbf..d4481a4135b 100644 --- a/unittest/mysys/byte_order-t.c +++ b/unittest/mysys/byte_order-t.c @@ -94,7 +94,7 @@ void test_byte_order() #undef TEST } -int main(int argc, char **argv) +int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) { plan(68); test_byte_order(); diff --git a/zlib/infback.c b/zlib/infback.c index 59679ecbfc5..4f79cead2a2 100644 --- a/zlib/infback.c +++ b/zlib/infback.c @@ -477,6 +477,7 @@ void FAR *out_desc; } Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN; + /* falls through */ case LEN: /* use inflate_fast() if we have enough input and output */ diff --git a/zlib/inflate.c b/zlib/inflate.c index ac333e8c2ed..c10064c7ee2 100644 --- a/zlib/inflate.c +++ b/zlib/inflate.c @@ -740,6 +740,7 @@ int flush; CRC2(state->check, hold); INITBITS(); state->mode = EXLEN; + /* falls through */ case EXLEN: if (state->flags & 0x0400) { NEEDBITS(16); @@ -753,6 +754,7 @@ int flush; else if (state->head != Z_NULL) state->head->extra = Z_NULL; state->mode = EXTRA; + /* falls through */ case EXTRA: if (state->flags & 0x0400) { copy = state->length; @@ -775,6 +777,7 @@ int flush; } state->length = 0; state->mode = NAME; + /* falls through */ case NAME: if (state->flags & 0x0800) { if (have == 0) goto inf_leave; @@ -796,6 +799,7 @@ int flush; state->head->name = Z_NULL; state->length = 0; state->mode = COMMENT; + /* falls through */ case COMMENT: if (state->flags & 0x1000) { if (have == 0) goto inf_leave; @@ -816,6 +820,7 @@ int flush; else if (state->head != Z_NULL) state->head->comment = Z_NULL; state->mode = HCRC; + /* falls through */ case HCRC: if (state->flags & 0x0200) { NEEDBITS(16); @@ -839,6 +844,7 @@ int flush; strm->adler = state->check = ZSWAP32(hold); INITBITS(); state->mode = DICT; + /* falls through */ case DICT: if (state->havedict == 0) { RESTORE(); @@ -846,8 +852,10 @@ int flush; } strm->adler = state->check = adler32(0L, Z_NULL, 0); state->mode = TYPE; + /* falls through */ case TYPE: if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave; + /* falls through */ case TYPEDO: if (state->last) { BYTEBITS(); @@ -898,8 +906,10 @@ int flush; INITBITS(); state->mode = COPY_; if (flush == Z_TREES) goto inf_leave; + /* falls through */ case COPY_: state->mode = COPY; + /* falls through */ case COPY: copy = state->length; if (copy) { @@ -1039,8 +1049,10 @@ int flush; Tracev((stderr, "inflate: codes ok\n")); state->mode = LEN_; if (flush == Z_TREES) goto inf_leave; + /* falls through */ case LEN_: state->mode = LEN; + /* falls through */ case LEN: if (have >= 6 && left >= 258) { RESTORE(); @@ -1090,6 +1102,7 @@ int flush; } state->extra = (unsigned)(here.op) & 15; state->mode = LENEXT; + /* falls through */ case LENEXT: if (state->extra) { NEEDBITS(state->extra); @@ -1100,6 +1113,7 @@ int flush; Tracevv((stderr, "inflate: length %u\n", state->length)); state->was = state->length; state->mode = DIST; + /* falls through */ case DIST: for (;;) { here = state->distcode[BITS(state->distbits)]; @@ -1127,6 +1141,7 @@ int flush; state->offset = (unsigned)here.val; state->extra = (unsigned)(here.op) & 15; state->mode = DISTEXT; + /* falls through */ case DISTEXT: if (state->extra) { NEEDBITS(state->extra); @@ -1143,6 +1158,7 @@ int flush; #endif Tracevv((stderr, "inflate: distance %u\n", state->offset)); state->mode = MATCH; + /* falls through */ case MATCH: if (left == 0) goto inf_leave; copy = out - left; @@ -1218,6 +1234,7 @@ int flush; } #ifdef GUNZIP state->mode = LENGTH; + /* falls through */ case LENGTH: if (state->wrap && state->flags) { NEEDBITS(32); @@ -1231,6 +1248,7 @@ int flush; } #endif state->mode = DONE; + /* falls through */ case DONE: ret = Z_STREAM_END; goto inf_leave; From a10a94b26275fb2badcf0ec3d2b027e9c5cce2b4 Mon Sep 17 00:00:00 2001 From: Sachin Date: Fri, 31 Jan 2020 11:47:17 +0530 Subject: [PATCH 03/16] Empty commit From 88bcc7f21c294f90140eb5468f7c95ce10dc18e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 31 Jan 2020 09:17:12 +0200 Subject: [PATCH 04/16] Fixup cd2c0e013ccb5f9b009743dfd7188585a539d9b5 The variable 'dlh' was being used uninitialized if WSREP_PROVIDER is not set. --- mysql-test/lib/My/SafeProcess/wsrep_check_version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c index 52dfbe6d2df..91098be882a 100644 --- a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c +++ b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c @@ -90,7 +90,7 @@ int main(int argc, char **argv) if (!provider) { fprintf(stderr, "WSREP_PROVIDER is not set\n"); - goto err; + return 1; } if (!(dlh = dlopen(provider, RTLD_NOW | RTLD_LOCAL))) { From d87b725eebbddb6d319ee99e51924a62635185a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Fri, 31 Jan 2020 09:54:43 +0200 Subject: [PATCH 05/16] MDEV-17844 recs_off_validate() fails in page_zip_write_trx_id_and_roll_ptr() In commit 0e5a4ac2532c64a545796c787354dc41d61d0e62 (MDEV-15562) we introduced was a bogus debug check failure that does not affect the correctness of the release build. With a fixed-length PRIMARY KEY, we do not have to recompute the rec_get_offsets() after restarting the mini-transaction, because the offsets of DB_TRX_ID,DB_ROLL_PTR are not going to change. row_undo_mod_clust(): Invoke rec_offs_make_valid() to keep the debug check in page_zip_write_trx_id_and_roll_ptr() happy. The scenario to reproduce this bug should be rather unlikely: In the time frame when row_undo_mod_clust() has committed its first mini-transaction and has not yet started the next one, another mini-transaction must do something that causes the page to be reorganized, split or merged. --- storage/innobase/row/row0umod.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/storage/innobase/row/row0umod.cc b/storage/innobase/row/row0umod.cc index e028e0ccb56..d2707130439 100644 --- a/storage/innobase/row/row0umod.cc +++ b/storage/innobase/row/row0umod.cc @@ -457,6 +457,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( &node->pcur))); From 4b291588bb374ec72fd19202911abe949fc0c7c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 1 Feb 2020 14:53:41 +0200 Subject: [PATCH 06/16] MDEV-19845: Make my_cpu.h self-contained Fix up commit f5c080c7353cc9c30d0b269c07024cd38253c3bc --- include/my_cpu.h | 9 ++++++++- mysys/my_cpu.c | 3 +-- storage/innobase/include/ib0mutex.h | 3 +-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/my_cpu.h b/include/my_cpu.h index 0e37eafe60e..b7d7008a8e3 100644 --- a/include/my_cpu.h +++ b/include/my_cpu.h @@ -1,6 +1,6 @@ #ifndef MY_CPU_INCLUDED #define MY_CPU_INCLUDED -/* Copyright (c) 2013, MariaDB foundation Ab and SkySQL +/* Copyright (c) 2013, 2020, MariaDB 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 @@ -50,6 +50,13 @@ # define HAVE_PAUSE_INSTRUCTION /* added in Intel Pentium 4 */ #endif +#ifdef _WIN32 +#elif defined HAVE_PAUSE_INSTRUCTION +#elif defined(_ARCH_PWR8) +#else +# include "my_atomic.h" +#endif + static inline void MY_RELAX_CPU(void) { #ifdef _WIN32 diff --git a/mysys/my_cpu.c b/mysys/my_cpu.c index 72705263aae..52500d78ef7 100644 --- a/mysys/my_cpu.c +++ b/mysys/my_cpu.c @@ -1,4 +1,4 @@ -/* 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 @@ -14,7 +14,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ #include -#include #include #include 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" From 1b414c0313794c4e9aa36cf099e957f1eb283e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Sat, 1 Feb 2020 15:06:12 +0200 Subject: [PATCH 07/16] MDEV-21256 after-merge fix: Use std::atomic Starting with MariaDB Server 10.4, C++11 is being used. Hence, std::atomic should be preferred to my_atomic. --- storage/innobase/include/ut0rnd.h | 9 ++++----- storage/innobase/ut/ut0rnd.cc | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) 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 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/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 ut_rnd_current; /** These random numbers are used in ut_find_prime */ /*@{*/ From 5a6023cf6f5f72e36837761f5df0de91c7de62ed Mon Sep 17 00:00:00 2001 From: Sachin Setiya Date: Tue, 8 Oct 2019 17:35:09 +0530 Subject: [PATCH 08/16] MDEV-18791 Wrong error upon creating Aria table with long index on BLOB If we have long unique key for aria engine return too long key error, because Aria does not support key on virtual generated column. --- mysql-test/main/long_unique_bugs.result | 2 ++ mysql-test/main/long_unique_bugs.test | 6 ++++++ storage/maria/ha_maria.cc | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 33496c4e20d..d4b71e2bc46 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -265,3 +265,5 @@ ERROR 40001: Deadlock found when trying to get lock; try restarting transaction disconnect con1; connection default; DROP TABLE t1, t2; +CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; +ERROR 42000: Specified key was too long; max key length is 1000 bytes diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index dc78f6c7067..62c4076cee0 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -317,3 +317,9 @@ INSERT IGNORE INTO t1 VALUES (4, 1)/*4*/; --disconnect con1 --connection default DROP TABLE t1, t2; + +# +# MDEV-18791 Wrong error upon creating Aria table with long index on BLOB +# +--error ER_TOO_LONG_KEY +CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 0e0aa09825b..5dd40a7843a 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); } From b615d275b8c26ecec943003e1275ee19f94d9887 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Sun, 2 Feb 2020 15:13:29 +0300 Subject: [PATCH 09/16] MDEV-17798 System variable system_versioning_asof accepts wrong values (10.4) --- mysql-test/suite/versioning/r/sysvars.result | 16 ++++++++++++++++ mysql-test/suite/versioning/t/sysvars.test | 16 ++++++++++++++++ sql/sys_vars.ic | 9 +++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/versioning/r/sysvars.result b/mysql-test/suite/versioning/r/sysvars.result index 79aa8fce746..165458ef170 100644 --- a/mysql-test/suite/versioning/r/sysvars.result +++ b/mysql-test/suite/versioning/r/sysvars.result @@ -31,6 +31,14 @@ set global system_versioning_asof= 1; ERROR 42000: Incorrect argument type to variable 'system_versioning_asof' set global system_versioning_asof= 1.1; ERROR 42000: Incorrect argument type to variable 'system_versioning_asof' +set global system_versioning_asof= '2011-02-29 00:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '2011-02-29 00:00' +set global system_versioning_asof= '2011-02-28 24:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '2011-02-28 24:00' +set global system_versioning_asof= '2011-00-28 00:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '2011-00-28 00:00' +set global system_versioning_asof= '0000-00-00 00:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '0000-00-00 00:00' set system_versioning_asof= 'alley'; ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of 'alley' set system_versioning_asof= null; @@ -39,6 +47,14 @@ set system_versioning_asof= 1; ERROR 42000: Incorrect argument type to variable 'system_versioning_asof' set system_versioning_asof= 1.1; ERROR 42000: Incorrect argument type to variable 'system_versioning_asof' +set system_versioning_asof= '2011-02-29 00:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '2011-02-29 00:00' +set system_versioning_asof= '2011-02-28 24:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '2011-02-28 24:00' +set system_versioning_asof= '2011-00-28 00:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '2011-00-28 00:00' +set system_versioning_asof= '0000-00-00 00:00'; +ERROR 42000: Variable 'system_versioning_asof' can't be set to the value of '0000-00-00 00:00' # GLOBAL @@system_versioning_asof set global system_versioning_asof= '1911-11-11 11:11:11.1111119'; Warnings: diff --git a/mysql-test/suite/versioning/t/sysvars.test b/mysql-test/suite/versioning/t/sysvars.test index 52fab81b8e6..e82a116f30e 100644 --- a/mysql-test/suite/versioning/t/sysvars.test +++ b/mysql-test/suite/versioning/t/sysvars.test @@ -23,6 +23,14 @@ set global system_versioning_asof= null; set global system_versioning_asof= 1; --error ER_WRONG_TYPE_FOR_VAR set global system_versioning_asof= 1.1; +--error ER_WRONG_VALUE_FOR_VAR +set global system_versioning_asof= '2011-02-29 00:00'; +--error ER_WRONG_VALUE_FOR_VAR +set global system_versioning_asof= '2011-02-28 24:00'; +--error ER_WRONG_VALUE_FOR_VAR +set global system_versioning_asof= '2011-00-28 00:00'; +--error ER_WRONG_VALUE_FOR_VAR +set global system_versioning_asof= '0000-00-00 00:00'; # session --error ER_WRONG_VALUE_FOR_VAR @@ -33,6 +41,14 @@ set system_versioning_asof= null; set system_versioning_asof= 1; --error ER_WRONG_TYPE_FOR_VAR set system_versioning_asof= 1.1; +--error ER_WRONG_VALUE_FOR_VAR +set system_versioning_asof= '2011-02-29 00:00'; +--error ER_WRONG_VALUE_FOR_VAR +set system_versioning_asof= '2011-02-28 24:00'; +--error ER_WRONG_VALUE_FOR_VAR +set system_versioning_asof= '2011-00-28 00:00'; +--error ER_WRONG_VALUE_FOR_VAR +set system_versioning_asof= '0000-00-00 00:00'; --echo # GLOBAL @@system_versioning_asof set global system_versioning_asof= '1911-11-11 11:11:11.1111119'; diff --git a/sql/sys_vars.ic b/sql/sys_vars.ic index 6862dcfde6f..e983347f4ce 100644 --- a/sql/sys_vars.ic +++ b/sql/sys_vars.ic @@ -2634,7 +2634,10 @@ public: if (!Sys_var_enum::do_check(thd, var)) return false; MYSQL_TIME ltime; - Datetime::Options opt(TIME_CONV_NONE, thd); + // FIXME: please resolve both conflicts to "old" and remove this comment + Datetime::Options opt(TIME_CONV_NONE | + TIME_NO_ZERO_IN_DATE | + TIME_NO_ZERO_DATE, thd); bool res= var->value->get_date(thd, <ime, opt); if (!res) { @@ -2653,7 +2656,9 @@ private: if (var->value) { THD *thd= current_thd; - Datetime::Options opt(TIME_CONV_NONE, thd); + Datetime::Options opt(TIME_CONV_NONE | + TIME_NO_ZERO_IN_DATE | + TIME_NO_ZERO_DATE, thd); res= var->value->get_date(thd, &out.ltime, opt); } else // set DEFAULT from global var From eed6d215f13cae8b84d9381918a3bd56dcf16188 Mon Sep 17 00:00:00 2001 From: Sachin Date: Wed, 9 Oct 2019 21:16:31 +0530 Subject: [PATCH 10/16] MDEV-20001 Potential dangerous regression: INSERT INTO >=100 rows fail for myisam table with HASH indexes Problem:- So the issue is when we do bulk insert with rows > MI_MIN_ROWS_TO_DISABLE_INDEXES(100) , We try to disable the indexes to speedup insert. But current logic also disables the long unique indexes. Solution:- In ha_myisam::start_bulk_insert if we find long hash index (HA_KEY_ALG_LONG_HASH) we will not disable the index. This commit also refactors the mi_disable_indexes_for_rebuild function, Since this is function is called at only one place, it is inlined into start_bulk_insert mi_clear_key_active is added into myisamdef.h because now it is also used in ha_myisam.cc file. (Same is done for Aria Storage engine) --- include/maria.h | 1 + include/myisam.h | 1 + mysql-test/main/long_unique_bugs.result | 3 +++ mysql-test/main/long_unique_bugs.test | 17 +++++++++++++ storage/maria/ha_maria.cc | 27 +++++++++++++++++++- storage/maria/ma_check.c | 34 +------------------------ storage/myisam/ha_myisam.cc | 30 +++++++++++++++++++++- storage/myisam/mi_check.c | 34 +------------------------ storage/myisam/myisamdef.h | 2 -- 9 files changed, 79 insertions(+), 70 deletions(-) diff --git a/include/maria.h b/include/maria.h index a1396d3a4c7..a946363c57b 100644 --- a/include/maria.h +++ b/include/maria.h @@ -396,6 +396,7 @@ int maria_preload(MARIA_HA *info, ulonglong key_map, my_bool ignore_leaves); void maria_versioning(MARIA_HA *info, my_bool versioning); void maria_ignore_trids(MARIA_HA *info); uint maria_max_key_length(void); +my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows); #define maria_max_key_segments() HA_MAX_KEY_SEG /* fulltext functions */ diff --git a/include/myisam.h b/include/myisam.h index 216f041c8a9..f2e31bb9f60 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -430,6 +430,7 @@ int sort_ft_buf_flush(MI_SORT_PARAM *sort_param); int thr_write_keys(MI_SORT_PARAM *sort_param); int sort_write_record(MI_SORT_PARAM *sort_param); int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, ulonglong); +my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows); #ifdef __cplusplus } diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index d4b71e2bc46..c0ba4d0b87d 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -267,3 +267,6 @@ connection default; DROP TABLE t1, t2; CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; ERROR 42000: Specified key was too long; max key length is 1000 bytes +create table t1(a int, unique(a) using hash); +#BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES) +drop table t1; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 62c4076cee0..13a4e1367a0 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -323,3 +323,20 @@ DROP TABLE t1, t2; # --error ER_TOO_LONG_KEY CREATE TABLE t1 (a TEXT, UNIQUE(a)) ENGINE=Aria; + +# +# MDEV-20001 Potential dangerous regression: INSERT INTO >=100 rows fail for myisam table with HASH indexes +# +create table t1(a int, unique(a) using hash); +--let $count=150 +--let insert_stmt= insert into t1 values(200) +while ($count) +{ + --let $insert_stmt=$insert_stmt,($count) + --dec $count +} +--disable_query_log +--echo #BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES) +--eval $insert_stmt +--enable_query_log +drop table t1; diff --git a/storage/maria/ha_maria.cc b/storage/maria/ha_maria.cc index 5dd40a7843a..dabacc5af53 100644 --- a/storage/maria/ha_maria.cc +++ b/storage/maria/ha_maria.cc @@ -2157,7 +2157,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 9094345c9c0..0a271a77a36 100644 --- a/storage/maria/ma_check.c +++ b/storage/maria/ma_check.c @@ -6441,7 +6441,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) @@ -6456,38 +6456,6 @@ static my_bool maria_too_big_key_for_sort(MARIA_KEYDEF *key, ha_rows rows) (ulonglong) maria_max_temp_length)); } -/* - 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 diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index c046572f0c8..f5f36266347 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -1750,7 +1750,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) @@ -4681,38 +4681,6 @@ static my_bool mi_too_big_key_for_sort(MI_KEYDEF *key, ha_rows rows) ((ulonglong) rows * key_maxlength > myisam_max_temp_length)); } -/* - 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 diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index c6fa777774a..f7b61ae638c 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -715,8 +715,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); From 574354a6b2a9e9438d81e341dfcc4077545b5fb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Mon, 3 Feb 2020 19:45:30 +0200 Subject: [PATCH 11/16] MDEV-20625 : MariaDB asserting when enabling wsrep_on When wsrep_on is changed to ON we might need to run wsrep_init if wsrep-provider is set and wsrep is not inited. --- sql/wsrep_var.cc | 116 +++++++++++++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 48 deletions(-) diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index 5f76f650b34..e5bd3d0416d 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -41,6 +41,53 @@ int wsrep_init_vars() return 0; } +static int get_provider_option_value(const char* opts, + const char* opt_name, + ulong* opt_value) +{ + int ret= 1; + ulong opt_value_tmp; + char *opt_value_str, *s, *opts_copy= my_strdup(opts, MYF(MY_WME)); + + if ((opt_value_str= strstr(opts_copy, opt_name)) == NULL) + goto end; + opt_value_str= strtok_r(opt_value_str, "=", &s); + if (opt_value_str == NULL) goto end; + opt_value_str= strtok_r(NULL, ";", &s); + if (opt_value_str == NULL) goto end; + + opt_value_tmp= strtoul(opt_value_str, NULL, 10); + if (errno == ERANGE) goto end; + + *opt_value= opt_value_tmp; + ret= 0; + +end: + my_free(opts_copy); + return ret; +} + +static bool refresh_provider_options() +{ + WSREP_DEBUG("refresh_provider_options: %s", + (wsrep_provider_options) ? wsrep_provider_options : "null"); + + try + { + std::string opts= Wsrep_server_state::instance().provider().options(); + wsrep_provider_options_init(opts.c_str()); + get_provider_option_value(wsrep_provider_options, + (char*)"repl.max_ws_size", + &wsrep_max_ws_size); + return false; + } + catch (...) + { + WSREP_ERROR("Failed to get provider options"); + return true; + } +} + /* This is intentionally declared as a weak global symbol, so that linking will succeed even if the server is built with a dynamically linked InnoDB. */ @@ -50,8 +97,28 @@ struct handlerton* innodb_hton_ptr __attribute__((weak)); bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type) { if (var_type == OPT_GLOBAL) { - // FIXME: this variable probably should be changed only per session thd->variables.wsrep_on= global_system_variables.wsrep_on; + + // If wsrep has not been inited we need to do it now + if (global_system_variables.wsrep_on && wsrep_provider && !wsrep_inited) + { + bool rcode= false; + char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider + //when fails + + if (wsrep_init()) + { + my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp, my_error, "wsrep_init failed"); + rcode= true; + } + free(tmp); + + // we sure don't want to use old address with new provider + wsrep_cluster_address_init(NULL); + wsrep_provider_options_init(NULL); + if (!rcode) + refresh_provider_options(); + } } return false; @@ -224,53 +291,6 @@ bool wsrep_start_position_init (const char* val) return false; } -static int get_provider_option_value(const char* opts, - const char* opt_name, - ulong* opt_value) -{ - int ret= 1; - ulong opt_value_tmp; - char *opt_value_str, *s, *opts_copy= my_strdup(opts, MYF(MY_WME)); - - if ((opt_value_str= strstr(opts_copy, opt_name)) == NULL) - goto end; - opt_value_str= strtok_r(opt_value_str, "=", &s); - if (opt_value_str == NULL) goto end; - opt_value_str= strtok_r(NULL, ";", &s); - if (opt_value_str == NULL) goto end; - - opt_value_tmp= strtoul(opt_value_str, NULL, 10); - if (errno == ERANGE) goto end; - - *opt_value= opt_value_tmp; - ret= 0; - -end: - my_free(opts_copy); - return ret; -} - -static bool refresh_provider_options() -{ - WSREP_DEBUG("refresh_provider_options: %s", - (wsrep_provider_options) ? wsrep_provider_options : "null"); - - try - { - std::string opts= Wsrep_server_state::instance().provider().options(); - wsrep_provider_options_init(opts.c_str()); - get_provider_option_value(wsrep_provider_options, - (char*)"repl.max_ws_size", - &wsrep_max_ws_size); - return false; - } - catch (...) - { - WSREP_ERROR("Failed to get provider options"); - return true; - } -} - static int wsrep_provider_verify (const char* provider_str) { MY_STAT f_stat; From 93278ee8ad0798a042bd8141b646ff3a17a7383d Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Tue, 8 Oct 2019 10:47:30 +0200 Subject: [PATCH 12/16] MDEV-20625: MariaDB asserting when enabling wsrep=on --- mysql-test/suite/wsrep/r/MDEV-20625.result | 4 ++++ mysql-test/suite/wsrep/t/MDEV-20625.cnf | 8 ++++++++ mysql-test/suite/wsrep/t/MDEV-20625.test | 9 +++++++++ 3 files changed, 21 insertions(+) create mode 100644 mysql-test/suite/wsrep/r/MDEV-20625.result create mode 100644 mysql-test/suite/wsrep/t/MDEV-20625.cnf create mode 100644 mysql-test/suite/wsrep/t/MDEV-20625.test diff --git a/mysql-test/suite/wsrep/r/MDEV-20625.result b/mysql-test/suite/wsrep/r/MDEV-20625.result new file mode 100644 index 00000000000..cf48f163b77 --- /dev/null +++ b/mysql-test/suite/wsrep/r/MDEV-20625.result @@ -0,0 +1,4 @@ +SET GLOBAL wsrep_on=ON; +SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size'; +Variable_name Value +wsrep_cluster_size 1 diff --git a/mysql-test/suite/wsrep/t/MDEV-20625.cnf b/mysql-test/suite/wsrep/t/MDEV-20625.cnf new file mode 100644 index 00000000000..75f8a25caff --- /dev/null +++ b/mysql-test/suite/wsrep/t/MDEV-20625.cnf @@ -0,0 +1,8 @@ +!include ../my.cnf + +[mysqld.1] +wsrep-on=OFF +binlog-format=ROW +wsrep-provider=@ENV.WSREP_PROVIDER +wsrep-cluster-address='gcomm://' +innodb_autoinc_lock_mode=2 diff --git a/mysql-test/suite/wsrep/t/MDEV-20625.test b/mysql-test/suite/wsrep/t/MDEV-20625.test new file mode 100644 index 00000000000..09092b454c3 --- /dev/null +++ b/mysql-test/suite/wsrep/t/MDEV-20625.test @@ -0,0 +1,9 @@ +# +# Check SHOW GLOBAL STATUS after dynamic setting WSREP=ON +# +--source include/have_innodb.inc +--source include/have_wsrep_provider.inc +--source include/have_binlog_format_row.inc + +SET GLOBAL wsrep_on=ON; +SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size'; From 46386661a2311cabd7bac914c44b1af0b4746e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 4 Feb 2020 09:00:36 +0200 Subject: [PATCH 13/16] MDEV-20625 : MariaDB asserting when enabling wsrep_on We need to release global system variables mutex before doing wsrep_init to avoid race with next show status and we need to save wsrep_on value as it is changed on wsrep_init. Added test case. --- mysql-test/suite/wsrep/r/MDEV-20625.result | 3 ++- mysql-test/suite/wsrep/t/MDEV-20625.test | 1 + sql/wsrep_var.cc | 21 +++++++++++---------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/mysql-test/suite/wsrep/r/MDEV-20625.result b/mysql-test/suite/wsrep/r/MDEV-20625.result index cf48f163b77..3e2b621c8f9 100644 --- a/mysql-test/suite/wsrep/r/MDEV-20625.result +++ b/mysql-test/suite/wsrep/r/MDEV-20625.result @@ -1,4 +1,5 @@ SET GLOBAL wsrep_on=ON; SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size'; Variable_name Value -wsrep_cluster_size 1 +wsrep_cluster_size 0 +SET GLOBAL wsrep_on=OFF; diff --git a/mysql-test/suite/wsrep/t/MDEV-20625.test b/mysql-test/suite/wsrep/t/MDEV-20625.test index 09092b454c3..2a537fe432e 100644 --- a/mysql-test/suite/wsrep/t/MDEV-20625.test +++ b/mysql-test/suite/wsrep/t/MDEV-20625.test @@ -7,3 +7,4 @@ SET GLOBAL wsrep_on=ON; SHOW GLOBAL STATUS LIKE 'wsrep_cluster_size'; +SET GLOBAL wsrep_on=OFF; diff --git a/sql/wsrep_var.cc b/sql/wsrep_var.cc index e5bd3d0416d..8ec251d8915 100644 --- a/sql/wsrep_var.cc +++ b/sql/wsrep_var.cc @@ -97,28 +97,29 @@ struct handlerton* innodb_hton_ptr __attribute__((weak)); bool wsrep_on_update (sys_var *self, THD* thd, enum_var_type var_type) { if (var_type == OPT_GLOBAL) { + my_bool saved_wsrep_on= global_system_variables.wsrep_on; + thd->variables.wsrep_on= global_system_variables.wsrep_on; // If wsrep has not been inited we need to do it now if (global_system_variables.wsrep_on && wsrep_provider && !wsrep_inited) { - bool rcode= false; char* tmp= strdup(wsrep_provider); // wsrep_init() rewrites provider //when fails + mysql_mutex_unlock(&LOCK_global_system_variables); + if (wsrep_init()) { my_error(ER_CANT_OPEN_LIBRARY, MYF(0), tmp, my_error, "wsrep_init failed"); - rcode= true; + //rcode= true; } - free(tmp); - // we sure don't want to use old address with new provider - wsrep_cluster_address_init(NULL); - wsrep_provider_options_init(NULL); - if (!rcode) - refresh_provider_options(); + free(tmp); + mysql_mutex_lock(&LOCK_global_system_variables); } + + thd->variables.wsrep_on= global_system_variables.wsrep_on= saved_wsrep_on; } return false; @@ -342,11 +343,11 @@ bool wsrep_provider_update (sys_var *self, THD* thd, enum_var_type type) WSREP_DEBUG("wsrep_provider_update: %s", wsrep_provider); - /* stop replication is heavy operation, and includes closing all client + /* stop replication is heavy operation, and includes closing all client connections. Closing clients may need to get LOCK_global_system_variables at least in MariaDB. - Note: releasing LOCK_global_system_variables may cause race condition, if + Note: releasing LOCK_global_system_variables may cause race condition, if there can be several concurrent clients changing wsrep_provider */ mysql_mutex_unlock(&LOCK_global_system_variables); From a56f78243ee06167b5baf8255d3866099f3a3936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 4 Feb 2020 16:31:52 +0200 Subject: [PATCH 14/16] MDEV-21645 SIGSEGV in innobase_get_computed_value ha_innobase::commit_inplace_alter_table(): After ALTER_STORED_COLUMN_ORDER, ensure that the virtual column metadata will be reloaded also when the table is not being rebuilt. --- mysql-test/suite/innodb/r/instant_alter_bugs.result | 9 +++++++++ mysql-test/suite/innodb/t/instant_alter_bugs.test | 10 ++++++++++ storage/innobase/handler/handler0alter.cc | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_bugs.result b/mysql-test/suite/innodb/r/instant_alter_bugs.result index 4512542f612..53f2d4f1c60 100644 --- a/mysql-test/suite/innodb/r/instant_alter_bugs.result +++ b/mysql-test/suite/innodb/r/instant_alter_bugs.result @@ -358,4 +358,13 @@ t1 CREATE TABLE `t1` ( `a` char(1) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin2 ROW_FORMAT=REDUNDANT DROP TABLE t1; +# +# MDEV-21645 SIGSEGV in innobase_get_computed_value +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, va INTEGER GENERATED ALWAYS AS (a)) +ENGINE=InnoDB; +INSERT INTO t1 SET a=1, b=NULL; +ALTER TABLE t1 MODIFY COLUMN b INT FIRST; +ALTER TABLE t1 ADD UNIQUE INDEX (va); +DROP TABLE t1; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test index 0a1de256b6a..d76a586cfa1 100644 --- a/mysql-test/suite/innodb/t/instant_alter_bugs.test +++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test @@ -374,4 +374,14 @@ ALTER TABLE t1 MODIFY a CHAR, ALGORITHM=INSTANT; SHOW CREATE TABLE t1; DROP TABLE t1; +--echo # +--echo # MDEV-21645 SIGSEGV in innobase_get_computed_value +--echo # +CREATE TABLE t1 (a INT PRIMARY KEY, b INT, va INTEGER GENERATED ALWAYS AS (a)) +ENGINE=InnoDB; +INSERT INTO t1 SET a=1, b=NULL; +ALTER TABLE t1 MODIFY COLUMN b INT FIRST; +ALTER TABLE t1 ADD UNIQUE INDEX (va); +DROP TABLE t1; + SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 741a94ae42b..4200e87fa7f 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -11172,7 +11172,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); From 2acc6f2d95d31f4ea82de8a66c5f2f7fd6583a16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 5 Feb 2020 11:12:10 +0200 Subject: [PATCH 15/16] MDEV-21658 Error on online ADD PRIMARY KEY after instant DROP/reorder row_log_table_get_pk_old_col(): For replacing a NULL value for a column of the being-added primary key, look up the correct default value, even if columns had been instantly reordered or dropped earlier. This ought to have been broken ever since commit 0e5a4ac2532c64a545796c787354dc41d61d0e62 (MDEV-15562). --- .../suite/innodb/r/instant_alter_debug.result | 24 +++++++++++++++++ .../suite/innodb/t/instant_alter_debug.test | 26 +++++++++++++++++++ storage/innobase/row/row0log.cc | 15 ++++++++--- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/innodb/r/instant_alter_debug.result b/mysql-test/suite/innodb/r/instant_alter_debug.result index 72c9a85e369..9fcb8b05a34 100644 --- a/mysql-test/suite/innodb/r/instant_alter_debug.result +++ b/mysql-test/suite/innodb/r/instant_alter_debug.result @@ -343,6 +343,30 @@ UPDATE t1 SET b = 1; SET DEBUG_SYNC='now SIGNAL update'; connection con2; connection default; +DROP TABLE t1; +# +# MDEV-21658 Error on online ADD PRIMARY KEY after instant DROP/reorder +# +CREATE TABLE t1 (a INT, b INT, c INT, col INT) ENGINE=InnoDB; +INSERT INTO t1 () VALUES (); +ALTER TABLE t1 DROP b, DROP c, DROP col; +ALTER TABLE t1 ADD COLUMN col INT; +ALTER TABLE t1 DROP a, DROP col, ADD COLUMN b INT; +connection con2; +SET SQL_MODE= ''; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR dml'; +ALTER TABLE t1 ADD PRIMARY KEY(b); +connection default; +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +UPDATE t1 SET b = 1; +SET DEBUG_SYNC = 'now SIGNAL dml'; +connection con2; +Warnings: +Warning 1265 Data truncated for column 'b' at row 1 +connection default; +SELECT * FROM t1; +b +1 SET DEBUG_SYNC='RESET'; disconnect con2; DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/instant_alter_debug.test b/mysql-test/suite/innodb/t/instant_alter_debug.test index 22452c78f4d..fe80de2ca51 100644 --- a/mysql-test/suite/innodb/t/instant_alter_debug.test +++ b/mysql-test/suite/innodb/t/instant_alter_debug.test @@ -385,6 +385,32 @@ SET DEBUG_SYNC='now SIGNAL update'; --reap --connection default +DROP TABLE t1; + +--echo # +--echo # MDEV-21658 Error on online ADD PRIMARY KEY after instant DROP/reorder +--echo # + +CREATE TABLE t1 (a INT, b INT, c INT, col INT) ENGINE=InnoDB; +INSERT INTO t1 () VALUES (); +ALTER TABLE t1 DROP b, DROP c, DROP col; +ALTER TABLE t1 ADD COLUMN col INT; +ALTER TABLE t1 DROP a, DROP col, ADD COLUMN b INT; + +--connection con2 +SET SQL_MODE= ''; +SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR dml'; +send ALTER TABLE t1 ADD PRIMARY KEY(b); + +--connection default +SET DEBUG_SYNC = 'now WAIT_FOR scanned'; +UPDATE t1 SET b = 1; +SET DEBUG_SYNC = 'now SIGNAL dml'; +--connection con2 +reap; +--connection default +SELECT * FROM t1; + SET DEBUG_SYNC='RESET'; --disconnect con2 DROP TABLE t1; 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( - 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); From c1eaa385ffb44bdf6264d2cc4b4cc0e10284c88a Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 3 Feb 2020 18:20:24 +0100 Subject: [PATCH 16/16] MDEV-21616: Server crash when using "SET STATEMENT max_statement_time=0 FOR desc xxx" lead to collapse Main select should be pushed first. --- mysql-test/main/parser.result | 10 ++++++++++ mysql-test/main/parser.test | 10 ++++++++++ sql/sql_yacc.yy | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index b39f496e3db..868e3458368 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1797,4 +1797,14 @@ select * from t2; ERROR HY000: Table 't2' was not locked with LOCK TABLES SET STATEMENT max_statement_time=900 FOR unlock tables; drop table t1, t2; +# +# MDEV-21616: Server crash when using +# "SET STATEMENT max_statement_time=0 FOR desc xxx" lead to collapse +# +create table t1 (a int); +SET STATEMENT max_statement_time=0 FOR desc t1; +Field Type Null Key Default Extra +a int(11) YES NULL +drop table t1; +SET STATEMENT max_statement_time=0 FOR do 1; # End of 10.4 tests diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index c6e9f13cdaf..54048d0de1d 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1565,4 +1565,14 @@ select * from t2; SET STATEMENT max_statement_time=900 FOR unlock tables; drop table t1, t2; +--echo # +--echo # MDEV-21616: Server crash when using +--echo # "SET STATEMENT max_statement_time=0 FOR desc xxx" lead to collapse +--echo # + +create table t1 (a int); +SET STATEMENT max_statement_time=0 FOR desc t1; +drop table t1; +SET STATEMENT max_statement_time=0 FOR do 1; + --echo # End of 10.4 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 476196f38ea..ed04d2a0584 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -13253,11 +13253,14 @@ do: { LEX *lex=Lex; lex->sql_command = SQLCOM_DO; + if (lex->main_select_push()) + MYSQL_YYABORT; mysql_init_select(lex); } expr_list { Lex->insert_list= $3; + Lex->pop_select(); //main select } ; @@ -14552,6 +14555,8 @@ describe: describe_command table_ident { LEX *lex= Lex; + if (lex->main_select_push()) + MYSQL_YYABORT; mysql_init_select(lex); lex->current_select->parsing_place= SELECT_LIST; lex->sql_command= SQLCOM_SHOW_FIELDS; @@ -14563,6 +14568,7 @@ describe: opt_describe_column { Select->parsing_place= NO_MATTER; + Lex->pop_select(); //main select } | describe_command opt_extended_describe { Lex->describe|= DESCRIBE_NORMAL; }