perf scripts python: exported-sql-viewer.py: Fix use of TRUE with SQLite

commit af833988c0 upstream.

Prior to version 3.23 SQLite does not support TRUE or FALSE, so always
use 1 and 0 for SQLite.

Fixes: 26c11206f4 ("perf scripts python: exported-sql-viewer.py: Use new 'has_calls' column")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: stable@vger.kernel.org # v5.3+
Link: http://lore.kernel.org/lkml/20191113120206.26957-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
[Adrian: backported to v5.3, v5.4]
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Adrian Hunter 2019-11-13 14:02:06 +02:00 committed by Greg Kroah-Hartman
parent 1c4472b7dc
commit b5e2dee3bd

View File

@ -625,7 +625,7 @@ class CallGraphRootItem(CallGraphLevelItemBase):
self.query_done = True self.query_done = True
if_has_calls = "" if_has_calls = ""
if IsSelectable(glb.db, "comms", columns = "has_calls"): if IsSelectable(glb.db, "comms", columns = "has_calls"):
if_has_calls = " WHERE has_calls = TRUE" if_has_calls = " WHERE has_calls = " + glb.dbref.TRUE
query = QSqlQuery(glb.db) query = QSqlQuery(glb.db)
QueryExec(query, "SELECT id, comm FROM comms" + if_has_calls) QueryExec(query, "SELECT id, comm FROM comms" + if_has_calls)
while query.next(): while query.next():
@ -905,7 +905,7 @@ class CallTreeRootItem(CallGraphLevelItemBase):
self.query_done = True self.query_done = True
if_has_calls = "" if_has_calls = ""
if IsSelectable(glb.db, "comms", columns = "has_calls"): if IsSelectable(glb.db, "comms", columns = "has_calls"):
if_has_calls = " WHERE has_calls = TRUE" if_has_calls = " WHERE has_calls = " + glb.dbref.TRUE
query = QSqlQuery(glb.db) query = QSqlQuery(glb.db)
QueryExec(query, "SELECT id, comm FROM comms" + if_has_calls) QueryExec(query, "SELECT id, comm FROM comms" + if_has_calls)
while query.next(): while query.next():
@ -3509,6 +3509,12 @@ class DBRef():
def __init__(self, is_sqlite3, dbname): def __init__(self, is_sqlite3, dbname):
self.is_sqlite3 = is_sqlite3 self.is_sqlite3 = is_sqlite3
self.dbname = dbname self.dbname = dbname
self.TRUE = "TRUE"
self.FALSE = "FALSE"
# SQLite prior to version 3.23 does not support TRUE and FALSE
if self.is_sqlite3:
self.TRUE = "1"
self.FALSE = "0"
def Open(self, connection_name): def Open(self, connection_name):
dbname = self.dbname dbname = self.dbname