aboutsummaryrefslogtreecommitdiff
path: root/ext/rtree
diff options
context:
space:
mode:
Diffstat (limited to 'ext/rtree')
-rw-r--r--ext/rtree/rtree.c12
-rw-r--r--ext/rtree/rtreeH.test19
2 files changed, 29 insertions, 2 deletions
diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c
index 5e9fa6996..fb35bc10e 100644
--- a/ext/rtree/rtree.c
+++ b/ext/rtree/rtree.c
@@ -64,6 +64,8 @@
#endif
int sqlite3GetToken(const unsigned char*,int*); /* In the SQLite core */
+#include <stddef.h>
+
/*
** If building separately, we will need some setup that is normally
** found in sqliteInt.h
@@ -95,7 +97,7 @@ typedef unsigned int u32;
# define NEVER(X) (X)
#endif
#ifndef offsetof
-#define offsetof(STRUCTURE,FIELD) ((size_t)((char*)&((STRUCTURE*)0)->FIELD))
+# define offsetof(ST,M) ((size_t)((char*)&((ST*)0)->M - (char*)0))
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
# define FLEXARRAY
@@ -1133,6 +1135,12 @@ static void resetCursor(RtreeCursor *pCsr){
pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
pCsr->pReadAux = pStmt;
+ /* The following will only fail if the previous sqlite3_step() call failed,
+ ** in which case the error has already been caught. This statement never
+ ** encounters an error within an sqlite3_column_xxx() function, as it
+ ** calls sqlite3_column_value(), which does not use malloc(). So it is safe
+ ** to ignore the error code here. */
+ sqlite3_reset(pStmt);
}
/*
@@ -2848,7 +2856,7 @@ static int deleteCell(Rtree *pRtree, RtreeNode *pNode, int iCell, int iHeight){
return rc;
}
-
+
/*
** Insert cell pCell into node pNode. Node pNode is the head of a
** subtree iHeight high (leaf nodes have iHeight==0).
diff --git a/ext/rtree/rtreeH.test b/ext/rtree/rtreeH.test
index e26107f07..79bf9808d 100644
--- a/ext/rtree/rtreeH.test
+++ b/ext/rtree/rtreeH.test
@@ -99,5 +99,24 @@ do_execsql_test rtreeH-300 {
ORDER BY id;
} {box-48,48 box-49,48 box-48,49 xbox-49,49}
+#-------------------------------------------------------------------------
+reset_db
+do_execsql_test rtreeH-300 {
+ CREATE TABLE t0(c0);
+ INSERT INTO t0(c0) VALUES (NULL);
+ INSERT INTO t0(c0) VALUES (1);
+ CREATE VIRTUAL TABLE t1 USING rtree(c0, c1, c2, +c3 BLOB );
+ INSERT INTO t1(c2, c3, c0) VALUES (1, 2, 1);
+}
+
+do_execsql_test rtreeH-310 {
+ SELECT 1 FROM t1 WHERE t1.c3;
+} {1}
+
+do_execsql_test rtreeH-320 {
+ SELECT * FROM t0 WHERE NOT EXISTS (
+ SELECT 1 FROM t1 WHERE t1.c3 OR t0.c0 ISNULL
+ );
+} {}
finish_test