Repository: sysown/proxysql (language: cpp)

Issue:
Space in stats_mysql_query_digest.digest
Using ProxySQL 2.7.0-11-g3835029 I sometimes get spaces in the digest:

`
SELECT * FROM workshop_labour_unavailable WHERE Type = 'Workshop' AND Depot = 'STOCK';
`

Gives a digest of: 0x 6E817ACFD8D15DC

Inserting this into mysql_query_rules results in NULL, causing it to match everything.

Deleting the space works as expected.


Discussion / hints:

Fix patch:
diff --git a/lib/ProxySQL_Admin.cpp b/lib/ProxySQL_Admin.cpp
index efd6d5ba27..f80826327d 100644
--- a/lib/ProxySQL_Admin.cpp
+++ b/lib/ProxySQL_Admin.cpp
@@ -10376,7 +10376,7 @@ int ProxySQL_Admin::stats___save_mysql_query_digest_to_sqlite(
 		SQLite3_row *row  = resultset ? resultset->rows[i] : NULL;
 		char digest_hex_str[20]; // 2+sizeof(unsigned long long)*2+2
 		if (!resultset) {
-			sprintf(digest_hex_str, "0x%16llX", (long long unsigned int)qds->digest);
+			sprintf(digest_hex_str, "0x%016llX", (long long unsigned int)qds->digest);
 		}
 		int idx=row_idx%32;
 		if (row_idx<max_bulk_row_idx) { // bulk


Test patch: