#!/bin/bash 

function tx1() {
    while :
    do
        psql testdb <<EOF
            BEGIN;
            UPDATE /* onlyUPDATE      */ t SET col2 = 'A' WHERE col1 = 1;
            COMMIT;
EOF
    done
}

function tx2() {
    while :
    do
        psql testdb <<EOF
            BEGIN;
            SELECT * FROM t WHERE col1 = 1 FOR UPDATE;
            UPDATE /* SELECTandUPDATE */ t SET col2 = 'A' WHERE col1 = 1;
            COMMIT;
EOF
    done
}

tx1 > /dev/null &
tx1 > /dev/null &
tx2 > /dev/null &
wait
