Blame SOURCES/0027-ras-mc-ctl-Print-useful-message-when-run-without-ras.patch

97e186
From caa44c3946ddc900896830297c28b90ce5b9034b Mon Sep 17 00:00:00 2001
97e186
From: Betty Dall <betty.dall@hp.com>
97e186
Date: Wed, 19 Mar 2014 15:54:56 -0600
97e186
Subject: [PATCH 27/32] ras-mc-ctl: Print useful message when run without rasdaemon -r
97e186
97e186
The utility script ras-mc-ctl requires that rasdaemon --record be run
97e186
to create the me_event table in the SQLite database. The current behaviour
97e186
is this:
97e186
[root@sa1 util]# ras-mc-ctl --errors
97e186
DBD::SQLite::db prepare failed: no such table: mc_event at
97e186
/usr/local/sbin/ras-mc-ctl line 914.
97e186
Can't call method "execute" on an undefined value at
97e186
/usr/local/sbin/ras-mc-ctl line 915.
97e186
97e186
With this change, the user sees:
97e186
[root@sa1 util]# ras-mc-ctl --errors
97e186
DBD::SQLite::db prepare failed: no such table: mc_event at
97e186
/usr/local/sbin/ras-mc-ctl line 914.
97e186
ras-mc-ctl: Error: mc_event table missing from
97e186
/usr/local/var/lib/rasdaemon/ras-mc_event.db. Run 'rasdaemon --record'.
97e186
97e186
Signed-off-by: Betty Dall <betty.dall@hp.com>
97e186
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
97e186
---
97e186
 util/ras-mc-ctl.in |    4 ++++
97e186
 1 files changed, 4 insertions(+), 0 deletions(-)
97e186
97e186
diff --git a/util/ras-mc-ctl.in b/util/ras-mc-ctl.in
97e186
index 196a643..e9f9c59 100755
97e186
--- a/util/ras-mc-ctl.in
97e186
+++ b/util/ras-mc-ctl.in
97e186
@@ -912,6 +912,10 @@ sub errors
97e186
     # Memory controller mc_event errors
97e186
     $query = "select id, timestamp, err_count, err_type, err_msg, label, mc, top_layer,middle_layer,lower_layer, address, grain, syndrome, driver_detail from mc_event order by id";
97e186
     $query_handle = $dbh->prepare($query);
97e186
+    if (!$query_handle) {
97e186
+        log_error ("mc_event table missing from $dbname. Run 'rasdaemon --record'.\n");
97e186
+        exit -1
97e186
+    }
97e186
     $query_handle->execute();
97e186
     $query_handle->bind_columns(\($id, $time, $count, $type, $msg, $label, $mc, $top, $mid, $low, $addr, $grain, $syndrome, $detail));
97e186
     $out = "";
97e186
-- 
97e186
1.7.1
97e186