diff --git a/cgi-bin/addnotes.pl b/cgi-bin/addnotes.pl index bdc4b04..6ea4e5d 100755 --- a/cgi-bin/addnotes.pl +++ b/cgi-bin/addnotes.pl @@ -96,6 +96,8 @@ end where name = $1 and status = 'approved' + -- makes request idempotent + and sys_notes is distinct from nullif($2,'') }; diff --git a/cgi-bin/upgrade.pl b/cgi-bin/upgrade.pl index 7f80207..540b415 100755 --- a/cgi-bin/upgrade.pl +++ b/cgi-bin/upgrade.pl @@ -132,24 +132,28 @@ $os_version ||= $old_os; $compiler_version ||= $old_comp; - my $new_personality = q{ + # makes request idempotent + if ($os_version ne $old_os || $compiler_version ne $old_comp) + { + my $new_personality = q{ - insert into personality (name, os_version, compiler_version) - values (?,?,?) + insert into personality (name, os_version, compiler_version) + values (?,?,?) - }; + }; - $sth = $db->prepare($new_personality); - $rv = $sth->execute($animal, $os_version, $compiler_version); + $sth = $db->prepare($new_personality); + $rv = $sth->execute($animal, $os_version, $compiler_version); - $sth->finish; + $sth->finish; - unless ($rv) - { - print "Status: 470 new data insert\nContent-Type: text/plain\n\n"; - print "error: $db->errstr\n"; - $db->disconnect; - exit; + unless ($rv) + { + print "Status: 470 new data insert\nContent-Type: text/plain\n\n"; + print "error: $db->errstr\n"; + $db->disconnect; + exit; + } } }