From: drh Date: Thu, 17 Feb 2005 00:03:06 +0000 (+0000) Subject: Compile-time option to limit the size of AUTOINCREMENT rowids to 32-bits. (CVS 2349) X-Git-Tag: version-3.6.10~3809 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=75f86a4b0b0bf437832d079e4d548203db5373f1;p=thirdparty%2Fsqlite.git Compile-time option to limit the size of AUTOINCREMENT rowids to 32-bits. (CVS 2349) FossilOrigin-Name: c5366deaf5beca9c99558c0f375ba73f817acd92 --- diff --git a/manifest b/manifest index 80d0523a49..3dcf8d4b79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Clarify\sthat\scolumns\sare\sindexed\sfrom\s0\swhen\susing\ssqlite3_column_XXX()\sAPIs.\sNo\scode\schanges.\s(CVS\s2348) -D 2005-02-16T23:43:34 +C Compile-time\soption\sto\slimit\sthe\ssize\sof\sAUTOINCREMENT\srowids\sto\s32-bits.\s(CVS\s2349) +D 2005-02-17T00:03:07 F Makefile.in 76443a83549d1539105e12d13bd0054a05ab2214 F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457 F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1 @@ -64,7 +64,7 @@ F src/sqlite.h.in c85f6bad9ca7de29f505fe886646cfff7df4c55e F src/sqliteInt.h f95cc4becd7b27293aae8f8c4ed2f6ef44830fbb F src/table.c 25b3ff2b39b7d87e8d4a5da0713d68dfc06cbee9 F src/tclsqlite.c 101994a2c4c0eaa69f1de9bfe4a02167f6049e7d -F src/test1.c feac8a742aca920c8ab18a43b3208ae3a834fe9d +F src/test1.c 8b3c7c1765920d8f313c1d74015a6a67c0cd3111 F src/test2.c 7f0ef466706ac01414e1136b96e5d8a65cb97545 F src/test3.c 683e1e3819152ffd35da2f201e507228921148d0 F src/test4.c 7c6b9fc33dd1f3f93c7f1ee6e5e6d016afa6c1df @@ -75,7 +75,7 @@ F src/update.c b6f4668c11059f86b71581187d09197fa28ec4be F src/utf.c bda5eb85039ef16f2d17004c1e18c96e1ab0a80c F src/util.c 1b7b9a127b66743ab6cba8d44597aeb570723c99 F src/vacuum.c 5cf598003191bd91c17a64742bad8e46241698a8 -F src/vdbe.c d9ec62c9f63768b4d4f8513b25aded8faf2de17b +F src/vdbe.c 40de3ba927a8a99b582d9cd554a2f9eca1c7a025 F src/vdbe.h bb9186484f749a839c6c43953e79a6530253f7cd F src/vdbeInt.h e80721cd8ff611789e20743eec43363a9fb5a48e F src/vdbeapi.c 467caa6e6fb9247528b1c7ab9132ae1b4748e8ac @@ -89,7 +89,7 @@ F test/attach.test 5147d531ca5fc5c2539fd20ce3b07a00420e1fbb F test/attach2.test 6f3a3a3a7f5be40388dd4d805e0e0712718dca9d F test/attach3.test c05c70b933afbde0901dab9da3e66ee842c09f38 F test/auth.test b24d12de3a6ba49237216429f8dc672a8a52b342 -F test/autoinc.test c6daf10ffce8a898cd375b4a71615a741a6029d0 +F test/autoinc.test d619da7d5cb9a3d63e6a7925259fc173f7e2080e F test/autovacuum.test 8ba29face873300394f9446ded0e4a142d24e7e4 F test/autovacuum_crash.test 05a63b8805b20cfba7ace82856ce4ccdda075a31 F test/autovacuum_ioerr.test 9cf27275ca47b72e188a47c53b61b6d583a01d24 @@ -273,7 +273,7 @@ F www/tclsqlite.tcl e73f8f8e5f20e8277619433f7970060ab01088fc F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618 F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0 F www/whentouse.tcl 3e522a06ad41992023c80ca29a048ae2331ca5bd -P 0cd3bf02d25933286085708308ff963c50c8d33d -R 492a5c01b632304cfb90a3f1de846e00 -U danielk1977 -Z b428f0e9786ef55978d4f9bb1c1581b6 +P d5eb25d8d0d444ab98b26f7f1ac763919e692806 +R 1437f9ebc073df7aac84814cf952caaa +U drh +Z d1a958ef419bfdc9162ae87175aeda5a diff --git a/manifest.uuid b/manifest.uuid index ef0a63329c..f420f0c4bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5eb25d8d0d444ab98b26f7f1ac763919e692806 \ No newline at end of file +c5366deaf5beca9c99558c0f375ba73f817acd92 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index da0d701dfa..b6ebe36697 100644 --- a/src/test1.c +++ b/src/test1.c @@ -13,7 +13,7 @@ ** is not included in the SQLite library. It is used for automated ** testing of the SQLite library. ** -** $Id: test1.c,v 1.129 2005/02/04 04:07:18 danielk1977 Exp $ +** $Id: test1.c,v 1.130 2005/02/17 00:03:07 drh Exp $ */ #include "sqliteInt.h" #include "tcl.h" @@ -2682,6 +2682,12 @@ static int tcl_variable_type( ** procedures use this to determine when tests should be omitted. */ static void set_options(Tcl_Interp *interp){ +#ifdef SQLITE_32BIT_ROWID + Tcl_SetVar2(interp, "sqlite_options", "rowid32", "1", TCL_GLOBAL_ONLY); +#else + Tcl_SetVar2(interp, "sqlite_options", "rowid32", "0", TCL_GLOBAL_ONLY); +#endif + #ifdef SQLITE_OMIT_ALTERTABLE Tcl_SetVar2(interp, "sqlite_options", "altertable", "0", TCL_GLOBAL_ONLY); #else diff --git a/src/vdbe.c b/src/vdbe.c index 98d5c0d58e..9f5dbfa2aa 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -43,7 +43,7 @@ ** in this file for details. If in doubt, do not deviate from existing ** commenting and indentation practices when changing or adding code. ** -** $Id: vdbe.c,v 1.454 2005/02/08 07:50:42 danielk1977 Exp $ +** $Id: vdbe.c,v 1.455 2005/02/17 00:03:07 drh Exp $ */ #include "sqliteInt.h" #include "os.h" @@ -2890,11 +2890,15 @@ case OP_NewRecno: { assert( (sqlite3BtreeFlags(pC->pCursor) & BTREE_INTKEY)!=0 ); assert( (sqlite3BtreeFlags(pC->pCursor) & BTREE_ZERODATA)==0 ); +#ifdef SQLITE_32BIT_ROWID +# define MAX_ROWID 0x7fffffff +#else /* Some compilers complain about constants of the form 0x7fffffffffffffff. ** Others complain about 0x7ffffffffffffffffLL. The following macro seems ** to provide the constant while making all compilers happy. */ -# define MAX_I64 ( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) +# define MAX_ROWID ( (((u64)0x7fffffff)<<32) | (u64)0xffffffff ) +#endif if( !pC->useRandomRowid ){ if( pC->nextRowidValid ){ @@ -2906,7 +2910,7 @@ case OP_NewRecno: { }else{ sqlite3BtreeKeySize(pC->pCursor, &v); v = keyToInt(v); - if( v==MAX_I64 ){ + if( v==MAX_ROWID ){ pC->useRandomRowid = 1; }else{ v++; @@ -2921,7 +2925,7 @@ case OP_NewRecno: { pMem = &p->aMem[pOp->p2]; Integerify(pMem); assert( (pMem->flags & MEM_Int)!=0 ); /* mem(P2) holds an integer */ - if( pMem->i==MAX_I64 || pC->useRandomRowid ){ + if( pMem->i==MAX_ROWID || pC->useRandomRowid ){ rc = SQLITE_FULL; goto abort_due_to_error; } @@ -2932,7 +2936,7 @@ case OP_NewRecno: { } #endif - if( vnextRowidValid = 1; pC->nextRowid = v+1; }else{ diff --git a/test/autoinc.test b/test/autoinc.test index 82e05f16f3..6a2a9fb772 100644 --- a/test/autoinc.test +++ b/test/autoinc.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this script is testing the AUTOINCREMENT features. # -# $Id: autoinc.test,v 1.3 2005/01/21 11:55:27 danielk1977 Exp $ +# $Id: autoinc.test,v 1.4 2005/02/17 00:03:07 drh Exp $ # set testdir [file dirname $argv0] @@ -449,13 +449,24 @@ do_test autoinc-5.4 { # Requirement REQ00310: Make sure an insert fails if the sequence is # already at its maximum value. # -do_test autoinc-6.1 { - execsql { - CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w); - INSERT INTO t6 VALUES(9223372036854775807,1); - SELECT seq FROM main.sqlite_sequence WHERE name='t6'; - } -} 9223372036854775807 +ifcapable {rowid32} { + do_test autoinc-6.1 { + execsql { + CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w); + INSERT INTO t6 VALUES(2147483647,1); + SELECT seq FROM main.sqlite_sequence WHERE name='t6'; + } + } 2147483647 +} +ifcapable {!rowid32} { + do_test autoinc-6.1 { + execsql { + CREATE TABLE t6(v INTEGER PRIMARY KEY AUTOINCREMENT, w); + INSERT INTO t6 VALUES(9223372036854775807,1); + SELECT seq FROM main.sqlite_sequence WHERE name='t6'; + } + } 9223372036854775807 +} do_test autoinc-6.2 { catchsql { INSERT INTO t6 VALUES(NULL,1);