From c42feda0ee1662c20d2a801f953c70e134ff8068 Mon Sep 17 00:00:00 2001 From: Will Budicm Date: Fri, 4 Dec 2020 22:07:15 +1100 Subject: [PATCH] Bug 31 - PostgreSQL new log view is not being created. --- htdocs/cgi-bin/login_ctr.cgi | 19 +++++++++++++++---- htdocs/cgi-bin/main.cgi | 4 ++-- htdocs/cgi-bin/system/modules/Settings.pm | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/htdocs/cgi-bin/login_ctr.cgi b/htdocs/cgi-bin/login_ctr.cgi index 5938a73..a699bcd 100755 --- a/htdocs/cgi-bin/login_ctr.cgi +++ b/htdocs/cgi-bin/login_ctr.cgi @@ -344,16 +344,16 @@ sub checkCreateTables { $db->do(Settings::createLOGStmt()); my $st = $db->prepare('INSERT INTO LOG(ID_CAT,DATE,LOG) VALUES (?,?,?)'); - $st->execute( 3, $today, "DB Created!"); - $st->finish(); - $session->param("cdb", "1"); + $st->execute( 3, $today, "DB Created!"); + $session->param("cdb", "1"); } # From v.1.6 view uses server side views, for pages and correct record by ID and PID lookups. # This should make queries faster, less convulsed, and log renumeration less needed for accurate pagination. if(!$curr_tables{'VW_LOG'}) { - $db->do(Settings::createViewLOGStmt()); + $db->do(Settings::createViewLOGStmt()) or LifeLogException -> throw("ERROR:".$@) ; } + if(!$curr_tables{'CAT'}) { $db->do(Settings::createCATStmt()); $changed = 1; @@ -389,6 +389,17 @@ sub checkCreateTables { # if(!$hasNotesTbl) {$db->do(Settings::createNOTEStmt())} + if(Settings::isProgressDB()){ + my @tbls = $db->tables(undef, 'public'); + foreach (@tbls){ + my $t = uc substr($_,7); + $curr_tables{$t} = 1; + } + if(!$curr_tables{'VW_LOG'}) { + LifeLogException -> throw("VW_LOG not created! Try logging in again."); + } + } + if($changed){ #It is also good to run db fix (config page) to renum if this is an release update? #Release in software might not be what is in db, which counts. diff --git a/htdocs/cgi-bin/main.cgi b/htdocs/cgi-bin/main.cgi index 6f4d22e..307b308 100755 --- a/htdocs/cgi-bin/main.cgi +++ b/htdocs/cgi-bin/main.cgi @@ -103,10 +103,10 @@ if ( $rs_keys || $stmD || $prm_vc > 0 || $prm_xc > 0 || $prm_aa > 0) { $toggle = ##Handle Session Keeps -$sss->expire(&Settings::sessionExprs); +$sss->expire(Settings::sessionExprs()); $sss->param('theme', $TH_CSS); $sss->param('bgcolor', $BGCOL); -$sss->param('sss_main', $today); +#ss->param('sss_main', $today); # #Reset Clicked diff --git a/htdocs/cgi-bin/system/modules/Settings.pm b/htdocs/cgi-bin/system/modules/Settings.pm index 9cc14cf..f825b6a 100644 --- a/htdocs/cgi-bin/system/modules/Settings.pm +++ b/htdocs/cgi-bin/system/modules/Settings.pm @@ -273,7 +273,7 @@ sub selStartOfYear { sub createViewLOGStmt { if($IS_PG_DB){ return qq( - CREATE VIEW VW_LOG AS + CREATE VIEW public.VW_LOG AS SELECT *, (select count(ID) from LOG as recount where a.id >= recount.id) as PID FROM LOG as a ORDER BY Date(DATE) DESC; ); -- 2.34.1