Add the SQLITE_OMIT_TRUNCATE_OPTIMIZATION option. Other unrelated

documentation enhancements. (CVS 5798)

FossilOrigin-Name: fab4940d54fd1e5459a3d0d9b64b491e6972fd8d
This commit is contained in:
drh 2008-10-10 23:48:25 +00:00
parent 49ffdbf47e
commit f8cecdab84
5 changed files with 107 additions and 60 deletions

View File

@ -1,5 +1,5 @@
C Further\ssimplifications\sof\sthe\scode\sfor\sthe\sLIMIT\sclause\son\san\sUPDATE\sor\sDELETE.\s\sAdded\sa\sfew\stest\scases\sto\swherelimit.test.\s(CVS\s5797)
D 2008-10-10T18:25:46
C Add\sthe\sSQLITE_OMIT_TRUNCATE_OPTIMIZATION\soption.\s\sOther\sunrelated\ndocumentation\senhancements.\s(CVS\s5798)
D 2008-10-10T23:48:26
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in 7fc26e087207e7a4a7723583dbd7997477af3b13
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -106,7 +106,7 @@ F src/build.c 8714bd809583bbe07bf22d0e1808a3fc31abe330
F src/callback.c e970e5beddbdb23f89a6d05cb1a6419d9f755624
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 1b1fc801df40aae891bff8b03f65313df192d677
F src/delete.c c7aaf47f274494f9ae1f89cf095ca890b1d9d2bf
F src/delete.c d3f2adfdd07e701115a111cc81dca33ed6039d10
F src/expr.c 0ceafeff3a4e0f460d6a7695a675ae12391e313d
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
F src/func.c 8431b40a7843d1024145684d303c55b4ee087bbe
@ -150,7 +150,7 @@ F src/random.c a87afbd598aa877e23ac676ee92fd8ee5c786a51
F src/resolve.c d45e7b69f9ff653799384d7fcdd0c8d7096908b7
F src/select.c d910d7350df0d918e22286c5bfd39d4ea68ec813
F src/shell.c d83b578a8ccdd3e0e7fef4388a0887ce9f810967
F src/sqlite.h.in 28e6466da6b90e56bfbc6c50a1a281931a8c733c
F src/sqlite.h.in 2b8ef43244589ef2d8060b076adaafacda58acf8
F src/sqlite3ext.h 1e3887c9bd3ae66cb599e922824b04cd0d0f2c3e
F src/sqliteInt.h f60fac64c8970ca366080daa3aa65b9a54a2334a
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
@ -169,7 +169,7 @@ F src/test9.c 904ebe0ed1472d6bad17a81e2ecbfc20017dc237
F src/test_async.c 45024094ed7cf780c5d5dccda645145f95cf78ef
F src/test_autoext.c f53b0cdf7bf5f08100009572a5d65cdb540bd0ad
F src/test_btree.c d7b8716544611c323860370ee364e897c861f1b0
F src/test_config.c e5d6390729f0c63333ebe7e5927c07e50bc9deea
F src/test_config.c 91ae677efad9ee440ea42565ec675f204dd5fb3a
F src/test_devsym.c 802d10e65b4217208cb47059b84adf46318bcdf4
F src/test_func.c a55c4d5479ff2eb5c0a22d4d88e9528ab59c953b
F src/test_hexio.c 2f1122aa3f012fa0142ee3c36ce5c902a70cd12f
@ -648,7 +648,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 84e73fe8a6f538c4b1bb4f641a661d6fafb60c76
R eb4c22bf5cef8091ed9bce14d73bbe63
U shane
Z 9ca81fedb812b2854e888eab6c64b7ec
P 282c6a46b25f4e4278fd4c8b0b1cde1de28d8f51
R 6ffb2f1fe0d56d1b89a5f8c7d49a18a5
U drh
Z e18361551100757c34ff8614b91b50fa

View File

@ -1 +1 @@
282c6a46b25f4e4278fd4c8b0b1cde1de28d8f51
fab4940d54fd1e5459a3d0d9b64b491e6972fd8d

View File

@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser
** in order to generate code for DELETE FROM statements.
**
** $Id: delete.c,v 1.181 2008/10/10 18:25:46 shane Exp $
** $Id: delete.c,v 1.182 2008/10/10 23:48:26 drh Exp $
*/
#include "sqliteInt.h"
@ -364,6 +364,7 @@ void sqlite3DeleteFrom(
sqlite3VdbeAddOp2(v, OP_Integer, 0, memCnt);
}
#ifndef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
/* Special case: A DELETE without a WHERE clause deletes everything.
** It is easier just to erase the whole table. Note, however, that
** this means that the row change count will be incorrect.
@ -391,11 +392,12 @@ void sqlite3DeleteFrom(
sqlite3VdbeAddOp2(v, OP_Clear, pIdx->tnum, iDb);
}
}
}
}else
#endif /* SQLITE_OMIT_TRUNCATE_OPTIMIZATION */
/* The usual case: There is a WHERE clause so we have to scan through
** the table and pick which records to delete.
*/
else{
{
int iRowid = ++pParse->nMem; /* Used for storing rowid values. */
/* Begin the database scan

View File

@ -30,7 +30,7 @@
** the version number) and changes its name to "sqlite3.h" as
** part of the build process.
**
** @(#) $Id: sqlite.h.in,v 1.402 2008/10/10 17:26:35 drh Exp $
** @(#) $Id: sqlite.h.in,v 1.403 2008/10/10 23:48:26 drh Exp $
*/
#ifndef _SQLITE3_H_
#define _SQLITE3_H_
@ -983,95 +983,97 @@ int sqlite3_os_end(void);
**
** INVARIANTS:
**
** {H14103} A successful invocation of sqlite3_config() shall return
** SQLITE_OK.
** {H14103} A successful invocation of [sqlite3_config()] shall return
** [SQLITE_OK].
**
** {H14106} The sqlite3_config() interface shall return SQLITE_MISUSE
** if it is invoked in between calls to sqlite3_initialize() and
** sqlite3_shutdown().
** {H14106} The [sqlite3_config()] interface shall return [SQLITE_MISUSE]
** if it is invoked in between calls to [sqlite3_initialize()] and
** [sqlite3_shutdown()].
**
** {H14120} A successful call to sqlite3_config(SQLITE_CONFIG_SINGLETHREAD)
** {H14120} A successful call to [sqlite3_config]([SQLITE_CONFIG_SINGLETHREAD])
** shall set the default [threading mode] to Single-thread.
**
** {H14123} A successful call to sqlite3_config(SQLITE_CONFIG_MULTITHREAD)
** {H14123} A successful call to [sqlite3_config]([SQLITE_CONFIG_MULTITHREAD])
** shall set the default [threading mode] to Multi-thread.
**
** {H14126} A successful call to sqlite3_config(SQLITE_CONFIG_SERIALIZED)
** {H14126} A successful call to [sqlite3_config]([SQLITE_CONFIG_SERIALIZED])
** shall set the default [threading mode] to Serialized.
**
** {H14129} A successful call to sqlite3_config(SQLITE_CONFIG_MUTEX,X)
** {H14129} A successful call to [sqlite3_config]([SQLITE_CONFIG_MUTEX],X)
** where X is a pointer to an initialized [sqlite3_mutex_methods]
** object shall cause all subsequent mutex operations performed
** by SQLite to use the mutex methods that were present in X
** during the call to sqlite3_config().
** during the call to [sqlite3_config()].
**
** {H14132} A successful call to sqlite3_config(SQLITE_CONFIG_GETMUTEX,X)
** {H14132} A successful call to [sqlite3_config]([SQLITE_CONFIG_GETMUTEX],X)
** where X is a pointer to an [sqlite3_mutex_methods] object
** shall overwrite the content of [sqlite3_mutex_methods] object
** with the mutex methods currently in use by SQLite.
**
** {H14135} A successful call to sqlite3_config(SQLITE_CONFIG_MALLOC,M)
** {H14135} A successful call to [sqlite3_config]([SQLITE_CONFIG_MALLOC],M)
** where M is a pointer to an initialized [sqlite3_mem_methods]
** object shall cause all subsequent memory allocation operations
** performed by SQLite to use the methods that were present in
** M during the call to sqlite3_config().
** M during the call to [sqlite3_config()].
**
** {H14138} A successful call to sqlite3_config(SQLITE_CONFIG_GETMALLOC,M)
** {H14138} A successful call to [sqlite3_config]([SQLITE_CONFIG_GETMALLOC],M)
** where M is a pointer to an [sqlite3_mem_methods] object shall
** overwrite the content of [sqlite3_mem_methods] object with
** the memory allocation methods currently in use by
** SQLite.
**
** {H14141} A successful call to sqlite3_config(SQLITE_CONFIG_MEMSTATUS,1)
** {H14141} A successful call to [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],1)
** shall enable the memory allocation status collection logic.
**
** {H14144} A successful call to sqlite3_config(SQLITE_CONFIG_MEMSTATUS,0)
** {H14144} A successful call to [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],0)
** shall disable the memory allocation status collection logic.
**
** {H14147} The memory allocation status collection logic shall be
** enabled by default.
**
** {H14150} A successful call to sqlite3_config(SQLITE_CONFIG_SCRATCH,S,Z,N)
** {H14150} A successful call to [sqlite3_config]([SQLITE_CONFIG_SCRATCH],S,Z,N)
** where Z and N are non-negative integers and
** S is a pointer to an aligned memory buffer not less than
** Z*N bytes in size shall cause S to be used by the
** [scratch memory allocator] for as many as N simulataneous
** allocations each of size Z.
**
** {H14153} A successful call to sqlite3_config(SQLITE_CONFIG_SCRATCH,S,Z,N)
** {H14153} A successful call to [sqlite3_config]([SQLITE_CONFIG_SCRATCH],S,Z,N)
** where S is a NULL pointer shall disable the
** [scratch memory allocator].
**
** {H14156} A successful call to sqlite3_config(SQLITE_CONFIG_PAGECACHE,S,Z,N)
** {H14156} A successful call to
** [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],S,Z,N)
** where Z and N are non-negative integers and
** S is a pointer to an aligned memory buffer not less than
** Z*N bytes in size shall cause S to be used by the
** [pagecache memory allocator] for as many as N simulataneous
** allocations each of size Z.
**
** {H14159} A successful call to sqlite3_config(SQLITE_CONFIG_PAGECACHE,S,Z,N)
** {H14159} A successful call to
** [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],S,Z,N)
** where S is a NULL pointer shall disable the
** [pagecache memory allocator].
**
** {H14162} A successful call to sqlite3_config(SQLITE_CONFIG_HEAP,H,Z,N)
** {H14162} A successful call to [sqlite3_config]([SQLITE_CONFIG_HEAP],H,Z,N)
** where Z and N are non-negative integers and
** H is a pointer to an aligned memory buffer not less than
** Z bytes in size shall enable the [memsys5] memory allocator
** and cause it to use buffer S as its memory source and to use
** a minimum allocation size of N.
**
** {H14165} A successful call to sqlite3_config(SQLITE_CONFIG_HEAP,H,Z,N)
** {H14165} A successful call to [sqlite3_config]([SQLITE_CONFIG_HEAP],H,Z,N)
** where H is a NULL pointer shall disable the
** [memsys5] memory allocator.
**
** {H14168} A successful call to sqlite3_config(SQLITE_CONFIG_LOOKASIZE,Z,N)
** {H14168} A successful call to [sqlite3_config]([SQLITE_CONFIG_LOOKASIDE],Z,N)
** shall cause the default [lookaside memory allocator] configuration
** for new [database connections] to be N slots of Z bytes each.
*/
SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
/*
** CAPI3REF: Configure database connections {H10180} <S20000>
** CAPI3REF: Configure database connections {H14200} <S20000>
** EXPERIMENTAL
**
** The sqlite3_db_config() interface is used to make configuration
@ -1088,6 +1090,38 @@ SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
** New verbs are likely to be added in future releases of SQLite.
** Additional arguments depend on the verb.
**
** INVARIANTS:
**
** {H14203} A call to [sqlite3_db_config(D,V,...)] shall return [SQLITE_OK]
** if and only if the call is successful.
**
** {H14206} If one or more slots of the [lookaside memory allocator] for
** [database connection] D are in use, then a call to
** [sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],...) shall
** fail with an [SQLITE_BUSY] return code.
**
** {H14209} A successful call to
** [sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],B,Z,N) where
** D is an open [database connection] and Z and N are positive
** integers and B is an aligned buffer at least Z*N bytes in size
** shall cause the [lookaside memory allocator] for D to use buffer B
** with N slots of Z bytes each.
**
** {H14212} A successful call to
** [sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],B,Z,N) where
** D is an open [database connection] and Z and N are positive
** integers and B is NULL pointer shall cause the
** [lookaside memory allocator] for D to a obtain Z*N byte buffer
** from the primary memory allocator and use that buffer
** with N lookaside slots of Z bytes each.
**
** {H14215} A successful call to
** [sqlite3_db_config](D,[SQLITE_DBCONFIG_LOOKASIDE],B,Z,N) where
** D is an open [database connection] and Z and N are zero shall
** disable the [lookaside memory allocator] for D.
**
**
*/
SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
@ -1353,17 +1387,17 @@ 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]
** in the first argument. If no successful INSERTs
** successful [INSERT] into the database from the [database connection]
** in the first argument. If no successful [INSERT]s
** have ever occurred on that database connection, zero is returned.
**
** If an INSERT occurs within a trigger, then the rowid of the inserted
** If an [INSERT] occurs within a trigger, then the rowid of the inserted
** row is returned by this routine as long as the trigger is running.
** But once the trigger terminates, the value returned by this routine
** reverts to the last value inserted before the trigger fired.
**
** An INSERT that fails due to a constraint violation is not a
** successful INSERT and does not change the value returned by this
** An [INSERT] that fails due to a constraint violation is not a
** successful [INSERT] and does not change the value returned by this
** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
** and INSERT OR ABORT make no changes to the return value of this
** routine when their insertion fails. When INSERT OR REPLACE
@ -1372,23 +1406,24 @@ int sqlite3_extended_result_codes(sqlite3*, int onoff);
** the constraint problem so INSERT OR REPLACE will always change
** the return value of this interface.
**
** For the purposes of this routine, an INSERT is considered to
** For the purposes of this routine, an [INSERT] is considered to
** be successful even if it is subsequently rolled back.
**
** INVARIANTS:
**
** {H12221} The [sqlite3_last_insert_rowid()] function returns the rowid
** of the most recent successful INSERT performed on the same
** {H12221} The [sqlite3_last_insert_rowid()] function shall return the rowid
** of the most recent successful [INSERT] performed on the same
** [database connection] and within the same or higher level
** trigger context, or zero if there have been no qualifying inserts.
** trigger context, or zero if there have been no qualifying
** [INSERT] statements.
**
** {H12223} The [sqlite3_last_insert_rowid()] function returns the
** {H12223} The [sqlite3_last_insert_rowid()] function shall return the
** same value when called from the same trigger context
** immediately before and after a ROLLBACK.
** immediately before and after a [ROLLBACK].
**
** ASSUMPTIONS:
**
** {A12232} If a separate thread performs a new INSERT on the same
** {A12232} If a separate thread performs a new [INSERT] on the same
** database connection while the [sqlite3_last_insert_rowid()]
** function is running and thus changes the last insert rowid,
** then the value returned by [sqlite3_last_insert_rowid()] is
@ -1403,8 +1438,8 @@ sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
** This function returns the number of database rows that were changed
** or inserted or deleted by the most recently completed SQL statement
** on the [database connection] specified by the first parameter.
** Only changes that are directly specified by the INSERT, UPDATE,
** or DELETE statement are counted. Auxiliary changes caused by
** Only changes that are directly specified by the [INSERT], [UPDATE],
** or [DELETE] statement are counted. Auxiliary changes caused by
** triggers are not counted. Use the [sqlite3_total_changes()] function
** to find the total number of changes including changes caused by triggers.
**
@ -1438,13 +1473,15 @@ sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
** caused by subtriggers since those have their own context.
**
** SQLite implements the command "DELETE FROM table" without a WHERE clause
** by dropping and recreating the table. (This is much faster than going
** through and deleting individual elements from the table.) Because of this
** by dropping and recreating the table. Doing so is much faster than going
** through and deleting individual elements from the table. Because of this
** optimization, the deletions in "DELETE FROM table" are not row changes and
** will not be counted by the sqlite3_changes() or [sqlite3_total_changes()]
** functions, regardless of the number of elements that were originally
** in the table. To get an accurate count of the number of rows deleted, use
** "DELETE FROM table WHERE 1" instead.
** "DELETE FROM table WHERE 1" instead. Or recompile using the
** [SQLITE_OMIT_TRUNCATE_OPTIMIZATION] compile-time option to disable the
** optimization on all queries.
**
** INVARIANTS:
**
@ -1486,7 +1523,9 @@ int sqlite3_changes(sqlite3*);
** will not be counted by the sqlite3_changes() or [sqlite3_total_changes()]
** functions, regardless of the number of elements that were originally
** in the table. To get an accurate count of the number of rows deleted, use
** "DELETE FROM table WHERE 1" instead.
** "DELETE FROM table WHERE 1" instead. Or recompile using the
** [SQLITE_OMIT_TRUNCATE_OPTIMIZATION] compile-time option to disable the
** optimization on all queries.
**
** See also the [sqlite3_changes()] interface.
**

View File

@ -16,7 +16,7 @@
** The focus of this file is providing the TCL testing layer
** access to compile-time constants.
**
** $Id: test_config.c,v 1.39 2008/10/10 04:34:16 shane Exp $
** $Id: test_config.c,v 1.40 2008/10/10 23:48:26 drh Exp $
*/
#include "sqliteLimit.h"
@ -402,6 +402,12 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
STRINGVALUE(SQLITE_THREADSAFE), TCL_GLOBAL_ONLY);
assert( sqlite3_threadsafe()==SQLITE_THREADSAFE );
#ifdef SQLITE_OMIT_TEMPDB
Tcl_SetVar2(interp, "sqlite_options", "tempdb", "0", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "tempdb", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_OMIT_TRACE
Tcl_SetVar2(interp, "sqlite_options", "trace", "0", TCL_GLOBAL_ONLY);
#else
@ -414,10 +420,10 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double",
Tcl_SetVar2(interp, "sqlite_options", "trigger", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_OMIT_TEMPDB
Tcl_SetVar2(interp, "sqlite_options", "tempdb", "0", TCL_GLOBAL_ONLY);
#ifdef SQLITE_OMIT_TRUCATE_OPTIMIZATION
Tcl_SetVar2(interp, "sqlite_options", "truncate_opt", "0", TCL_GLOBAL_ONLY);
#else
Tcl_SetVar2(interp, "sqlite_options", "tempdb", "1", TCL_GLOBAL_ONLY);
Tcl_SetVar2(interp, "sqlite_options", "truncate_opt", "1", TCL_GLOBAL_ONLY);
#endif
#ifdef SQLITE_OMIT_UTF16