# HG changeset patch # User HIROSE Yuuji # Date 1587597249 -32400 # Node ID b1ddb2559d7778a400dedd5cf4735d5f15105e55 # Parent 5c9b7add02e9ee36cddbf505eed9b0ecf562f891 TEST: Use intermediate file instead of query-pipe to shorten db-lock diff -r 5c9b7add02e9 -r b1ddb2559d77 s4-blog.sh --- a/s4-blog.sh Wed Apr 22 12:23:33 2020 +0900 +++ b/s4-blog.sh Thu Apr 23 08:14:09 2020 +0900 @@ -270,7 +270,10 @@ [ -s $quizmodefile ] && cond_qz=`cat $quizmodefile` # *** DO NOT USE query(), use "sq $db" instead here *** # because the next block in pipe line uses query() repeatedly. - sq $db< $midfile WITH a_s AS ( SELECT id, max(CASE key WHEN 'ctime' THEN val END) TIME, @@ -336,9 +339,11 @@ a_s s ON a.id=s.id; EOF + cat $midfile | while IFS='|' read id edit notify uid author uname icon aid \ tm reki new hte fa imgids do + mf2=$tmpd/midfile2 cachefile="$td/$id.row.html" stampfile="$td/$id.row.stamp" editlink="${edit:+編集 }" @@ -408,7 +413,8 @@ # !!NOTE!! Create row stamp ONLY WHEN imgcache is active else query "SELECT hex(bin) FROM article_m WHERE rowid=$mrid;" \ - | unhexize \ + > $mf2 # Stop query here 2020-04-23 + cat $mf2| unhexize \ | convert -define ${fmt}:size=100x100 -resize 100x100'>' \ - ${fmt}:- \ | tee "$outfile" \ @@ -694,6 +700,7 @@ isgrpowner "$user" "$owner" && isgrpadmin=true || isgrpadmin=false i=0 + midfile=$tmpd/midfile bd=$tmpd/archive.$$ mkdir $bd case "$mode" in @@ -748,12 +755,12 @@ AND s.key='text'; EOF fi - query <<-EOF | + query <<-EOF > $midfile # Using tempfile for quick db-unlock SELECT a.rowid, a.id artid, a.author, hex(s.val) FROM article a JOIN article_s s ON a.id=s.id WHERE blogid=(SELECT id FROM blog WHERE rowid=$rid); EOF - while IFS='|' read rowid artid author text; do + cat $midfile | while IFS='|' read rowid artid author text; do isfilereadable $user article_s $rowid || continue dir=`printf $bd/%d/%06d "$rid" "$rowid"` mkdir -p $dir