Page 1 of 1

error on update of multiple records

PostPosted: Tue Nov 03, 2009 11:39 am
by ststoddard
I am trying to do updates of multiple records, first and edit and then a remove operation (yes I have permissions set correctly). Normally this works (most tables). This time, however, I got the following error:

Fatal error: Uncaught exception 'Exception' with message 'Table 'dataface__mtimes' already exists' in /var/www/private/xataface-1.2.2/Dataface/IO.php:2365 Stack trace: #0 /var/www/private/xataface-1.2.2/Dataface/IO.php(2372): Dataface_IO::createModificationTimesTable() #1 /var/www/private/xataface-1.2.2/Dataface/IO.php(686): Dataface_IO::touchTable('Participants') #2 /var/www/private/xataface-1.2.2/dataface-public-api.php(404): Dataface_IO->write(Object(Dataface_Record), Array, NULL, false) #3 /var/www/private/xataface-1.2.2/Dataface/Record.php(2645): df_save_record(Object(Dataface_Record), Array, 'es', false) #4 /var/www/private/xataface-1.2.2/actions/copy_replace.php(295): Dataface_Record->save() #5 [internal function]: dataface_actions_copy_replace->process(Array) #6 /var/www/private/xataface-1.2.2/lib/HTML/QuickForm.php(1626): call_user_func(Array, Array) #7 /var/www/private/xataface-1.2.2/actions/copy_replace.php(114): HTML_QuickForm->process(Array, true) #8 /var/www/private/xataface-1.2.2/Dataface/Application.php(11 in /var/www/private/xataface-1.2.2/Dataface/IO.php on line 2365


This probably has something to do with my configuration, but I can't tell from the error where I would look for a solution. Any ideas?

Thanks.

PostPosted: Tue Nov 03, 2009 11:45 am
by ststoddard
Just a quick update. The update operation (on 4 records) worked on the first record (deleted it) but not the subsequent 3.

PostPosted: Tue Nov 03, 2009 5:59 pm
by shannah
On line 2372 of Dataface/IO.php, please make the following modification:
Change the touchTable() function to look like:
Code: Select all
static function touchTable($table){
      $sql = "replace into dataface__mtimes (`name`,`mtime`) values ('".addslashes($table)."','".addslashes(time())."')";
      $res = mysql_query($sql, df_db());
      if ( !$res ){
         try {
            self::createModificationTimesTable();
         } catch ( $e ){
         
         }
         $res = mysql_query($sql, df_db());
         if ( !$res ) throw new Exception(mysql_error(df_db()));
      }
   }
   


This should report the real error.

PostPosted: Thu Nov 05, 2009 12:54 pm
by ststoddard
This is what worked:
Code: Select all
static function touchTable($table){
      $sql = "replace into dataface__mtimes (`name`,`mtime`) values('".addslashes($table)."','".addslashes(time())."')";
      $res = mysql_query($sql, df_db());
      if ( !$res ){
         try {
            self::createModificationTimesTable();
         } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
         
         }
      $res = mysql_query($sql, df_db());
      if ( !$res ) throw new Exception(mysql_error(df_db()));
      }
   }


And it confirmed the issue was with my configuration.

This use of the database by xataface, i.e. creating tables and views, is new... Is this going to cause issues where I have 3 peer to peer replication servers?

PostPosted: Thu Nov 05, 2009 1:16 pm
by shannah
What about your configuration gave it problems?

PostPosted: Thu Nov 12, 2009 3:23 pm
by ststoddard
I was in the process of setting up a new mirror of my db and needed a temporary way to prevent data entry on one, so I removed insert privileges for the dataface user. Previously dataface didn't write to the database so much, now it does (I think?). That killed the update.