mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Add tests for legacy geometry callbacks to rtreedoc2.test.
FossilOrigin-Name: 6ad00e52eda5bc4cb8e6fffbd7538bcd4c6b22f84b837a746eba6bf8c91eb55a
This commit is contained in:
@ -468,7 +468,8 @@ TESTSRC += \
|
|||||||
$(TOP)/ext/misc/unionvtab.c \
|
$(TOP)/ext/misc/unionvtab.c \
|
||||||
$(TOP)/ext/misc/wholenumber.c \
|
$(TOP)/ext/misc/wholenumber.c \
|
||||||
$(TOP)/ext/misc/zipfile.c \
|
$(TOP)/ext/misc/zipfile.c \
|
||||||
$(TOP)/ext/userauth/userauth.c
|
$(TOP)/ext/userauth/userauth.c \
|
||||||
|
$(TOP)/ext/rtree/test_rtreedoc.c
|
||||||
|
|
||||||
# Source code to the library files needed by the test fixture
|
# Source code to the library files needed by the test fixture
|
||||||
#
|
#
|
||||||
|
@ -1586,6 +1586,7 @@ TESTEXT = \
|
|||||||
$(TOP)\ext\misc\totype.c \
|
$(TOP)\ext\misc\totype.c \
|
||||||
$(TOP)\ext\misc\unionvtab.c \
|
$(TOP)\ext\misc\unionvtab.c \
|
||||||
$(TOP)\ext\misc\wholenumber.c \
|
$(TOP)\ext\misc\wholenumber.c \
|
||||||
|
$(TOP)\ext\rtree\test_rtreedoc.c \
|
||||||
fts5.c
|
fts5.c
|
||||||
|
|
||||||
# If use of zlib is enabled, add the "zipfile.c" source file.
|
# If use of zlib is enabled, add the "zipfile.c" source file.
|
||||||
|
@ -902,6 +902,12 @@ set ::contained_in 0
|
|||||||
proc contained_in {args} {incr ::contained_in ; return 0}
|
proc contained_in {args} {incr ::contained_in ; return 0}
|
||||||
db func contained_in contained_in
|
db func contained_in contained_in
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-32671-43888 Then an efficient way to find the specific
|
||||||
|
# ZIP code for the main SQLite office would be to run a query like this:
|
||||||
|
# SELECT objname FROM demo_data, demo_index WHERE
|
||||||
|
# demo_data.id=demo_index.id AND contained_in(demo_data.boundary,
|
||||||
|
# 35.37785, -80.77470) AND minX<=-80.77470 AND maxX>=-80.77470 AND
|
||||||
|
# minY<=35.37785 AND maxY>=35.37785;
|
||||||
do_vmstep_test 1.2 {
|
do_vmstep_test 1.2 {
|
||||||
SELECT objname FROM demo_data, demo_index
|
SELECT objname FROM demo_data, demo_index
|
||||||
WHERE demo_data.id=demo_index.id
|
WHERE demo_data.id=demo_index.id
|
||||||
|
249
ext/rtree/rtreedoc2.test
Normal file
249
ext/rtree/rtreedoc2.test
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
# 2021 September 13
|
||||||
|
#
|
||||||
|
# The author disclaims copyright to this source code. In place of
|
||||||
|
# a legal notice, here is a blessing:
|
||||||
|
#
|
||||||
|
# May you do good and not evil.
|
||||||
|
# May you find forgiveness for yourself and forgive others.
|
||||||
|
# May you share freely, never taking more than you give.
|
||||||
|
#
|
||||||
|
#***********************************************************************
|
||||||
|
#
|
||||||
|
# The focus of this file is testing the r-tree extension.
|
||||||
|
#
|
||||||
|
|
||||||
|
if {![info exists testdir]} {
|
||||||
|
set testdir [file join [file dirname [info script]] .. .. test]
|
||||||
|
}
|
||||||
|
source [file join [file dirname [info script]] rtree_util.tcl]
|
||||||
|
source $testdir/tester.tcl
|
||||||
|
set testprefix rtreedoc2
|
||||||
|
|
||||||
|
ifcapable !rtree {
|
||||||
|
finish_test
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
# Section 6 of documentation.
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
set testprefix rtreedoc2-1
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-35254-48865 A call to one of the above APIs creates a
|
||||||
|
# new SQL function named by the second parameter (zQueryFunc or zGeom).
|
||||||
|
#
|
||||||
|
# [register_circle_geom db] registers new geometry callback "Qcircle"
|
||||||
|
# and legacy implementation "circle". Test that these do actually appear.
|
||||||
|
#
|
||||||
|
do_execsql_test 1.1.0 {
|
||||||
|
SELECT * FROM pragma_function_list WHERE name IN('circle', 'qcircle');
|
||||||
|
} {
|
||||||
|
}
|
||||||
|
do_test 1.1 {
|
||||||
|
register_circle_geom db
|
||||||
|
} {SQLITE_OK}
|
||||||
|
do_execsql_test 1.1.2 {
|
||||||
|
SELECT * FROM pragma_function_list WHERE name = 'circle' AND enc='utf8';
|
||||||
|
} {
|
||||||
|
circle 0 s utf8 -1 0
|
||||||
|
}
|
||||||
|
do_execsql_test 1.1.3 {
|
||||||
|
SELECT * FROM pragma_function_list WHERE name = 'qcircle' AND enc='utf8';
|
||||||
|
} {
|
||||||
|
qcircle 0 s utf8 -1 0
|
||||||
|
}
|
||||||
|
|
||||||
|
do_execsql_test 1.2.0 { SELECT circle(1, 2, 3); } {{}}
|
||||||
|
do_execsql_test 1.2.1 { SELECT qcircle(1, 2, 3); } {{}}
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-61427-46983
|
||||||
|
do_execsql_test 1.3.0 {
|
||||||
|
CREATE VIRTUAL TABLE demo_index USING rtree(id, x1,x2, y1,y2);
|
||||||
|
INSERT INTO demo_index VALUES(10, 45,45, 24,24);
|
||||||
|
INSERT INTO demo_index VALUES(20, 50,50, 28,28);
|
||||||
|
INSERT INTO demo_index VALUES(30, 43,43, 22,22);
|
||||||
|
}
|
||||||
|
do_execsql_test 1.3.1 {
|
||||||
|
SELECT id FROM demo_index WHERE id MATCH circle(45.3, 22.9, 5.0)
|
||||||
|
} {10 30}
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-16907-50223 The SQL syntax for custom queries is the
|
||||||
|
# same regardless of which interface, sqlite3_rtree_geometry_callback()
|
||||||
|
# or sqlite3_rtree_query_callback(), is used to register the SQL
|
||||||
|
# function.
|
||||||
|
do_execsql_test 1.3.2 {
|
||||||
|
SELECT id FROM demo_index WHERE id MATCH qcircle(45.3, 22.9, 5.0, 1)
|
||||||
|
} {10 30}
|
||||||
|
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-59634-51678 When that SQL function appears on the
|
||||||
|
# right-hand side of the MATCH operator and the left-hand side of the
|
||||||
|
# MATCH operator is any column in the R*Tree virtual table, then the
|
||||||
|
# callback defined by the third argument (xQueryFunc or xGeom) is
|
||||||
|
# invoked to determine if a particular object or subtree overlaps the
|
||||||
|
# desired region.
|
||||||
|
proc box_geom {args} {
|
||||||
|
lappend ::box_geom [concat [lindex $args 0] [lrange $args 2 end-1]]
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
register_box_geom db box_geom
|
||||||
|
set box_geom [list]
|
||||||
|
do_execsql_test 1.3.2 {
|
||||||
|
SELECT id FROM demo_index WHERE id MATCH box(43,46, 21,25);
|
||||||
|
} {10 30}
|
||||||
|
do_test 1.3.3 {
|
||||||
|
set ::box_geom
|
||||||
|
} [list {*}{
|
||||||
|
{box {43.0 46.0 21.0 25.0} {45.0 45.0 24.0 24.0}}
|
||||||
|
{box {43.0 46.0 21.0 25.0} {50.0 50.0 28.0 28.0}}
|
||||||
|
{box {43.0 46.0 21.0 25.0} {43.0 43.0 22.0 22.0}}
|
||||||
|
}]
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
# Section 6 of documentation.
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
set testprefix rtreedoc2-2
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-02424-24769 The second argument is the number of
|
||||||
|
# coordinates in each r-tree entry, and is always the same for any given
|
||||||
|
# R*Tree.
|
||||||
|
#
|
||||||
|
# EVIDENCE-OF: R-40260-16838 The number of coordinates is 2 for a
|
||||||
|
# 1-dimensional R*Tree, 4 for a 2-dimensional R*Tree, 6 for a
|
||||||
|
# 3-dimensional R*Tree, and so forth.
|
||||||
|
#
|
||||||
|
# The second argument refered to above is the length of the list passed
|
||||||
|
# as the 3rd parameter to the Tcl script.
|
||||||
|
#
|
||||||
|
do_execsql_test 1.0 {
|
||||||
|
CREATE VIRTUAL TABLE rt1 USING rtree(id, x1,x2);
|
||||||
|
CREATE VIRTUAL TABLE rt2 USING rtree(id, x1,x2, y1,y2);
|
||||||
|
CREATE VIRTUAL TABLE rt3 USING rtree(id, x1,x2, y1,y2, z1,z2);
|
||||||
|
|
||||||
|
INSERT INTO rt1 DEFAULT VALUES;
|
||||||
|
INSERT INTO rt2 DEFAULT VALUES;
|
||||||
|
INSERT INTO rt3 DEFAULT VALUES;
|
||||||
|
}
|
||||||
|
foreach {tn tbl nCoord} {
|
||||||
|
1 rt1 2
|
||||||
|
2 rt2 4
|
||||||
|
3 rt3 6
|
||||||
|
} {
|
||||||
|
set ::box_geom [list]
|
||||||
|
do_catchsql_test 1.$tn.1 "
|
||||||
|
SELECT id FROM $tbl WHERE id MATCH box();
|
||||||
|
" {1 {SQL logic error}}
|
||||||
|
|
||||||
|
do_test 1.$tn.2 {
|
||||||
|
llength [lindex $::box_geom 0 2]
|
||||||
|
} $nCoord
|
||||||
|
}
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-28051-48608 If xGeom returns anything other than
|
||||||
|
# SQLITE_OK, then the r-tree query will abort with an error.
|
||||||
|
proc box_geom {args} {
|
||||||
|
error "an error!"
|
||||||
|
}
|
||||||
|
do_catchsql_test 2.0 {
|
||||||
|
SELECT * FROM rt2 WHERE id MATCH box(22,23, 24,25);
|
||||||
|
} {1 {SQL logic error}}
|
||||||
|
|
||||||
|
do_execsql_test 3.0 {
|
||||||
|
INSERT INTO rt1 VALUES(10, 10, 10);
|
||||||
|
INSERT INTO rt1 VALUES(11, 11, 11);
|
||||||
|
INSERT INTO rt1 VALUES(12, 12, 12);
|
||||||
|
INSERT INTO rt1 VALUES(13, 13, 13);
|
||||||
|
INSERT INTO rt1 VALUES(14, 14, 14);
|
||||||
|
}
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-53759-57366 The exact same sqlite3_rtree_geometry
|
||||||
|
# structure is used for every callback for same MATCH operator in the
|
||||||
|
# same query.
|
||||||
|
proc box_geom {args} {
|
||||||
|
lappend ::ptr_list [lindex $args 4]
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
set ::ptr_list [list]
|
||||||
|
do_execsql_test 3.1 {
|
||||||
|
SELECT * FROM rt1 WHERE id MATCH box(1,1);
|
||||||
|
}
|
||||||
|
do_test 3.2 {
|
||||||
|
set val [lindex $::ptr_list 0]
|
||||||
|
foreach p $::ptr_list {
|
||||||
|
if {$p!=$val} {error "pointer mismatch"}
|
||||||
|
}
|
||||||
|
} {}
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-60247-35692 The contents of the sqlite3_rtree_geometry
|
||||||
|
# structure are initialized by SQLite but are not subsequently modified.
|
||||||
|
proc box_geom {args} {
|
||||||
|
lappend ::box_geom [concat [lindex $args 0] [lrange $args 2 end-1]]
|
||||||
|
if {[llength $::box_geom]==3} {
|
||||||
|
return "zero"
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
set ::box_geom [list]
|
||||||
|
do_catchsql_test 3.2 {
|
||||||
|
SELECT * FROM rt1 WHERE id MATCH box(1,1);
|
||||||
|
} {1 {SQL logic error}}
|
||||||
|
do_test 3.3 {
|
||||||
|
set ::box_geom
|
||||||
|
} [list {*}{
|
||||||
|
{box {1.0 1.0} {0.0 0.0}}
|
||||||
|
{box {1.0 1.0} {10.0 10.0}}
|
||||||
|
{box {1.0 1.0} {11.0 11.0}}
|
||||||
|
{box 0.0 {12.0 12.0}}
|
||||||
|
}]
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-31246-29731 The pContext member of the
|
||||||
|
# sqlite3_rtree_geometry structure is always set to a copy of the
|
||||||
|
# pContext argument passed to sqlite3_rtree_geometry_callback() when the
|
||||||
|
# callback is registered.
|
||||||
|
reset_db
|
||||||
|
do_execsql_test 4.0 {
|
||||||
|
CREATE VIRTUAL TABLE r1 USING rtree(id, minX,maxX, minY,maxY);
|
||||||
|
WITH s(i) AS (
|
||||||
|
VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<120
|
||||||
|
)
|
||||||
|
INSERT INTO r1 SELECT i,i,i+1, 200,201 FROM s;
|
||||||
|
}
|
||||||
|
set ctx [register_box_geom db box_geom]
|
||||||
|
set ::box_geom [list]
|
||||||
|
proc box_geom {args} {
|
||||||
|
lappend ::box_geom [lindex $args 1]
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
do_execsql_test 4.1 {
|
||||||
|
SELECT count(*) FROM r1 WHERE id MATCH box(0,150,199,201)
|
||||||
|
} 120
|
||||||
|
do_test 4.2 {
|
||||||
|
foreach g $::box_geom {
|
||||||
|
if {$g!=$ctx} {error "pointer mismatch"}
|
||||||
|
}
|
||||||
|
} {}
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-09904-19077 The aParam[] array (size nParam) contains
|
||||||
|
# the parameter values passed to the SQL function on the right-hand side
|
||||||
|
# of the MATCH operator.
|
||||||
|
proc box_geom {args} {
|
||||||
|
set ::box_geom [lindex $args 2]
|
||||||
|
}
|
||||||
|
foreach {tn q vals} {
|
||||||
|
1 "SELECT count(*) FROM r1 WHERE id MATCH box(1,2,3)" {1.0 2.0 3.0}
|
||||||
|
2 "SELECT count(*) FROM r1 WHERE id MATCH box(10001)" {10001.0}
|
||||||
|
3 "SELECT count(*) FROM r1 WHERE id MATCH box(-10001)" {-10001.0}
|
||||||
|
} {
|
||||||
|
do_catchsql_test 5.$tn.1 $q {1 {SQL logic error}}
|
||||||
|
do_test 5.$tn.2 { set ::box_geom } $vals
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
finish_test
|
||||||
|
|
192
ext/rtree/test_rtreedoc.c
Normal file
192
ext/rtree/test_rtreedoc.c
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
** 2010 August 28
|
||||||
|
**
|
||||||
|
** The author disclaims copyright to this source code. In place of
|
||||||
|
** a legal notice, here is a blessing:
|
||||||
|
**
|
||||||
|
** May you do good and not evil.
|
||||||
|
** May you find forgiveness for yourself and forgive others.
|
||||||
|
** May you share freely, never taking more than you give.
|
||||||
|
**
|
||||||
|
*************************************************************************
|
||||||
|
** Code for testing all sorts of SQLite interfaces. This code
|
||||||
|
** is not included in the SQLite library.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "sqlite3.h"
|
||||||
|
#if defined(INCLUDE_SQLITE_TCL_H)
|
||||||
|
# include "sqlite_tcl.h"
|
||||||
|
#else
|
||||||
|
# include "tcl.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Solely for the UNUSED_PARAMETER() macro. */
|
||||||
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
|
#ifdef SQLITE_ENABLE_RTREE
|
||||||
|
|
||||||
|
typedef struct BoxGeomCtx BoxGeomCtx;
|
||||||
|
struct BoxGeomCtx {
|
||||||
|
Tcl_Interp *interp;
|
||||||
|
Tcl_Obj *pScript;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int invokeTclGeomCb(
|
||||||
|
const char *zName,
|
||||||
|
sqlite3_rtree_geometry *p,
|
||||||
|
int nCoord,
|
||||||
|
sqlite3_rtree_dbl *aCoord
|
||||||
|
){
|
||||||
|
int rc = SQLITE_OK;
|
||||||
|
if( p->pContext ){
|
||||||
|
char aPtr[64];
|
||||||
|
BoxGeomCtx *pCtx = (BoxGeomCtx*)p->pContext;
|
||||||
|
Tcl_Interp *interp = pCtx->interp;
|
||||||
|
Tcl_Obj *pScript = 0;
|
||||||
|
Tcl_Obj *pParam = 0;
|
||||||
|
Tcl_Obj *pCoord = 0;
|
||||||
|
int ii;
|
||||||
|
Tcl_Obj *pRes;
|
||||||
|
|
||||||
|
pScript = Tcl_DuplicateObj(pCtx->pScript);
|
||||||
|
Tcl_IncrRefCount(pScript);
|
||||||
|
Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(zName,-1));
|
||||||
|
|
||||||
|
sqlite3_snprintf(sizeof(aPtr)-1, aPtr, "%p", (void*)p->pContext);
|
||||||
|
Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(aPtr,-1));
|
||||||
|
|
||||||
|
pParam = Tcl_NewObj();
|
||||||
|
for(ii=0; ii<p->nParam; ii++){
|
||||||
|
Tcl_ListObjAppendElement(
|
||||||
|
interp, pParam, Tcl_NewDoubleObj(p->aParam[ii])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Tcl_ListObjAppendElement(interp, pScript, pParam);
|
||||||
|
|
||||||
|
pCoord = Tcl_NewObj();
|
||||||
|
for(ii=0; ii<nCoord; ii++){
|
||||||
|
Tcl_ListObjAppendElement(interp, pCoord, Tcl_NewDoubleObj(aCoord[ii]));
|
||||||
|
}
|
||||||
|
Tcl_ListObjAppendElement(interp, pScript, pCoord);
|
||||||
|
|
||||||
|
sqlite3_snprintf(sizeof(aPtr)-1, aPtr, "%p", (void*)p);
|
||||||
|
Tcl_ListObjAppendElement(interp, pScript, Tcl_NewStringObj(aPtr,-1));
|
||||||
|
|
||||||
|
rc = Tcl_EvalObjEx(interp, pScript, 0);
|
||||||
|
if( rc!=TCL_OK ) rc = SQLITE_ERROR;
|
||||||
|
|
||||||
|
pRes = Tcl_GetObjResult(interp);
|
||||||
|
if( 0==sqlite3_stricmp(Tcl_GetString(pRes), "zero") ){
|
||||||
|
p->aParam[0] = 0.0;
|
||||||
|
p->nParam = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
# EVIDENCE-OF: R-00693-36727 The legacy xGeom callback is invoked with
|
||||||
|
# four arguments.
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-50437-53270 The first argument is a pointer to an
|
||||||
|
# sqlite3_rtree_geometry structure which provides information about how
|
||||||
|
# the SQL function was invoked.
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-40260-16838 The number of coordinates is 2 for a
|
||||||
|
# 1-dimensional R*Tree, 4 for a 2-dimensional R*Tree, 6 for a
|
||||||
|
# 3-dimensional R*Tree, and so forth.
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-00090-24248 The third argument, aCoord[], is an array
|
||||||
|
# of nCoord coordinates that defines a bounding box to be tested.
|
||||||
|
|
||||||
|
# EVIDENCE-OF: R-28207-40885 The last argument is a pointer into which
|
||||||
|
# the callback result should be written.
|
||||||
|
|
||||||
|
*/
|
||||||
|
static int box_geom(
|
||||||
|
sqlite3_rtree_geometry *p, /* R-50437-53270 */
|
||||||
|
int nCoord, /* R-02424-24769 */
|
||||||
|
sqlite3_rtree_dbl *aCoord, /* R-00090-24248 */
|
||||||
|
int *pRes /* R-28207-40885 */
|
||||||
|
){
|
||||||
|
int ii;
|
||||||
|
|
||||||
|
if( p->nParam!=nCoord ){
|
||||||
|
invokeTclGeomCb("box", p, nCoord, aCoord);
|
||||||
|
return SQLITE_ERROR;
|
||||||
|
}
|
||||||
|
if( invokeTclGeomCb("box", p, nCoord, aCoord) ) return SQLITE_ERROR;
|
||||||
|
|
||||||
|
for(ii=0; ii<nCoord; ii+=2){
|
||||||
|
if( aCoord[ii]>p->aParam[ii+1] || aCoord[ii+1]<p->aParam[ii] ){
|
||||||
|
/* R-28207-40885 */
|
||||||
|
*pRes = 0;
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* R-28207-40885 */
|
||||||
|
*pRes = 1;
|
||||||
|
|
||||||
|
return SQLITE_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int SQLITE_TCLAPI register_box_geom(
|
||||||
|
void * clientData,
|
||||||
|
Tcl_Interp *interp,
|
||||||
|
int objc,
|
||||||
|
Tcl_Obj *CONST objv[]
|
||||||
|
){
|
||||||
|
extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
|
||||||
|
extern const char *sqlite3ErrName(int);
|
||||||
|
sqlite3 *db;
|
||||||
|
int rc;
|
||||||
|
BoxGeomCtx *pCtx;
|
||||||
|
char aPtr[64];
|
||||||
|
|
||||||
|
if( objc!=3 ){
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "DB SCRIPT");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||||
|
|
||||||
|
pCtx = (BoxGeomCtx*)ckalloc(sizeof(BoxGeomCtx*));
|
||||||
|
pCtx->interp = interp;
|
||||||
|
pCtx->pScript = Tcl_DuplicateObj(objv[2]);
|
||||||
|
Tcl_IncrRefCount(pCtx->pScript);
|
||||||
|
|
||||||
|
rc = sqlite3_rtree_geometry_callback(db, "box", box_geom, (void*)pCtx);
|
||||||
|
|
||||||
|
sqlite3_snprintf(64, aPtr, "%p", (void*)pCtx);
|
||||||
|
Tcl_SetObjResult(interp, Tcl_NewStringObj(aPtr, -1));
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int SQLITE_TCLAPI register_box_query(
|
||||||
|
void * clientData,
|
||||||
|
Tcl_Interp *interp,
|
||||||
|
int objc,
|
||||||
|
Tcl_Obj *CONST objv[]
|
||||||
|
){
|
||||||
|
extern int getDbPointer(Tcl_Interp*, const char*, sqlite3**);
|
||||||
|
extern const char *sqlite3ErrName(int);
|
||||||
|
sqlite3 *db;
|
||||||
|
|
||||||
|
if( objc!=3 ){
|
||||||
|
Tcl_WrongNumArgs(interp, 1, objv, "DB SCRIPT");
|
||||||
|
return TCL_ERROR;
|
||||||
|
}
|
||||||
|
if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR;
|
||||||
|
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
||||||
|
#endif /* SQLITE_ENABLE_RTREE */
|
||||||
|
|
||||||
|
|
||||||
|
int Sqlitetestrtreedoc_Init(Tcl_Interp *interp){
|
||||||
|
#ifdef SQLITE_ENABLE_RTREE
|
||||||
|
Tcl_CreateObjCommand(interp, "register_box_geom", register_box_geom, 0, 0);
|
||||||
|
Tcl_CreateObjCommand(interp, "register_box_query", register_box_query, 0, 0);
|
||||||
|
#endif /* SQLITE_ENABLE_RTREE */
|
||||||
|
return TCL_OK;
|
||||||
|
}
|
3
main.mk
3
main.mk
@ -387,7 +387,8 @@ TESTSRC += \
|
|||||||
$(TOP)/ext/misc/zipfile.c \
|
$(TOP)/ext/misc/zipfile.c \
|
||||||
$(TOP)/ext/fts5/fts5_tcl.c \
|
$(TOP)/ext/fts5/fts5_tcl.c \
|
||||||
$(TOP)/ext/fts5/fts5_test_mi.c \
|
$(TOP)/ext/fts5/fts5_test_mi.c \
|
||||||
$(TOP)/ext/fts5/fts5_test_tok.c
|
$(TOP)/ext/fts5/fts5_test_tok.c \
|
||||||
|
$(TOP)/ext/rtree/test_rtreedoc.c
|
||||||
|
|
||||||
|
|
||||||
#TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c
|
#TESTSRC += $(TOP)/ext/fts2/fts2_tokenizer.c
|
||||||
|
24
manifest
24
manifest
@ -1,11 +1,11 @@
|
|||||||
C Make\sthe\saffinity()\sfunction\savailable\seven\sif\scompiled\swithout\nSQLITE_DEBUG.\s\sSurround\sthe\simplementation\sof\sall\stest-only\sSQL\sfunctions\nwith\s#ifndef\sSQLITE_UNTESTABLE.
|
C Add\stests\sfor\slegacy\sgeometry\scallbacks\sto\srtreedoc2.test.
|
||||||
D 2021-09-17T13:07:15.263
|
D 2021-09-17T20:43:27.549
|
||||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||||
F Makefile.in 83c348515cb62f6f2a2ddf3fd014113ff20564b776e1a614079722c88c6ff43d
|
F Makefile.in 2a6e71e91f29e9eb0cb800b6500bbbfef31730d5c37eaadb6e8ea8a45e6ead21
|
||||||
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
|
F Makefile.linux-gcc f609543700659711fbd230eced1f01353117621dccae7b9fb70daa64236c5241
|
||||||
F Makefile.msc 7dc32ba195639311ef4fa3d8f8ec218de37fde12d7ef5a33e9a7de921b0025ca
|
F Makefile.msc b18738be47ba9293dbea2048fe1d5a737456fdc630361cc98ef2c2f73bf3395c
|
||||||
F README.md 27fb76aa7eb57ed63a53bbba7292b6bf71f51125554f79f16b5d040edd1e6110
|
F README.md 27fb76aa7eb57ed63a53bbba7292b6bf71f51125554f79f16b5d040edd1e6110
|
||||||
F VERSION c6595fef606851f2bc3ebed6a7386c73751835fc909feab7c093739fa4b3c1d1
|
F VERSION c6595fef606851f2bc3ebed6a7386c73751835fc909feab7c093739fa4b3c1d1
|
||||||
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
|
F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50
|
||||||
@ -418,9 +418,11 @@ F ext/rtree/rtree_util.tcl db734b4c5e75fed6acc56d9701f2235345acfdec750b5fc7b5879
|
|||||||
F ext/rtree/rtreecheck.test d67d5b3e9e45bfa8cd90734e8e9302144ac415b8e9176c6f02d4f92892ee8a35
|
F ext/rtree/rtreecheck.test d67d5b3e9e45bfa8cd90734e8e9302144ac415b8e9176c6f02d4f92892ee8a35
|
||||||
F ext/rtree/rtreecirc.test aec664eb21ae943aeb344191407afff5d392d3ae9d12b9a112ced0d9c5de298e
|
F ext/rtree/rtreecirc.test aec664eb21ae943aeb344191407afff5d392d3ae9d12b9a112ced0d9c5de298e
|
||||||
F ext/rtree/rtreeconnect.test 225ad3fcb483d36cbee423a25052a6bbae762c9576ae9268332360c68c170d3d
|
F ext/rtree/rtreeconnect.test 225ad3fcb483d36cbee423a25052a6bbae762c9576ae9268332360c68c170d3d
|
||||||
F ext/rtree/rtreedoc.test 07e76da2148aa9aa46951060d15e16023d3d822118704057c7f153517217a318
|
F ext/rtree/rtreedoc.test 243cd3fdee1cb89e290e908ddde0cc0cfda0ccb85473c6d1b3c43e6260b14cac
|
||||||
|
F ext/rtree/rtreedoc2.test ae13849b390f6878434896ecee113cc44bb2bcbcd868f6c47b5d80a73e3e4ab1
|
||||||
F ext/rtree/rtreefuzz001.test 0fc793f67897c250c5fde96cefee455a5e2fb92f4feeabde5b85ea02040790ee
|
F ext/rtree/rtreefuzz001.test 0fc793f67897c250c5fde96cefee455a5e2fb92f4feeabde5b85ea02040790ee
|
||||||
F ext/rtree/sqlite3rtree.h 03c8db3261e435fbddcfc961471795cbf12b24e03001d0015b2636b0f3881373
|
F ext/rtree/sqlite3rtree.h 03c8db3261e435fbddcfc961471795cbf12b24e03001d0015b2636b0f3881373
|
||||||
|
F ext/rtree/test_rtreedoc.c 72f78e9930e861ba2a780f36cb6ecbf02ebda350111ecab9594c564c10a30b1c
|
||||||
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
||||||
F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff
|
F ext/rtree/util/randomshape.tcl 54ee03d0d4a1c621806f7f44d5b78d2db8fac26e0e8687c36c4bd0203b27dbff
|
||||||
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
||||||
@ -467,7 +469,7 @@ F ext/userauth/userauth.c 7f00cded7dcaa5d47f54539b290a43d2e59f4b1eb5f447545fa865
|
|||||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||||
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8
|
||||||
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
F magic.txt 8273bf49ba3b0c8559cb2774495390c31fd61c60
|
||||||
F main.mk 4e075c9618c06c55d1cc723087b0722f384247b6b8db1ac2cb161f864c953c97
|
F main.mk 002e77acdfeb08d1d8f4d360b01e130aa243fb5701728e81fac9085794f27155
|
||||||
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
F mkso.sh fd21c06b063bb16a5d25deea1752c2da6ac3ed83
|
||||||
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
F mptest/config01.test 3c6adcbc50b991866855f1977ff172eb6d901271
|
||||||
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
F mptest/config02.test 4415dfe36c48785f751e16e32c20b077c28ae504
|
||||||
@ -598,7 +600,7 @@ F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe
|
|||||||
F src/test_sqllog.c 540feaea7280cd5f926168aee9deb1065ae136d0bbbe7361e2ef3541783e187a
|
F src/test_sqllog.c 540feaea7280cd5f926168aee9deb1065ae136d0bbbe7361e2ef3541783e187a
|
||||||
F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e
|
F src/test_superlock.c 4839644b9201da822f181c5bc406c0b2385f672e
|
||||||
F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
|
F src/test_syscall.c 1073306ba2e9bfc886771871a13d3de281ed3939
|
||||||
F src/test_tclsh.c eeafce33ad2136d57e5dec10f1e9a4347447eb72ffd504a1c7b9c6bfe2e71578
|
F src/test_tclsh.c c4065ced25126e25c40122c5ff62dc89902ea617d72cdd27765151cdd7fcc477
|
||||||
F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc
|
F src/test_tclvar.c 33ff42149494a39c5fbb0df3d25d6fafb2f668888e41c0688d07273dcb268dfc
|
||||||
F src/test_thread.c 269ea9e1fa5828dba550eb26f619aa18aedbc29fd92f8a5f6b93521fbb74a61c
|
F src/test_thread.c 269ea9e1fa5828dba550eb26f619aa18aedbc29fd92f8a5f6b93521fbb74a61c
|
||||||
F src/test_vdbecov.c f60c6f135ec42c0de013a1d5136777aa328a776d33277f92abac648930453d43
|
F src/test_vdbecov.c f60c6f135ec42c0de013a1d5136777aa328a776d33277f92abac648930453d43
|
||||||
@ -1923,7 +1925,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
|||||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||||
P ebfc18aaa6506ccac80f297a1792e726972bb39c0b5c8706faadeb8df94a45e9
|
P b7e00ef8059f6fb5658c6ad6f337cfdf065a5f1b1130452122282f3a69e98a93
|
||||||
R 2b89e9e309868e78306907ed116b8c82
|
R 0b7caecd3af74a3c80ac98749a9df12e
|
||||||
U drh
|
U dan
|
||||||
Z 9f5272dd467b9f232b6577a308d23359
|
Z 75db5feff0f016247e2a2ef39c35bcd5
|
||||||
|
@ -1 +1 @@
|
|||||||
b7e00ef8059f6fb5658c6ad6f337cfdf065a5f1b1130452122282f3a69e98a93
|
6ad00e52eda5bc4cb8e6fffbd7538bcd4c6b22f84b837a746eba6bf8c91eb55a
|
@ -87,6 +87,7 @@ const char *sqlite3TestInit(Tcl_Interp *interp){
|
|||||||
extern int Sqlitetestintarray_Init(Tcl_Interp*);
|
extern int Sqlitetestintarray_Init(Tcl_Interp*);
|
||||||
extern int Sqlitetestvfs_Init(Tcl_Interp *);
|
extern int Sqlitetestvfs_Init(Tcl_Interp *);
|
||||||
extern int Sqlitetestrtree_Init(Tcl_Interp*);
|
extern int Sqlitetestrtree_Init(Tcl_Interp*);
|
||||||
|
extern int Sqlitetestrtreedoc_Init(Tcl_Interp*);
|
||||||
extern int Sqlitequota_Init(Tcl_Interp*);
|
extern int Sqlitequota_Init(Tcl_Interp*);
|
||||||
extern int Sqlitemultiplex_Init(Tcl_Interp*);
|
extern int Sqlitemultiplex_Init(Tcl_Interp*);
|
||||||
extern int SqliteSuperlock_Init(Tcl_Interp*);
|
extern int SqliteSuperlock_Init(Tcl_Interp*);
|
||||||
@ -156,6 +157,7 @@ const char *sqlite3TestInit(Tcl_Interp *interp){
|
|||||||
Sqlitetestintarray_Init(interp);
|
Sqlitetestintarray_Init(interp);
|
||||||
Sqlitetestvfs_Init(interp);
|
Sqlitetestvfs_Init(interp);
|
||||||
Sqlitetestrtree_Init(interp);
|
Sqlitetestrtree_Init(interp);
|
||||||
|
Sqlitetestrtreedoc_Init(interp);
|
||||||
Sqlitequota_Init(interp);
|
Sqlitequota_Init(interp);
|
||||||
Sqlitemultiplex_Init(interp);
|
Sqlitemultiplex_Init(interp);
|
||||||
SqliteSuperlock_Init(interp);
|
SqliteSuperlock_Init(interp);
|
||||||
|
Reference in New Issue
Block a user