From 252f39619aec89bac9148e9534c41d2bf61532d7 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 18 May 2018 15:21:43 +0000 Subject: [PATCH] Improved error messages. Limit the number of auxiliary columns to 100. FossilOrigin-Name: 059d20abd57727e6d312f15b640359ef778786f577d9b50b17b57195db2d0aef --- ext/rtree/rtree.c | 8 ++++++-- ext/rtree/rtree1.test | 32 ++++++++++++++++++++++++++++++++ manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 46 insertions(+), 10 deletions(-) diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 5d76a8d801..e569c94ace 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -95,6 +95,9 @@ typedef struct RtreeSearchPoint RtreeSearchPoint; /* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */ #define RTREE_MAX_DIMENSIONS 5 +/* Maximum number of auxiliary columns */ +#define RTREE_MAX_AUX_COLUMN 100 + /* Size of hash table Rtree.aHash. This hash table is not expected to ** ever contain very many entries, so a fixed number of buckets is ** used. @@ -3554,10 +3557,11 @@ static int rtreeInit( "Wrong number of columns for an rtree table", /* 1 */ "Too few columns for an rtree table", /* 2 */ "Too many columns for an rtree table", /* 3 */ - "AUX: columns must be last" /* 4 */ + "Auxiliary rtree columns must be last" /* 4 */ }; - if( argc>=256 ){ + assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */ + if( argc>RTREE_MAX_AUX_COLUMN+3 ){ *pzErr = sqlite3_mprintf("%s", aErrMsg[3]); return SQLITE_ERROR; } diff --git a/ext/rtree/rtree1.test b/ext/rtree/rtree1.test index ac6e8d9d96..ed154cd3a3 100644 --- a/ext/rtree/rtree1.test +++ b/ext/rtree/rtree1.test @@ -609,5 +609,37 @@ do_execsql_test 15.2 { COMMIT; } +# Test cases for the new auxiliary columns feature +# +do_catchsql_test 16.100 { + CREATE VIRTUAL TABLE t16 USING rtree(id,x0,x1,y0,+aux1,x1); +} {1 {Auxiliary rtree columns must be last}} +do_test 16.110 { + set sql { + CREATE VIRTUAL TABLE t16 USING rtree( + id, x00, x01, x10, x11, x20, x21, x30, x31, x40, x41 + } + for {set i 12} {$i<=100} {incr i} { + append sql ", +a$i" + } + append sql ");" + execsql $sql +} {} +do_test 16.120 { + set sql { + CREATE VIRTUAL TABLE t16b USING rtree( + id, x00, x01, x10, x11, x20, x21, x30, x31, x40, x41 + } + for {set i 12} {$i<=101} {incr i} { + append sql ", +a$i" + } + append sql ");" + catchsql $sql +} {1 {Too many columns for an rtree table}} + + + + + expand_all_sql db finish_test diff --git a/manifest b/manifest index 76e14de3ae..becef90153 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sissue\swith\srtreecheck()\sand\sauxiliary\sdata\scolumns. -D 2018-05-16T19:56:20.915 +C Improved\serror\smessages.\s\sLimit\sthe\snumber\sof\sauxiliary\scolumns\sto\s100. +D 2018-05-18T15:21:43.725 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in bfc40f350586923e0419d2ea4b559c37ec10ee4b6e210e08c14401f8e340f0da @@ -355,9 +355,9 @@ F ext/repair/test/checkfreelist01.test 3e8aa6aeb4007680c94a8d07b41c339aa635cc782 F ext/repair/test/checkindex01.test 6945d0ffc0c1dc993b2ce88036b26e0f5d6fcc65da70fc9df27c2647bb358b0f F ext/repair/test/test.tcl 686d76d888dffd021f64260abf29a55c57b2cedfa7fc69150b42b1d6119aac3c F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 -F ext/rtree/rtree.c 90c35907cedf73c7b2a69497f88a17da266616ee6f7bced787f8cc49002d4372 +F ext/rtree/rtree.c b590972cdca5595fcd494697328971d7b142b9345ed8145fab2ca5e93286a3a0 F ext/rtree/rtree.h 4a690463901cb5e6127cf05eb8e642f127012fd5003830dbc974eca5802d9412 -F ext/rtree/rtree1.test 47e2095bebea6813754fd7afa6a20e2b7b4ebcd5cb7dbcb6932b6c9f86bbf972 +F ext/rtree/rtree1.test 0300c431a6b78a59ca001af22f2e9ae4f54ccb7139cae1b70d654e4403f4d233 F ext/rtree/rtree2.test 5f25b01acd03470067a2d52783b2eb0a50bf836803d4342d20ca39e541220fe2 F ext/rtree/rtree3.test 4ee5d7df86040efe3d8d84f141f2962a7745452200a7cba1db06f86d97050499 F ext/rtree/rtree4.test 304de65d484540111b896827e4261815e5dca4ce28eeecd58be648cd73452c4b @@ -1729,7 +1729,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 9abe023e1afa7dc1a7eba7fbb3128401de129873d86b7c71c221decca26a821c -R 7a064c4cbbc33c8c1ab943f10eb67b1c +P 46715136078a51ca7dd08b83214d6ad0e85728af8a26cd342077b8dd4ada1d60 +R b5f8deb455b8613a5ff615c4f1065cf5 U drh -Z 2eb6f867a66e47a61ca5b21b3b9da89e +Z 905a75dcd2e1b90246040880bfb14954 diff --git a/manifest.uuid b/manifest.uuid index 1fa5732712..d66723f675 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -46715136078a51ca7dd08b83214d6ad0e85728af8a26cd342077b8dd4ada1d60 \ No newline at end of file +059d20abd57727e6d312f15b640359ef778786f577d9b50b17b57195db2d0aef \ No newline at end of file