Skip to contentSkip to conversation

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

PATCH In review Adrian Hunter 2 participants 2 messages Dec 2, 2019 – Dec 6, 2019

Subsystems (2)
lore
Share & tools
lore

Adrian Hunter

author reviewer
#0 lore raw

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

commit af833988c088d3fed3e7188e7c3dd9ca17178dc3 upstream

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

Fixes 26c11206f433 ("perf scripts python: exported-sql-viewer.py: Use new 'has_calls' column")
Cc Jiri Olsa <[email protected]>
[Adrian: backported to v5.3, v5.4]
---
 tools/perf/scripts/python/exported-sql-viewer.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +8 -2
index 61b3911d91e6..4b28c9d08d5a 100755
@@ -625,7 +625,7 @@ class CallGraphRootItem(CallGraphLevelItemBase):
 		self.query_done = True
 		if_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)
 		QueryExec(query, "SELECT id, comm FROM comms" + if_has_calls)
 		while query.next():
@@ -905,7 +905,7 @@ class CallTreeRootItem(CallGraphLevelItemBase):
 		self.query_done = True
 		if_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)
 		QueryExec(query, "SELECT id, comm FROM comms" + if_has_calls)
 		while query.next():
@@ -3509,6 +3509,12 @@ class DBRef():
 	def __init__(self, is_sqlite3, dbname):
 		self.is_sqlite3 = is_sqlite3
 		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):
 		dbname = self.dbname
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 13 lines · Adrian Hunter

commit af833988c088d3fed3e7188e7c3dd9ca17178dc3 upstream

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

Fixes 26c11206f433 ("perf scripts python: exported-sql-viewer.py: Use new 'has_calls' column")
Cc Jiri Olsa <[email protected]>
[Adrian: backported to v5.3, v5.4]
Quoted 3 lines
---
 tools/perf/scripts/python/exported-sql-viewer.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Now queued up, thanks!

greg k-h