Skip to contentSkip to conversation

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

PATCH Applied Adrian Hunter 3 participants 5 messages Nov 13, 2019 – Nov 19, 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

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")
---
 tools/perf/scripts/python/exported-sql-viewer.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +9 -3
index ebc6a2e5eae9..26d7be785288 100755
@@ -637,7 +637,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():
@@ -918,7 +918,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():
@@ -1290,7 +1290,7 @@ class SwitchGraphData(GraphData):
 		QueryExec(query, "SELECT id, c_time"
 					" FROM comms"
 					" WHERE c_thread_id = " + str(thread_id) +
-					"   AND exec_flag = TRUE"
+					"   AND exec_flag = " + self.collection.glb.dbref.TRUE +
 					"   AND c_time >= " + str(start_time) +
 					"   AND c_time <= " + str(end_time) +
 					" ORDER BY c_time, id")
@@ -5016,6 +5016,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
#1 lore raw

Em Wed, Nov 13, 2019 at 02:02:06PM +0200, Adrian Hunter escreveu:

Quoted 6 lines

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")

Thanks, applied and added the first tag with that fixed cset:

[acme@quaco perf]$ git tag --contains 26c11206f433 | grep ^v[3-9] | head v5.3
v5.3-rc1
v5.3-rc2
v5.3-rc3
v5.3-rc4
v5.3-rc5
v5.3-rc6
v5.3-rc7
v5.3-rc8
v5.4-rc1
[acme@quaco perf]$

- Arnaldo

Quoted 50 lines
---
 tools/perf/scripts/python/exported-sql-viewer.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +9 -3
index ebc6a2e5eae9..26d7be785288 100755
@@ -637,7 +637,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():
@@ -918,7 +918,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():
@@ -1290,7 +1290,7 @@ class SwitchGraphData(GraphData):
 		QueryExec(query, "SELECT id, c_time"
 					" FROM comms"
 					" WHERE c_thread_id = " + str(thread_id) +
-					"   AND exec_flag = TRUE"
+					"   AND exec_flag = " + self.collection.glb.dbref.TRUE +
 					"   AND c_time >= " + str(start_time) +
 					"   AND c_time <= " + str(end_time) +
 					" ORDER BY c_time, id")
@@ -5016,6 +5016,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
Signature · 1 line
- Arnaldo
author reviewer
#2 lore raw
Quoted 11 lines · Arnaldo Carvalho de Melo

Em Wed, Nov 13, 2019 at 02:02:06PM +0200, Adrian Hunter escreveu:

Quoted 6 lines

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")

Thanks, applied and added the first tag with that fixed cset:

Thanks, but I just noticed it doesn't apply to 5.3 or 5.4-rc7, sorry :-(. I guess the Fixes and stable tags should be dropped and I will send the stable patch separately.

#3 lore raw

Em Wed, Nov 13, 2019 at 02:28:24PM +0200, Adrian Hunter escreveu:

Quoted 9 lines · Arnaldo Carvalho de Melo
Quoted 8 lines

Em Wed, Nov 13, 2019 at 02:02:06PM +0200, Adrian Hunter escreveu:

Quoted 6 lines

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")
Quoted 7 lines
Quoted 3 lines

Thanks, applied and added the first tag with that fixed cset:

Thanks, but I just noticed it doesn't apply to 5.3 or 5.4-rc7, sorry :-(. I guess the Fixes and stable tags should be dropped and I will send the stable patch separately.

Humm, I think this is still appropriate, i.e. the fixes/stables should not be taken literally as being the patch to apply to those older versions, just that this patch addresses a problem that was introduced at that tag and that affects the stable kernels since tag v5.3.

Which in turn makes people try to apply it, if it fails, then the stable guys ask for guidance.

Of course you can be proactive and do what you say you'll do, i.e. test it and provide patches for the stable kernels, taking into account whatever adjustments needed due to this code having been touched after that problem.

So I'm keeping the fixes and cc stable lines,

Thanks,

- Arnaldo

merge bot Applied
#4 lore raw
In reply to Adrian Hunter
The following commit has been merged into the perf/core branch of tip:

The following commit has been merged into the perf/core branch of tip:

Commit-ID:     af833988c088d3fed3e7188e7c3dd9ca17178dc3
Gitweb:        https://git.kernel.org/tip/af833988c088d3fed3e7188e7c3dd9ca17178dc3
Author:        Adrian Hunter <[email protected]>
AuthorDate:    Wed, 13 Nov 2019 14:02:06 +02:00
Committer:     Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Wed, 13 Nov 2019 09:13:16 -03:00

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

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]>
---
 tools/perf/scripts/python/exported-sql-viewer.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +9 -3
index ebc6a2e..26d7be7 100755
@@ -637,7 +637,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():
@@ -918,7 +918,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():
@@ -1290,7 +1290,7 @@ class SwitchGraphData(GraphData):
 		QueryExec(query, "SELECT id, c_time"
 					" FROM comms"
 					" WHERE c_thread_id = " + str(thread_id) +
-					"   AND exec_flag = TRUE"
+					"   AND exec_flag = " + self.collection.glb.dbref.TRUE +
 					"   AND c_time >= " + str(start_time) +
 					"   AND c_time <= " + str(end_time) +
 					" ORDER BY c_time, id")
@@ -5016,6 +5016,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