]> lifelog.hopto.org Git - LifeLog.git/commitdiff
Started work on bug 35, PG db related.
authorwbudic <redacted>
Thu, 5 Aug 2021 10:05:11 +0000 (20:05 +1000)
committerwbudic <redacted>
Thu, 5 Aug 2021 10:05:11 +0000 (20:05 +1000)
Current Development Check List.md
dbLifeLog/main.cnf
htdocs/cgi-bin/data.cgi
htdocs/cgi-bin/login_ctr.cgi
htdocs/cgi-bin/system/modules/Settings.pm

index e640b1962d6f165ee0e67ab0599c8f9550f55114..524369ae65d5b92bc1b3271689ea75e800f90371 100644 (file)
@@ -6,6 +6,7 @@
 
 ### New Development
 
+* Bug 35. SQL migration, version update, not working for PG based databases.
 * JS - Event, on expense sum in log numbers found at beginning of lines.
 * &#10004; Update to CNF v.2.2, branch to $RELEASE_VER = 2.3, Earth Stage initial.
 * Plugins
@@ -206,6 +207,7 @@ between 2018-08-22 04:13:55 **Moon Stable** production release and this
 
 ### v. 2.2 Encountered/Fixed
 
+* Bug 35, Migration and version updating SQL is wrong for PG database, it doesn't have rowid's.
 * Bug 34, DB fix in config, removes associated RTF documents, for some reason.
 * &#10004; Bug 33 Changing session timeout in config to an lib. background unparsable format cause unrecoverable system error.
   * i.e. Putting +1hr instead of +1h.
index b58940d5e64fdb4387a73aeeff5c02dc25bd35a4..2b3418067324a342caf303167ff3f8b066247ac1 100644 (file)
@@ -13,9 +13,9 @@ This is an Open Source License project -> https://choosealicense.com/licenses/is
 Note Remove -> '!' prefix to tag name, to enable, set,
 and override any previously set from now on, top to end of file approach.
 
-<<DBI_SOURCE<DBI:SQLite:>>>
+<<!DBI_SOURCE<DBI:SQLite:>>>
 # ProgresSQL DB driver. 
-<<!DBI_SOURCE<DBI:Pg:host=localhost;>>>
+<<DBI_SOURCE<DBI:Pg:host=localhost;>>>
 # LOG actual variable size limit, - 1024 default, 128 minimum value. 
 <<DBI_LOG_VAR_SIZE<8024>>>
 
@@ -39,6 +39,10 @@ America/Austin=America/Chicago
 America/Texas=America/Chicago
 >>
 
+<<PLUGINS<
+HelpPlugin->help.pl
+BankingPlugin->banking.pl
+>>
 
 # @See help at bottom of config for all the following.
 
index f29bb87177e2d642ad4723639322063fd0ad5170..a594e67d0ee27366a8a95f48ecc4790048e7dd31 100755 (executable)
@@ -22,7 +22,7 @@ my $dbname    = Settings::dbName();
 my $human     = DateTime::Format::Human::Duration->new();
 my $PRC_WIDTH = Settings::pagePrcWidth();
 my $DEBUG     = Settings::debug();
-my $today     =  Settings::today();
+my $today     = Settings::today();
 my $tbl_rc    = 0;
 my $imgw      = 210;
 my $imgh      = 120;
index 3f48209b5662f1fe59f415050ea1c63a9dced2ee..068cf3b3e17387ccd6c9e136b8f14ab103524a41 100755 (executable)
@@ -103,7 +103,7 @@ try{
             "<hr><font color=red><b>SERVER ERROR</b></font> on ".DateTime->now().
             "<pre>".$pwd."/$0 -> [\n$err]","\n$dbg</pre>",
             $cgi->end_html;
- };
+ }
 exit;
 
 sub processSubmit {
@@ -172,7 +172,6 @@ sub checkAutologinSet {
     #exit;
     # Autologin credential in file next.
     if(@cre &&scalar(@cre)>1){
-
             if($alias && $passw && $alias ne $cre[0]){ # Is this an new alias login attempt? If so, autologin is of the agenda.
                 return;                                # Note, we do assign entered password even passw as autologin is set. Not entering one bypasses this.
             }                                          # If stricter access is required set it to zero in main.cnf, or disable in config.
@@ -191,7 +190,6 @@ sub checkAutologinSet {
             }
             $db -> disconnect();
     }
-
 }
 
 sub checkPreparePGDB {
@@ -236,11 +234,8 @@ sub checkPreparePGDB {
     return 0;
 }
 
-sub checkCreateTables {
-my ($pst, $sql,$rv, $changed) = 0;
-try{    
-    
-    
+sub checkCreateTables {     my ($pst, $sql,$rv, $changed) = 0;
+ try{
     # We live check database for available tables now only once.
     # If brand new database, this sill returns fine an empty array.
     my %curr_tables = ();
@@ -330,18 +325,27 @@ try{
             $db->do('CREATE TABLE life_log_login_ctr_temp_table AS SELECT * FROM LOG;');
             my %notes_ids = ();
             if($hasNotesTbl){
-                $pst =  Settings::selectRecords($db, 'SELECT rowid, DATE FROM LOG WHERE ID_RTF > 0 ORDER BY DATE;');
+               if(Settings::isProgressDB()){
+                     $sql='SELECT ID, DATE FROM LOG WHERE ID_RTF > 0 ORDER BY DATE;'}
+                else{$sql='SELECT rowid, DATE FROM LOG WHERE ID_RTF > 0 ORDER BY DATE;'}
+                $pst =  Settings::selectRecords($db, $sql);
                 while(my @row = $pst->fetchrow_array()) {
                         my $sql_date = $row[1];;
                         $sql_date = DateTime::Format::SQLite->parse_datetime($sql_date);
-                        my $pst2  = Settings::selectRecords($db, "SELECT rowid, DATE FROM life_log_login_ctr_temp_table WHERE RTF > 0 AND DATE = '".$sql_date."';");
+                        if(Settings::isProgressDB()){
+                             $sql="SELECT ID, DATE FROM life_log_login_ctr_temp_table WHERE RTF > 0 AND DATE = '".$sql_date."';"}
+                        else{$sql="SELECT rowid, DATE FROM life_log_login_ctr_temp_table WHERE RTF > 0 AND DATE = '".$sql_date."';"}                        
+                        my $pst2  = Settings::selectRecords($db, $sql);
                         my @rec   = $pst2->fetchrow_array();
                         if(@rec){
-                            $db->do("UPDATE NOTES SET LID =". $rec[0]." WHERE LID ==".$row[0].";");
-                            $pst2  = Settings::selectRecords($db, "SELECT rowid FROM NOTES WHERE LID == ".$rec[0].";");
+                            $db->do("UPDATE NOTES SET LID=". $rec[0]." WHERE LID=".$row[0].";");
+                            if(Settings::isProgressDB()){
+                                 $sql="SELECT LID FROM NOTES WHERE LID = ".$rec[0].";"}
+                            else{$sql="SELECT rowid FROM NOTES WHERE LID = ".$rec[0].";"}
+                            $pst2  = Settings::selectRecords($db, $sql);
                             @rec   = $pst2->fetchrow_array();
                             if(@rec){
-                                    $notes_ids{$sql_date} = $rec[0];
+                               $notes_ids{$sql_date} = $rec[0];
                             }
                         }
                 }
@@ -369,7 +373,7 @@ try{
             foreach my $date (keys %notes_ids){
                 #next if(ref($notes_ids{$date}) eq 'HASH');
                 my $nid = $notes_ids{$date};
-                my $stmt= "UPDATE LOG SET RTF =". $nid." WHERE DATE == '".$date."';";
+                my $stmt= "UPDATE LOG SET RTF =". $nid." WHERE DATE = '".$date."';";
                 try{
                     $db->do($stmt);
                 }
@@ -395,9 +399,7 @@ try{
         my $t ="BYTE"; $t = "SMALLINT" if Settings::isProgressDB();
         $db->do("ALTER TABLE LOG ADD COLUMN RTF $t default 0");$changed = 1;
     }    
-    elsif($SCRIPT_RELEASE > $DB_VERSION){$changed = 1;}
-
-    
+    elsif($SCRIPT_RELEASE > $DB_VERSION){$changed = 1;}    
 
     if(!$hasLogTbl) {
 
@@ -539,9 +541,9 @@ try{
     #Then we check if we are login in intereactively back. Interective, logout should bring us to the login screen.
     #Bypassing auto login. So to start maybe working on another database, and a new session.
     return $cgi->param('autologoff') == 1;
-}catch{
-    LifeLogException -> throw(error=>"DSN:".Settings::dsn()." Error:".$@."\nLAST_SQL:".$sql,show_trace=>1);
-}
+ }catch{
+     LifeLogException -> throw(error=>"DSN:".Settings::dsn()." Error:".$@."\nLAST_SQL:".$sql,show_trace=>1);
+ }
 }
 
 sub createPageViewExcludeSQL {
index bedb1ae68ac53deb95acf6a4f2fea077cf8d7d25..475208bc5b2436e486e825674f66b70b859e7c7d 100644 (file)
@@ -110,6 +110,7 @@ sub release        {$RELEASE_VER}
 sub logPath        {$S_ = shift;$LOG_PATH = $S_ if $S_;$LOG_PATH}
 sub theme          {$THEME}                               
 sub timezone       {$TIME_ZONE}
+sub language       {$LANGUAGE}
 sub sessionExprs   {$SESSN_EXPR}
 sub imgWidthHeight {$IMG_W_H}
 sub pagePrcWidth   {$PRC_WIDTH}
@@ -507,11 +508,11 @@ sub renumerate {
         my @new  = selectRecords($db, $sql)->fetchrow_array();
         if(scalar @new > 0){
              try{#can fail here, for various reasons.
-                $sql="UPDATE NOTES SET LID =". $new[0]." WHERE LID==".$row[0].";";
+                $sql="UPDATE NOTES SET LID =". $new[0]." WHERE LID=".$row[0].";";
                 $db->do($sql);
              }
              catch{
-                 SettingsException->throw(error=>"Database error encountered. sql->$sql", show_trace=>$DEBUG);
+                 SettingsException->throw(error=>"\@Settings::renumerate Database error encountered. sql->$sql", show_trace=>$DEBUG);
              };
         }
     }