]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Make shell auto-column work with lots of columns when log() is missing.
authorlarrybr <larrybr@noemail.net>
Sat, 16 Apr 2022 17:53:25 +0000 (17:53 +0000)
committerlarrybr <larrybr@noemail.net>
Sat, 16 Apr 2022 17:53:25 +0000 (17:53 +0000)
FossilOrigin-Name: 82366436ef74838dae1f379f3e5b8ad187225a30ec58fb49f047ab7c08a263cf

manifest
manifest.uuid
src/shell.c.in

index 1436d1d1ca877a8a63f49746fd35a285529b428c..375c4eca3648ed582be9c77933345ac82294a50e 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\swith\s"ON\sDELETE\sRESTRICT"\sand\s"ON\sUPDATE\sRESTRICT"\sforeign\skeys\sin\sattached\sdatabases\sscanning\schild\stables\sin\sthe\swrong\sschema.
-D 2022-04-16T15:46:23.749
+C Make\sshell\sauto-column\swork\swith\slots\sof\scolumns\swhen\slog()\sis\smissing.
+D 2022-04-16T17:53:25.671
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -553,7 +553,7 @@ F src/random.c 097dc8b31b8fba5a9aca1697aeb9fd82078ec91be734c16bffda620ced7ab83c
 F src/resolve.c 18d99e7146852d6064559561769fcca0743eb32b14a97da6dbed373a30ee0e76
 F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
 F src/select.c 5ac7c08646ac5a03634da8a954645bdaa13d9bf692fb6b0b5fb3b55b19ab884e
-F src/shell.c.in eb7f10d5e2c47bd014d92ec5db1def21fcc1ed56ffaaa4ee715b6c37c370b47f
+F src/shell.c.in ecff6f4ab0e8e25acd578b3eb27ac0bad4d48643c160259a277151d6e9d412e1
 F src/sqlite.h.in 2a35f62185eb5e7ecc64a2f68442b538ce9be74f80f28a00abc24837edcf1c17
 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
 F src/sqlite3ext.h f49e28c25bd941e79794db5415fdf7b202deb3bc072ed6f1ed273d578703684e
@@ -1945,8 +1945,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 12645f100d902690630a2925674aedbb01d41a53426a26a2f56de5b8fdec955f
-R 65b6ae478c0c46336b2e3d4a00d84d7d
-U dan
-Z 20ffa409115b35ade94fa1104d7de644
+P 04d5b637f087520cd58211505f9b5c086ff96d864a1908f60464b6fe22c62b7d
+R 247d42769b42eb4f49b3d0e81a9caafe
+U larrybr
+Z 012ec694a47eae04b9be0b86d525b8a4
 # Remove this line to create a well-formed Fossil manifest.
index d23cd4cac54a09167500a619c7e32998eb72c18f..0034ef782e9a66400619501274cc3a43acbe80ad 100644 (file)
@@ -1 +1 @@
-04d5b637f087520cd58211505f9b5c086ff96d864a1908f60464b6fe22c62b7d
\ No newline at end of file
+82366436ef74838dae1f379f3e5b8ad187225a30ec58fb49f047ab7c08a263cf
\ No newline at end of file
index 996a7f942bbbf944502a1949c7a92ff802d244c8..5a2ff6ea26c09ddf0b70d9ac94bc9410dce87f31 100644 (file)
@@ -7833,7 +7833,7 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
 #endif /* !(SQLITE_OMIT_VIRTUALTABLE) && defined(SQLITE_ENABLE_DBPAGE_VTAB) */
 
 
-/* 
+/*
  * zAutoColumn(zCol, &db, ?) => Maybe init db, add column zCol to it.
  * zAutoColumn(0, &db, ?) => (db!=0) Form columns spec for CREATE TABLE,
  *   close db and set it to 0, and return the columns spec, to later
@@ -7916,6 +7916,13 @@ UPDATE ColNames AS t SET reps=\
   static const char * const zColDigits = "\
 SELECT CAST(ceil(log(count(*)+0.5)) AS INT) FROM ColNames \
 ";
+#else
+  /* Counting on SQLITE_MAX_COLUMN < 100,000 here. (32767 is the hard limit.) */
+  static const char * const zColDigits = "\
+SELECT CASE WHEN (nc < 10) THEN 1 WHEN (nc < 100) THEN 2 \
+ WHEN (nc < 1000) THEN 3 WHEN (nc < 10000) THEN 4 \
+ ELSE 5 FROM (SELECT count(*) AS nc FROM ColNames) \
+";
 #endif
   static const char * const zRenameRank =
 #ifdef SHELL_COLUMN_RENAME_CLEAN
@@ -8001,11 +8008,7 @@ FROM (\
     /* Formulate the columns spec, close the DB, zero *pDb. */
     char *zColsSpec = 0;
     int hasDupes = db_int(*pDb, zHasDupes);
-#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
     int nDigits = (hasDupes)? db_int(*pDb, zColDigits) : 0;
-#else
-# define nDigits 2
-#endif
     if( hasDupes ){
 #ifdef SHELL_COLUMN_RENAME_CLEAN
       rc = sqlite3_exec(*pDb, zDedoctor, 0, 0, 0);