@@ -191,7 +191,9 @@ END
if (!$already) {
$dbh_tests->do(<<END, {}, $fl,$rev);
- INSERT INTO flights_harness_touched VALUES (?,?)
+ INSERT INTO flights_harness_touched
+ (flight, harness)
+ VALUES (?,?)
END
}
}
@@ -309,7 +309,9 @@ sub store_runvar ($$) {
WHERE flight=? AND job=? AND name=? AND synth='t'
END
$dbh_tests->do(<<END,{}, $flight,$job, $param,$value);
- INSERT INTO runvars VALUES (?,?,?,?,'t')
+ INSERT INTO runvars
+ (flight, job, name, val, synth)
+ VALUES (?,?,?,?,'t')
END
});
$r{$param}= get_runvar($param, "$flight.$job");
@@ -368,7 +370,9 @@ END
WHERE flight=? AND job=? AND name=? AND synth='t'
END
$dbh_tests->do(<<END, undef, $flight, $job, $param, $value+1);
- INSERT INTO runvars VALUES (?,?,?,?,'t')
+ INSERT INTO runvars
+ (flight, job, name, val, synth)
+ VALUES (?,?,?,?,'t')
END
});
logm("runvar increment: $param=$value");
@@ -1775,7 +1779,9 @@ END
logm("select_ether $prefix:... $ether (first in flight)");
}
$dbh_tests->do(<<END, {}, $flight,$job,$vn,$ether);
- INSERT INTO runvars VALUES (?,?,?,?,'t')
+ INSERT INTO runvars
+ (flight, job, name, val, synth)
+ VALUES (?,?,?,?,'t')
END
my $chkrow= $dbh_tests->selectrow_hashref(<<END,{}, $flight);
SELECT val, count(*) FROM runvars WHERE flight=?
@@ -196,11 +196,11 @@ sub copy_jobs ($$) {
my ($srcflight, $jobs) = @_;
prep_rm_jobs();
my @job_copy_qs = map { $dbh_tests->prepare($_) }
- ("INSERT INTO jobs".
+ ("INSERT INTO jobs (flight, job, recipe, status)".
" SELECT ?, job, recipe, 'queued'".
" FROM jobs".
" WHERE flight = ? AND job = ?",
- "INSERT INTO runvars".
+ "INSERT INTO runvars (flight, job, name, val, synth)".
" SELECT ?, job, name, val, 'f'".
" FROM runvars".
" WHERE flight = ? AND job = ? AND NOT synth");
@@ -246,7 +246,8 @@ sub change__copy_jobs {
our $runvar_rm_q = $dbh_tests->prepare
("DELETE FROM runvars WHERE flight = ? AND job = ? AND name = ?");
our $runvar_insert_q = $dbh_tests->prepare
- ("INSERT INTO runvars VALUES (?, ?, ?, ?, 'f')");
+ ("INSERT INTO runvars (flight, job, name, val, synth)".
+ " VALUES (?, ?, ?, ?, 'f')");
sub runvar_set ($$$;$) {
my ($job, $name, $val, $xwhat) = @_;
@@ -1255,7 +1255,8 @@ END
" from $copyflight)\n";
$dbh_tests->do(<<END, {}, $popflight,$popjob,$recipe);
- INSERT INTO jobs VALUES (?, ?, ?, 'queued')
+ INSERT INTO jobs (flight, job, recipe, status)
+ VALUES (?, ?, ?, 'queued')
END
$dbh_tests->do(<<END, {}, $popflight,$popjob);
INSERT INTO runvars (
@@ -180,7 +180,7 @@ sub alloc_1rescand ($$) {
if ($allocate && $restype eq 'share-flight' && $shareix == $tid) {
$dbh_tests->do(<<END,{},
- INSERT INTO resources
+ INSERT INTO resources (restype, resname, shareix, owntaskid)
(SELECT ? AS restype,
? AS resname,
? AS shareix,
@@ -178,6 +178,7 @@ sub cmd_create_like () {
foreach my $dst (l($dsts)) {
$dbh_tests->do(<<END,{}, $dst,$src);
INSERT INTO resources
+ (restype, resname, shareix, owntaskid)
SELECT restype,
? AS resname,
0 AS shareix,
@@ -282,7 +282,9 @@ proc spawn-step-begin {flight job ts stepnovar} {
set stepno 1
}
db-execute "
- INSERT INTO steps
+ INSERT INTO steps (flight, job, stepno,
+ step, status,
+ testid)
VALUES ([pg_quote $flight], [pg_quote $job], $stepno,
[pg_quote $ts], 'running',
'STARTING')
This makes the code more robust against schema updates. Specifically, if any columns were to be deleted, these runes would break. (Also if any column was inserted other than after the existing columns, although this is not something Postgres can currently do AIUI.) Affected tables are: flights_harness_touched jobs resources runvars steps Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com> --- Osstest/JobDB/Executive.pm | 4 +++- Osstest/TestSupport.pm | 12 +++++++++--- cs-adjust-flight | 7 ++++--- cs-bisection-step | 3 ++- mg-allocate | 2 +- mg-hosts | 1 + tcl/JobDB-Executive.tcl | 4 +++- 7 files changed, 23 insertions(+), 10 deletions(-)