summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2012-04-14 13:13:20 +0000
committerMarc Espie <espie@cvs.openbsd.org>2012-04-14 13:13:20 +0000
commitcb5c37711f2a4e64ac2d4f12b5e940d6fa52c2b1 (patch)
tree481abdd69b64d30a35befa1005a2b936d028b942 /lib
parentccb1729af9a0244b0675ddd18c8012128858db5d (diff)
sqlite 3.7.11 library, vendor sources
Diffstat (limited to 'lib')
-rw-r--r--lib/libsqlite3/ext/async/sqlite3async.c3
-rw-r--r--lib/libsqlite3/ext/rtree/rtree1.test130
-rw-r--r--lib/libsqlite3/src/btree.h58
-rw-r--r--lib/libsqlite3/src/test_func.c201
-rw-r--r--lib/libsqlite3/src/vdbeblob.c104
-rw-r--r--lib/libsqlite3/src/walker.c36
-rw-r--r--lib/libsqlite3/tool/mksqlite3h.tcl54
7 files changed, 136 insertions, 450 deletions
diff --git a/lib/libsqlite3/ext/async/sqlite3async.c b/lib/libsqlite3/ext/async/sqlite3async.c
index 9810c56f5a6..b2bb85d7a16 100644
--- a/lib/libsqlite3/ext/async/sqlite3async.c
+++ b/lib/libsqlite3/ext/async/sqlite3async.c
@@ -10,7 +10,7 @@
**
*************************************************************************
**
-** $Id: sqlite3async.c,v 1.1.1.2 2013/03/18 10:45:29 espie Exp $
+** $Id: sqlite3async.c,v 1.1 2012/04/14 13:13:18 espie Exp $
**
** This file contains the implementation of an asynchronous IO backend
** for SQLite.
@@ -1510,7 +1510,6 @@ static void asyncWriterThread(void){
case ASYNC_DELETE:
ASYNC_TRACE(("DELETE %s\n", p->zBuf));
rc = pVfs->xDelete(pVfs, p->zBuf, (int)p->iOffset);
- if( rc==SQLITE_IOERR_DELETE_NOENT ) rc = SQLITE_OK;
break;
case ASYNC_OPENEXCLUSIVE: {
diff --git a/lib/libsqlite3/ext/rtree/rtree1.test b/lib/libsqlite3/ext/rtree/rtree1.test
index 0beb16cc949..583b0285076 100644
--- a/lib/libsqlite3/ext/rtree/rtree1.test
+++ b/lib/libsqlite3/ext/rtree/rtree1.test
@@ -17,7 +17,6 @@ if {![info exists testdir]} {
}
source [file join [file dirname [info script]] rtree_util.tcl]
source $testdir/tester.tcl
-set testprefix rtree1
# Test plan:
#
@@ -33,7 +32,6 @@ set testprefix rtree1
# rtree-8.*: Test constrained scans of r-tree data.
#
# rtree-12.*: Test that on-conflict clauses are supported.
-# rtree-13.*: Test that bug [d2889096e7bdeac6d] has been fixed.
#
ifcapable !rtree {
@@ -106,34 +104,21 @@ for {set nCol 1} {$nCol<[llength $cols]} {incr nCol} {
catchsql { DROP TABLE t1 }
}
-# Like execsql except display output as integer where that can be
-# done without loss of information.
-#
-proc execsql_intout {sql} {
- set out {}
- foreach term [execsql $sql] {
- regsub {\.0$} $term {} term
- lappend out $term
- }
- return $out
-}
-
# Test that it is possible to open an existing database that contains
# r-tree tables.
#
-do_execsql_test rtree-1.4.1a {
- CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2);
- INSERT INTO t1 VALUES(1, 5.0, 10.0);
- SELECT substr(hex(data),1,40) FROM t1_node;
-} {00000001000000000000000140A0000041200000}
-do_execsql_test rtree-1.4.1b {
- INSERT INTO t1 VALUES(2, 15.0, 20.0);
+do_test rtree-1.4.1 {
+ execsql {
+ CREATE VIRTUAL TABLE t1 USING rtree(ii, x1, x2);
+ INSERT INTO t1 VALUES(1, 5.0, 10.0);
+ INSERT INTO t1 VALUES(2, 15.0, 20.0);
+ }
} {}
do_test rtree-1.4.2 {
db close
sqlite3 db test.db
- execsql_intout { SELECT * FROM t1 ORDER BY ii }
-} {1 5 10 2 15 20}
+ execsql { SELECT * FROM t1 ORDER BY ii }
+} {1 5.0 10.0 2 15.0 20.0}
do_test rtree-1.4.3 {
execsql { DROP TABLE t1 }
} {}
@@ -142,12 +127,12 @@ do_test rtree-1.4.3 {
# column names.
#
do_test rtree-1.5.1 {
- execsql_intout {
+ execsql {
CREATE VIRTUAL TABLE t1 USING rtree("the key", "x dim.", "x2'dim");
INSERT INTO t1 VALUES(1, 2, 3);
SELECT "the key", "x dim.", "x2'dim" FROM t1;
}
-} {1 2 3}
+} {1 2.0 3.0}
do_test rtree-1.5.1 {
execsql { DROP TABLE t1 }
} {}
@@ -176,8 +161,8 @@ do_test rtree-2.1.1 {
do_test rtree-2.1.2 {
execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }
- execsql_intout { SELECT * FROM t1 }
-} {1 1 3 2 4}
+ execsql { SELECT * FROM t1 }
+} {1 1.0 3.0 2.0 4.0}
do_test rtree-2.1.3 {
execsql { INSERT INTO t1 VALUES(NULL, 1, 3, 2, 4) }
execsql { SELECT rowid FROM t1 ORDER BY rowid }
@@ -216,17 +201,17 @@ do_test rtree-3.1.1 {
}
} {}
do_test rtree-3.1.2 {
- execsql_intout {
+ execsql {
INSERT INTO t1 VALUES(5, 1, 3, 2, 4);
SELECT * FROM t1;
}
-} {5 1 3 2 4}
+} {5 1.0 3.0 2.0 4.0}
do_test rtree-3.1.3 {
- execsql_intout {
+ execsql {
INSERT INTO t1 VALUES(6, 2, 6, 4, 8);
SELECT * FROM t1;
}
-} {5 1 3 2 4 6 2 6 4 8}
+} {5 1.0 3.0 2.0 4.0 6 2.0 6.0 4.0 8.0}
# Test the constraint on the coordinates (c[i]<=c[i+1] where (i%2==0)):
do_test rtree-3.2.1 {
@@ -243,25 +228,25 @@ do_test rtree-5.1.1 {
execsql { CREATE VIRTUAL TABLE t2 USING rtree(ii, x1, x2) }
} {}
do_test rtree-5.1.2 {
- execsql_intout {
+ execsql {
INSERT INTO t2 VALUES(1, 10, 20);
INSERT INTO t2 VALUES(2, 30, 40);
INSERT INTO t2 VALUES(3, 50, 60);
SELECT * FROM t2 ORDER BY ii;
}
-} {1 10 20 2 30 40 3 50 60}
+} {1 10.0 20.0 2 30.0 40.0 3 50.0 60.0}
do_test rtree-5.1.3 {
- execsql_intout {
+ execsql {
DELETE FROM t2 WHERE ii=2;
SELECT * FROM t2 ORDER BY ii;
}
-} {1 10 20 3 50 60}
+} {1 10.0 20.0 3 50.0 60.0}
do_test rtree-5.1.4 {
- execsql_intout {
+ execsql {
DELETE FROM t2 WHERE ii=1;
SELECT * FROM t2 ORDER BY ii;
}
-} {3 50 60}
+} {3 50.0 60.0}
do_test rtree-5.1.5 {
execsql {
DELETE FROM t2 WHERE ii=3;
@@ -279,16 +264,16 @@ do_test rtree-6.1.1 {
execsql { CREATE VIRTUAL TABLE t3 USING rtree(ii, x1, x2, y1, y2) }
} {}
do_test rtree-6.1.2 {
- execsql_intout {
+ execsql {
INSERT INTO t3 VALUES(1, 2, 3, 4, 5);
UPDATE t3 SET x2=5;
SELECT * FROM t3;
}
-} {1 2 5 4 5}
+} {1 2.0 5.0 4.0 5.0}
do_test rtree-6.1.3 {
execsql { UPDATE t3 SET ii = 2 }
- execsql_intout { SELECT * FROM t3 }
-} {2 2 5 4 5}
+ execsql { SELECT * FROM t3 }
+} {2 2.0 5.0 4.0 5.0}
#----------------------------------------------------------------------------
# Test cases rtree-7.* test rename operations.
@@ -301,29 +286,29 @@ do_test rtree-7.1.1 {
} {}
do_test rtree-7.1.2 {
execsql { ALTER TABLE t4 RENAME TO t5 }
- execsql_intout { SELECT * FROM t5 }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM t5 }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.1.3 {
db close
sqlite3 db test.db
- execsql_intout { SELECT * FROM t5 }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM t5 }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.1.4 {
execsql { ALTER TABLE t5 RENAME TO 'raisara "one"'''}
- execsql_intout { SELECT * FROM "raisara ""one""'" }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM "raisara ""one""'" }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.1.5 {
- execsql_intout { SELECT * FROM 'raisara "one"''' }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM 'raisara "one"''' }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.1.6 {
execsql { ALTER TABLE "raisara ""one""'" RENAME TO "abc 123" }
- execsql_intout { SELECT * FROM "abc 123" }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM "abc 123" }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.1.7 {
db close
sqlite3 db test.db
- execsql_intout { SELECT * FROM "abc 123" }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM "abc 123" }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
# An error midway through a rename operation.
do_test rtree-7.2.1 {
@@ -333,8 +318,8 @@ do_test rtree-7.2.1 {
catchsql { ALTER TABLE "abc 123" RENAME TO t4 }
} {1 {SQL logic error or missing database}}
do_test rtree-7.2.2 {
- execsql_intout { SELECT * FROM "abc 123" }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM "abc 123" }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.2.3 {
execsql {
DROP TABLE t4_node;
@@ -345,13 +330,13 @@ do_test rtree-7.2.3 {
do_test rtree-7.2.4 {
db close
sqlite3 db test.db
- execsql_intout { SELECT * FROM "abc 123" }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM "abc 123" }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
do_test rtree-7.2.5 {
execsql { DROP TABLE t4_rowid }
execsql { ALTER TABLE "abc 123" RENAME TO t4 }
- execsql_intout { SELECT * FROM t4 }
-} {1 2 3 4 5 6 7}
+ execsql { SELECT * FROM t4 }
+} {1 2.0 3.0 4.0 5.0 6.0 7.0}
#----------------------------------------------------------------------------
@@ -437,18 +422,16 @@ do_test rtree-11.2 {
# Test on-conflict clause handling.
#
db_delete_and_reopen
-do_execsql_test 12.0.1 {
+do_execsql_test 12.0 {
CREATE VIRTUAL TABLE t1 USING rtree_i32(idx, x1, x2, y1, y2);
INSERT INTO t1 VALUES(1, 1, 2, 3, 4);
- SELECT substr(hex(data),1,56) FROM t1_node;
-} {00000001000000000000000100000001000000020000000300000004}
-do_execsql_test 12.0.2 {
INSERT INTO t1 VALUES(2, 2, 3, 4, 5);
INSERT INTO t1 VALUES(3, 3, 4, 5, 6);
CREATE TABLE source(idx, x1, x2, y1, y2);
INSERT INTO source VALUES(5, 8, 8, 8, 8);
INSERT INTO source VALUES(2, 7, 7, 7, 7);
+
}
db_save_and_close
foreach {tn sql_template testdata} {
@@ -514,25 +497,4 @@ foreach {tn sql_template testdata} {
db close
}
}
-
-#-------------------------------------------------------------------------
-# Test that bug [d2889096e7bdeac6d] has been fixed.
-#
-reset_db
-do_execsql_test 13.1 {
- CREATE VIRTUAL TABLE t9 USING rtree(id, xmin, xmax);
- INSERT INTO t9 VALUES(1,0,0);
- INSERT INTO t9 VALUES(2,0,0);
- SELECT * FROM t9 WHERE id IN (1, 2);
-} {1 0.0 0.0 2 0.0 0.0}
-
-do_execsql_test 13.2 {
- WITH r(x) AS (
- SELECT 1 UNION ALL
- SELECT 2 UNION ALL
- SELECT 3
- )
- SELECT * FROM r CROSS JOIN t9 WHERE id=x;
-} {1 1 0.0 0.0 2 2 0.0 0.0}
-
finish_test
diff --git a/lib/libsqlite3/src/btree.h b/lib/libsqlite3/src/btree.h
index 3edc2b3b577..9832001b7f7 100644
--- a/lib/libsqlite3/src/btree.h
+++ b/lib/libsqlite3/src/btree.h
@@ -19,7 +19,7 @@
/* TODO: This definition is just included so other modules compile. It
** needs to be revisited.
*/
-#define SQLITE_N_BTREE_META 16
+#define SQLITE_N_BTREE_META 10
/*
** If defined as non-zero, auto-vacuum is enabled by default. Otherwise
@@ -63,25 +63,21 @@ int sqlite3BtreeOpen(
int sqlite3BtreeClose(Btree*);
int sqlite3BtreeSetCacheSize(Btree*,int);
-#if SQLITE_MAX_MMAP_SIZE>0
- int sqlite3BtreeSetMmapLimit(Btree*,sqlite3_int64);
-#endif
-int sqlite3BtreeSetPagerFlags(Btree*,unsigned);
+int sqlite3BtreeSetSafetyLevel(Btree*,int,int,int);
int sqlite3BtreeSyncDisabled(Btree*);
int sqlite3BtreeSetPageSize(Btree *p, int nPagesize, int nReserve, int eFix);
int sqlite3BtreeGetPageSize(Btree*);
int sqlite3BtreeMaxPageCount(Btree*,int);
u32 sqlite3BtreeLastPage(Btree*);
int sqlite3BtreeSecureDelete(Btree*,int);
-int sqlite3BtreeGetOptimalReserve(Btree*);
-int sqlite3BtreeGetReserveNoMutex(Btree *p);
+int sqlite3BtreeGetReserve(Btree*);
int sqlite3BtreeSetAutoVacuum(Btree *, int);
int sqlite3BtreeGetAutoVacuum(Btree *);
int sqlite3BtreeBeginTrans(Btree*,int);
int sqlite3BtreeCommitPhaseOne(Btree*, const char *zMaster);
int sqlite3BtreeCommitPhaseTwo(Btree*, int);
int sqlite3BtreeCommit(Btree*);
-int sqlite3BtreeRollback(Btree*,int,int);
+int sqlite3BtreeRollback(Btree*,int);
int sqlite3BtreeBeginStmt(Btree*,int);
int sqlite3BtreeCreateTable(Btree*, int*, int flags);
int sqlite3BtreeIsInTrans(Btree*);
@@ -113,14 +109,11 @@ int sqlite3BtreeIncrVacuum(Btree *);
int sqlite3BtreeDropTable(Btree*, int, int*);
int sqlite3BtreeClearTable(Btree*, int, int*);
-int sqlite3BtreeClearTableOfCursor(BtCursor*);
-int sqlite3BtreeTripAllCursors(Btree*, int, int);
+void sqlite3BtreeTripAllCursors(Btree*, int);
void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
-int sqlite3BtreeNewDb(Btree *p);
-
/*
** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
** should be one of the following values. The integer values are assigned
@@ -132,11 +125,6 @@ int sqlite3BtreeNewDb(Btree *p);
** For example, the free-page-count field is located at byte offset 36 of
** the database file header. The incr-vacuum-flag field is located at
** byte offset 64 (== 36+4*7).
-**
-** The BTREE_DATA_VERSION value is not really a value stored in the header.
-** It is a read-only number computed by the pager. But we merge it with
-** the header value access routines since its access pattern is the same.
-** Call it a "virtual meta value".
*/
#define BTREE_FREE_PAGE_COUNT 0
#define BTREE_SCHEMA_VERSION 1
@@ -146,24 +134,6 @@ int sqlite3BtreeNewDb(Btree *p);
#define BTREE_TEXT_ENCODING 5
#define BTREE_USER_VERSION 6
#define BTREE_INCR_VACUUM 7
-#define BTREE_APPLICATION_ID 8
-#define BTREE_DATA_VERSION 15 /* A virtual meta-value */
-
-/*
-** Values that may be OR'd together to form the second argument of an
-** sqlite3BtreeCursorHints() call.
-**
-** The BTREE_BULKLOAD flag is set on index cursors when the index is going
-** to be filled with content that is already in sorted order.
-**
-** The BTREE_SEEK_EQ flag is set on cursors that will get OP_SeekGE or
-** OP_SeekLE opcodes for a range search, but where the range of entries
-** selected will all have the same key. In other words, the cursor will
-** be used only for equality key searches.
-**
-*/
-#define BTREE_BULKLOAD 0x00000001 /* Used to full index in sorted order */
-#define BTREE_SEEK_EQ 0x00000002 /* EQ seeks only - no range seeks */
int sqlite3BtreeCursor(
Btree*, /* BTree containing table to open */
@@ -183,8 +153,7 @@ int sqlite3BtreeMovetoUnpacked(
int bias,
int *pRes
);
-int sqlite3BtreeCursorHasMoved(BtCursor*);
-int sqlite3BtreeCursorRestore(BtCursor*, int*);
+int sqlite3BtreeCursorHasMoved(BtCursor*, int*);
int sqlite3BtreeDelete(BtCursor*);
int sqlite3BtreeInsert(BtCursor*, const void *pKey, i64 nKey,
const void *pData, int nData,
@@ -196,24 +165,21 @@ int sqlite3BtreeEof(BtCursor*);
int sqlite3BtreePrevious(BtCursor*, int *pRes);
int sqlite3BtreeKeySize(BtCursor*, i64 *pSize);
int sqlite3BtreeKey(BtCursor*, u32 offset, u32 amt, void*);
-const void *sqlite3BtreeKeyFetch(BtCursor*, u32 *pAmt);
-const void *sqlite3BtreeDataFetch(BtCursor*, u32 *pAmt);
+const void *sqlite3BtreeKeyFetch(BtCursor*, int *pAmt);
+const void *sqlite3BtreeDataFetch(BtCursor*, int *pAmt);
int sqlite3BtreeDataSize(BtCursor*, u32 *pSize);
int sqlite3BtreeData(BtCursor*, u32 offset, u32 amt, void*);
+void sqlite3BtreeSetCachedRowid(BtCursor*, sqlite3_int64);
+sqlite3_int64 sqlite3BtreeGetCachedRowid(BtCursor*);
char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
struct Pager *sqlite3BtreePager(Btree*);
int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*);
-void sqlite3BtreeIncrblobCursor(BtCursor *);
+void sqlite3BtreeCacheOverflow(BtCursor *);
void sqlite3BtreeClearCursor(BtCursor *);
+
int sqlite3BtreeSetVersion(Btree *pBt, int iVersion);
-void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask);
-#ifdef SQLITE_DEBUG
-int sqlite3BtreeCursorHasHint(BtCursor*, unsigned int mask);
-#endif
-int sqlite3BtreeIsReadonly(Btree *pBt);
-int sqlite3HeaderSizeBtree(void);
#ifndef NDEBUG
int sqlite3BtreeCursorIsValid(BtCursor*);
diff --git a/lib/libsqlite3/src/test_func.c b/lib/libsqlite3/src/test_func.c
index 2e34fa074ef..fff070e7eec 100644
--- a/lib/libsqlite3/src/test_func.c
+++ b/lib/libsqlite3/src/test_func.c
@@ -18,9 +18,6 @@
#include <string.h>
#include <assert.h>
-#include "sqliteInt.h"
-#include "vdbeInt.h"
-
/*
** Allocate nByte bytes of space using sqlite3_malloc(). If the
@@ -205,7 +202,7 @@ static void test_auxdata(
}else {
zRet[i*2] = '0';
}
- n = (int)strlen(z) + 1;
+ n = strlen(z) + 1;
zAux = testContextMalloc(pCtx, n);
if( zAux ){
memcpy(zAux, z, n);
@@ -425,201 +422,11 @@ static void testHexToUtf16le(
}
#endif
-/*
-** SQL function: real2hex(X)
-**
-** If argument X is a real number, then convert it into a string which is
-** the big-endian hexadecimal representation of the ieee754 encoding of
-** that number. If X is not a real number, return NULL.
-*/
-static void real2hex(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- union {
- sqlite3_uint64 i;
- double r;
- unsigned char x[8];
- } v;
- char zOut[20];
- int i;
- int bigEndian;
- v.i = 1;
- bigEndian = v.x[0]==0;
- v.r = sqlite3_value_double(argv[0]);
- for(i=0; i<8; i++){
- if( bigEndian ){
- zOut[i*2] = "0123456789abcdef"[v.x[i]>>4];
- zOut[i*2+1] = "0123456789abcdef"[v.x[i]&0xf];
- }else{
- zOut[14-i*2] = "0123456789abcdef"[v.x[i]>>4];
- zOut[14-i*2+1] = "0123456789abcdef"[v.x[i]&0xf];
- }
- }
- zOut[16] = 0;
- sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT);
-}
-
-/*
-** tclcmd: test_extract(record, field)
-**
-** This function implements an SQL user-function that accepts a blob
-** containing a formatted database record as the first argument. The
-** second argument is the index of the field within that record to
-** extract and return.
-*/
-static void test_extract(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- sqlite3 *db = sqlite3_context_db_handle(context);
- u8 *pRec;
- u8 *pEndHdr; /* Points to one byte past record header */
- u8 *pHdr; /* Current point in record header */
- u8 *pBody; /* Current point in record data */
- u64 nHdr; /* Bytes in record header */
- int iIdx; /* Required field */
- int iCurrent = 0; /* Current field */
-
- assert( argc==2 );
- pRec = (u8*)sqlite3_value_blob(argv[0]);
- iIdx = sqlite3_value_int(argv[1]);
-
- pHdr = pRec + sqlite3GetVarint(pRec, &nHdr);
- pBody = pEndHdr = &pRec[nHdr];
-
- for(iCurrent=0; pHdr<pEndHdr && iCurrent<=iIdx; iCurrent++){
- u64 iSerialType;
- Mem mem;
-
- memset(&mem, 0, sizeof(mem));
- mem.db = db;
- mem.enc = ENC(db);
- pHdr += sqlite3GetVarint(pHdr, &iSerialType);
- pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
-
- if( iCurrent==iIdx ){
- sqlite3_result_value(context, &mem);
- }
-
- if( mem.szMalloc ) sqlite3DbFree(db, mem.zMalloc);
- }
-}
-
-/*
-** tclcmd: test_decode(record)
-**
-** This function implements an SQL user-function that accepts a blob
-** containing a formatted database record as its only argument. It returns
-** a tcl list (type SQLITE_TEXT) containing each of the values stored
-** in the record.
-*/
-static void test_decode(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- sqlite3 *db = sqlite3_context_db_handle(context);
- u8 *pRec;
- u8 *pEndHdr; /* Points to one byte past record header */
- u8 *pHdr; /* Current point in record header */
- u8 *pBody; /* Current point in record data */
- u64 nHdr; /* Bytes in record header */
- Tcl_Obj *pRet; /* Return value */
-
- pRet = Tcl_NewObj();
- Tcl_IncrRefCount(pRet);
-
- assert( argc==1 );
- pRec = (u8*)sqlite3_value_blob(argv[0]);
-
- pHdr = pRec + sqlite3GetVarint(pRec, &nHdr);
- pBody = pEndHdr = &pRec[nHdr];
- while( pHdr<pEndHdr ){
- Tcl_Obj *pVal = 0;
- u64 iSerialType;
- Mem mem;
-
- memset(&mem, 0, sizeof(mem));
- mem.db = db;
- mem.enc = ENC(db);
- pHdr += sqlite3GetVarint(pHdr, &iSerialType);
- pBody += sqlite3VdbeSerialGet(pBody, (u32)iSerialType, &mem);
-
- switch( sqlite3_value_type(&mem) ){
- case SQLITE_TEXT:
- pVal = Tcl_NewStringObj((const char*)sqlite3_value_text(&mem), -1);
- break;
-
- case SQLITE_BLOB: {
- char hexdigit[] = {
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
- };
- int n = sqlite3_value_bytes(&mem);
- u8 *z = (u8*)sqlite3_value_blob(&mem);
- int i;
- pVal = Tcl_NewStringObj("x'", -1);
- for(i=0; i<n; i++){
- char hex[3];
- hex[0] = hexdigit[((z[i] >> 4) & 0x0F)];
- hex[1] = hexdigit[(z[i] & 0x0F)];
- hex[2] = '\0';
- Tcl_AppendStringsToObj(pVal, hex, 0);
- }
- Tcl_AppendStringsToObj(pVal, "'", 0);
- break;
- }
-
- case SQLITE_FLOAT:
- pVal = Tcl_NewDoubleObj(sqlite3_value_double(&mem));
- break;
-
- case SQLITE_INTEGER:
- pVal = Tcl_NewWideIntObj(sqlite3_value_int64(&mem));
- break;
-
- case SQLITE_NULL:
- pVal = Tcl_NewStringObj("NULL", -1);
- break;
-
- default:
- assert( 0 );
- }
-
- Tcl_ListObjAppendElement(0, pRet, pVal);
-
- if( mem.szMalloc ){
- sqlite3DbFree(db, mem.zMalloc);
- }
- }
-
- sqlite3_result_text(context, Tcl_GetString(pRet), -1, SQLITE_TRANSIENT);
- Tcl_DecrRefCount(pRet);
-}
-
-/*
-** The implementation of scalar SQL function "test_zeroblob()". This is
-** similar to the built-in zeroblob() function, except that it does not
-** check that the integer parameter is within range before passing it
-** to sqlite3_result_zeroblob().
-*/
-static void test_zeroblob(
- sqlite3_context *context,
- int argc,
- sqlite3_value **argv
-){
- int nZero = sqlite3_value_int(argv[0]);
- sqlite3_result_zeroblob(context, nZero);
-}
-
static int registerTestFunctions(sqlite3 *db){
static const struct {
char *zName;
signed char nArg;
- unsigned int eTextRep; /* 1: UTF-16. 0: UTF-8 */
+ unsigned char eTextRep; /* 1: UTF-16. 0: UTF-8 */
void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
} aFuncs[] = {
{ "randstr", 2, SQLITE_UTF8, randStr },
@@ -637,10 +444,6 @@ static int registerTestFunctions(sqlite3 *db){
{ "test_eval", 1, SQLITE_UTF8, test_eval},
{ "test_isolation", 2, SQLITE_UTF8, test_isolation},
{ "test_counter", 1, SQLITE_UTF8, counterFunc},
- { "real2hex", 1, SQLITE_UTF8, real2hex},
- { "test_decode", 1, SQLITE_UTF8, test_decode},
- { "test_extract", 2, SQLITE_UTF8, test_extract},
- { "test_zeroblob", 1, SQLITE_UTF8|SQLITE_DETERMINISTIC, test_zeroblob},
};
int i;
diff --git a/lib/libsqlite3/src/vdbeblob.c b/lib/libsqlite3/src/vdbeblob.c
index ea01f5ce80c..ae77a47ba36 100644
--- a/lib/libsqlite3/src/vdbeblob.c
+++ b/lib/libsqlite3/src/vdbeblob.c
@@ -64,8 +64,7 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
rc = sqlite3_step(p->pStmt);
if( rc==SQLITE_ROW ){
- VdbeCursor *pC = v->apCsr[0];
- u32 type = pC->aType[p->iCol];
+ u32 type = v->apCsr[0]->aType[p->iCol];
if( type<12 ){
zErr = sqlite3MPrintf(p->db, "cannot open value of type %s",
type==0?"null": type==7?"real": "integer"
@@ -74,10 +73,12 @@ static int blobSeekToRow(Incrblob *p, sqlite3_int64 iRow, char **pzErr){
sqlite3_finalize(p->pStmt);
p->pStmt = 0;
}else{
- p->iOffset = pC->aType[p->iCol + pC->nField];
+ p->iOffset = v->apCsr[0]->aOffset[p->iCol];
p->nByte = sqlite3VdbeSerialTypeLen(type);
- p->pCsr = pC->pCursor;
- sqlite3BtreeIncrblobCursor(p->pCsr);
+ p->pCsr = v->apCsr[0]->pCursor;
+ sqlite3BtreeEnterCursor(p->pCsr);
+ sqlite3BtreeCacheOverflow(p->pCsr);
+ sqlite3BtreeLeaveCursor(p->pCsr);
}
}
@@ -131,20 +132,22 @@ int sqlite3_blob_open(
** which closes the b-tree cursor and (possibly) commits the
** transaction.
*/
- static const int iLn = VDBE_OFFSET_LINENO(4);
static const VdbeOpList openBlob[] = {
- /* {OP_Transaction, 0, 0, 0}, // 0: Inserted separately */
- {OP_TableLock, 0, 0, 0}, /* 1: Acquire a read or write lock */
+ {OP_Transaction, 0, 0, 0}, /* 0: Start a transaction */
+ {OP_VerifyCookie, 0, 0, 0}, /* 1: Check the schema cookie */
+ {OP_TableLock, 0, 0, 0}, /* 2: Acquire a read or write lock */
+
/* One of the following two instructions is replaced by an OP_Noop. */
- {OP_OpenRead, 0, 0, 0}, /* 2: Open cursor 0 for reading */
- {OP_OpenWrite, 0, 0, 0}, /* 3: Open cursor 0 for read/write */
- {OP_Variable, 1, 1, 1}, /* 4: Push the rowid to the stack */
- {OP_NotExists, 0, 10, 1}, /* 5: Seek the cursor */
- {OP_Column, 0, 0, 1}, /* 6 */
- {OP_ResultRow, 1, 0, 0}, /* 7 */
- {OP_Goto, 0, 4, 0}, /* 8 */
- {OP_Close, 0, 0, 0}, /* 9 */
- {OP_Halt, 0, 0, 0}, /* 10 */
+ {OP_OpenRead, 0, 0, 0}, /* 3: Open cursor 0 for reading */
+ {OP_OpenWrite, 0, 0, 0}, /* 4: Open cursor 0 for read/write */
+
+ {OP_Variable, 1, 1, 1}, /* 5: Push the rowid to the stack */
+ {OP_NotExists, 0, 10, 1}, /* 6: Seek the cursor */
+ {OP_Column, 0, 0, 1}, /* 7 */
+ {OP_ResultRow, 1, 0, 0}, /* 8 */
+ {OP_Goto, 0, 5, 0}, /* 9 */
+ {OP_Close, 0, 0, 0}, /* 10 */
+ {OP_Halt, 0, 0, 0}, /* 11 */
};
int rc = SQLITE_OK;
@@ -153,18 +156,8 @@ int sqlite3_blob_open(
Parse *pParse = 0;
Incrblob *pBlob = 0;
-#ifdef SQLITE_ENABLE_API_ARMOR
- if( ppBlob==0 ){
- return SQLITE_MISUSE_BKPT;
- }
-#endif
- *ppBlob = 0;
-#ifdef SQLITE_ENABLE_API_ARMOR
- if( !sqlite3SafetyCheckOk(db) || zTable==0 ){
- return SQLITE_MISUSE_BKPT;
- }
-#endif
flags = !!flags; /* flags = (flags ? 1 : 0); */
+ *ppBlob = 0;
sqlite3_mutex_enter(db->mutex);
@@ -185,10 +178,6 @@ int sqlite3_blob_open(
pTab = 0;
sqlite3ErrorMsg(pParse, "cannot open virtual table: %s", zTable);
}
- if( pTab && !HasRowid(pTab) ){
- pTab = 0;
- sqlite3ErrorMsg(pParse, "cannot open table without rowid: %s", zTable);
- }
#ifndef SQLITE_OMIT_VIEW
if( pTab && pTab->pSelect ){
pTab = 0;
@@ -246,7 +235,7 @@ int sqlite3_blob_open(
#endif
for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){
int j;
- for(j=0; j<pIdx->nKeyCol; j++){
+ for(j=0; j<pIdx->nColumn; j++){
if( pIdx->aiColumn[j]==iCol ){
zFault = "indexed";
}
@@ -261,37 +250,42 @@ int sqlite3_blob_open(
}
}
- pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(pParse);
+ pBlob->pStmt = (sqlite3_stmt *)sqlite3VdbeCreate(db);
assert( pBlob->pStmt || db->mallocFailed );
if( pBlob->pStmt ){
Vdbe *v = (Vdbe *)pBlob->pStmt;
int iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
+ sqlite3VdbeAddOpList(v, sizeof(openBlob)/sizeof(VdbeOpList), openBlob);
+
- sqlite3VdbeAddOp4Int(v, OP_Transaction, iDb, flags,
- pTab->pSchema->schema_cookie,
- pTab->pSchema->iGeneration);
- sqlite3VdbeChangeP5(v, 1);
- sqlite3VdbeAddOpList(v, ArraySize(openBlob), openBlob, iLn);
+ /* Configure the OP_Transaction */
+ sqlite3VdbeChangeP1(v, 0, iDb);
+ sqlite3VdbeChangeP2(v, 0, flags);
+
+ /* Configure the OP_VerifyCookie */
+ sqlite3VdbeChangeP1(v, 1, iDb);
+ sqlite3VdbeChangeP2(v, 1, pTab->pSchema->schema_cookie);
+ sqlite3VdbeChangeP3(v, 1, pTab->pSchema->iGeneration);
/* Make sure a mutex is held on the table to be accessed */
sqlite3VdbeUsesBtree(v, iDb);
/* Configure the OP_TableLock instruction */
#ifdef SQLITE_OMIT_SHARED_CACHE
- sqlite3VdbeChangeToNoop(v, 1);
+ sqlite3VdbeChangeToNoop(v, 2);
#else
- sqlite3VdbeChangeP1(v, 1, iDb);
- sqlite3VdbeChangeP2(v, 1, pTab->tnum);
- sqlite3VdbeChangeP3(v, 1, flags);
- sqlite3VdbeChangeP4(v, 1, pTab->zName, P4_TRANSIENT);
+ sqlite3VdbeChangeP1(v, 2, iDb);
+ sqlite3VdbeChangeP2(v, 2, pTab->tnum);
+ sqlite3VdbeChangeP3(v, 2, flags);
+ sqlite3VdbeChangeP4(v, 2, pTab->zName, P4_TRANSIENT);
#endif
/* Remove either the OP_OpenWrite or OpenRead. Set the P2
** parameter of the other to pTab->tnum. */
- sqlite3VdbeChangeToNoop(v, 3 - flags);
- sqlite3VdbeChangeP2(v, 2 + flags, pTab->tnum);
- sqlite3VdbeChangeP3(v, 2 + flags, iDb);
+ sqlite3VdbeChangeToNoop(v, 4 - flags);
+ sqlite3VdbeChangeP2(v, 3 + flags, pTab->tnum);
+ sqlite3VdbeChangeP3(v, 3 + flags, iDb);
/* Configure the number of columns. Configure the cursor to
** think that the table has one more column than it really
@@ -300,8 +294,8 @@ int sqlite3_blob_open(
** we can invoke OP_Column to fill in the vdbe cursors type
** and offset cache without causing any IO.
*/
- sqlite3VdbeChangeP4(v, 2+flags, SQLITE_INT_TO_PTR(pTab->nCol+1),P4_INT32);
- sqlite3VdbeChangeP2(v, 6, pTab->nCol);
+ sqlite3VdbeChangeP4(v, 3+flags, SQLITE_INT_TO_PTR(pTab->nCol+1),P4_INT32);
+ sqlite3VdbeChangeP2(v, 7, pTab->nCol);
if( !db->mallocFailed ){
pParse->nVar = 1;
pParse->nMem = 1;
@@ -319,7 +313,7 @@ int sqlite3_blob_open(
}
sqlite3_bind_int64(pBlob->pStmt, 1, iRow);
rc = blobSeekToRow(pBlob, iRow, &zErr);
- } while( (++nAttempt)<SQLITE_MAX_SCHEMA_RETRY && rc==SQLITE_SCHEMA );
+ } while( (++nAttempt)<5 && rc==SQLITE_SCHEMA );
blob_open_out:
if( rc==SQLITE_OK && db->mallocFailed==0 ){
@@ -328,9 +322,8 @@ blob_open_out:
if( pBlob && pBlob->pStmt ) sqlite3VdbeFinalize((Vdbe *)pBlob->pStmt);
sqlite3DbFree(db, pBlob);
}
- sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
+ sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr);
sqlite3DbFree(db, zErr);
- sqlite3ParserReset(pParse);
sqlite3StackFree(db, pParse);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
@@ -378,9 +371,10 @@ static int blobReadWrite(
sqlite3_mutex_enter(db->mutex);
v = (Vdbe*)p->pStmt;
- if( n<0 || iOffset<0 || ((sqlite3_int64)iOffset+n)>p->nByte ){
+ if( n<0 || iOffset<0 || (iOffset+n)>p->nByte ){
/* Request is out of range. Return a transient error. */
rc = SQLITE_ERROR;
+ sqlite3Error(db, SQLITE_ERROR, 0);
}else if( v==0 ){
/* If there is no statement handle, then the blob-handle has
** already been invalidated. Return SQLITE_ABORT in this case.
@@ -398,10 +392,10 @@ static int blobReadWrite(
sqlite3VdbeFinalize(v);
p->pStmt = 0;
}else{
+ db->errCode = rc;
v->rc = rc;
}
}
- sqlite3Error(db, rc);
rc = sqlite3ApiExit(db, rc);
sqlite3_mutex_leave(db->mutex);
return rc;
@@ -460,7 +454,7 @@ int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
char *zErr;
rc = blobSeekToRow(p, iRow, &zErr);
if( rc!=SQLITE_OK ){
- sqlite3ErrorWithMsg(db, rc, (zErr ? "%s" : 0), zErr);
+ sqlite3Error(db, rc, (zErr ? "%s" : 0), zErr);
sqlite3DbFree(db, zErr);
}
assert( rc!=SQLITE_SCHEMA );
diff --git a/lib/libsqlite3/src/walker.c b/lib/libsqlite3/src/walker.c
index e30bb60b5a4..c95a9c169db 100644
--- a/lib/libsqlite3/src/walker.c
+++ b/lib/libsqlite3/src/walker.c
@@ -19,7 +19,7 @@
/*
** Walk an expression tree. Invoke the callback once for each node
-** of the expression, while descending. (In other words, the callback
+** of the expression, while decending. (In other words, the callback
** is invoked before visiting children.)
**
** The return value from the callback should be one of the WRC_*
@@ -43,7 +43,7 @@ int sqlite3WalkExpr(Walker *pWalker, Expr *pExpr){
testcase( ExprHasProperty(pExpr, EP_Reduced) );
rc = pWalker->xExprCallback(pWalker, pExpr);
if( rc==WRC_Continue
- && !ExprHasProperty(pExpr,EP_TokenOnly) ){
+ && !ExprHasAnyProperty(pExpr,EP_TokenOnly) ){
if( sqlite3WalkExpr(pWalker, pExpr->pLeft) ) return WRC_Abort;
if( sqlite3WalkExpr(pWalker, pExpr->pRight) ) return WRC_Abort;
if( ExprHasProperty(pExpr, EP_xIsSelect) ){
@@ -113,12 +113,7 @@ int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){
/*
** Call sqlite3WalkExpr() for every expression in Select statement p.
** Invoke sqlite3WalkSelect() for subqueries in the FROM clause and
-** on the compound select chain, p->pPrior.
-**
-** If it is not NULL, the xSelectCallback() callback is invoked before
-** the walk of the expressions and FROM clause. The xSelectCallback2()
-** method, if it is not NULL, is invoked following the walk of the
-** expressions and FROM clause.
+** on the compound select chain, p->pPrior.
**
** Return WRC_Continue under normal conditions. Return WRC_Abort if
** there is an abort request.
@@ -128,27 +123,14 @@ int sqlite3WalkSelectFrom(Walker *pWalker, Select *p){
*/
int sqlite3WalkSelect(Walker *pWalker, Select *p){
int rc;
- if( p==0 || (pWalker->xSelectCallback==0 && pWalker->xSelectCallback2==0) ){
- return WRC_Continue;
- }
+ if( p==0 || pWalker->xSelectCallback==0 ) return WRC_Continue;
rc = WRC_Continue;
- pWalker->walkerDepth++;
- while( p ){
- if( pWalker->xSelectCallback ){
- rc = pWalker->xSelectCallback(pWalker, p);
- if( rc ) break;
- }
- if( sqlite3WalkSelectExpr(pWalker, p)
- || sqlite3WalkSelectFrom(pWalker, p)
- ){
- pWalker->walkerDepth--;
- return WRC_Abort;
- }
- if( pWalker->xSelectCallback2 ){
- pWalker->xSelectCallback2(pWalker, p);
- }
+ while( p ){
+ rc = pWalker->xSelectCallback(pWalker, p);
+ if( rc ) break;
+ if( sqlite3WalkSelectExpr(pWalker, p) ) return WRC_Abort;
+ if( sqlite3WalkSelectFrom(pWalker, p) ) return WRC_Abort;
p = p->pPrior;
}
- pWalker->walkerDepth--;
return rc & WRC_Abort;
}
diff --git a/lib/libsqlite3/tool/mksqlite3h.tcl b/lib/libsqlite3/tool/mksqlite3h.tcl
index cabce1f50b7..f68f61a3689 100644
--- a/lib/libsqlite3/tool/mksqlite3h.tcl
+++ b/lib/libsqlite3/tool/mksqlite3h.tcl
@@ -63,32 +63,14 @@ close $in
# Set up patterns for recognizing API declarations.
#
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]+)(\(.*)$}
+set declpattern {^ *[a-zA-Z][a-zA-Z_0-9 ]+ \**sqlite3_[_a-zA-Z0-9]+\(}
# Force the output to use unix line endings, even on Windows.
fconfigure stdout -translation lf
-set filelist [subst {
- $TOP/src/sqlite.h.in
- $TOP/ext/rtree/sqlite3rtree.h
-}]
-
-# These are the functions that accept a variable number of arguments. They
-# always need to use the "cdecl" calling convention even when another calling
-# convention (e.g. "stcall") is being used for the rest of the library.
-set cdecllist {
- sqlite3_config
- sqlite3_db_config
- sqlite3_log
- sqlite3_mprintf
- sqlite3_snprintf
- sqlite3_test_control
- sqlite3_vtab_config
-}
-
-# Process the source files.
+# Process the src/sqlite.h.in ext/rtree/sqlite3rtree.h files.
#
-foreach file $filelist {
+foreach file [list $TOP/src/sqlite.h.in $TOP/ext/rtree/sqlite3rtree.h] {
set in [open $file]
while {![eof $in]} {
@@ -102,23 +84,21 @@ foreach file $filelist {
regsub -- --VERS-- $line $zVersion line
regsub -- --VERSION-NUMBER-- $line $nVersion line
regsub -- --SOURCE-ID-- $line "$zDate $zUuid" line
-
- if {[regexp $varpattern $line] && ![regexp {^ *typedef} $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"
- } else {
- if {[regexp $declpattern $line all rettype funcname rest]} {
- set line SQLITE_API
- append line " " [string trim $rettype]
- if {[string index $rettype end] ne "*"} {
- append line " "
- }
- if {[lsearch -exact $cdecllist $funcname] >= 0} {
- append line SQLITE_CDECL
- } else {
- append line SQLITE_STDCALL
- }
- append line " " $funcname $rest
- }
}
puts $line
}