From 32d255851ece950f4f5d6e89f786ede516a2d1e8 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 21 Oct 2024 10:47:24 +0000 Subject: [PATCH] Avoid using LIKE in sqlite3expert.c, in case "PRAGMA case_sensitive_like" has been used or the "like" UDF replaced by something unexpected. FossilOrigin-Name: 9f642b3dbc8febfacad97076030f44e9b40067e27222f2bcb84813c5765d3d2a --- ext/expert/sqlite3expert.c | 12 +++++++----- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ext/expert/sqlite3expert.c b/ext/expert/sqlite3expert.c index c9cce2e75f..84b4793ddd 100644 --- a/ext/expert/sqlite3expert.c +++ b/ext/expert/sqlite3expert.c @@ -1463,9 +1463,11 @@ static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){ ** 2) Create the equivalent virtual table in dbv. */ rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg, - "SELECT type, name, sql, 1, sql LIKE 'create virtual%%' " + "SELECT type, name, sql, 1, " + " substr(sql,1,14)=='create virtual' COLLATE nocase " "FROM sqlite_schema " - "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' " + "WHERE type IN ('table','view') AND " + " substr(name,1,7)!='sqlite_' COLLATE nocase " " UNION ALL " "SELECT type, name, sql, 2, 0 FROM sqlite_schema " "WHERE type = 'trigger'" @@ -2024,9 +2026,9 @@ sqlite3expert *sqlite3_expert_new(sqlite3 *db, char **pzErrmsg){ if( rc==SQLITE_OK ){ sqlite3_stmt *pSql = 0; rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg, - "SELECT sql, name, sql LIKE 'create virtual%%' AS virt " - " FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'" - " ORDER BY virt DESC, rowid" + "SELECT sql, name, substr(sql,1,14)=='create virtual' COLLATE nocase" + " FROM sqlite_schema WHERE substr(name,1,7)!='sqlite_' COLLATE nocase" + " ORDER BY 3 DESC, rowid" ); while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){ const char *zSql = (const char*)sqlite3_column_text(pSql, 0); diff --git a/manifest b/manifest index 817b8dea1f..039c042011 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sanother\sproblem\swith\s".expert"\sand\svirtual\stables.\s[forum:/forumpost/49d6a19ec|Forum\spost\s49d6a19ec]. -D 2024-10-20T07:19:38.106 +C Avoid\susing\sLIKE\sin\ssqlite3expert.c,\sin\scase\s"PRAGMA\scase_sensitive_like"\shas\sbeen\sused\sor\sthe\s"like"\sUDF\sreplaced\sby\ssomething\sunexpected. +D 2024-10-21T10:47:24.220 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -61,7 +61,7 @@ F ext/consio/console_io.h b5ebe34aa15b357621ebbea3d3f2e2b24750d4280b5802516409e2 F ext/expert/README.md b321c2762bb93c18ea102d5a5f7753a4b8bac646cb392b3b437f633caf2020c3 F ext/expert/expert.c d548d603a4cc9e61f446cc179c120c6713511c413f82a4a32b1e1e69d3f086a4 F ext/expert/expert1.test 1d2da6606623b57bb47064e02140823ce1daecd4cacbf402c73ad3473d7f000c -F ext/expert/sqlite3expert.c 9c5d1509407e00e6ed92ca68de33a6310d8f85c6760cfa07aa0083091da85b32 +F ext/expert/sqlite3expert.c 9d87c5eeb86707e4dbf140ca20a32935f88cfb5d8da94a406b7e0f0cdb815af6 F ext/expert/sqlite3expert.h ca81efc2679a92373a13a3e76a6138d0310e32be53d6c3bfaedabd158ea8969b F ext/expert/test_expert.c b767b2039a0df707eb3147e86bcf68b252d8455d9a41774b1a836cd052ceca70 F ext/fts3/README.content b9078d0843a094d86af0d48dffbff13c906702b4c3558012e67b9c7cc3bf59ee @@ -2219,8 +2219,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 10f5c4a2fce8a9ea9b1533cabbaf4ca8549e72950d5c460c0f4501a9fc50e3e8 -R 6bc83e3b61f3cce2168614e10c5b279e +P 7a7162293c8fdb0078fe56948d697703539dd23273b2072990d4391c761e6ae2 +R 9a25b364d37dfe1d99d32efb1c760e91 U dan -Z cf287584db61588d64066982eaae1b83 +Z 4dfdbcd58f369b4095a2bf4d76d23cc9 # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.uuid b/manifest.uuid index e34e178680..b0a2f034c5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a7162293c8fdb0078fe56948d697703539dd23273b2072990d4391c761e6ae2 +9f642b3dbc8febfacad97076030f44e9b40067e27222f2bcb84813c5765d3d2a