diff --git a/auxdir/x_ac_databases.m4 b/auxdir/x_ac_databases.m4 index fbbf7e79a045ba80b9164901948b5bd825f77bce..564986849ace3003db75b3a203dd34170b887e03 100644 --- a/auxdir/x_ac_databases.m4 +++ b/auxdir/x_ac_databases.m4 @@ -42,6 +42,14 @@ AC_DEFUN([X_AC_DATABASES], AC_MSG_WARN([*** mysql-$mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version available, we need >= mysql-5.0.0 installed for the mysql interface.]) ac_have_mysql="no" else + + # In mysql 5.7.4 we can't use the 'IGNORE' option when + # altering tables so deal with it then. + if test $mysql_config_minor_version -gt 7 || + (test $mysql_config_minor_version -eq 7 && + test $mysql_config_micro_version -gt 3); then + AC_DEFINE(NO_ALTER_IGNORE_MYSQL, 1, [Define to 1 if we can't use the alter ignore when messing with a database table]) + fi # mysql_config puts -I on the front of the dir. We don't # want that so we remove it. MYSQL_CFLAGS=`$HAVEMYSQLCONFIG --include` @@ -60,7 +68,7 @@ AC_DEFUN([X_AC_DATABASES], CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" if test "$ac_have_mysql" = yes; then - AC_MSG_RESULT([MySQL test program built properly.]) + AC_MSG_RESULT([MySQL $mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version test program built properly.]) AC_SUBST(MYSQL_LIBS) AC_SUBST(MYSQL_CFLAGS) AC_DEFINE(HAVE_MYSQL, 1, [Define to 1 if using MySQL libaries]) diff --git a/config.h.in b/config.h.in index 0e4cb9b8280ada8be2c8e8873e3cb019a4dc0810..edabe6eba4053f8618ccab03a54ef613c149059b 100644 --- a/config.h.in +++ b/config.h.in @@ -504,6 +504,10 @@ /* Define to 1 if you are building a production release. */ #undef NDEBUG +/* Define to 1 if we can't use the alter ignore when messing with a database + table */ +#undef NO_ALTER_IGNORE_MYSQL + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT diff --git a/configure b/configure index 1435f9167ae5362544d15edb9dd2622355f19983..d5340fe5d47b09923e4d691d173471cbece675a3 100755 --- a/configure +++ b/configure @@ -23240,6 +23240,16 @@ $as_echo "$as_me: WARNING: *** mysql_config not found. Evidently no MySQL develo $as_echo "$as_me: WARNING: *** mysql-$mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version available, we need >= mysql-5.0.0 installed for the mysql interface." >&2;} ac_have_mysql="no" else + + # In mysql 5.7.4 we can't use the 'IGNORE' option when + # altering tables so deal with it then. + if test $mysql_config_minor_version -gt 7 || + (test $mysql_config_minor_version -eq 7 && + test $mysql_config_micro_version -gt 3); then + +$as_echo "#define NO_ALTER_IGNORE_MYSQL 1" >>confdefs.h + + fi # mysql_config puts -I on the front of the dir. We don't # want that so we remove it. MYSQL_CFLAGS=`$HAVEMYSQLCONFIG --include` @@ -23273,8 +23283,8 @@ rm -f core conftest.err conftest.$ac_objext \ CFLAGS="$save_CFLAGS" LIBS="$save_LIBS" if test "$ac_have_mysql" = yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: MySQL test program built properly." >&5 -$as_echo "MySQL test program built properly." >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: MySQL $mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version test program built properly." >&5 +$as_echo "MySQL $mysql_config_major_version.$mysql_config_minor_version.$mysql_config_micro_version test program built properly." >&6; } diff --git a/src/database/mysql_common.c b/src/database/mysql_common.c index 965601a0c4d7f9a6d8f0ef34b1a883f914e6fe47..967ac41dca86c52ed6a4aeeb0733227f72901d73 100644 --- a/src/database/mysql_common.c +++ b/src/database/mysql_common.c @@ -264,8 +264,18 @@ static int _mysql_make_table_current(mysql_conn_t *mysql_conn, char *table_name, itr = list_iterator_create(columns); +#ifdef NO_ALTER_IGNORE_MYSQL + /* In MySQL 5.7.4 we lost the ability to run 'alter ignore'. This was + * needed when converting old tables to new schemas. If people convert + * in the future from an older version of Slurm that needed the ignore + * to work they will have to downgrade mysql to <= 5.7.3 to make things + * work correctly or manually edit the database to get things to work. + */ + query = xstrdup_printf("alter table %s", table_name); +#else query = xstrdup_printf("alter ignore table %s", table_name); - correct_query = xstrdup_printf("alter ignore table %s", table_name); +#endif + correct_query = xstrdup(query); START_TIMER; while (fields[i].name) { int found = 0;