From: drh Date: Sat, 9 Nov 2013 18:15:35 +0000 (+0000) Subject: Throw an error if AUTOINCREMENT appears in a WITHOUT ROWID table. X-Git-Tag: version-3.8.2~123 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d2fe3358cff19be1537118ecd3b2ab9fa83cf77f;p=thirdparty%2Fsqlite.git Throw an error if AUTOINCREMENT appears in a WITHOUT ROWID table. Updates to API documentation to discuss WITHOUT ROWID. FossilOrigin-Name: b1abb2b078d1cb9ec5fbd7f98221914b93632e9f --- diff --git a/manifest b/manifest index 04ad0fc6e1..27bc758d0d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarnings. -D 2013-11-08T17:13:23.004 +C Throw\san\serror\sif\sAUTOINCREMENT\sappears\sin\sa\sWITHOUT\sROWID\stable.\s\s\nUpdates\sto\sAPI\sdocumentation\sto\sdiscuss\sWITHOUT\sROWID. +D 2013-11-09T18:15:35.427 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d12e4455cf7a36e42d3949876c1c3b88ff70867a F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -168,7 +168,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c 260dedc13119e6fb7930380bd3d294b98362bf5a F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0 -F src/build.c d4d5ceedf196a7da36d6dd15f4d073cb68c8f079 +F src/build.c 837587dbeb02327e9df15f803abc661a6eb71ad3 F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c @@ -220,7 +220,7 @@ F src/resolve.c fc4673cc49b116e51e7f12de074c0acf8f2388f9 F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 60af46f5f6bc3803c27af3edd8881ed2d0c3f19f F src/shell.c 03d8d9b4052430343ff30d646334621f980f1202 -F src/sqlite.h.in a8cad179541b8d171fed425a737084702ef462ef +F src/sqlite.h.in a2580d959495539fe9e9c17804a90b2aca176c88 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqliteInt.h 3da1940a2ba05a663e9016d57f1ea1f79ffcb03e @@ -827,7 +827,7 @@ F test/syscall.test a653783d985108c4912cc64d341ffbbb55ad2806 F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6 F test/table.test 580d23530187026d4502fae74a490f0408cf2cc7 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 -F test/tableopts.test 2950f094a984c8aa53493598bf0a07ac7549eb02 +F test/tableopts.test dba698ba97251017b7c80d738c198d39ab747930 F test/tclsqlite.test 37a61c2da7e3bfe3b8c1a2867199f6b860df5d43 F test/tempdb.test 19d0f66e2e3eeffd68661a11c83ba5e6ace9128c F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 @@ -1135,7 +1135,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 830629d31d171155d90ff87ae8e70094d17bb2d3 -R adecbc2b2722d8396e4c1e0a55a342fc +P 0077c0772a884b54d81fa3733aac6f0c364ef1a8 +R 563b03556821aa7157a2f09d27059ceb U drh -Z f6606fc6407dbb7e80e344c001d6847c +Z 70e0a7dbdf3eec5dcb68edfd8a49c4f3 diff --git a/manifest.uuid b/manifest.uuid index 7f84bf0349..b3f5c9c136 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0077c0772a884b54d81fa3733aac6f0c364ef1a8 \ No newline at end of file +b1abb2b078d1cb9ec5fbd7f98221914b93632e9f \ No newline at end of file diff --git a/src/build.c b/src/build.c index 27ea43e2f3..a6b255d764 100644 --- a/src/build.c +++ b/src/build.c @@ -1769,8 +1769,13 @@ void sqlite3EndTable( /* Special processing for WITHOUT ROWID Tables */ if( tabOpts & TF_WithoutRowid ){ + if( (p->tabFlags & TF_Autoincrement) ){ + sqlite3ErrorMsg(pParse, + "AUTOINCREMENT not allowed on WITHOUT ROWID tables"); + return; + } if( (p->tabFlags & TF_HasPrimaryKey)==0 ){ - sqlite3ErrorMsg(pParse, "no PRIMARY KEY for table %s", p->zName); + sqlite3ErrorMsg(pParse, "PRIMARY KEY missing on table %s", p->zName); }else{ p->tabFlags |= TF_WithoutRowid; convertToWithoutRowidTable(pParse, p); diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 403ee725b4..3ecb1578de 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1790,11 +1790,13 @@ int sqlite3_extended_result_codes(sqlite3*, int onoff); ** is another alias for the rowid. ** ** ^This routine returns the [rowid] of the most recent -** successful [INSERT] into the database from the [database connection] +** successful [INSERT] into a rowid table from the [database connection] ** in the first argument. ^As of SQLite version 3.7.7, this routines ** records the last insert rowid of both ordinary tables and [virtual tables]. -** ^If no successful [INSERT]s -** have ever occurred on that database connection, zero is returned. +** ^Inserts into [WITHOUT ROWID] tables are not recorded. +** ^If no successful [INSERT]s into rowid tables +** have ever occurred on the database connection D, +** then sqlite3_last_insert_rowid(D) returns zero. ** ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] ** method, then this routine will return the [rowid] of the inserted @@ -4811,12 +4813,13 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); ** ** ^The sqlite3_update_hook() interface registers a callback function ** with the [database connection] identified by the first argument -** to be invoked whenever a row is updated, inserted or deleted. +** to be invoked whenever a row is updated, inserted or deleted in +** a rowid table. ** ^Any callback set by a previous call to this function ** for the same database connection is overridden. ** ** ^The second argument is a pointer to the function to invoke when a -** row is updated, inserted or deleted. +** row is updated, inserted or deleted in a rowid table. ** ^The first argument to the callback is a copy of the third argument ** to sqlite3_update_hook(). ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], @@ -4829,6 +4832,7 @@ void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); ** ** ^(The update hook is not invoked when internal system tables are ** modified (i.e. sqlite_master and sqlite_sequence).)^ +** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified. ** ** ^In the current implementation, the update hook ** is not invoked when duplication rows are deleted because of an @@ -5518,6 +5522,9 @@ typedef struct sqlite3_blob sqlite3_blob; ** interface. Use the [UPDATE] SQL command to change the size of a ** blob. ** +** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID] +** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables. +** ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces ** and the built-in [zeroblob] SQL function can be used, if desired, ** to create an empty, zero-filled blob in which to read or write using diff --git a/test/tableopts.test b/test/tableopts.test index ab1eb61cf6..0b2457ec4c 100644 --- a/test/tableopts.test +++ b/test/tableopts.test @@ -21,7 +21,12 @@ do_test tableopt-1.1 { catchsql { CREATE TABLE t1(a,b) WITHOUT rowid; } -} {1 {no PRIMARY KEY for table t1}} +} {1 {PRIMARY KEY missing on table t1}} +do_test tableopt-1.1b { + catchsql { + CREATE TABLE t1(a INTEGER PRIMARY KEY AUTOINCREMENT,b) WITHOUT rowid; + } +} {1 {AUTOINCREMENT not allowed on WITHOUT ROWID tables}} do_test tableopt-1.2 { catchsql { CREATE TABLE t1(a,b) WITHOUT unknown2;