drh 9591d3fe93 In the (debugging) rtreenode() function, do not override an error coming out 2 semanas atrás
..
util 7894b8547d Add the randomshape.tcl test-case generator script to the util subdirectory 6 anos atrás
README 0d287cf775 Fix another typo in the rtree README file. (CVS 5187) 16 anos atrás
geopoly.c 4b136ed70a Enable SQLITE_VTAB_INNOCUOUS for FTS3, FTS5, and RTREE. 1 ano atrás
rtree.c 9591d3fe93 In the (debugging) rtreenode() function, do not override an error coming out 2 semanas atrás
rtree.h 2f94935409 Allow the shell to be built from the configure script with 7 anos atrás
rtree1.test a64342ee9c Correction to the previous check-in. 10 meses atrás
rtree2.test 0a64ddbe76 In the rtree extension, actively suppress extra tokens on the column names, 5 anos atrás
rtree3.test f703b42dc4 Update the expected error messages in some OOM test cases to account for [44d77a7f807]. 2 anos atrás
rtree4.test eab0e10304 In extensions rtree, fts3 and fts5, ensure that when dynamic buffers are bound 7 anos atrás
rtree5.test eab0e10304 In extensions rtree, fts3 and fts5, ensure that when dynamic buffers are bound 7 anos atrás
rtree6.test 3410e550dc Make the SQLITE_DBCONFIG_STMT_SCANSTATUS option on by default. 1 ano atrás
rtree7.test 1917e92fdb Add SQL scalar function rtreecheck() to the rtree module. For running checks 7 anos atrás
rtree8.test 7de8ae22f7 Omit the Reinsert algorithm from RTree. This causes most benchmarks to run 1 ano atrás
rtree9.test dcf10a1a4b Fix harmless compiler warnings. Improve the independence of some TCL tests. 3 anos atrás
rtreeA.test 7de8ae22f7 Omit the Reinsert algorithm from RTree. This causes most benchmarks to run 1 ano atrás
rtreeB.test 1917e92fdb Add SQL scalar function rtreecheck() to the rtree module. For running checks 7 anos atrás
rtreeC.test c583719b65 Show LEFT and RIGHT JOIN processing in the EXPLAIN QUERY PLAN output. 2 anos atrás
rtreeD.test a690ff360b Change the error message text for SQLITE_ERROR to omit the part about 7 anos atrás
rtreeE.test 1917e92fdb Add SQL scalar function rtreecheck() to the rtree module. For running checks 7 anos atrás
rtreeF.test 1917e92fdb Add SQL scalar function rtreecheck() to the rtree module. For running checks 7 anos atrás
rtreeG.test eab0e10304 In extensions rtree, fts3 and fts5, ensure that when dynamic buffers are bound 7 anos atrás
rtreeH.test 348d7f64f2 Be strict about type enforcement on rowid look-ups in the RTREE extension. 5 anos atrás
rtreeI.test b6c947251b Fix to the rowvalue logic that avoids disabling rowvalue inequality 5 anos atrás
rtreeJ.test 722bd1fe89 Bring test cases into alignment with the latest enhancements. 11 meses atrás
rtree_perf.tcl c81c11f62c Remove the obsolete "$Id:$" RCS identifier strings from the source code. 15 anos atrás
rtree_util.tcl 961c2a9f36 Add the xIntegrity method to the sqlite3_module object. Implement this 1 ano atrás
rtreecheck.test bc60d7bee9 Ensure that the database encoding is detected before the code generator gets 2 meses atrás
rtreecirc.test deb201b866 Use SQLITE_PREPARE_NO_VTAB in rtree as well. 6 anos atrás
rtreeconnect.test 865c3c58ab Add test cases for ticket [be436a7f4587ce517] using virtual table modules fts5 7 anos atrás
rtreedoc.test 7de8ae22f7 Omit the Reinsert algorithm from RTree. This causes most benchmarks to run 1 ano atrás
rtreedoc2.test 5488e0827a Further tests for legacy rtree geom callbacks. 3 anos atrás
rtreedoc3.test eda0001d89 Add new test file rtreedoc3.test. 3 anos atrás
rtreefuzz001.test 7de8ae22f7 Omit the Reinsert algorithm from RTree. This causes most benchmarks to run 1 ano atrás
sqlite3rtree.h 1ba88c7f1d Fix a typo in a comment. No changes to code. 6 anos atrás
test_rtreedoc.c 064b681e9b First attempt at getting the build to work with Tcl 9.0. 5 meses atrás
tkt3363.test 897230eb7a Fix a couple of memory leaks in r-tree that can occur following an OOM condition. 14 anos atrás
viewrtree.tcl c81c11f62c Remove the obsolete "$Id:$" RCS identifier strings from the source code. 15 anos atrás
visual01.txt 60afcb80ee Add the geopoly_regular(X,Y,R,N) function to the geopoly extension. 6 anos atrás

README


This directory contains an SQLite extension that implements a virtual
table type that allows users to create, query and manipulate r-tree[1]
data structures inside of SQLite databases. Users create, populate
and query r-tree structures using ordinary SQL statements.

1. SQL Interface

1.1 Table Creation
1.2 Data Manipulation
1.3 Data Querying
1.4 Introspection and Analysis

2. Compilation and Deployment

3. References


1. SQL INTERFACE

1.1 Table Creation.

All r-tree virtual tables have an odd number of columns between
3 and 11. Unlike regular SQLite tables, r-tree tables are strongly
typed.

The leftmost column is always the pimary key and contains 64-bit
integer values. Each subsequent column contains a 32-bit real
value. For each pair of real values, the first (leftmost) must be
less than or equal to the second. R-tree tables may be
constructed using the following syntax:

CREATE VIRTUAL TABLE USING rtree()

For example:

CREATE VIRTUAL TABLE boxes USING rtree(boxno, xmin, xmax, ymin, ymax);
INSERT INTO boxes VALUES(1, 1.0, 3.0, 2.0, 4.0);

Constructing a virtual r-tree table creates the following three
real tables in the database to store the data structure:

_node
_rowid
_parent

Dropping or modifying the contents of these tables directly will
corrupt the r-tree structure. To delete an r-tree from a database,
use a regular DROP TABLE statement:

DROP TABLE ;

Dropping the main r-tree table automatically drops the automatically
created tables.

1.2 Data Manipulation (INSERT, UPDATE, DELETE).

The usual INSERT, UPDATE or DELETE syntax is used to manipulate data
stored in an r-tree table. Please note the following:

* Inserting a NULL value into the primary key column has the
same effect as inserting a NULL into an INTEGER PRIMARY KEY
column of a regular table. The system automatically assigns
an unused integer key value to the new record. Usually, this
is one greater than the largest primary key value currently
present in the table.

* Attempting to insert a duplicate primary key value fails with
an SQLITE_CONSTRAINT error.

* Attempting to insert or modify a record such that the value
stored in the (N*2)th column is greater than that stored in
the (N*2+1)th column fails with an SQLITE_CONSTRAINT error.

* When a record is inserted, values are always converted to
the required type (64-bit integer or 32-bit real) as if they
were part of an SQL CAST expression. Non-numeric strings are
converted to zero.

1.3 Queries.

R-tree tables may be queried using all of the same SQL syntax supported
by regular tables. However, some query patterns are more efficient
than others.

R-trees support fast lookup by primary key value (O(logN), like
regular tables).

Any combination of equality and range (<, <=, >, >=) constraints
on spatial data columns may be used to optimize other queries. This
is the key advantage to using r-tree tables instead of creating
indices on regular tables.

1.4 Introspection and Analysis.

TODO: Describe rtreenode() and rtreedepth() functions.


2. COMPILATION AND USAGE

The easiest way to compile and use the RTREE extension is to build
and use it as a dynamically loadable SQLite extension. To do this
using gcc on *nix:

gcc -shared rtree.c -o libSqliteRtree.so

You may need to add "-I" flags so that gcc can find sqlite3ext.h
and sqlite3.h. The resulting shared lib, libSqliteRtree.so, may be
loaded into sqlite in the same way as any other dynamicly loadable
extension.


3. REFERENCES

[1] Atonin Guttman, "R-trees - A Dynamic Index Structure For Spatial
Searching", University of California Berkeley, 1984.

[2] Norbert Beckmann, Hans-Peter Kriegel, Ralf Schneider, Bernhard Seeger,
"The R*-tree: An Efficient and Robust Access Method for Points and
Rectangles", Universitaet Bremen, 1990.