cvsserver: avoid warning about active db handles
Turns out that DBD::SQLite does not favour preparing statements which are never executed. So, turn all 4 statements, which were prepared _always_, into methods, like the other 12 prepared statements. Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Johannes Schindelin committed
Jul 25, 2006 at 13:57 UTC
96256bba949f43548a0be0af877680eb62b156f6
1 file changed
+56
-14
git-cvsserver.perl
+56
-14
@@ -2129,12 +2129,6 @@ sub update
2129
# first lets get the commit list
2130
$ENV{GIT_DIR} = $self->{git_path};
2131
2132
- # prepare database queries
2133
- my $db_insert_rev = $self->{dbh}->prepare_cached("INSERT INTO revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
2134
- my $db_insert_mergelog = $self->{dbh}->prepare_cached("INSERT INTO commitmsgs (key, value) VALUES (?,?)",{},1);
2135
- my $db_delete_head = $self->{dbh}->prepare_cached("DELETE FROM head",{},1);
2136
- my $db_insert_head = $self->{dbh}->prepare_cached("INSERT INTO head (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
2137
-
2132
my $commitinfo = `git-cat-file commit $self->{module} 2>&1`;
2133
unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ )
2134
{
@@ -2323,7 +2317,7 @@ sub update
2317
author => $commit->{author},
2318
mode => $git_perms,
2319
};
2326
- $db_insert_rev->execute($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2320
+ $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2321
}
2322
elsif ( $3 eq "M" )
2323
{
@@ -2337,7 +2331,7 @@ sub update
2331
author => $commit->{author},
2332
mode => $git_perms,
2333
};
2340
- $db_insert_rev->execute($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2334
+ $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2335
}
2336
elsif ( $3 eq "A" )
2337
{
@@ -2351,7 +2345,7 @@ sub update
2345
author => $commit->{author},
2346
mode => $git_perms,
2347
};
2354
- $db_insert_rev->execute($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2348
+ $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2349
}
2350
else
2351
{
@@ -2408,7 +2402,7 @@ sub update
2402
};
2403
2404
2411
- $db_insert_rev->execute($git_filename, $newrevision, $git_hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2405
+ $self->insert_rev($git_filename, $newrevision, $git_hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
2406
}
2407
}
2408
close FILELIST;
@@ -2424,7 +2418,7 @@ sub update
2418
$head->{$file}{modified} = $commit->{date};
2419
$head->{$file}{author} = $commit->{author};
2420
2427
- $db_insert_rev->execute($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $commit->{date}, $commit->{author}, $head->{$file}{mode});
2421
+ $self->insert_rev($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $commit->{date}, $commit->{author}, $head->{$file}{mode});
2422
}
2423
}
2424
# END : "Detect deleted files"
@@ -2433,7 +2427,7 @@ sub update
2427
2428
if (exists $commit->{mergemsg})
2429
{
2436
- $db_insert_mergelog->execute($commit->{hash}, $commit->{mergemsg});
2430
+ $self->insert_mergelog($commit->{hash}, $commit->{mergemsg});
2431
}
2432
2433
$lastpicked = $commit->{hash};
@@ -2441,10 +2435,10 @@ sub update
2435
$self->_set_prop("last_commit", $commit->{hash});
2436
}
2437
2444
- $db_delete_head->execute();
2438
+ $self->delete_head();
2439
foreach my $file ( keys %$head )
2440
{
2447
- $db_insert_head->execute(
2441
+ $self->insert_head(
2442
$file,
2443
$head->{$file}{revision},
2444
$head->{$file}{filehash},
@@ -2462,6 +2456,54 @@ sub update
2456
$self->{dbh}->commit() or die "Failed to commit changes to SQLite";
2457
}
2458
2459
+sub insert_rev
2460
+{
2461
+ my $self = shift;
2462
+ my $name = shift;
2463
+ my $revision = shift;
2464
+ my $filehash = shift;
2465
+ my $commithash = shift;
2466
+ my $modified = shift;
2467
+ my $author = shift;
2468
+ my $mode = shift;
2469
+
2470
+ my $insert_rev = $self->{dbh}->prepare_cached("INSERT INTO revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
2471
+ $insert_rev->execute($name, $revision, $filehash, $commithash, $modified, $author, $mode);
2472
+}
2473
+
2474
+sub insert_mergelog
2475
+{
2476
+ my $self = shift;
2477
+ my $key = shift;
2478
+ my $value = shift;
2479
+
2480
+ my $insert_mergelog = $self->{dbh}->prepare_cached("INSERT INTO commitmsgs (key, value) VALUES (?,?)",{},1);
2481
+ $insert_mergelog->execute($key, $value);
2482
+}
2483
+
2484
+sub delete_head
2485
+{
2486
+ my $self = shift;
2487
+
2488
+ my $delete_head = $self->{dbh}->prepare_cached("DELETE FROM head",{},1);
2489
+ $delete_head->execute();
2490
+}
2491
+
2492
+sub insert_head
2493
+{
2494
+ my $self = shift;
2495
+ my $name = shift;
2496
+ my $revision = shift;
2497
+ my $filehash = shift;
2498
+ my $commithash = shift;
2499
+ my $modified = shift;
2500
+ my $author = shift;
2501
+ my $mode = shift;
2502
+
2503
+ my $insert_head = $self->{dbh}->prepare_cached("INSERT INTO head (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
2504
+ $insert_head->execute($name, $revision, $filehash, $commithash, $modified, $author, $mode);
2505
+}
2506
+
2507
sub _headrev
2508
{
2509
my $self = shift;