SQLite Forum

RTree on ESP32 SQLite Version
Login
Fascinating.  I assume that means that "pragma page_size;" actually returns a value.  Note that the payload of the first B-Tree node should be created as soon as a new RTree virtual table if defined even though it is all empty:

```
sqlite> create virtual table x using rtree(id, minx, maxx, miny, maxy);
sqlite> select *, length(data) from x_node;
┌────────┬──────┬──────────────┐
│ nodeno │ data │ length(data) │
├────────┼──────┼──────────────┤
│ 1      │      │ 1228         │
└────────┴──────┴──────────────┘
```

(data shows as empty because it should be 1228 bytes of all zero which makes it a zero-length string).

This is with a page_size of 4096.  The size of the BTree payloads varies depending on the page_size and the number of dimensions.  For two dimensions the maximum node size is 1228 bytes and that is reached with a page size of 2048.

Note that the node size is computed by function getNodeSize at line 3644 in rtree.c.  The only way for the node size to be 0 without causing an error is if either `pragma page_size` returns 0 **or** if the value of the define RTREE_MAXCELLS is fubar.

Note that the creation of the virtual table WILL NOT FAIL just because the computed nodesize is zero.  (see the rtreeSqlInit function at line 3484 which will quite contentedly insert a zeroblob(0) as _node 1).

If this happens then the RTRee is unusable.

So see if `pragma page_size` returns something rational, and if it does then if it is bigger than 1024 bytes the only other way to get a nodesize of 0 is if the RTREE_MAXCELLS define is fubar (ie, 0).