mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-27 20:41:58 +03:00
When generating sqlite3.h, append the contents of sqlite3rtree.h.
FossilOrigin-Name: fc4d75370bad9021d01b76dbb1b8dde9ff223d2c
This commit is contained in:
@ -185,8 +185,8 @@ struct RtreeConstraint {
|
||||
int iCoord; /* Index of constrained coordinate */
|
||||
int op; /* Constraining operation */
|
||||
double rValue; /* Constraint value. */
|
||||
int (*xGeom)(RtreeGeometry *, int, double *, int *);
|
||||
RtreeGeometry *pGeom; /* Constraint callback argument for a MATCH */
|
||||
int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
|
||||
sqlite3_rtree_geometry *pGeom; /* Constraint callback argument for a MATCH */
|
||||
};
|
||||
|
||||
/* Possible values for RtreeConstraint.op */
|
||||
@ -234,6 +234,11 @@ struct RtreeCell {
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
** Value for the first field of every RtreeGeomBlob object. The MATCH
|
||||
** operator tests that the first field of a blob operand matches this
|
||||
** value to avoid operating on invalid blobs (which could cause a segfault).
|
||||
*/
|
||||
#define RTREE_GEOMETRY_MAGIC 0x891245AB
|
||||
|
||||
/*
|
||||
@ -243,7 +248,7 @@ struct RtreeCell {
|
||||
*/
|
||||
struct RtreeGeomBlob {
|
||||
u32 magic; /* Always RTREE_GEOMETRY_MAGIC */
|
||||
int (*xGeom)(RtreeGeometry *, int, double *, int *);
|
||||
int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
|
||||
void *pContext;
|
||||
int nParam;
|
||||
double aParam[1];
|
||||
@ -745,7 +750,7 @@ static void freeCursorConstraints(RtreeCursor *pCsr){
|
||||
if( pCsr->aConstraint ){
|
||||
int i; /* Used to iterate through constraint array */
|
||||
for(i=0; i<pCsr->nConstraint; i++){
|
||||
RtreeGeometry *pGeom = pCsr->aConstraint[i].pGeom;
|
||||
sqlite3_rtree_geometry *pGeom = pCsr->aConstraint[i].pGeom;
|
||||
if( pGeom ){
|
||||
if( pGeom->xDelUser ) pGeom->xDelUser(pGeom->pUser);
|
||||
sqlite3_free(pGeom);
|
||||
@ -1102,7 +1107,7 @@ static int findLeafNode(Rtree *pRtree, i64 iRowid, RtreeNode **ppLeaf){
|
||||
*/
|
||||
static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
|
||||
RtreeGeomBlob *p;
|
||||
RtreeGeometry *pGeom;
|
||||
sqlite3_rtree_geometry *pGeom;
|
||||
int nBlob;
|
||||
|
||||
/* Check that value is actually a blob. */
|
||||
@ -1116,9 +1121,11 @@ static int deserializeGeometry(sqlite3_value *pValue, RtreeConstraint *pCons){
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
|
||||
pGeom = (RtreeGeometry *)sqlite3_malloc(sizeof(RtreeGeometry) + nBlob);
|
||||
pGeom = (sqlite3_rtree_geometry *)sqlite3_malloc(
|
||||
sizeof(sqlite3_rtree_geometry) + nBlob
|
||||
);
|
||||
if( !pGeom ) return SQLITE_NOMEM;
|
||||
memset(pGeom, 0, sizeof(RtreeGeometry));
|
||||
memset(pGeom, 0, sizeof(sqlite3_rtree_geometry));
|
||||
p = (RtreeGeomBlob *)&pGeom[1];
|
||||
|
||||
memcpy(p, sqlite3_value_blob(pValue), nBlob);
|
||||
@ -3076,16 +3083,30 @@ int sqlite3RtreeInit(sqlite3 *db){
|
||||
return rc;
|
||||
}
|
||||
|
||||
typedef struct GeomCallbackCtx GeomCallbackCtx;
|
||||
struct GeomCallbackCtx {
|
||||
int (*xGeom)(RtreeGeometry *, int, double *, int *);
|
||||
void *pContext;
|
||||
};
|
||||
|
||||
/*
|
||||
** A version of sqlite3_free() that can be used as a callback. This is used
|
||||
** in two places - as the destructor for the blob value returned by the
|
||||
** invocation of a geometry function, and as the destructor for the geometry
|
||||
** functions themselves.
|
||||
*/
|
||||
static void doSqlite3Free(void *p){
|
||||
sqlite3_free(p);
|
||||
}
|
||||
|
||||
typedef struct GeomCallbackCtx GeomCallbackCtx;
|
||||
struct GeomCallbackCtx {
|
||||
int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *);
|
||||
void *pContext;
|
||||
};
|
||||
|
||||
/*
|
||||
** Each call to sqlite3_rtree_geometry_callback() creates an ordinary SQLite
|
||||
** scalar user function. This C function is the callback used for all such
|
||||
** registered SQL functions.
|
||||
**
|
||||
** The scalar user functions return a blob that is interpreted by r-tree
|
||||
** table MATCH operators.
|
||||
*/
|
||||
static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
|
||||
GeomCallbackCtx *pGeomCtx = (GeomCallbackCtx *)sqlite3_user_data(ctx);
|
||||
RtreeGeomBlob *pBlob;
|
||||
@ -3108,10 +3129,13 @@ static void geomCallback(sqlite3_context *ctx, int nArg, sqlite3_value **aArg){
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Register a new geometry function for use with the r-tree MATCH operator.
|
||||
*/
|
||||
int sqlite3_rtree_geometry_callback(
|
||||
sqlite3 *db,
|
||||
const char *zGeom,
|
||||
int (*xGeom)(RtreeGeometry *, int nCoord, double *aCoord, int *piResOut),
|
||||
int (*xGeom)(sqlite3_rtree_geometry *, int, double *, int *),
|
||||
void *pContext
|
||||
){
|
||||
GeomCallbackCtx *pGeomCtx; /* Context object for new user-function */
|
||||
|
@ -1,9 +1,46 @@
|
||||
/*
|
||||
** 2010 August 30
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
*************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef _SQLITE3RTREE_H_
|
||||
#define _SQLITE3RTREE_H_
|
||||
|
||||
#include <sqlite3.h>
|
||||
|
||||
typedef struct RtreeGeometry RtreeGeometry;
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct RtreeGeometry {
|
||||
typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
|
||||
|
||||
/*
|
||||
** Register a geometry callback named zGeom that can be used as part of an
|
||||
** R-Tree geometry query as follows:
|
||||
**
|
||||
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
|
||||
*/
|
||||
int sqlite3_rtree_geometry_callback(
|
||||
sqlite3 *db,
|
||||
const char *zGeom,
|
||||
int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
|
||||
void *pContext
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
** A pointer to a structure of the following type is passed as the first
|
||||
** argument to callbacks registered using rtree_geometry_callback().
|
||||
*/
|
||||
struct sqlite3_rtree_geometry {
|
||||
void *pContext; /* Copy of pContext passed to s_r_g_c() */
|
||||
int nParam; /* Size of array aParam[] */
|
||||
double *aParam; /* Parameters passed to SQL geom function */
|
||||
@ -11,16 +48,9 @@ struct RtreeGeometry {
|
||||
void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */
|
||||
};
|
||||
|
||||
/*
|
||||
** Register a geometry callback named zGeom that can be used as part of an
|
||||
** R-Tree geometry query as follows:
|
||||
**
|
||||
** SELECT ... FROM <rtree> WHERE <rtree> MATCH $zGeom(... params ...)
|
||||
*/
|
||||
int sqlite3_rtree_geometry_callback(
|
||||
sqlite3 *db,
|
||||
const char *zGeom,
|
||||
int (*xGeom)(RtreeGeometry *, int nCoord, double *aCoord, int *piResOut),
|
||||
void *pContext
|
||||
);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end of the 'extern "C"' block */
|
||||
#endif
|
||||
|
||||
#endif /* ifndef _SQLITE3RTREE_H_ */
|
||||
|
18
manifest
18
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sa\sproblem\sin\spagerfault.test\suncovered\sby\sthe\sprevious\schange.
|
||||
D 2010-08-30T16:15:54
|
||||
C When\sgenerating\ssqlite3.h,\sappend\sthe\scontents\sof\ssqlite3rtree.h.
|
||||
D 2010-08-30T18:39:50
|
||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||
F Makefile.in c599a15d268b1db2aeadea19df2adc3bf2eb6bee
|
||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||
@ -78,7 +78,7 @@ F ext/icu/README.txt bf8461d8cdc6b8f514c080e4e10dc3b2bbdfefa9
|
||||
F ext/icu/icu.c 850e9a36567bbcce6bd85a4b68243cad8e3c2de2
|
||||
F ext/icu/sqliteicu.h 728867a802baa5a96de7495e9689a8e01715ef37
|
||||
F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
|
||||
F ext/rtree/rtree.c 2d86907e9b80204530a68f73e1c9368ea87cf603
|
||||
F ext/rtree/rtree.c 556479bc9c32aa80316dc9edd18b8c47c9afaf8d
|
||||
F ext/rtree/rtree.h 834dbcb82dc85b2481cde6a07cdadfddc99e9b9e
|
||||
F ext/rtree/rtree1.test dbd4250ac0ad367a262eb9676f7e3080b0368206
|
||||
F ext/rtree/rtree2.test acbb3a4ce0f4fbc2c304d2b4b784cfa161856bba
|
||||
@ -91,7 +91,7 @@ F ext/rtree/rtree8.test 9772e16da71e17e02bdebf0a5188590f289ab37d
|
||||
F ext/rtree/rtree9.test c3ab7efd3617bc4d3da1d96265fdb8a28e5a3d55
|
||||
F ext/rtree/rtree_perf.tcl 6c18c1f23cd48e0f948930c98dfdd37dfccb5195
|
||||
F ext/rtree/rtree_util.tcl 06aab2ed5b826545bf215fff90ecb9255a8647ea
|
||||
F ext/rtree/sqlite3rtree.h 24ded963afda4658cb25a6df4a26efada6204931
|
||||
F ext/rtree/sqlite3rtree.h 1af0899c63a688e272d69d8e746f24e76f10a3f0
|
||||
F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de
|
||||
F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024
|
||||
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x
|
||||
@ -208,7 +208,7 @@ F src/test_mutex.c ce06b59aca168cd8c520b77159a24352a7469bd3
|
||||
F src/test_onefile.c 40cf9e212a377a6511469384a64b01e6e34b2eec
|
||||
F src/test_osinst.c f408c6a181f2fb04c56273afd5c3e1e82f60392c
|
||||
F src/test_pcache.c 7bf828972ac0d2403f5cfa4cd14da41f8ebe73d8
|
||||
F src/test_rtree.c a65ca2727c4421f88745dbcc1589ed57276cbb29
|
||||
F src/test_rtree.c 85b550f364c3694e6844bc5d41829d9c1f354e17
|
||||
F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0
|
||||
F src/test_server.c bbba05c144b5fc4b52ff650a4328027b3fa5fcc6
|
||||
F src/test_stat.c f682704b5d1ba8e1d4e7e882a6d7922e2dcf066c
|
||||
@ -829,7 +829,7 @@ F tool/mkkeywordhash.c d2e6b4a5965e23afb80fbe74bb54648cd371f309
|
||||
F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e
|
||||
F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97
|
||||
F tool/mksqlite3c.tcl aff0d53f0e84cf919922c0d02e767bdf5eeafb90
|
||||
F tool/mksqlite3h.tcl eb100dce83f24b501b325b340f8b5eb8e5106b3b
|
||||
F tool/mksqlite3h.tcl 03b6ca938c833814923674d8a160e91fcedb4571
|
||||
F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87
|
||||
F tool/omittest.tcl 27d6f6e3b1e95aeb26a1c140e6eb57771c6d794a
|
||||
F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c
|
||||
@ -851,7 +851,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P b06f4695bdab244d9c764c082cd434a764dc5c29
|
||||
R 16a673223830391e795f1e030294703e
|
||||
P b6719ce32892a38b9b3dff07decdd6e94c01b3e2
|
||||
R e20fba69bef0c45289549a99445b5f1f
|
||||
U dan
|
||||
Z aed5b848a613ada0c01dcbcb20c02b7d
|
||||
Z 95b89ac5a9e9b52985b26a8b5f89fc31
|
||||
|
@ -1 +1 @@
|
||||
b6719ce32892a38b9b3dff07decdd6e94c01b3e2
|
||||
fc4d75370bad9021d01b76dbb1b8dde9ff223d2c
|
@ -48,7 +48,7 @@ static int gHere = 42;
|
||||
** The width, height and depth parameters must all be greater than zero.
|
||||
*/
|
||||
static int cube_geom(
|
||||
RtreeGeometry *p,
|
||||
sqlite3_rtree_geometry *p,
|
||||
int nCoord,
|
||||
double *aCoord,
|
||||
int *piRes
|
||||
|
@ -65,32 +65,39 @@ close $in
|
||||
set varpattern {^[a-zA-Z][a-zA-Z_0-9 *]+sqlite3_[_a-zA-Z0-9]+(\[|;| =)}
|
||||
set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(}
|
||||
|
||||
# Process the src/sqlite.h.in file.
|
||||
# Process the src/sqlite.h.in ext/rtree/sqlite3rtree.h files.
|
||||
#
|
||||
set in [open $TOP/src/sqlite.h.in]
|
||||
while {![eof $in]} {
|
||||
foreach file [list $TOP/src/sqlite.h.in $TOP/ext/rtree/sqlite3rtree.h] {
|
||||
set in [open $file]
|
||||
while {![eof $in]} {
|
||||
|
||||
set line [gets $in]
|
||||
|
||||
set line [gets $in]
|
||||
|
||||
regsub -- --VERS-- $line $zVersion line
|
||||
regsub -- --VERSION-NUMBER-- $line $nVersion line
|
||||
regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line
|
||||
|
||||
if {[regexp {define SQLITE_EXTERN extern} $line]} {
|
||||
# File sqlite3rtree.h contains a line "#include <sqlite3.h>". Omit this
|
||||
# line when copying sqlite3rtree.h into sqlite3.h.
|
||||
#
|
||||
if {[string match {*#include*<sqlite3.h>*} $line]} continue
|
||||
|
||||
regsub -- --VERS-- $line $zVersion line
|
||||
regsub -- --VERSION-NUMBER-- $line $nVersion line
|
||||
regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line
|
||||
|
||||
if {[regexp {define SQLITE_EXTERN extern} $line]} {
|
||||
puts $line
|
||||
puts [gets $in]
|
||||
puts ""
|
||||
puts "#ifndef SQLITE_API"
|
||||
puts "# define SQLITE_API"
|
||||
puts "#endif"
|
||||
set line ""
|
||||
}
|
||||
|
||||
if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line])
|
||||
|| ([regexp $declpattern $line])
|
||||
} {
|
||||
set line "SQLITE_API $line"
|
||||
}
|
||||
puts $line
|
||||
puts [gets $in]
|
||||
puts ""
|
||||
puts "#ifndef SQLITE_API"
|
||||
puts "# define SQLITE_API"
|
||||
puts "#endif"
|
||||
set line ""
|
||||
}
|
||||
|
||||
if {([regexp $varpattern $line] && ![regexp {^ *typedef} $line])
|
||||
|| ([regexp $declpattern $line])
|
||||
} {
|
||||
set line "SQLITE_API $line"
|
||||
}
|
||||
puts $line
|
||||
close $in
|
||||
}
|
||||
close $in
|
||||
|
Reference in New Issue
Block a user