diff options
author | Erich Eckner <git@eckner.net> | 2018-09-04 10:19:43 +0200 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2018-09-04 10:19:43 +0200 |
commit | 114200a9c3b183cae9c9ea3bb2aacf8ae6a3cb3c (patch) | |
tree | cf38c5435b46dcbe0d6cde1978076a0ae4b1c6e1 /lib | |
parent | a39e5b93ef6eae11c76d34e800eda64ce9e36bca (diff) | |
download | builder-114200a9c3b183cae9c9ea3bb2aacf8ae6a3cb3c.tar.xz |
lib/mysql-functions: mysql_run_query() if a query containing "LOAD DATA LOCAL INFILE ..." failed, save those files for furhter inspection
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/mysql-functions | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/mysql-functions b/lib/mysql-functions index e0715c3..d38169b 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -22,9 +22,6 @@ base64_encode_each() { done } -# TODO: if a query containing 'LOAD DATA LOCAL INFILE ...' failed, save -# those files for furhter inspection! - # mysql_run_query # wrapper function to query mysql mysql_run_query() { @@ -34,6 +31,8 @@ mysql_run_query() { local file_name_extra local file + local files + loval number file_name_extra='' if [ "x$1" = 'xunimportant' ]; then @@ -62,6 +61,18 @@ mysql_run_query() { # a present query_file means there was an error if [ -f "${query_stdin}" ]; then >&2 printf 'I could not complete a mysql query!\n' + files="${query_stdin} ${query_stdout} ${query_stderr}$( + sed -n ' + s/^.*INFILE "\(\S\+\)".*$/\1/ + T + p + ' "${query_stdin}" | \ + cat -n | \ + while read -r number file; do + cp "${file}" "${query_stdin%.stdin}.infile.${number}" + printf ' %s' "${query_stdin%.stdin}.infile.${number}" + done + )" if ${i_am_the_master}; then if [ ! -s "${work_dir}/build-master-sanity" ] && \ [ -z "${file_name_extra}" ]; then @@ -69,10 +80,7 @@ mysql_run_query() { "${query_stdin##*/}" \ | irc_say fi - for file in \ - "${query_stdin}" \ - "${query_stdout}" \ - "${query_stderr}"; do + for file in ${files}; do cp "${file}" "${webserver_directory}/mysql-queries/${file##*/}.txt" chmod go+r "${webserver_directory}/mysql-queries/${file##*/}.txt" done @@ -81,10 +89,8 @@ mysql_run_query() { echo 'A mysql query failed.' > \ "${work_dir}/build-master-sanity" else - rm -f \ - "${query_stdin}" \ - "${query_stdout}" \ - "${query_stderr}" + # shellcheck disable=SC2086 + rm -f ${files} fi return 2 fi |