git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cvsserver: avoid warning about active db handles
@ 2006-07-25 11:57 Johannes Schindelin
  2006-07-25 12:07 ` Martin Langhoff (CatalystIT)
  0 siblings, 1 reply; 27+ messages in thread
From: Johannes Schindelin @ 2006-07-25 11:57 UTC (permalink / raw)
  To: git, Martin Langhoff (CatalystIT), junkio


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>
---
	Now, the only warning left is the gzip one...

 git-cvsserver.perl |   70 ++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 56 insertions(+), 14 deletions(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index 981b6ba..b2837ad 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -2131,12 +2131,6 @@ sub update
     # first lets get the commit list
     $ENV{GIT_DIR} = $self->{git_path};
 
-    # prepare database queries
-    my $db_insert_rev = $self->{dbh}->prepare_cached("INSERT INTO revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
-    my $db_insert_mergelog = $self->{dbh}->prepare_cached("INSERT INTO commitmsgs (key, value) VALUES (?,?)",{},1);
-    my $db_delete_head = $self->{dbh}->prepare_cached("DELETE FROM head",{},1);
-    my $db_insert_head = $self->{dbh}->prepare_cached("INSERT INTO head (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
-
     my $commitinfo = `git-cat-file commit $self->{module} 2>&1`;
     unless ( $commitinfo =~ /tree\s+[a-zA-Z0-9]{40}/ )
     {
@@ -2325,7 +2319,7 @@ sub update
                         author => $commit->{author},
                         mode => $git_perms,
                     };
-                    $db_insert_rev->execute($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
                 }
                 elsif ( $3 eq "M" )
                 {
@@ -2339,7 +2333,7 @@ sub update
                         author => $commit->{author},
                         mode => $git_perms,
                     };
-                    $db_insert_rev->execute($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
                 }
                 elsif ( $3 eq "A" )
                 {
@@ -2353,7 +2347,7 @@ sub update
                         author => $commit->{author},
                         mode => $git_perms,
                     };
-                    $db_insert_rev->execute($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($4, $head->{$4}{revision}, $2, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
                 }
                 else
                 {
@@ -2410,7 +2404,7 @@ sub update
                     };
 
 
-                    $db_insert_rev->execute($git_filename, $newrevision, $git_hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
+                    $self->insert_rev($git_filename, $newrevision, $git_hash, $commit->{hash}, $commit->{date}, $commit->{author}, $git_perms);
                 }
             }
             close FILELIST;
@@ -2426,7 +2420,7 @@ sub update
                     $head->{$file}{modified} = $commit->{date};
                     $head->{$file}{author} = $commit->{author};
 
-                    $db_insert_rev->execute($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $commit->{date}, $commit->{author}, $head->{$file}{mode});
+                    $self->insert_rev($file, $head->{$file}{revision}, $head->{$file}{filehash}, $commit->{hash}, $commit->{date}, $commit->{author}, $head->{$file}{mode});
                 }
             }
             # END : "Detect deleted files"
@@ -2435,7 +2429,7 @@ sub update
 
         if (exists $commit->{mergemsg})
         {
-            $db_insert_mergelog->execute($commit->{hash}, $commit->{mergemsg});
+            $self->insert_mergelog($commit->{hash}, $commit->{mergemsg});
         }
 
         $lastpicked = $commit->{hash};
@@ -2443,10 +2437,10 @@ sub update
         $self->_set_prop("last_commit", $commit->{hash});
     }
 
-    $db_delete_head->execute();
+    $self->delete_head();
     foreach my $file ( keys %$head )
     {
-        $db_insert_head->execute(
+        $self->insert_head(
             $file,
             $head->{$file}{revision},
             $head->{$file}{filehash},
@@ -2464,6 +2458,54 @@ sub update
     $self->{dbh}->commit() or die "Failed to commit changes to SQLite";
 }
 
+sub insert_rev
+{
+    my $self = shift;
+    my $name = shift;
+    my $revision = shift;
+    my $filehash = shift;
+    my $commithash = shift;
+    my $modified = shift;
+    my $author = shift;
+    my $mode = shift;
+
+    my $insert_rev = $self->{dbh}->prepare_cached("INSERT INTO revision (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
+    $insert_rev->execute($name, $revision, $filehash, $commithash, $modified, $author, $mode);
+}
+
+sub insert_mergelog
+{
+    my $self = shift;
+    my $key = shift;
+    my $value = shift;
+
+    my $insert_mergelog = $self->{dbh}->prepare_cached("INSERT INTO commitmsgs (key, value) VALUES (?,?)",{},1);
+    $insert_mergelog->execute($key, $value);
+}
+
+sub delete_head
+{
+    my $self = shift;
+
+    my $delete_head = $self->{dbh}->prepare_cached("DELETE FROM head",{},1);
+    $delete_head->execute();
+}
+
+sub insert_head
+{
+    my $self = shift;
+    my $name = shift;
+    my $revision = shift;
+    my $filehash = shift;
+    my $commithash = shift;
+    my $modified = shift;
+    my $author = shift;
+    my $mode = shift;
+
+    my $insert_head = $self->{dbh}->prepare_cached("INSERT INTO head (name, revision, filehash, commithash, modified, author, mode) VALUES (?,?,?,?,?,?,?)",{},1);
+    $insert_head->execute($name, $revision, $filehash, $commithash, $modified, $author, $mode);
+}
+
 sub _headrev
 {
     my $self = shift;
-- 
1.4.2.rc1.gd3c5-dirty

^ permalink raw reply related	[flat|nested] 27+ messages in thread
* Re: Perl gurus: why do we need Scalar::Util?
@ 2006-07-10 13:00 Petr Baudis
  2006-07-11  0:53 ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm Petr Baudis
  0 siblings, 1 reply; 27+ messages in thread
From: Petr Baudis @ 2006-07-10 13:00 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git

  Hi,

Dear diary, on Mon, Jul 10, 2006 at 01:44:39PM CEST, I got a letter
where Johannes Schindelin <Johannes.Schindelin@gmx.de> said that...
> please do not let my die dumb: what is this "blessed" thing all about? And 
> why do we need it in the private-Error.pm??

  I'm working on it. I'll try to get a patch together by the evening.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
Snow falling on Perl. White noise covering line noise.
Hides all the bugs too. -- J. Putnam

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2006-07-27 14:32 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-25 11:57 [PATCH] cvsserver: avoid warning about active db handles Johannes Schindelin
2006-07-25 12:07 ` Martin Langhoff (CatalystIT)
2006-07-25 14:53   ` Johannes Schindelin
2006-07-25 15:52     ` Petr Baudis
2006-07-25 16:10       ` Git.xs problem, was " Johannes Schindelin
2006-07-26  1:03         ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm Petr Baudis
2006-07-26  2:01           ` Johannes Schindelin
2006-07-26  2:03             ` Johannes Schindelin
2006-07-26  2:11               ` Petr Baudis
2006-07-26  2:26                 ` Johannes Schindelin
2006-07-26  2:10             ` Petr Baudis
2006-07-26  2:25               ` Johannes Schindelin
2006-07-26 13:35                 ` Jakub Narebski
2006-07-26 15:17                   ` Johannes Schindelin
2006-07-26 17:59                     ` Luben Tuikov
2006-07-27 12:47                     ` Randal L. Schwartz
2006-07-27 14:00                       ` Johannes Schindelin
2006-07-27 14:22                         ` Randal L. Schwartz
2006-07-27 14:32                           ` Johannes Schindelin
2006-07-26 21:34                 ` Petr Baudis
     [not found]           ` <7vhd15cfaj.fsf@assigned-by-dhcp.cox.net>
2006-07-26  2:15             ` Petr Baudis
  -- strict thread matches above, loose matches on Subject: below --
2006-07-10 13:00 Perl gurus: why do we need Scalar::Util? Petr Baudis
2006-07-11  0:53 ` [PATCH] Eliminate Scalar::Util usage from private-Error.pm Petr Baudis
2006-07-11  1:38   ` Randal L. Schwartz
2006-07-11  1:40     ` Randal L. Schwartz
2006-07-11  1:42       ` Randal L. Schwartz
2006-07-11  1:57   ` Junio C Hamano
2006-07-11  3:38     ` Randal L. Schwartz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).