# HG changeset patch # User HIROSE Yuuji # Date 1588500419 -32400 # Node ID b7aeab02d2425014dc5a48b78ccf6a8348cbe469 # Parent 1c36cb1a1a0eedfac2f9b3e39e1b8d44f150219c Check the SQL output size in case of DB timeout diff -r 1c36cb1a1a0e -r b7aeab02d242 s4-blog.sh --- a/s4-blog.sh Sun May 03 16:50:46 2020 +0900 +++ b/s4-blog.sh Sun May 03 19:06:59 2020 +0900 @@ -208,8 +208,9 @@ $isgrpadmin && href5=" 読刻" quizmodefile=$tmpd/quiz; rm -f "$quizmodefile" # XXX: Global state + midfile=$tmpd/midfile - query<<-EOF | + query<<-EOF > $midfile SELECT coalesce((SELECT "yes" FROM blog -- GrpAdmin CAN EDIT heading since 2019-08-15 WHERE '$isgrpadmin' = 'true' @@ -226,11 +227,8 @@ END FROM $ts WHERE id='$id' GROUP BY id; EOF - { IFS='|' read edit ctime hexhead blogtype - if [ -z "$ctime" ]; then # Maybe database timeout - echo "時間をおいて繋いでください(Please visit later)." | html p - return - fi + if test -s $midfile && IFS='|' read edit ctime hexhead blogtype < $midfile + then cat<<-EOF ${edit:+$href }$ctime $blogtype $href2$href3 $href4 $href5 @@ -245,15 +243,17 @@ echo '' if [ x"$blogtype" = x"クイズ" -o x"$blogtype" = x"XXXX集計" ]; then if $isgroup; then - if ! isgrpowner "$user" "$blogowner"; then - qgrp=`sqlquote "$blogowner"` - cat<<-EOF > $quizmodefile + # Failsafe to query timeout + qgrp=`sqlquote "$blogowner"` + cat<<-EOF > $quizmodefile AND (author IN (SELECT user FROM grp_adm WHERE gname=$qgrp) OR author='$user') EOF + if isgrpowner "$user" "$blogowner"; then + : > $quizmodefile fi - else # if user's blog + else # if user-blog if [ x"$user" != x"$blogowner" ]; then cat<<-EOF > $quizmodefile AND author IN ('$blogowner', '$user') @@ -261,7 +261,10 @@ fi fi fi - } + else # Cannot read SQL output + echo "時間をおいて繋いでください(Please visit later)." | html p + return + fi lkhome=" $midfile WITH a_s AS ( SELECT id,