--- loncom/interface/lonmysql.pm	2007/03/12 17:10:02	1.36
+++ loncom/interface/lonmysql.pm	2009/02/01 22:03:42	1.38
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # MySQL utility functions
 #
-# $Id: lonmysql.pm,v 1.36 2007/03/12 17:10:02 albertel Exp $
+# $Id: lonmysql.pm,v 1.38 2009/02/01 22:03:42 lueken Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -751,7 +751,6 @@ sub build_table_creation_request {
         $table_id = &get_new_table_id();
     }
     my $tablename = &translate_id($table_id);
-    &Apache::lonnet::logthis(" hmm $tablename, $table_id, ". $table_des->{'id'});
     my $request = "CREATE TABLE IF NOT EXISTS ".$tablename." ";
     foreach my $coldata (@{$table_des->{'columns'}}) {
         my $column = $coldata->{'name'};
@@ -1096,16 +1095,29 @@ Returns undef on error.
 =cut
 
 ###########################################
+
+########## Show-Tables Cache
+my $have_read_tables = 0;
+my $dbh_sth;
+##########
+
 sub tables_in_db {
     return undef if (!defined(&connect_to_db()));
-    my $sth=$dbh->prepare('SHOW TABLES');
-    $sth->execute();
-    $sth->execute();
-    my $aref = $sth->fetchall_arrayref;
-    if ($sth->err()) {
+    
+    ########## Show-Tables Cache
+    if(!$have_read_tables) { 
+     $dbh_sth=$dbh->prepare('SHOW TABLES');
+     $have_read_tables = 1;
+    }   
+    $dbh_sth->execute();
+    #$dbh_sth->execute(); # Removed strange execute - from release 119
+    ##########    
+    
+    my $aref = $dbh_sth->fetchall_arrayref;
+    if ($dbh_sth->err()) {
         $errorstring = 
             "$dbh ATTEMPTED:\n".'fetchall_arrayref after SHOW TABLES'.
-            "\nRESULTING ERROR:\n".$sth->errstr;
+            "\nRESULTING ERROR:\n".$dbh_sth->errstr;
         return undef;
     }
     my @table_list;