# HG changeset patch # User HIROSE Yuuji # Date 1588154597 -32400 # Node ID b73ef3fd0e19b62235c17d9714a0b15fd3faa6d0 # Parent ae37fefb7a2b58118acdc063bd5d12f585fd5e9d Table update done in 1 .read outside of shell loop. diff -r ae37fefb7a2b -r b73ef3fd0e19 s4-funcs.sh --- a/s4-funcs.sh Wed Apr 29 18:28:47 2020 +0900 +++ b/s4-funcs.sh Wed Apr 29 19:03:17 2020 +0900 @@ -3550,6 +3550,7 @@ ## Insertion to master table, done fi + transaction=$tmpd/sqlfile.sql; touch $transaction for kt in s m; do tb2=${tbl}_$kt for col in `gettbl_${kt}_cols $tbl`; do @@ -3606,15 +3607,25 @@ if [ x"$bin" = x"NULL" ]; then ## err repl:normal sql=`echo $sql` - query "$sql -delete from $tb2 where type='string' and val='';" - ## err repl:normal done + if [ -n "$transaction" ]; then + cat<<-EOF >> $transaction + $sql + DELETE FROM $tb2 WHERE type='string' AND val=''; + EOF + else + query "$sql +delete from $tb2 where type='string' and val='';" + ## err repl:normal done + fi else + # Binary update line is TOO LONG to pipelining sqlfile="$tmpd/sqlf.$$" - echo "$sql" > $sqlfile - ## err repl:sqlfile=`ls -lF $sqlfile` - query ".read $sqlfile" - ## err repl:done + if [ -n "$transaction" ]; then + echo "$sql" >> $transaction + else + echo "$sql" > $sqlfile + query ".read $sqlfile" + fi fi # Rest of kt==m: set multiple mode nr=`getparcount $col` @@ -3674,18 +3685,32 @@ sql="replace into $tb2 values($pval, \"$col\", $type, $val, $bin);" if [ x"$bin" = x"NULL" ]; then ## err Normal-query: `echo $sql` - query "$sql" + if [ -n "$transaction" ]; then + echo "$sql" >> $transaction + else + query "$sql" + fi else sqlfile="$tmpd/query.$$" - echo "$sql" > $sqlfile ## err sqlfile=`ls -lF $sqlfile` - query ".read $sqlfile" + if [ -n "$transaction" ]; then + echo "$sql" >> $transaction + else + echo "$sql" > $sqlfile + query ".read $sqlfile" + fi fi ## err p2t done done done done - return 0 + [ -n "$transaction" -a -s "$transaction" ] && cat <<-EOF | query + -- We cannot use transaction here, because groupupdate may use it. + SAVEPOINT pa2table_insert; + .read $transaction + RELEASE SAVEPOINT pa2table_insert; + EOF + return $? ##err donee ) genform() {