/ Check-in [059d20ab]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Improved error messages. Limit the number of auxiliary columns to 100.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | aux-data-in-rtree
Files: files | file ages | folders
SHA3-256: 059d20abd57727e6d312f15b640359ef778786f577d9b50b17b57195db2d0aef
User & Date: drh 2018-05-18 15:21:43
Context
2018-05-18
16:46
Fix a prepare-statement leak. check-in: 95fd296f user: drh tags: aux-data-in-rtree
15:21
Improved error messages. Limit the number of auxiliary columns to 100. check-in: 059d20ab user: drh tags: aux-data-in-rtree
2018-05-16
19:56
Fix an issue with rtreecheck() and auxiliary data columns. check-in: 46715136 user: drh tags: aux-data-in-rtree
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/rtree/rtree.c.

    90     90   typedef struct RtreeMatchArg RtreeMatchArg;
    91     91   typedef struct RtreeGeomCallback RtreeGeomCallback;
    92     92   typedef union RtreeCoord RtreeCoord;
    93     93   typedef struct RtreeSearchPoint RtreeSearchPoint;
    94     94   
    95     95   /* The rtree may have between 1 and RTREE_MAX_DIMENSIONS dimensions. */
    96     96   #define RTREE_MAX_DIMENSIONS 5
           97  +
           98  +/* Maximum number of auxiliary columns */
           99  +#define RTREE_MAX_AUX_COLUMN 100
    97    100   
    98    101   /* Size of hash table Rtree.aHash. This hash table is not expected to
    99    102   ** ever contain very many entries, so a fixed number of buckets is 
   100    103   ** used.
   101    104   */
   102    105   #define HASHSIZE 97
   103    106   
................................................................................
  3550   3553     int iErr;
  3551   3554   
  3552   3555     const char *aErrMsg[] = {
  3553   3556       0,                                                    /* 0 */
  3554   3557       "Wrong number of columns for an rtree table",         /* 1 */
  3555   3558       "Too few columns for an rtree table",                 /* 2 */
  3556   3559       "Too many columns for an rtree table",                /* 3 */
  3557         -    "AUX: columns must be last"                           /* 4 */
         3560  +    "Auxiliary rtree columns must be last"                /* 4 */
  3558   3561     };
  3559   3562   
  3560         -  if( argc>=256 ){
         3563  +  assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
         3564  +  if( argc>RTREE_MAX_AUX_COLUMN+3 ){
  3561   3565       *pzErr = sqlite3_mprintf("%s", aErrMsg[3]);
  3562   3566       return SQLITE_ERROR;
  3563   3567     }
  3564   3568   
  3565   3569     sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
  3566   3570   
  3567   3571     /* Allocate the sqlite3_vtab structure */

Changes to ext/rtree/rtree1.test.

   604    604     BEGIN;
   605    605     INSERT INTO rt VALUES(1,2,3,4,5);
   606    606   }
   607    607   do_execsql_test 15.2 {
   608    608     DROP TABLE t13;
   609    609     COMMIT;
   610    610   }
          611  +
          612  +# Test cases for the new auxiliary columns feature
          613  +#
          614  +do_catchsql_test 16.100 {
          615  +  CREATE VIRTUAL TABLE t16 USING rtree(id,x0,x1,y0,+aux1,x1);
          616  +} {1 {Auxiliary rtree columns must be last}}
          617  +do_test 16.110 {
          618  +  set sql {
          619  +    CREATE VIRTUAL TABLE t16 USING rtree(
          620  +      id, x00, x01, x10, x11, x20, x21, x30, x31, x40, x41
          621  +  }
          622  +  for {set i 12} {$i<=100} {incr i} {
          623  +     append sql ", +a$i"
          624  +  }
          625  +  append sql ");"
          626  +  execsql $sql
          627  +} {}
          628  +do_test 16.120 {
          629  +  set sql {
          630  +    CREATE VIRTUAL TABLE t16b USING rtree(
          631  +      id, x00, x01, x10, x11, x20, x21, x30, x31, x40, x41
          632  +  }
          633  +  for {set i 12} {$i<=101} {incr i} {
          634  +     append sql ", +a$i"
          635  +  }
          636  +  append sql ");"
          637  +  catchsql $sql
          638  +} {1 {Too many columns for an rtree table}}
          639  +
          640  +
          641  +
          642  +
   611    643   
   612    644   expand_all_sql db
   613    645   finish_test