Lines Matching refs:iT
48 ** underlying operating system supports it. If the OS lacks
133 ** It used to be the case that setting this value to zero would
134 ** turn the limit off. That is no longer true. It is not possible
222 ** compile time. This is no longer permitted, on the grounds that it creates
334 ** if it is available, it requires an #include of specific headers
351 #else /* Generates a warning - but it always works */
377 ** It determines whether or not the features related to
393 ** pared it down to just these two.)
418 ** so it is omitted there. See ticket #2673.
421 ** implemented on some systems. So we avoid defining it at all
422 ** if it is already defined or if it is unneeded because we are
557 ** or constant definition does not appear in this file, then it is
610 ** that we have taken it all out and gone back to using simple
637 ** be larger than the release from which it is derived. Either Y will
730 ** the mutexes are omitted. Without the mutexes, it is not safe
734 ** So if speed is of utmost importance, it makes sense to disable
739 ** version of SQLite that it is linking against was compiled with
762 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
820 ** outstanding [prepared statements] or [BLOB handles], then it returns
837 ** This is legacy and deprecated. It is included for historical
854 ** sqlite3_exec() is not NULL, then it is invoked for each result row
975 ** The SQLITE_OK result code will never be extended. It will always
1066 ** argument to calls it makes to the xLock() and xUnlock() methods
1079 ** [sqlite3_io_methods] object it uses a combination of
1082 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
1132 ** may be invoked even if the xOpen reported that it failed. The
1153 ** PENDING, or EXCLUSIVE lock on the file. It returns true
1202 ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
1249 ** current transaction. This hint is not guaranteed to be accurate but it
1276 ** at the internal representation of an [sqlite3_mutex]. It only
1320 ** ^If a suffix is added to the zFilename parameter, it will
1327 ** filename if it needs to remember the filename for some reason.
1330 ** xFilename parameter is NULL it will also be the case that the
1337 ** If xOpen() opens a file read-only then it sets *pOutFlags to
1355 ** change the way it deals with files. For example, an application
1371 ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE]
1380 ** be created, and that it is an error if it already exists.
1381 ** It is <i>not</i> used to indicate the file should be opened
1387 ** allocate the structure; it should just fill it in. Note that
1475 ** currently unused, though it might be used in a future release of
1501 ** between unlocked and EXCLUSIVE. It cannot transition between SHARED
1530 ** A call to sqlite3_initialize() is an "effective" call if it is
1532 ** the process, or if it is the first time sqlite3_initialize() is invoked
1537 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
1554 ** the library (perhaps it is unable to allocate a needed resource such
1555 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
1561 ** initialized when [sqlite3_open()] is called if it has not be initialized
1566 ** it is recommended that applications always invoke sqlite3_initialize()
1586 ** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
1606 ** applications and so this routine is usually not necessary. It is
1615 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1665 ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
1683 ** xRealloc must be a no-op - it must not perform any allocation or
1703 ** it might allocate any require mutexes or initialize internal data
1709 ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
1711 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
1715 ** it is by default) and so the methods are automatically serialized.
1751 ** [threading mode] to Single-thread. In other words, it disables
1752 ** all mutexing and puts SQLite into a mode where it can only be used
1755 ** it is not possible to change the [threading mode] from its default
1762 ** [threading mode] to Multi-thread. In other words, it disables
1770 ** it is not possible to set the Multi-thread [threading mode] and
1786 ** it is not possible to set the Serialized [threading mode] and
1848 ** the host architecture. ^It is harmless, apart from the wasted memory,
1852 ** memory needs for the first N pages that it adds to cache. ^If additional
1913 ** object and uses it for page cache memory allocations.</dd>
1923 ** and a pointer to void. ^If the function pointer is not NULL, it is
1983 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2032 ** encounters a constraint violation, it does not fail. The
2038 ** be successful even if it is subsequently rolled back.
2141 ** ^It is safe to call this routine from a thread different from the
2142 ** thread that is currently running the database operation. But it
2147 ** sqlite3_interrupt() is called, then it might not have an opportunity
2179 ** complete if it ends with a semicolon token and is not a prefix of a
2227 ** The presence of a busy handler does not guarantee that it will be invoked
2229 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
2232 ** it is trying to promote to a reserved lock and
2233 ** a second process is holding a reserved lock that it is trying
2235 ** because it is blocked by the second and the second process cannot
2236 ** proceed because it is blocked by the first. If both processes
2247 ** already hold a RESERVED lock on the database file, but it needs
2248 ** to promote this lock to EXCLUSIVE so that it can spill cache
2250 ** readers. ^If it is unable to promote the lock, then the in-memory
2316 ** It is not safe to pass a result table directly to [sqlite3_free()].
2351 ** it must pass the result table pointer to sqlite3_free_table() in order to
2359 ** to any internal data structures of SQLite. It uses only the public
2412 ** ^(The %q option works like %s in that it substitutes a null-terminated
2415 ** character it escapes that character and allows it to be inserted into
2421 ** char *zText = "It's a happy day!";
2436 ** INSERT INTO table1 VALUES('It''s a happy day!')
2443 ** INSERT INTO table1 VALUES('It's a happy day!');
2449 ** ^(The %Q option works like %q except it also adds single quotes around
2482 ** memory, it returns a NULL pointer. ^If the parameter N to
2488 ** that it might be reused. ^The sqlite3_free() routine is
2519 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
2538 ** a block of memory after it has been released using
2824 ** Whether or not an error occurs when it is opened, resources
2826 ** passing it to [sqlite3_close()] when it is no longer required.
2829 ** except that it accepts two additional parameters for additional control
2847 ** <dd>The database is opened for reading and writing, and is creates it if
2848 ** it does not already exist. This is the behavior that is always used for
2868 ** participate in [shared cache mode] even if it is enabled.
2874 ** It is recommended that when a database filename actually does begin with
2916 ** interface is the same except that it always returns the
2927 ** When the serialized [threading mode] is in use, it might be the
2993 ** ^Hence, to find the current value of a limit without changing it,
3079 ** To execute an SQL query, it must first be compiled into a byte-code
3092 ** first zero terminator. ^If nByte is non-negative, then it is the maximum
3111 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
3127 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
3129 ** statement and try to run it again.
3213 ** for the values it stores. ^Values stored in sqlite3_value objects
3220 ** whether or not it requires a protected sqlite3_value.
3231 ** for maximum code portability it is recommended that applications
3306 ** string after SQLite has finished with it. ^The destructor is called
3318 ** (just an integer to hold its size) while it is being processed.
3565 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3591 ** Perhaps it was called on a [prepared statement] that has
3593 ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could
3597 ** For all versions of SQLite up to and including 3.6.23.1, it was required
3768 ** and atof(). SQLite does not really use these functions. It has its
3794 ** of conversion are done in place when it is possible, but sometimes they
3858 ** resource leaks. It is a grievous error for the application to try to use
3859 ** a prepared statement after it has been finalized. Any use of a prepared
3860 ** statement after it has been finalized can result in undefined and
3950 ** then it is destructor for the application data pointer.
3955 ** ^When the destructor callback of the tenth parameter is invoked, it
3959 ** ^It is permitted to register multiple implementations of the same
4191 ** calls to sqlite3_get_auxdata() might return this data, if it has
4193 ** ^If it is not NULL, SQLite will invoke the destructor
4218 ** argument is SQLITE_STATIC, it means that the content pointer is constant
4219 ** and will never change. It does not need to be destroyed. ^The
4310 ** function as the destructor on the text or BLOB result when it has
4316 ** when it has finished using that result.
4320 ** from [sqlite3_malloc()] before it returns.
4425 ** themselves rather than expecting SQLite to deal with it for them.
4464 ** then it is passed the names of undefined collation sequences as strings
4507 ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
4566 ** It is not safe to read or modify this variable in more than one
4567 ** thread at a time. It is not safe to read or modify this variable
4570 ** It is intended that this variable be set once
4576 ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
4581 ** Hence, if this variable is modified directly, either it should be
4629 ** satisfies the conditions of this routine, it returns NULL.
4671 ** hook returning non-zero, just as it would be with any other rollback.
4759 ** cache setting should set it explicitly.
4788 ** below the limit, it will exceed the limit rather than generate
4852 ** table or NULL. ^If it is NULL, then all attached databases are searched
4958 ** to turn extension loading on and call it with onoff==0 to turn
4959 ** it back off again.
4984 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
5014 ** interface fixed, support it indefinitely, and remove this comment.
5036 ** ^The registration remains valid until it is replaced by a different
5038 ** of this structure must not change while it is registered with
5092 ** is usable) and false if it cannot.)^
5183 ** invoke the destructor function (if it is not NULL) when SQLite
5286 ** interface fixed, support it indefinitely, and remove this comment.
5315 ** and write access. ^If it is zero, the BLOB is opened for read access.
5316 ** ^It is not possible to open a column that is part of an index or primary
5317 ** key for writing. ^If [foreign key constraints] are enabled, it is
5332 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
5372 ** ^This function is used to move an existing blob handle so that it points
5380 ** it must exist and there must be either a blob or text value stored in
5382 ** it does not contain a blob or text value, or if another error occurs, an
5471 ** ^This function may only modify the contents of the BLOB; it is
5517 ** ^To make an existing VFS into the default VFS, register it again
5566 ** mutex and returns a pointer to it. ^If it returns NULL
5587 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
5589 ** cases where it really needs one. ^If a faster non-recursive mutex
5610 ** dynamic mutex that it allocates. The dynamic mutexes must not be in
5698 ** (i.e. it is acceptable to provide an implementation that segfaults if
5699 ** it is passed a NULL pointer).
5701 ** The xMutexInit() method must be threadsafe. ^It must be harmless to
5713 ** If xMutexInit fails in any way, it is expected to clean up after itself
5736 ** provides implementations for these routines when it is compiled
5746 ** versions of these routines, it should at least provide stubs that always
5751 ** clearly the mutex cannot be held if it does not exist. But the
5836 ** This interface is not for use by applications. It exists solely
5899 ** and it is possible that another thread might change the parameter
5980 ** <dd>This parameter records the deepest parser stack. It is only
6072 ** of times it has performed specific operations.)^ These counters can
6127 ** The sqlite3_pcache type is opaque. It is implemented by
6173 ** It can be used to clean up
6179 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
6199 ** false if it is used for an in-memory database. The cache implementation
6201 ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
6213 ** value; it is advisory only.
6222 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
6229 ** parameter to help it determined what action to take:
6234 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
6260 ** previously contains an entry associated with newKey, it must be
6273 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
6307 ** It is useful either for creating backups of databases or
6314 ** read-locked while it is actually being read; it is not locked
6366 ** from source to destination, then it returns [SQLITE_DONE].
6419 ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
6480 ** same time as another thread is invoking sqlite3_backup_step() it is
6502 ** when the connection currently holding the required lock relinquishes it.
6509 ** its current transaction, either by committing it or rolling it back.
6515 ** application receives an SQLITE_LOCKED error, it may call the
6552 ** single void* pointer that is passed to the callback when it is invoked.
6554 ** it an array of void* context pointers. The first argument passed to
6562 ** multiple times, it is invoked once with the set of void* context pointers
6592 ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
6643 ** a few hundred characters, it will be truncated to the length of the
6660 ** ^The first parameter passed to the callback function when it is invoked
6672 ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value
6844 ** in the table, it is faster to do a linear search than to manage
6860 ** Again, this structure is intended to be opaque, but it can't really
6861 ** be opaque because it is used by macros.
7123 ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
7131 ** GCC does not define the offsetof() macro so we'll have to do it
7139 ** Check to see if this machine uses EBCDIC. (Yes, believe it or
7311 ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
7338 ** make it clear to human readers when a function parameter is deliberately
7343 ** if it knows that this is enforced elsewhere.
7346 ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
7426 /* TODO: This definition is just included so other modules compile. It
7433 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
7755 ** it takes up less space.
7787 ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still
7788 ** gets freed when the Vdbe is finalized so it still should be obtained
8132 ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
8133 ** reserved for working around a windows/posix incompatibility). It is
8536 /* If the SET_FULLSYNC macro is not defined above, then make it
8560 ** Mcafee started using SQLite in their anti-virus product and it
8647 ** file format. Depending on how it is changed, you might not notice
8731 it is available
8732 ** to all source files. We break it out in an effort to keep the code
8909 ** context. It is reset at start of sqlite3_exec.
8911 ** insert, update, or delete statement. It remains constant throughout the
8912 ** length of a statement and is then updated by OP_SetCounts. It keeps a
9017 ** unlock so that it can proceed.
9048 #define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */
9122 ** count on this object is decremented. When it reaches 0, the destructor
9247 ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the
9321 ** connection handle passed to it via the xConnect() or xCreate() method
9332 ** table, it searches the list for the VTable that corresponds to the
9345 ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
9434 ** done as a macro so that it will be optimized out when virtual
9587 ** it means this is not a unique index. Otherwise it is a unique index
9681 ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater
9682 ** than 32767 we have to make it 32-bit. 16-bit is preferred because
9683 ** it uses less memory in the Expr object, which is a big memory user
9727 ** it can be accessed after all aggregates are computed.
9739 ** If the Expr is of type OP_Column, and the table it is selecting from
9925 ** tables in a join to 32 instead of 64. But it also reduces the size
9995 ** It is included here only so that that compiler will know how big it
10001 ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the
10379 ** to save the Parse.zAuthContext value so that it can be restored later.
10619 ** FTS4 is really an extension for FTS3. It is enabled using the
10628 ** The ctype.h header is needed for non-ASCII systems. It is also
11006 ** and decode of the integers in a record header. It is faster for the common
11007 ** case where the integer is a single byte. It is a little slower when the
11008 ** integer is two or more bytes. But overall it is faster.
11308 ** it might have been allocated by lookaside, except the allocation was
11309 ** too large or lookaside was already full. It is important to verify
11315 ** All of this is no-op for a production build. It only comes into
11526 ** the database page that contains the pending byte. It never attempts
11530 ** During testing, it is often desirable to move the pending byte to
11978 ** 6000 lines long) it was split up into several smaller files and
12006 ** If the VdbeCursor.isTriggerRow flag is set it means that this cursor is
12043 ** aRow might point to (ephemeral) data for the current row, or it might
12060 ** restoring the state of the VM to as it was before the sub-program
12065 ** overwritten, the VdbeFrame object is not freed immediately. Instead, it
12218 ** This structure is defined inside of vdbeInt.h because it uses substructures
12250 ** any virtual table method invocations made by the vdbe program. It is
12446 ** Add N to the value of a status record. It is assumed that the
12657 ** as part of the "Secure CRT". It is essentially equivalent to
13123 ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
13637 sqlite3_int64 iT;
13644 sqlite3OsCurrentTimeInt64(db->pVfs, &iT);
13645 t = iT/1000 - 10000*(sqlite3_int64)21086676;
13992 ** Register a VFS with the system. It is harmless to register the same
14018 ** Unregister a VFS so that it is no longer accessible.
14141 ** This version of the memory allocator is the default. It is
14196 ** to obtain the memory it needs.
14203 ** This version of the memory allocator is the default. It is
14211 ** so that we can find it later using sqlite3MemSize().
14348 ** to obtain the memory it needs while adding lots of additional debugging
14440 ** sqlite3MallocAllow() decrements it.
14481 ** if they are incorrect it asserts.
14670 ** higher level code is using pointer to the old allocation, it is
14893 ** it is available. The mempool allocator is activated by calling
15005 ** Unlink the chunk at mem3.aPool[i] from list it is currently
15079 ** If the STATIC_MEM mutex is not already held, obtain it now. The mutex
15168 ** If it sees a chunk that is larger than mem3.iMaster, it replaces
15532 ** is not required to be threadsafe (it is not).
15626 ** it is not actually possible to reach this limit.
15694 ** Unlink the chunk at mem5.aPool[i] from list it is currently
15695 ** on. It should be found on mem5.aiFreelist[iLogsize].
15736 ** If the STATIC_MEM mutex is not already held, obtain it now. The mutex
16113 ** linkage. It returns a pointer to a static sqlite3_mem_methods
16240 ** until it can be obtained.
16250 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
16393 ** mutex and returns a pointer to it. If it returns NULL
16543 ** mutex and returns a pointer to it. If it returns NULL
16560 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
16562 ** cases where it really needs one. If a faster non-recursive mutex
16646 ** SQLite is careful to deallocate every mutex that it allocates.
16857 ** mutex and returns a pointer to it. If it returns NULL
16877 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
16879 ** cases where it really needs one. If a faster non-recursive mutex
16916 /* Use a recursive mutex if it is available */
16956 ** mutex that it allocates.
16982 ** is atomic - that it cannot be deceived into thinking self
17025 ** is atomic - that it cannot be deceived into thinking self
17168 ** API as long as we don't call it win running Win95/98/ME. A call to
17267 ** mutex and returns a pointer to it. If it returns NULL
17287 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
17289 ** cases where it really needs one. If a faster non-recursive mutex
17340 ** mutex that it allocates.
17383 ** The sqlite3_mutex_try() routine is very rarely used, and when it
17384 ** is used it is merely an optimization. So it is OK for it to always
17388 ** And some windows compilers complain if you try to use it without
17747 ** Allocate memory. This routine is like sqlite3_malloc() except that it
17788 ** is outstanding clearing it when the allocation is freed.
17797 ** This routine is similar to alloca() in that it is not intended
18052 ** failing, it fails consistently until mallocFailed is reset.
18060 ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed
18229 ** The "printf" code that follows dates from the 1980's. It is in
18334 ** The following table is searched linearly, so it is good to put the
18439 ** first argument to "func". Use it for whatever you like.
18707 /* It makes more sense to use 0.5 */
18819 /* The converted number is in buf[] and zero terminated. Output it.
19022 ** Finish off a string by making sure it is zero-terminated.
19159 ** sqlite3_snprintf() works like snprintf() except that it ignores the
19183 ** We house it in a separate routine from sqlite3_log() to avoid using
19186 ** sqlite3_log() must render into a static buffer. It cannot dynamically
19187 ** allocate memory because it might be called while the memory allocator
19217 ** and segfaults if you give it a long long int.
19284 ** subtle problems on some systems that could cause problems. It is hard
19535 ** 0xd800 and 0xe000 then it is rendered as 0xfffd.
19543 ** for unicode values 0x80 and greater. It do not change over-length
19592 ** desiredEnc. It is an error if the string is already of the desired
19732 ** UTF-16 string stored in *pMem. If one is present, it is removed and
19734 ** byte-swapping, it just sets Mem.enc appropriately.
19795 ** Hence it is only available in debug builds.
19804 ** The translation is done in-place (since it is impossible for the
19852 ** arrange to call sqlite3DbFree() on the returned pointer when it is
19901 ** It checks that the primitives for serializing and deserializing
19998 ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
20007 ** -O option since it can result in incorrect output for programs
20037 ** The value returned will never be negative. Nor will it ever be greater
20052 ** If it is not NULL, string zFormat specifies the format of the
20062 ** zFormat and any string tokens that follow it are assumed to be
20194 ** Convert this string to a double and write it into *pResult.
20211 ** returns FALSE but it still converts the prefix and writes the result
20400 ** if it is too big (used as a negative).
20438 ** than 19 digits (thus guaranteeing that it is too large) */
20441 /* Less than 19 digits, so we know that it fits in 64 bits */
20532 ** bit clear. Except, if we get to the 9th byte, it stores the full
20694 /* we can skip this cause it was (effectively) done above in calc'ing s */
20842 ** slightly faster, but it is also larger and much harder to test.
20973 ** foolproof but it does provide some measure of protection against
20976 ** 1 it means that the db pointer is valid and 0 if it should not be
21112 /* Resize the hash table so that it cantains "new_size" buckets.
21130 ** a performance hit but it is not a fatal error. So mark the
21215 ** that matches pKey,nKey. Return the data for this element if it is
21478 ** embedded systems, and when it does the developers normally have bigger
21525 ** This file should be #included by the os_*.c files only. It is not a
21579 ** It uses the RDTSC opcode to read the cycle count value out of the
21636 ** of the debugging and testing utilities, but it should at
21929 ** transitions leaving the lock state different from what it started but
21941 ** It is not possible to lower the locking level one step at a time. You
22049 ** release it now.
22123 ** It is not possible for this routine to fail if the second argument
22200 ** SQLite code assumes this function cannot fail. It also assumes that
22466 #ifdef NDEBUG /* when debugging we want to make sure it is deleted */
22875 ** underlying operating system supports it. If the OS lacks
22973 ** opportunity to either close or reuse it.
23023 ** it is larger than the struct CrashFile defined in test6.c.
23055 ** This file should be #included by the os_*.c files only. It is not a
23109 ** It uses the RDTSC opcode to read the cycle count value out of the
23166 ** of the debugging and testing utilities, but it should at
23262 ** The DJGPP compiler environment looks mostly like Unix, but it
23265 ** DJGPP. But it is DOS - what did you expect?
23403 ** useful to the clients of the sqlite3 functions. Specifically, it is
23422 * introspection, in which it actually means what it says */
23443 * introspection, in which it actually means what it says */
23448 * it actually means what it says */
23478 ** The structure is reclaimed when the number of pointers to it drops to
23482 ** a performance-critical path, so it is sufficient to put these
23612 ** by the same process. It does not explicitly say so, but this implies
23613 ** that it overrides locks set by the same process using a different
23622 ** on fd2, it works. I would have expected the second lock to
23647 ** descriptor. It is now a structure that holds the integer file
23652 ** a reference count (so we will know when to delete it) and a "cnt"
23716 ** object keeps a count of the number of unixFile pointing to it.
23747 ** It is invoked after an error occurs in an OS function and errno has been
23748 ** set. It logs a message using sqlite3_log() containing the current value of
23779 ** may point to aErr[], or it may point to some static storage somewhere.
23783 ** If the code incorrectly assumes that it is the POSIX version that is
23909 ** around this problem (we consider it a bug in OS X, not SQLite)
23983 /* Otherwise see if some other process holds it.
24020 ** transitions leaving the lock state different from what it started but
24049 ** A process may only obtain a RESERVED lock after it has a SHARED lock.
24053 ** A process may only obtain a PENDING lock after it has obtained a
24200 /* The request was for a RESERVED or EXCLUSIVE lock. It is
24468 ** common to all locking schemes. It closes the directory and file
24472 ** It is *not* necessary to hold the mutex when this routine is called,
24524 ** descriptor to pInode->pUnused list. It will be automatically closed
24547 ** (ex: databases that are burned into CD-ROM, for example.) It can
24614 ** In dotfile locking, either a lock exists or it does not. So in this
24653 ** transitions leaving the lock state different from what it started but
24708 /* got it, set the type and return ok */
24828 /* Otherwise see if some other process holds it. */
24833 /* got the lock, unlock it */
24847 /* someone else might have it reserved */
24878 ** transitions leaving the lock state different from what it started but
24902 /* if we already have a lock, it is exclusive.
24919 /* got it, set the type and return ok */
25000 ** Semaphore locking is like dot-lock and flock in that it really only
25027 /* Otherwise see if some other process holds it. */
25042 /* we could have it if we want it */
25063 ** transitions leaving the lock state different from what it started but
25087 /* if we already have a lock, it is exclusive.
25101 /* got it, set the type and return ok */
25277 /* Otherwise see if some other process holds it.
25283 /* if we succeeded in taking the reserved lock, unlock it to restore
25287 /* if we failed to get the lock then someone else must have it */
25313 ** transitions leaving the lock state different from what it started but
25443 /* The request was for a RESERVED or EXCLUSIVE lock. It is
25620 ** descriptor to pInode->aPending. It will be automatically closed when
25681 ** NB: If you define USE_PREAD or USE_PREAD64, then it might also
25901 ** it work better.
25910 ** The idea behind dataOnly is that it should only write the file content
25919 ** So, we always use fdatasync() if it is available, regardless of
25926 ** the one below. It is replicated here solely to avoid cluttering
25961 ** It shouldn't be possible for fullfsync to fail on the local
25965 ** It'd be better to detect fullfsync support once and avoid
25971 /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly
26043 ** A failed directory sync is not a big deal. So it seems
26071 ** file so that it consists of an integer number of chunks (i.e. the
26119 ** layers, we need to report this file size as zero even though it is
26140 ** If the user has configured a chunk-size for this file, it could be
26160 /* If the OS does not have posix_fallocate(), fake it. First use
26208 /* The pager calls this method to signal that it has done
26210 ** it hence it is OK for the transaction change counter to be
26233 ** SQLite code assumes this function cannot fail. It also assumes that
26406 ** This is not a VFS shared-memory method; it is a utility function called
26479 ** a new *-shm file is created, an attempt will be made to create it
26579 ** been allocated, it is allocated by this function.
26582 ** this call as described above, then it is mapped into this processes
26583 ** address space (if it is not already), *pp is set to point to the mapped
26598 /* If the shared-memory file has not yet been opened, open it now. */
26617 ** Check to see if it has been allocated (i.e. if the wal-index file is
26862 ** implement various file locking strategies. It also contains definitions
26991 ** The proxy locking method is a "super-method" in the sense that it
26993 ** it uses proxy, dot-file, AFP, and flock() locking methods on those
27031 ** for the database file "filePath". It then returns the sqlite3_io_methods
27097 ** for the database file "filePath". It then returns the sqlite3_io_methods
27223 ** findInodeInfo(). If this is the case, it is quite safe to close
27224 ** handle h - as it is guaranteed that no posix locks will be released
27239 /* AFP locking uses the file path so it needs to be included in
27266 /* Dotfile locking uses the file path so it needs to be included in
27283 /* Named semaphore locking uses the file path so it needs to be
27398 /* It's odd to simulate an io-error here, but really this is just
27408 ** name. If it is not, return SQLITE_ERROR.
27448 ** If a suitable file descriptor is found, then it is returned. If no
27455 ** vxworks would not benefit from the change (it might, we're not sure),
27456 ** but because no way to test it is currently available. It is better
27462 /* A stat() call may fail for various reasons. If this happens, it is
27464 ** For this reason, if an error occurs in the stat() call here, it is
27500 ** If the file being opened is a temporary file, it is always created with
27502 ** is a database or master journal file, it is created with the permissions
27724 /* It is safe to close fd at this point, because it is guaranteed not
27725 ** to be open on a database file. If it were open on a database file,
27726 ** it would not be safe to close as this would release any locks held
27771 ** on that file that are currently holding advisory locks on it,
27910 /* It's odd to simulate an io-error here, but really this is just
27949 ** message is available, it is written to zBufOut. If no error message
27972 ** We initialize x by assigning it a pointer to the dlsym() function.
28008 ** some users. Rather than argue, it seems easier just to initialize
28128 ** in the core. So this routine is never called. For now, it is merely
28146 ** Proxy locking is a "uber-locking-method" in this sense: It uses the
28204 ** host ID in it, the proxy path in the conch file will be used, otherwise
28213 ** Once a lock proxy is configured for a database connection, it can not
28214 ** be removed, however it may be switched to a different proxy path via
28236 ** If the conch file does not exist, or it's contents do not match the
28248 ** Requesting the lock proxy does not immediately take the conch, it is
28251 ** opening a connection to a database file does not take a lock on it.
28299 ** and local proxy files in it
28450 return SQLITE_IOERR_LOCK; /* even though it is the conch */
28487 /* Not always defined in the headers as it ought to be */
28527 ** it back. The newly created file's file descriptor is assigned to the
28557 /* write it out to the temporary break file */
28749 /* if the conch isn't writable and doesn't match, we can't take it */
28996 ** This routine find the filename associated with pFile and writes it
29022 ** Takes an already filled in unix file and alters it so all file locking
29212 ** transitions leaving the lock state different from what it started but
29296 /* restore the original locking context and pMethod then close it */
29347 ** more than that; it looks at the filesystem type that hosts the
29451 ** embedded systems, and when it does the developers normally have bigger
29504 ** This file should be #included by the os_*.c files only. It is not a
29558 ** It uses the RDTSC opcode to read the cycle count value out of the
29615 ** of the debugging and testing utilities, but it should at
29714 ** WinCE lacks native support for file locking so we have to fake it
29761 ** thereafter. It records whether the operating system is Win95
29783 ** API as long as we don't call it when running Win95/98/ME. A call to
29996 /* Replace the backslashes from the filename and lowercase it
30023 /* Set a flag that indicates we're the first to create the memory so it
30031 /* If we succeeded in making the shared memory handle, map it. */
30035 /* If mapping failed, close the shared memory handle and erase it */
30137 /* If no pending lock has been acquired, then acquire it */
30274 ** containing the lower 32-bits of the new file-offset. Or, if it fails,
30275 ** it returns INVALID_SET_FILE_POINTER. However according to MSDN,
30277 ** whether an error has actually occured, it is also necessary to call
30292 ** It is reported that an attempt to close a handle might sometimes
30294 ** for being unreasonable so I do not doubt that it might happen. If
30423 ** file so that it consists of an integer number of chunks (i.e. the
30431 /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
30590 ** transitions leaving the lock state different from what it started but
30602 ** It is not possible to lower the locking level one step at a time. You
30643 ** held by another reader process who will release it momentarily.
30702 ** release it
30757 ** It is not possible for this routine to fail if the second argument
30824 ** SQLite code assumes this function cannot fail. It also assumes that
31014 ** This is not a VFS shared-memory method; it is a utility function called
31346 ** been allocated, it is allocated by this function.
31349 ** this call as described above, then it is mapped into this processes
31350 ** address space (if it is not already), *pp is set to point to the mapped
31383 ** Check to see if it has been allocated (i.e. if the wal-index file is
31540 /* It's odd to simulate an io-error here, but really this is just
31561 ** it's important to not reference them for WINCE builds.
31579 ** name. If it is not, return SQLITE_ERROR.
31607 /* FormatMessage returns 0 on failure. Otherwise it
31632 ** it's important to not reference them for WINCE builds.
31767 ** created. SQLite doesn't use it to indicate "exclusive access"
31768 ** as it is usually understood.
31771 /* Creates a new file, only if it does not already exist. */
31772 /* If the file exists, it fails. */
31775 /* Open existing file, or create if it doesn't exist */
31778 /* Opens a file, only if it exists. */
31813 ** it's important to not reference them for WINCE builds.
31884 ** process has it open. Sometimes a virus scanner or indexing program
31885 ** will open a journal file shortly after it is created in order to do
31886 ** whatever it does. While this other process is holding the
31887 ** file open, we will be unable to delete it. To work around this
31919 ** it's important to not reference them for WINCE builds.
31966 ** as if it does not exist.
31985 ** it's important to not reference them for WINCE builds.
32041 /* It's odd to simulate an io-error here, but really this is just
32063 ** it's important to not reference them for WINCE builds.
32180 ** it's important to not reference them for WINCE builds.
32297 /* if SystemTimeToFileTime() fails, it returns zero. */
32344 ** it should be truncated. The return value of xGetLastError
32347 ** then it is not necessary to include the nul-terminator character
32351 ** on SQLite. It is fine to have an implementation that never
32359 ** However if an error message is supplied, it will be incorporated
32455 ** it will be aligned within the Bitvec struct. */
32598 /* completely fill the hash, then just add it without */
32607 /* there was a collision, check to see if it's already */
32608 /* in hash, if not, try to find a spot for it */
32614 /* we didn't find it in the hash. h points to the first */
32871 ** Check that the pCache->pSynced variable is set correctly. If it
33029 int createFlag, /* If true, create page if it does not exist already */
33040 ** allocate it now.
33115 ** reference count drops to 0, then it is made elible for recycling.
33143 ** page. This function deletes that reference, so after it returns the
33161 ** Make sure the page is marked as dirty. If it isn't dirty already,
33162 ** make it so.
33174 ** Make sure the page is marked as clean. If it isn't clean already,
33175 ** make it so.
33240 ** it must be that pgno==0.
33426 ** sqlite3_pcache interface). It also contains part of the implementation
33520 ** bytes of data are located directly before it in memory (i.e. the total
33570 ** such buffer exists or there is no space left in it, this function falls
33589 ** configured soft-heap-limit to be breached, it will be possible to
33668 ** The pointer is allowed to be NULL, which is prudent. But it turns out
33705 ** Return true if it desirable to avoid allocating a new page cache
33710 ** it is desirable to avoid allocating a new page cache entry because
33716 ** under memory pressure, then again it is desirable to avoid
33777 ** global LRU list, if is part of it. If pPage is not part of the global
33806 ** (PCache1.apHash structure) that it is currently stored in.
33965 ** copy of the requested page. If one is found, it is returned.
33994 ** then attempt to recycle a page from the LRU list. If it is the right
34092 /* It is an error to call this function if the page is already
34285 ** After all inserts are finished, it is possible to extract the
34313 ** a non-zero batch number, it will see all prior INSERTs.
34384 ** It must be the case that N is sufficient to make a Rowset. If not
34600 ** as deep as it needs to be in order to contain the entire list.
34622 ** Convert the list in p->pEntry into a sorted list if it is not
34624 ** convert it into a list too and merge it into the p->pEntry list.
34703 ** The pager is used to access a database disk file. It implements
34764 ** snapshot is like a read-transaction. It is the state of the database
34773 /* Read a page from the write-ahead log, if it is present. */
34837 ** automatically as soon as it is written when PRAGMA synchronous=OFF.
34844 ** (a) The original content of the page as it was at the beginning of
34880 ** Definition: Two databases (or the same database at two points it time)
34892 ** is called to restore the database file to the same size it was at
34895 ** invoke it.)
34994 ** it opens a read-transaction on the database and returns to state
35007 ** * Even if a read-transaction is not open, it is guaranteed that
35043 ** is opened (if it is not already open) and a header written to the
35044 ** start of it. The database file on disk has not been modified.
35049 ** to it, but the header has not been synced to disk.
35055 ** when it modifies the contents of the database file. WAL connections
35068 ** It is not possible for a WAL connection to enter this state.
35073 ** by finalizing the journal file. Once in WRITER_FINISHED state, it is
35087 ** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it
35096 ** At this point it would be dangerous to change back to READER state
35103 ** Once it has entered the ERROR state, any attempt to use the pager
35129 ** Condition (3) is necessary because it can be triggered by a read-only
35132 ** automatically attempt a rollback, as it assumes that an error in a
35171 ** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not
35177 ** at the system level, but it is never set to a more exclusive value.
35194 ** doesn't know it because of a previous error in xUnlock). If this happens
35197 ** without rolling it back.
35200 ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
35204 ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
35205 ** lock on the database file before attempting to roll it back. See function
35277 ** logic into thinking that it already has all the locks it will ever
35290 ** It is set to true when the change-counter field is updated, which
35292 ** It is cleared (set to false) whenever an exclusive lock is
35294 ** The changeCountDone flag is inspected. If it is true, the work of
35303 ** When PagerCommitPhaseOne() is called to commit a transaction, it may
35305 ** journal file before it is synced to disk.
35310 ** If a journal file does not contain a master-journal pointer, it is
35312 ** it does contain a master-journal pointer the journal file is finalized
35313 ** by truncating it to zero bytes, just as if the connection were
35336 ** while it is being traversed by code in pager_playback().
35356 ** It is valid in PAGER_READER and higher states (all states except for
35375 ** variable at the start of the transaction. It is used during rollback,
35380 ** the file on disk in pages. It is set to a copy of dbSize when the
35389 ** to measure the database file on disk, and then truncates it if required.
35409 ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It
35514 ** was obtained from /dev/random. It is used only as a sanity check.
35522 ** journal and ignore it.
35570 ** Return 0 if it is not open, or non-zero (but not 1) if it is.
35621 ** as if it has an exclusive lock on the database file. It never updates
35634 ** this means an in-memory pager performs no IO at all, it cannot encounter
35637 ** return SQLITE_IOERR_NOMEM while the journal file is being written). It
35685 /* It is possible that if journal_mode=wal here that neither the
35788 ** Return true if it is necessary to write page *pPg into the sub-journal.
35854 ** called, do not modify it. See the comment above the #define of
35880 ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK.
35907 ** The optimization is also always enabled for temporary files. It is
35911 ** If the optimization cannot be used, 0 is returned. If it can be used,
35912 ** then the value returned is the size of the journal file when it
35985 ** end of the file and, if successful, copies it into memory supplied
35997 ** file, then it is copied into the buffer pointed to by zMaster. A
36001 ** If it is determined that no master journal file name is present
36082 ** after writing or truncating it.
36113 ** space than that limit allows for, truncate it now. There is no need
36178 ** file it may contain some garbage data. There are two scenarios
36216 /* In theory, it is only necessary to write the 28 bytes that the
36222 ** However it has been discovered that on some systems this pattern can
36458 /* It is not possible for a call to PcacheFetch() with createFlag==0 to
36476 ** if it is open and the pager is not in exclusive mode.
36514 ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN
36520 ** closed (if it is open).
36586 ** it can safely move back to PAGER_OPEN state. This happens in both
36619 ** it were a hot-journal).
36643 ** This routine is never called in PAGER_ERROR state. If it is called
36645 ** exclusive than a RESERVED lock, it is a no-op.
36649 ** If the journal file is open, then it is "finalized". Once a journal
36650 ** file has been finalized it is not possible to use it to roll back a
36651 ** transaction. Nor will it be considered to be a hot-journal by this
36698 ** 1. After a successful hot-journal rollback, it is called with
36737 ** the database file, it will do so using an in-memory journal.
36797 ** will roll it back.
36824 ** This is not a real checksum. It is really just the sum of the
36834 ** It is much less likely that the two ends of the journal record will be
36876 ** If pDone is not NULL, then it is a record of pages that have already
36926 ** a hot-journal rollback. If it is a hot-journal rollback, the pager
36947 ** it could cause invalid data to be written into the journal. We need to
36948 ** detect this invalid data (with high probability) and ignore it.
36966 ** rollback, then don't bother to play it back again.
36991 ** pager cache if it exists and the main file. The page is then marked
36993 ** a hot-journal rollback, it is guaranteed that the page-cache is empty
37010 ** 2008-04-14: When attempting to vacuum a corrupt database file, it
37049 ** problem. When the page is next fetched by the b-tree layer, it
37061 ** requiring a journal-sync before it is written.
37088 ** as clean, since there will be no need to write it out to the
37093 ** unsynced portion of the main journal file, then it is not safe
37098 ** again within this transaction, it will be marked as dirty but
37099 ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially
37125 ** This routine checks if it is possible to delete the master journal file,
37126 ** and does so if it is.
37131 ** When a master journal file is created, it is populated with the names
37144 ** each child journal, it checks if:
37216 ** Open it and check if it points at the master journal. If
37264 ** xTruncate() method to truncate it.
37266 ** Or, it might might be the case that the file on disk is smaller than
37268 ** you try to truncate a file to some size that is larger than it
37285 /* TODO: Is it safe to use Pager.dbFileSize here? */
37313 ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it
37337 ** the state it was in before we started making changes.
37364 ** failure occurred while the journal was being written, it could be the
37366 ** the extra entries had not yet made it safely to disk. In such a case,
37370 ** If the nRec value is 0xffffffff it means that nRec should be computed
37386 ** that might be a hot journal. Or, it could be that the journal is
37412 /* Read the master journal name from the journal, if it is present.
37417 ** TODO: Technically the following is an error because it assumes that
37442 ** it is corrupted, then a process must have failed while writing it.
37464 ** process and if this is the final header in the journal, then it means
37473 ** the journal, it means that the journal might contain additional
37512 ** first place so it is OK to simply abandon the rollback. */
37567 ** see if it is possible to delete the master journal.
37575 ** value. Reset it to the correct value for this process.
37660 ** it is discarded. Otherwise, if there are one or more outstanding
37734 /* Increment the value just read and write it back to byte 24. */
37752 ** Hence, if page 1 appears anywhere on the list, it will be the first page.
37797 ** This routine used to be called "pagerOpenSnapshot()" because it essentially
37810 ** transaction in locking_mode=EXCLUSIVE. So call it now. If we
37848 ** determine it based on the size of the database file. If the size
37884 ** not exist (by deleting it) if the database file is empty.
37957 ** rolled back the first time it is encountered in either journal.
37963 ** is reset to the value that it held at the start of the savepoint
37965 ** is played back. If one is encountered it is simply skipped.
37984 /* Set the database size back to the value it was before the savepoint
38092 ** it is theoretically possible, though very unlikely,
38095 ** when it is rolled back.
38165 ** delete the temporary file when it is closed.
38199 ** lock. It does *not* invoke the busy handler when upgrading from
38211 ** retried. If it returns zero, then the SQLITE_BUSY error is
38227 ** If the pager is in the error state when this function is called, it
38238 ** * the database is either not an in-memory database or it is
38256 /* It is not possible to do a full assert_pager_state() here, as this
38308 ** occurs. But other modules are free to use it too, as long as
38392 ** the pager. It returns the total number of pages in the database.
38444 ** b) if the page content were written at this time, it would not
38456 ** database image would become corrupt. It is therefore fortunate that
38473 ** function does not actually modify the database file on disk. It
38486 ** This function is called before attempting a hot-journal rollback. It
38491 ** Syncing a hot-journal to disk before attempting to roll it back ensures
38520 ** is made to roll it back. If an error occurs during the rollback
38539 /* If it is open, sync the journal file before calling UnlockAndRollback.
38546 ** database and close the journal file without attempting to roll it
38547 ** back or finalize it. The next database user will have to do hot-journal
38606 ** been written following it. If the pager is operating in full-sync
38654 ** hot-journal rollback following recovery. It may roll back all
38656 ** out-of-date data that follows it. Database corruption.
38660 ** byte to the start of it to prevent it from being recognized.
38663 ** problematic header will occur, if it exists. aMagic is used
38687 ** it as a candidate for rollback.
38690 ** SAFE_APPEND property. Because in this case it is not possible
38750 ** is not yet open, it is created and opened before any data is
38755 ** a page is skipped if it meets either of the following criteria:
38777 /* If the file is a temp-file has not yet been opened, open it now. It
38850 ** Ensure that the sub-journal file is open. If it is already open, this
38871 ** It is the callers responsibility to use subjRequiresPage() to check
38872 ** that it is really required before calling this function.
38887 /* Open the sub-journal, if it has not already been opened */
38921 ** This function is called by the pcache layer when it has reached some
38955 ** lead to database corruption. In the current implementaton it
38957 ** while in the error state, hence it is impossible for this routine to
38986 ** the database image, it may need to be written to the sub-journal.
39003 ** data from the database file. This will be the copy of page X as it
39004 ** was when the transaction started, not as it was when "SAVEPOINT sp"
39008 ** sub-journal file now (if it is not already there), so that it will
39036 ** Allocate and initialize a new Pager object and put a pointer to it
39037 ** in *ppPager. The pager should eventually be freed by passing it
39044 ** all information is held in cache. It is never written to disk.
39052 ** operation of the pager. It should be passed some bitwise combination
39129 ** as it will not be possible to open the journal file or even
39235 /* If a temporary file is requested, it is not opened immediately.
39329 ** PAGER_SHARED state. It tests if there is a hot journal present in
39350 ** will not roll it back.
39391 /* Check the size of the database file. If it consists of 0 pages,
39411 ** it can be ignored.
39430 ** it might be due to the race condition described above and in
39432 ** This might be a false positive. But if it is, then the
39434 ** with it under an EXCLUSIVE lock where we do not need to
39450 ** It is illegal to call sqlite3PagerAcquire() until after this function
39452 ** this function is called, it is a no-op.
39503 ** database file, then it either needs to be played back or deleted.
39512 /* Get an EXCLUSIVE lock on the database file. At this point it is
39514 ** EXCLUSIVE lock. If it were, another process might open the
39532 /* If it is not already open and the file exists on disk, open the
39539 ** If the journal does not exist, it usually means that some
39540 ** other connection managed to get in and roll it back before
39541 ** this connection obtained the exclusive lock above. Or, it
39567 ** it back since the process that crashed and left the hot journal
39568 ** probably did not sync it and we are required to always sync
39569 ** the journal before playing it back.
39595 ** assert_pager_state() would fail now, as it should not be possible
39626 ** it can be neglected.
39695 ** successfully obtained, it is copied to *ppPage and SQLITE_OK returned.
39697 ** If the requested page is already in the cache, it is returned.
39706 ** data is left as it was when the page object was last used.
39714 ** If noContent is true, it means that we do not care about the contents
39736 ** in memory, this routine goes to disk to read it in whereas Lookup()
39737 ** just returns 0. This routine acquires a read-lock the first time it
39739 ** Since Lookup() never goes to disk, it never has to deal with locks
39805 ** It merely means that we might do some extra work to journal a
39845 ** Acquire a page if it is already in the in-memory cache. Do
39887 ** to the start of it. If there are active savepoints, open the sub-journal
39889 ** opened to write a rollback log for a transaction. It is not used
39890 ** when opening a hot journal file to roll it back.
39892 ** If the journal file is already open (as it may be in exclusive mode),
39922 /* Open the journal file if it is not already open. */
39980 ** has no effect if the sub-journal is already opened (as it may be when
39998 ** exclusive lock on the database is not already held, obtain it now.
40011 ** holds the write-lock. If possible, the upper layer will call it.
40030 ** when it has an open transaction, but never to DBMOD or FINISHED.
40066 ** It is never called in the ERROR state.
40086 ** rollback journal might not yet be open. Open it now if this is the case.
40089 ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then
40110 ** the transaction journal if it is not there already.
40172 /* If the statement journal is open and the page is not in it,
40175 ** in that it omits the checksums and the header.
40231 ** an integer power of 2. It sets variable pg1 to the identifier
40271 ** starting at pg1, then it needs to be set for all of them. Because
40297 ** to sqlite3PagerWrite(). In other words, return TRUE if it is ok
40307 ** A call to this routine tells the pager that it is not necessary to
40315 ** that it does not get written to disk.
40363 ** to this function. Otherwise, it is always set to zero.
40426 ** If successful, or if called on a pager for which it is a no-op, this
40446 ** If the EXCLUSIVE lock is already held or the attempt to obtain it is
40515 ** function has already been called, it is mostly a no-op. However, any
40531 /* The following block updates the change-counter. Exactly how it
40589 ** that it took at the start of the transaction. Otherwise, the
40627 ** atomic-update optimization is used it is almost certain that the
40629 ** on a system under memory pressure it is just possible that this is
40630 ** not the case. In this case it is likely enough that the redundant
40673 ** though, and if a failure occurs at this point it will eventually
40677 ** truncating or partially zeroing it, so that it cannot be used
40688 ** But if (due to a coding error elsewhere in the system) it does get
40730 ** it returns Pager.errCode immediately. No work is performed in this case.
40734 ** 1) It rolls back the journal file, restoring all database file and
40738 ** 2) It finalizes the journal file, so that it is not used for hot
40866 ** malloc failure occurs while populating it in the for(...) loop below.
40908 ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with
40909 ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes
40921 ** the transaction or unlock the database, it just restores the
40956 /* Only truncate if it is an in-memory sub-journal. */
40965 ** If this is a temp-file, it is possible that the journal file has
41047 ** in the rollback journal, it is not put there by by this routine.
41053 ** A transaction must be active when this routine is called. It used to be
41060 ** is being committed. In this case, it is guaranteed that the database page
41064 ** occurs. Otherwise, it returns SQLITE_OK.
41091 ** <journal page X, then modify it in memory>
41096 ** If page X were not written to the sub-journal here, it would not
41120 ** can be written to. The caller has already promised not to write to it.
41128 /* If the cache contains a page with page-number pgno, remove it
41130 ** page pgno before the 'move' operation, it needs to be retained
41153 ** as the original page since it has already been allocated.
41172 ** this transaction, it may be written to the database file before
41173 ** it is synced into the journal file. This way, it may end up in
41258 ** only. We invoke it once here to suppress a compiler warning. */
41307 /* In this case we would like to delete the journal file. If it is
41313 ** while it is in use by some other client.
41354 ** Return TRUE if the pager is in a state where it is OK to change the
41381 ** uses it opaquely as an argument to sqlite3BackupRestart() and
41417 ** is obtained instead, immediately release it.
41473 ** is not already open, make an attempt to open it now. If successful,
41527 ** it may need to be checkpointed before the connection can switch to
41528 ** rollback mode. Open it now so this can happen.
41648 ** magic number in the first 4 bytes of the WAL is 0x377f0683 and it
41679 ** To read a page from the database (call it page number P), a reader
41680 ** first checks the WAL to see if it contains page P. If so, then the
41691 ** and ignores the newly appended content, it will see a consistent snapshot
41715 ** connection to it closes. Because the wal-index is transient, it can
41716 ** use an architecture-specific format; it does not have to be cross-platform.
41873 ** Or it can be 1 to represent a 65536-byte page. The latter case was
41907 ** a special case; its value is never used and it exists as a place-holder
42133 ** architecture, it returns the u32 value that results from interpreting
42134 ** the 4 bytes as a big-endian value. On a big-endian architecture, it
42199 ** The checksum on pWal->hdr is updated before it is written.
42215 ** This function encodes a single frame header and writes it to a buffer
42251 ** in aData[] is valid. If it is a valid frame, fill *piPage and
42328 ** A lock cannot be moved directly between shared and exclusive - it must go
42389 ** slot in the hash table is set to N, it refers to frame number
42483 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
43024 ** WalIterator object when it has finished with it.
43036 ** it only runs if there is actually content in the log (mxFrame>0).
43121 ** it safe to delete the WAL since the new content will persist in the
43162 /*** TODO: Move this test out to the caller. Make it an assert() here ***/
43307 ** read it, which might result in inconsistency. A dirty read is detected
43328 ** meaning it is possible that an inconsistent snapshot is read
43398 /* If the first attempt failed, it might have been due to a race
43408 ** a WRITE lock, it can only mean that the header is corrupted and
43431 ** This is the value that walTryBeginRead returns when it needs to
43438 ** other transient condition. When that happens, it returns WAL_RETRY to
43439 ** indicate to the caller that it is safe to retry immediately.
43446 ** the case where the WAL is bypassed because it has been completely
43463 ** possibility is so small that it can be safely neglected, we believe.
43482 ** update values of the aReadMark[] array in the header, but if it does
43483 ** so it takes care to hold an exclusive lock on the corresponding
43502 ** during the few nanoseconds that it is holding the lock. In that case,
43503 ** it might take longer than normal for the lock to free.
43556 /* The WAL has been completely backfilled (or it is empty).
43563 /* It is not safe to allow the reader to continue here if frames
43574 ** it finished. Leaving a corrupt image in the database file.
43586 /* If we get this far, it means that the reader will want to use
43629 ** It is necessary to check that the wal-index header did not change
43630 ** between the time it was read and when the shared-lock was obtained
43641 ** blocking writers. It only guarantees that a dangerous checkpoint or
43663 ** it takes a snapshot of the state of the WAL and wal-index for the current
43700 ** Read a page from the WAL, if it is present in the WAL and if the
43799 /* If iRead is non-zero, then it is the log frame number that contains the
43838 ** the read transaction was started, then it is not possible for this
43895 ** other than SQLITE_OK, it is not invoked again and the error code is
43907 /* Restore the clients cache of the wal-index header to the state it
43922 ** If the upper layer is doing a rollback, it is guaranteed that there
43983 ** file (see sqlite3WalFrames()). It checks to see if, instead of appending
43984 ** to the current log file, it is possible to overwrite the start of the
43986 ** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left
44010 ** In theory it would be Ok to update the cache of the header only
44074 /* See if it is possible to write these frames into the start of the
44075 ** log file, instead of appending to it at pWal->hdr.mxFrame.
44177 /* Append data to the wal-index. It is not necessary to lock the
44236 ** is already running a checkpoint, or maybe a recovery. But it might
44251 ** next time the pager opens a snapshot on this database it knows that
44298 ** not actually change anything. The pager uses this to see if it
44366 ** big and we want to break it down some. This packaged seemed like
44471 ** except that it applies to leaf nodes in a LEAFDATA tree. The maximum
44472 ** payload fraction for a LEAFDATA tree is always 100% (or 255) and it
44693 ** this object for every database file that it has open. This structure
44700 ** has it own instance of this object. But each instance of this object
44742 ** sharing the same database file, each connection has it own
44750 ** may not be modified once it is initially set as long as nRef>0.
44834 ** If a tree that appears to be taller than this is encountered, it is
44978 ** if the database supports auto-vacuum or not. Because it is used
44980 ** (sqliteMallocRaw), it is not possible to use conditional compilation.
45394 it 65536.
45407 ** but the test harness needs to access it so we make it global for
45460 ** table with root page iRoot. Return 1 if it does and 0 if not.
45499 ** not loaded, then it is too difficult to actually check to see if
45509 ** written. For index b-trees, it is the root page of the associated
45544 ** Return true if it would be illegal for pBtree to write into the
45548 ** It is illegal for pBtree to write if some other Btree object that
45551 ** read-uncommitted flag set, then it is OK for the other object to
45666 /* This function should only be called on a sharable b-tree after it
45680 ** with table iTable, allocate one and link it into the list.
45712 ** transaction. If it does not, then the BtShared.isPending variable
45859 ** such a page is not even journalled (as it will not be modified,
45860 ** why bother journalling it?).
45863 ** from the database or written to the journal file (why should it
45864 ** be, if it is not at all meaningful?).
45870 ** it is moved to the free-list and it is also not journalled when it
45872 ** may be lost. In the event of a rollback, it may not be possible
45901 ** free-list for reuse. It returns false if it is safe to retrieve the
46033 ** Restore the cursor to the position it was in (or as close to as possible)
46062 ** Determine whether or not a cursor has moved from the position it
46113 ** so that it maps to type 'eType' and parent page number 'pgno'.
46542 ** the list that is large enough to accomadate it.
46627 ** freeblocks that overlapped cells. Nor does it detect when the
46675 /* If the cell content area begins with a freeblock, remove it. */
46730 ** guarantee that the page is well-formed. It only shows that
46776 ** returned if it does.
46840 ** Set up a raw page so that it looks like a database page holding
46892 ** If the noContent flag is set, it means that we do not care about
46944 ** Get a page from the pager and initialize it. This routine is just a
46948 ** If an error occurs, then the value *ppPage is set to is undefined. It
46949 ** may remain unchanged, or it may be set to an invalid value.
47007 /* pPage might not be a btree page; it might be an overflow page
47010 ** But no harm is done by this. And it is very important that
47033 ** be exclusively in memory, or it might use a disk-based memory cache.
47038 ** that is automatically destroyed when it is closed.
47313 ** Decrement the BtShared.nRef counter. When it reaches zero,
47316 ** false if it is still positive.
47403 ** it without having to hold the mutex.
47433 ** operate asynchronously - it will not stop to do fsync()s
47593 ** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it
47694 ** in WAL mode. If the log is not already open, open it now. Then
47762 ** a cell. Make sure it is small enough so that at least minFanout
47896 /* If the btree is already in a write-transaction, or it
47944 ** reading page 1 it discovers that the page-size of the database
47991 /* If the db-size header field is incorrect (as it may be if an old
47992 ** client has been writing the database file), update it now. Doing
48011 ** the sub-journal is not already open, then it will be opened here.
48066 ** that it points to iTo. Parameter eType describes the type of pointer to
48164 /* If pDbPage was a btree-page, then it may have child pages and/or cells
48188 ** that it points at iFreePage. Also fix the pointer map entry for
48224 ** it returns SQLITE_DONE or an error, and that nFin is the
48226 ** process is complete. If nFin is zero, it is assumed that
48259 ** truncated to zero after this function returns, so it doesn't
48260 ** matter if it still contains some garbage entries.
48334 ** It performs a single unit of work towards an incremental vacuum.
48337 ** SQLITE_DONE is returned. If it is not finished, but no error occurred,
48387 /* It is not possible to create a database for which the final page
48432 ** causes a rollback journal to be created (if it does not already exist)
48526 ** are no active cursors, it also releases the read lock.
48572 ** in assert() expressions, so it is only compiled if NDEBUG is not
48603 ** or moved root pages, so it is not sufficient to
48630 ** are no active cursors, it also releases the read lock.
48711 ** SQL statements. It is illegal to open, release or rollback any
48756 ** iTable. If a read-only cursor is requested, it is assumed that
48780 ** root page of a b-tree. If it is not, then the cursor acquired
48783 ** It is assumed that the sqlite3BtreeCursorZero() has been called
48864 ** to zero. But it turns out that the apPage[] and aiIdx[] arrays
48934 ** BtCursor.info structure. If it is not already valid, call
48935 ** btreeParseCell() to fill it in.
49002 ** This routine cannot fail. It always returns SQLITE_OK.
49025 ** It might just as well be a procedure (returning void) but we continue
49039 ** linked list of overflow pages. If possible, it uses the auto-vacuum
49050 ** reference. It is the responsibility of the caller to call releasePage()
49148 ** buffer pBuf). If it is non-zero, a write (data copied from
49163 ** Once an overflow page-list cache has been allocated, it may be
49224 ** has not been allocated, allocate it now. The array is sized at
49233 /* nOvfl is always positive. If it were zero, fetchPayload would have
49242 ** directly to it.
49276 /* Need to read this page properly. It contains some of the
49356 ** the key if skipKey==0 and it points to the beginning of data if
49361 ** This routine is an optimization. It is common for the entire key
49366 ** the key/data and copy it into a preallocated buffer.
49536 ** If this function returns successfully, it may be assumed that the
49577 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
49589 ** if the assumption were not true, and it is not possible for the flags
49615 ** entry to which it is currently pointing.
49637 ** page to which it is currently pointing. Notice the difference
49728 /* Move the cursor so that it points to an entry near the key
49736 ** left pointing at a leaf page which would hold the entry if it
50083 ** sqlite3PagerUnref() on the new page when it is done.
50095 ** anywhere on the free-list, then it is guarenteed to be returned. This
50152 ** is not true. Otherwise, it runs once for each trunk-page on the
50176 ** So extract the trunk page itself and use it as the newly
50195 ** to allocate, regardless of whether it has leaves.
50215 /* The trunk page is required by the caller but it contains
50371 ** It is assumed that the page is not already a part of the free-list.
50375 ** corresponding to page iPage handy, it may pass it as the second value.
50376 ** Otherwise, it may pass NULL.
50429 ** new free-list trunk page. Otherwise, it will become a leaf of the
50430 ** first trunk page in the current free-list. This block tests if it
50452 ** Note that the trunk page is not really full until it contains
50477 /* If control flows to this point, then it was not possible to add the
50549 ** So if there exists more than one reference to this page, then it
50551 ** It is helpful to detect this before calling freePage2(), as
50735 ** The cell content is not freed or deallocated. It is assumed that
50783 ** If the cell content will fit on the page, then put it there. If it
50786 ** in pPage->aOvfl[] and make it point to the cell content (either
50853 ** if it returns success */
51043 ** it is sometimes activated temporarily while debugging code responsible
51095 ** The performance of this function is not critical. It is only used by
51121 ** fairly obscure circumstances, even though it is a copy of initialized
51161 ** happens, it is the responsibility of the caller to invoke the correct
51164 ** If this routine fails for any reason, it might leave the database
51223 ** this overflow cell is present, it must be the cell with
51286 ** the cell within the parent, even though it has been dropped.
51288 ** four bytes of it, and this function does not need the first
51295 ** buffer. It will be copied out again as soon as the aSpace[] buffer
51609 ** bytes, then it may actually be smaller than this
51611 ** any cell). But it is important to pass the correct size to
51615 ** cells are at least 4 bytes. It only happens in b-trees used
51654 ** (it must be, as it was just reconstructed using assemblePage()). This
51794 ** page is then overwritten to make it an empty page with the right-child
51878 ** and copy the current contents of the root-page to it. The
51935 ** but it doesn't deal with overflow cells - just moves them to a
51937 ** has completed, it is safe to release the pSpace buffer used by
51945 /* If pFree is not NULL, it points to the pSpace buffer used
51948 ** new pSpace buffer, so it may be safely freed here. */
52032 ** operation - if it is not, the following is a no-op). */
52042 ** integer key to use. It then calls this function to actually insert the
52044 ** that the cursor is already where it needs to be and returns without
52045 ** doing any work. To avoid thwarting these optimizations, it is important
52109 ** happen while processing an "INSERT INTO ... SELECT" statement), it
52113 ** larger than the largest existing key, it is possible to insert the
52233 ** been corrected, so be it. Otherwise, after balancing the leaf node,
52234 ** walk the cursor up the tree to the internal node and balance it as
52317 ** allocated pgnoMove. If required (i.e. if it was not allocated
52473 ** is the root of a table b-tree - if it is not, the following call is
52513 /* It is illegal to drop a table if any cursors are open on the
52708 /* pPage is a leaf node. This loop navigates the cursor so that it
52709 ** points to the first interior cell that it points to the parent of
52926 ** 8. Make sure this page is at least 33% full or else it is
53263 ** open so it is safe to access without the BtShared mutex.
53276 ** open so it is safe to access without the BtShared mutex.
53342 ** allocated, it is returned as normal.
53380 ** if it is false.
53407 ** Only the data content may only be modified, it is not possible to
53550 ** Once it has been created using backup_init(), a single sqlite3_backup
53582 ** If the "temp" database is requested, it may need to be opened by this
53635 ** handle is not locked in this routine, but it is locked in
53766 ** If pFile is currently larger than iSize bytes, then truncate it to
53827 /* Lock the destination database, if it is not locked already. */
53836 ** one now. If a transaction is opened here, then it will be closed
53900 ** fix the size of the file. However it is important to call
54024 /* If a transaction is still open on the Btree, roll it back. */
54070 ** It is assumed that the mutex associated with the BtShared object
54079 /* The backup process p has already copied page iPage. But now it
54099 ** It is assumed that the mutex associated with the BtShared object
54226 ** current content of the cell is preserved. Otherwise, it may
54230 ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
54271 ** Make the given Mem object MEM_Dyn. In other words, make it so
54300 ** If the given Mem* has a zero-filled tail, turn it into an ordinary
54380 ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.
54425 ** invoking an external callback, free it now. Calling this function
54494 /* minInt is correct here - not maxInt. It turns out that assigning
54496 ** negative integer. This makes no sense, but it is what x86 hardware
54511 ** it into a integer and return that. If pMem represents an
54539 ** value. If it is a string or blob, try to convert it to a double.
54540 ** If it is a NULL, return 0.0.
54561 ** The MEM structure is already a MEM_Real. Try to also make it a
54581 ** true and could be omitted. But we leave it in because other
54604 ** Convert pMem so that it is of type MEM_Real.
54617 ** Convert pMem so that it has types MEM_Real or MEM_Int or both.
54838 ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH
54840 ** stored without allocating memory, then it is. If a memory allocation
54880 /* The following block sets the new values of Mem.z and Mem.xDel. It
54944 /* If one value is NULL, it is less than the other. If both values
55103 /* This function is only available internally, it is not part of the
55104 ** external API. It works in a similar way to sqlite3_value_text(),
55169 ** the value by passing it to sqlite3ValueFree() later on. If the expression
55295 ** that it uses the encoding "enc"
55323 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
55411 ** Resize the Vdbe.aOp array so that it is at least one op larger than
55412 ** it was.
55577 ** in a Vdbe main program and each of the sub-programs (triggers) it may
55578 ** invoke directly or indirectly. It should be used as follows:
55657 ** ABORT may be thrown, or false otherwise. Return true if it does
55754 ** the Vdbe passed as the first argument. It is the callers responsibility
55866 ** Change the P2 operand of instruction addr so that it points to
55875 ** If the input FuncDef structure is ephemeral, then free it. If
55937 ** opcodes contained within. If aOp is not NULL it is assumed to contain
55990 ** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure.
55995 ** caller should not free the allocation, it will be freed when the Vdbe is
56113 ** is readable but not writable, though it is cast to a writable value.
56256 ** will be used so that it can acquire mutexes on them all in sorted
56356 ** running the code, it invokes the callback once for each instruction.
56412 /* On the first call to sqlite3_step(), pSub will hold a NULL. It is
56602 ** NULL, it means that memory space has already been allocated and that
56639 ** After the VDBE has be prepped, it can be executed by one or more
56688 ** first time this function is called for a given VDBE, not when it is
56784 /* The pCx->pCursor will be close automatically, if it exists, by
56859 ** sorters that were left open. It also deletes the values of
56909 ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed
56936 ** db. If a transaction is active, commit it. If there is a
56992 ** string, it means the main database is :memory: or a temp file. In
57008 ** IO error while deleting or truncating a journal file. It is unlikely,
57106 ** master journal file will be orphaned. But we cannot delete it,
57163 ** This is an internal self-check only - it is not an essential processing
57200 ** reorder rootpages. So it is not sufficient just to save
57202 ** so that it is never used again.
57216 ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or
57217 ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement
57260 ** database handles deferred constraint counter to the value it had when
57272 ** that may be accessed by the VM passed as an argument. In doing so it
57304 ** an error message to it. Then return SQLITE_ERROR.
57325 ** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to
57329 ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it
57381 ** Even if the statement is read-only, it is important to perform
57546 ** To look at it another way, this routine resets the state of the
57554 /* If the VM did not run to completion or if it encountered an
57555 ** error, then it might not have been halted properly. So halt
57556 ** it now.
57702 ** Make sure the cursor p is ready to read or write the row to which it
57708 ** deleted out from under the cursor and if it has, mark the row as
57758 ** the blob of data that it corresponds to. In a table record, all serial
57842 ** (later): It is reported to me that the mixed-endian problem
57843 ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems
57890 ** buf. It is assumed that the caller has allocated sufficient space.
58057 ** VDbeParsedRecord structure if it is large enough. If it is
58078 int nOff; /* Increase pSpace by this much to 8-byte align it */
58081 ** We want to shift the pointer pSpace up such that it is 8-byte aligned.
58083 ** it by. If pSpace is already 8-byte aligned, nOff should be zero.
58145 ** specified by {nKey1, pKey1} and pPKey2. It returns a negative, zero
58161 ** the header of pKey1 is ignored. It is assumed that pKey1 is
58190 ** We could initialize it, as shown here, to silence those complaints.
58245 ** the following assert(). If the assert() fails, it indicates a
58255 ** larger. As it happens, the pPKey2 will always be the longer
58272 ** Read the rowid (the last field in the record) and store it in *rowid.
58353 ** pUnpacked is either created without a rowid or is truncated so that it
58399 ** Set a flag in the vdbe to update the change counter when it is finalised
58433 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
58434 ** constants) to the value before returning it.
58456 ** Configure SQL variable iVar so that binding a new value to it signals
58503 ** Check on a Vdbe to make sure it has not been finalized. Log
58504 ** an error and return true if it has been finalized (or is otherwise
58505 ** invalid). Return false if it is ok.
58558 ** Terminate the current execution of an SQL statement and reset it
58559 ** back to its starting state so that it can be reused. A success code from
58657 ** result as a string or blob but if the string or blob is too large, it
58780 ** This function is called after a transaction has been committed. It
58823 /* Check that malloc() has not failed. If it has, return early. */
58958 ** pointer to it.
58967 ** pointer to it.
59048 ** deleted by calling the delete function specified when it was set.
59094 ** This function is deprecated. Do not use it for new code. It is
59126 ** it is, return a pointer to the Mem for the value of that column.
59279 ** 0 The column name as it should be displayed for output
59285 ** If the result is not a simple column reference (if it is an expression
59628 ** work but it results in the same answer.
59987 ** When this global variable is positive, it gets decremented once before
59991 ** This facility is used for testing purposes only. It does not function
60037 ** Test a register to see if it exceeds the current maximum blob size.
60038 ** If it does, record the new maximum blob size.
60047 ** Convert the given register into a string if it isn't one
60058 ** does not control the string, it might be deleted without the register
60059 ** knowing it.
60062 ** string that the register itself controls. In other words, it
60100 ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL
60111 ** required for this VdbeCursor structure. It is convenient to use a
60162 ** looks like a number, convert it into a number. If it does not
60163 ** look like a number, leave it alone.
60227 ** is appropriate. But only do the conversion if it is possible without
60400 ** It uses the RDTSC opcode to read the cycle count value out of the
60457 ** of the debugging and testing utilities, but it should at
60473 ** sqlite3_interrupt() routine has been called. If it has been, then
60487 ** This function is only called from within an assert() expression. It
60531 ** will either invoke the busy callback (if there is one) or it will
61040 /* Call the progress callback if it is configured and the required number
61221 ** For errors, it can be some other value. If P1!=0 then P2 will determine
61227 ** If P4 is not null then it is an error message string.
61315 ** into an OP_String before it is executed for the first time.
61409 ** left holding a NULL. It is an error for register ranges
61489 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
61504 ** transaction. It needs to be rolled back. */
61566 ** It is illegal for P1 and P3 to be the same register. Sometimes,
61953 ** If register P1 holds an integer convert it to a real value.
61973 ** If the value is numeric, convert it to a string using the
61977 ** A NULL value is not changed by this routine. It remains NULL.
61996 ** If the value is numeric, convert it to a string first.
62000 ** A NULL value is not changed by this routine. It remains NULL.
62020 ** If the value is text or blob, try to convert it to an using the
62024 ** A NULL value is not changed by this routine. It remains NULL.
62037 ** If the value is text or blob, try to convert it to an integer using the
62040 ** A NULL value is not changed by this routine. It remains NULL.
62054 ** If The value is currently an integer, convert it.
62055 ** If the value is text or blob, try to convert it to an integer using the
62058 ** A NULL value is not changed by this routine. It remains NULL.
62109 ** If neither operand is NULL the the result is the same as it would be if
62121 ** If neither operand is NULL the the result is the same as it would be if
62407 ** is considered true if it is numeric and non-zero. If the value
62413 ** is considered true if it has a numeric value of zero. If the value
62522 ** u.am.zRec is set to be the complete text of the record if it is available.
62525 ** might be available in the u.am.pC->aRow cache. Or it might not be.
62551 ** payload size, so it is impossible for u.am.payloadSize64 to be
62674 /* Scan the header and use it to fill in the u.am.aType[] and u.am.aOffset[]
62899 ** sqlite3VdbeMemGrow() could clobber the value before it is used).
63033 /* It is not possible to release (commit) a savepoint if there are
63034 ** active write statements. It is not possible to rollback a savepoint
63086 /* If it is a RELEASE, then destroy the savepoint being operated on
63087 ** too. If it is a ROLLBACK TO, then set the number of deferred
63252 ** Read cookie number P3 from database P1 and write it into register P2.
63324 ** schema version) and make sure it is equal to P2.
63384 ** It is an error for P1 to be negative.
63399 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
63402 ** value, it is set to the number of columns in the table.
63413 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
63416 ** value, it is set to the number of columns in the table, or to the
63419 ** This instruction works just like OpenRead except that it opens the cursor
63492 /* Since it performs no memory allocation or IO, the only values that
63520 ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure
63531 ** This opcode works the same as OP_OpenEphemeral. It has a
63558 /* If a transient index is required, create it by calling
63560 ** opening it. If a transient table is required, just use the
63634 ** Reposition cursor P1 so that it points to the smallest entry that
63647 ** Reposition cursor P1 so that it points to the smallest entry that
63660 ** Reposition cursor P1 so that it points to the largest entry that
63673 ** Reposition cursor P1 so that it points to the largest entry that
63706 ** blob, or NULL. But it needs to be an integer before we can do
63707 ** the seek, so covert it. */
63836 ** for P1 to move so that it points to the rowid given by P2.
64042 ** pointing to the record if it exists.
64148 ** it already exists in the table. If it does not exist, we have
64223 ** it finds one that is not previously used. */
64262 ** created if it doesn't already exist or the data for an existing
64270 ** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
64286 ** may be NULL. If it is not NULL, then the update-hook
64378 ** record in the table. If it is left pointing at the next record, then
64379 ** the next Next instruction will be a no-op. Hence it is OK to delete
64385 ** P1 must not be pseudo-table. It has to be a real table with
64388 ** If P4 is not NULL, then it is the name of the table that P1 is
64389 ** pointing to. The update hook will be invoked, if it exists.
64418 ** below is always a no-op and cannot fail. We will run it anyhow, though,
64456 ** It is just copied onto the P2 register exactly as
64457 ** it is found in the database file.
64467 ** it is found in the database file.
64499 ** a no-op and can never fail. But we leave it in place as a safety.
64644 ** it increments an undocumented global variable used for testing.
64647 ** then rewinding that index and playing it back from beginning to
64697 ** Advance cursor P1 so that it points to the next key/data pair in its
64711 ** Back up cursor P1 so that it points to the previous key/data pair in its
64887 ** the result is false whereas it would be true with IdxGT.
64951 ** If AUTOVACUUM is enabled then it is possible that another root page
65095 ** then runs the new virtual machine. It is thus a re-entrant opcode.
65110 ** created by this VDBE, from the sqlite_master table. It only
65113 ** with the rest of the schema when it is required.
65117 ** read by this instruction) is currently held, it is necessary to
65334 ** the rowset object for P3, as it is guaranteed not to contain it,
65335 ** (b) when P4==-1 there is no need to insert the value, as it will
65338 ** previously inserted as part of set X (only if it was previously
65353 ** delete it now and initialize P1 with an empty rowset
65415 ** It is recursive invocation of triggers, at the SQL level, that is
65436 ** is already allocated. Otherwise, it must be initialized. */
65596 ** It is illegal to use this instruction on a register that does
65612 ** It is illegal to use this instruction on a register that does
65629 ** It is illegal to use this instruction on a register that does
65706 ** argument is not used by this opcode. It is only there to disambiguate
65778 ** is not called when the statement is prepared because it requires the
65870 ** machines to be created and run. It may not be called from within
65906 ** fails with an error code of SQLITE_SCHEMA if it is ever executed
65960 ** within a callback to a virtual table xSync() method. If it is, the error
66269 ** P1 is a boolean flag. If it is set to true and the xUpdate call
66384 ** This opcode records information from the optimizer. It is the
66413 ** of the program. It is only here for testing and debugging.
66414 ** On the other hand, it does burn CPU cycles every time through
66415 ** the evaluator loop. So we can leave it out when NDEBUG is defined.
66434 /* If we reach this point, it means that execution is finished with
66529 ** This function is used by both blob_open() and blob_reopen(). It seeks
66537 ** be set to point to a buffer containing an error message. It is the
66620 ** uses it to implement the blob_read(), blob_write() and
66705 ** column is not indexed, and that it is not part of a foreign key.
66706 ** It is against the rules to open a column to which either of these
66713 /* Check that the column is not part of an FK child key definition. It
66714 ** is not necessary to check if it is part of a parent key, as parent
66782 ** think that the table has one more column than it really
66784 ** always return an SQL NULL. This is useful because it means
67007 ** If it does not already exists, create and populate the on-disk file
67181 ** file has not yet been created, create it now.
67551 ** callback on p, but do invoke it on each FROM clause subquery
67687 ** allowing it to be repopulated by the memcpy() on the following line.
67715 ** value can be NULL if zDb is also NULL. If zTable is NULL it
67822 ** it is a new.* or old.* trigger argument reference
67927 ** Z is a string literal if it doesn't match any column names. In that
68209 ** to the AS-name of one of the terms of the expression list. If it is,
68249 ** as an indication to the caller that it should sort by the i-th column.
68625 ** re-evaluated for each reference to it.
69007 ** If the left hand expression has a collating sequence type, then it is
69013 ** it is not considered.
69064 ** expression depth allowed. If it is not, leave an error message in
69161 ** Construct a new expression node and return a pointer to it. Memory
69166 ** If dequote is true, then the token (if it exists) is dequoted.
69359 ** use it as the variable number */
69473 ** off if the expression is reduced. Note also that it does not work to
69474 ** make a EXPRDUP_REDUCE copy of a reduced expression. It is only legal
69773 ** NULL is returned. If non-NULL is returned, then it is guaranteed
69902 ** if it
69960 ** and 0 if it involves variables or function calls.
69973 ** Return 0 if it involves variables or function calls or terms from
69996 ** in *pValue. If the expression is not an integer or if it is too big
70069 ** determine that it can never generate a NULL, then the OP_IsNull operation
70178 ** It's job is to find or create a b-tree structure that may be used
70199 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
70277 ** be used in place of a temp-table, it must be ordered according
70283 ** it is not, it is not possible to use any index.
70386 /* This code must be run in its entirety every time it is encountered
70427 ** expression it is handled the same way. An ephemeral table is
70471 ** store it in the temporary table. If <expr> is a column, then use
70503 /* Evaluate the expression and insert it into the temp table */
70659 /* This branch runs if it is known at compile time that the RHS
70818 #if 0 /* This code wold remove the entry from the cache if it existed */
70831 /* Find an empty slot and replace it */
70894 ** to the state it was in N Pushes ago.
71058 ** register if it is convenient to do so. The calling function
71391 ** see if it is a column in a virtual table. This is done because
71528 /* If the column has REAL affinity, it may currently be stored as an
71529 ** integer. Use OP_RealAffinity to make sure it is really real. */
71551 ** X (if it exists) is in pExpr->pLeft.
71706 ** and modify the expression so that the next time it is evaluated,
71721 ** no way for a TK_REGISTER to exist here. But it seems prudent to
71904 ** Code it as such, taking care to do the common subexpression
72229 ** this routine is used, it does not hurt to get an extra 2 - that
72326 ** This is the xExprCallback for a tree walker. It is used to
72350 /* If we reach this point, it means that pExpr refers to a table
72393 ** because it was there before or because we just created it).
72645 ** parent table. It is passed three arguments:
72651 ** It returns the new CREATE TABLE statement. For example:
72811 ** allocated using sqlite3DbMalloc(). It is the responsibility of the
72812 ** caller to ensure that it is eventually freed.
72975 /* Make sure it is not a system table being altered, or a reserved name
73086 ** it with the new table name.
73281 ** to it. Routines called by the parser as the column definition
73390 ** If the sqlite_stat1 tables does not previously exist, it is created.
73392 ** is compiled with SQLITE_ENABLE_STAT2 defined, it is created.
73395 ** or it may be a NULL pointer. If it is not NULL, then all entries in
73432 /* The sqlite_stat[12] table does not exist. Create it. Note that a
73435 ** because the OpenWrite opcode below will be needing it. */
73550 ** not been populated. In this case populate it now. */
73608 ** store it. */
73675 ** If K>0 then it is always the case the D>0 so division by zero
73775 ** when it recognizes an ANALYZE command.
73930 ** read from it.
73935 ** table (if it is present) before returning.
74084 ** it treats the two expressions as literal strings 'abc' and 'def' instead of
74182 ** it to obtain the database schema. At this point the schema may
74246 ** we found it.
74399 ** statement only). For DETACH, set it to false (expire all existing
74614 ** systems that do not need this facility may omit it by recompiling
74660 ** SQLITE_OK is returned, it means that access is allowed. SQLITE_DENY
74726 ** is in pTabList or else it is the NEW or OLD table of a trigger.
74727 ** Check to see if it is OK to read this particular column.
74973 ** Note that if an error occurred, it might be the case that
75240 ** before the database closes. It is also called during a rollback
75326 ** This routine just deletes the data structure. It does not unlink
75327 ** the table data structure from the hash table. But it does destroy
75623 ** it does. The exception is if the statement being parsed was passed
75709 ** The record created does not contain anything yet. It will be replaced
75744 ** It is slightly faster than calling sqlite3StrICmp() directly, but
75747 ** WARNING: This macro is not compatible with the strcmp() family. It
76056 ** collation type was added. Correct this if it is the case.
76075 ** request it. If the collation factory does not supply such a sequence,
76112 ** changes. When a process first reads the schema it records the
76113 ** cookie. Thereafter, whenever it goes to access the database,
76114 ** it checks the cookie to make sure the schema has not changed
76115 ** since it was last read.
76117 ** This plan is not completely bullet-proof. It is possible for
76137 ** The estimate is conservative. It might be larger that what is
76158 ** then it is copied to the output buffer exactly as it is. Otherwise,
76159 ** it is quoted using double-quotes.
76263 ** it means we are reading the sqlite_master table because we just
76266 ** the sqlite_master table. We do not want to create it again.
76268 ** If the pSelect argument is not NULL, it means that this routine
76315 /* If the db->init.busy is 1 it means we are reading the SQL off the
76362 ** Once the SELECT has been coded by sqlite3Select(), it is in a
76367 ** as a schema-lock must have already been obtained to create it. Since
76582 ** a negative nCol, it means two or more views form a loop, like this:
76588 ** But the following test is still important as it does come up
76601 /* If we get this far, it means we need to compute the table names.
76720 ** is non-zero, then it is the root page number of a table moved to
76751 ** is not defined), then it is important to call OP_Destroy on the
76821 ** it is initialized.
76933 /* Drop any statistics from the sqlite_stat1 table, if it exists */
77110 ** if memRootPage is not negative, it means that the index is newly
77169 ** since sqlite3ReleaseTempRange() was called, it is safe to do so.
77313 ** If pName==0 it means that we are
77361 /* If pList==0, it means this routine was called to make a primary
77435 ** break backwards compatibility - it needs to be a warning.
77569 ** we don't want to recreate it.
77571 ** If pTblName==0 it means this index is generated as a primary key
77573 ** has just been created, it contains no data and the index initialization
77675 ** of the index. And so forth. It must always be the case that
77785 ** might be the same as the pArray parameter or it might be a different
77883 ** After the call above it would contain: A, B, nil, nil, nil.
77945 ** SrcList might be the same as the SrcList that was input or it might be
77949 ** If pDatabase is not null, it means that the table has an optional
78211 ** This function is called by the parser when it parses a command to create,
78267 ** It is important that all schema cookies be verified and all
78321 ** can be checked before any changes are made to the database, it is never
78335 ** If an abort occurs after some of these writes have completed, then it will
78344 ** The code generator calls this routine if is discovers that it is
78354 ** makes it more difficult to prove that the code is correct (in
78355 ** particular, it prevents us from writing an effective
78379 ** true if it does and false if it does not.
78615 ** If it is not NULL, then pColl must point to the database native encoding
78638 ** Call the collation factory to see if it can supply us with one.
78651 ** This routine is called on a collation sequence before it is used to
78652 ** check that it is defined. An undefined collation sequence exists when
78714 /* If a malloc() failure occurred in sqlite3HashInsert(), it will
78715 ** return the pColl pointer to be deleted (because it wasn't added
78903 ** install a new function. Whatever FuncDef structure is returned it will
78924 ** new entry to the hash table and return it.
78945 ** pointer itself, it just cleans up subsiduary resources (i.e. the contents
79037 ** Check to make sure the given table is writable. If it is not
79038 ** writable, generate an error message and return 1. If it is
79044 ** 1) It is a virtual table and no implementation of the xUpdate method
79046 ** 2) It is a system table (i.e. sqlite_master), this call is not
79064 sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
79167 /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree
79267 /* If pTab is really a view, make sure it has been initialized.
79337 ** It is easier just to erase the whole table. Prior to version 3.6.5,
79484 ** (this can happen if a trigger program has already deleted it), do
79485 ** not attempt to delete it or fire any DELETE triggers. */
79518 /* Seek the cursor to the row to be deleted again. It may be that
79591 ** Generate code that will assemble an index key and put it in register
80171 ** in the list by making it the first character after '[' or '^'. A
80174 ** it the last character in the list.
80755 /* IMP: R-25361-16150 This function is omitted from SQLite by default. It
80855 ** that it returns NULL if it sums over no inputs. TOTAL returns
80857 ** SUM might return an integer if it never encounters a floating point
80859 ** it overflows an integer.
80935 ** sure it still operates correctly, verify that its count agrees with our
80971 ** sqlite3_user_data() function returns (void *)-1. For min() it
81095 ** it is appropriate to apply the LIKE optimization to that function
81270 ** or which row it is not satisfied for.
81275 ** Despite these problems, this approach is adopted as it seems simpler
81318 ** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT
81382 ** Otherwise, it is set to point to an allocated array of size N, where
81427 /* If this is a non-composite (single column) foreign key, check if it
81524 ** Each time it is called, this function generates VDBE code to locate the
81585 ** will have INTEGER affinity applied to it, which may not be correct. */
81843 ** (b) The table is the child table of a deferred FK constraint and it is
82146 ** passed a pointer to the list of columns being modified. If it is a
82149 ** It returns a pointer to a Trigger structure containing a trigger
82167 ** The returned pointer is cached as part of the foreign key object. It
82217 /* Create the expression "OLD.zToCol = zFromCol". It is important
82318 /* Re-enable the lookaside buffer, if it was disabled earlier. */
82475 ** is managed along with the rest of the Index structure. It will be
82481 ** required, it is allocated and populated here. It is then stored as
82522 ** is required, it is allocated and populated here. It is then
82652 /* This routine is never called during trigger-generation. It is
82939 /* If pTab is really a view, make sure it has been initialized.
82949 * (b) that if it is a view then ON INSERT triggers exist
82980 ** sqlite_sequence table and store it in memory cell regAutoinc.
83007 ** On each invocation of the co-routine, it puts a single row of the
83010 ** the SELECT completes, it sets the EOF flag stored in regEof.
83023 /* Resolve the expressions in the SELECT statement and execute it. */
83055 ** and add it to a transient table srcTab. The code generated
83127 ** the index of the primary key as it appears in IDLIST, not as
83255 /* Cannot have triggers on a virtual table. If it were possible,
83503 ** INSERT statement. If rowidChng is false, it means that the rowid is
83689 ** when it is inserted.
83939 ** is happening when it is suppose to.
84159 /* If we get this far, it means either:
84643 ** it can get access to the sqlite3_api_routines structure
84942 ** not NULL before calling it.
85595 ** If the TEMP database is open, close it and mark the database schema
85661 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
85796 ** pragma, make sure it is open.
86090 ** creates the database file. It is important that it is created
86156 ** page cache size value. It does not change the persistent
86181 ** Note that it is possible for the library compile-time options to
86696 ** database. If the database is not initialized, it is initialized now.
86699 ** has not already been initialized. In this case it sets the default
86710 ** new database files created using this database handle. It is only
86742 ** will be overwritten when the schema is next loaded. If it does not
86743 ** already exists, it will be created to use the new encoding value.
86776 ** The schema-cookie is usually only manipulated internally by SQLite. It
86786 ** The user-version is not used internally by SQLite. It may be used by
87082 /* If the SQL column is blank it means this is an index that
87197 ** on the b-tree database, open one now. If a transaction is opened, it
87233 ** For an attached db, it is an error if the encoding is not the same
87437 ** on the b-tree database, open one now. If a transaction is opened, it
87448 /* Read the schema cookie from the database. If it does not match the
87481 ** statements too, but it never hurts to play the odds).
87523 /* Check to verify that it is possible to get a read lock on all
87536 ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it
87543 ** but it does *not* override schema lock detection, so this all still
88131 ** defer the handling of t1.x=5, it will be processed immediately
88336 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
88450 ** saving that record, use it as a key to delete elements from
88633 ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
88651 ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
88661 ** false, or the second form if it is true.
88853 ** possible. However, it can still be true for statements like
88861 ** though it should really be "INTEGER".
88879 ** test case misc2.2.2) - it always evaluates to NULL.
89108 ** append a integer to the name so that it becomes unique.
89549 ** it is that we currently need.
89582 /* INTERSECT is different from the others since it requires
89583 ** two temporary tables. Hence it has its own case. Begin
89662 ** SELECT might also skip this part if it has no ORDER BY clause and
89727 ** If regPrev>0 then it is the first register in a vector that
90295 /* Reassembly the compound query so that it will be freed correctly
90324 ** changes to pExpr so that it refers directly to the source table
90400 ** execution. It returns 1 if it makes changes and 0 if no flattening
90470 ** (17) The sub-query is not a compound select, or it is a UNION ALL
90489 ** (20) If the sub-query is a compound select, then it must not use
90600 /* Restriction 17: If the sub-query is a compound SELECT, then it must
90640 ** 17 and 18 above) it must be a UNION ALL and the parent query must
90766 ** then expand the outer query to make space for it to hold all elements
90875 ** Analyze the SELECT statement passed as an argument to see if it
90877 ** it is, or 0 otherwise. At present, a query is considered to be
90882 ** 2. There is a single expression in the result set, and it is
91074 ** with the TK_ALL operator for each "*" that it found in the column list.
91090 ** If we get here it means the result set contains one or more "*"
91145 ** for virtual tables), do not include it in the expanded
91224 ** For additional information on what it means to "expand" a SELECT
91492 ** results each time it is invoked. The entry point
91548 ** DISTINCT so it can be removed too. */
91819 ** implement it. Allocate that sorting index now. If it turns out
91820 ** that we do not need it after all, the OpenEphemeral instruction
91848 ** it might be a single loop that uses an index to extract information
91941 ** over to a0,a1,a2. It then calls the output subroutine
92022 ** This statement is so common that it is optimized specially. The
92024 ** contains the data for table <tbl> or on one of its indexes. It
92039 ** there is such an index, and it has less columns than the table
92040 ** does, then we can assume that it consumes less space on disk and
92046 ** In practice the KeyInfo structure will not be used. It is only
92074 ** If it is, then ask the code in where.c to attempt to sort results
92091 ** satisfying the 'ORDER BY' clause than it does in other cases.
92384 ** the calling procedure is finished using it.
92510 ** To state it another way: This routine returns a list of all triggers
92539 ** This is called by the parser when it sees a CREATE TRIGGER statement
92682 ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code
92798 ** The parser calls this routine when it finds a SELECT statement in
92841 ** The parser calls this routine when it sees an INSERT inside the
92874 it
92899 ** a pointer to that trigger step. The parser calls this routine when it
92936 ** same job as this routine except it takes a pointer to the trigger
93066 ** then return TRUE. If pIdList==NULL, then it is considered a
93068 ** it matches anything so always return true. Return false only
93115 ** trigger is in TEMP in which case it can refer to any other database it
93158 ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use
93218 ** program. It is not used in production code, only for debugging.
93316 /* If one was specified, code the WHEN clause. If it evaluates to false
93376 /* It may be that this trigger has already been coded (or is in the
93492 ** or else it must be a TEMP trigger. */
93521 ** It is not possible to determine if the old.rowid or new.rowid column is
93522 ** accessed by triggers. The caller must always assume that it is.
93524 ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
93610 ** complicated default expression value was provided, it is evaluated
94028 /* If it did not delete it, the row-trigger may still have modified
94157 ** it out of the ephemeral table before calling VUpdate.
94308 ** collapse free space, etc. It is modelled after the VACUUM command
94350 /* Save the current value of the database flags so that it can be
94365 ** can be set to 'off' for this file, as it is not recovered if a crash
94374 ** empty. Only the journal header is written. Apparently it takes more
94375 ** time to parse and run the PRAGMA to turn journalling off than it does
94394 ** to read the schema was concluded. Unlock it here so that this doesn't
94502 ** transaction is then committed, so the SQL level never knows it was
94557 ** was committed at the btree level). So it safe to end the transaction
94663 ** Lock the virtual table so that it cannot be disconnected.
94723 ** this makes it safe to access the sqlite3.pDisconnect list of any
94760 ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to
94767 ** by multiple threads. It is thread-safe.
94791 ** Since it is a virtual-table, the Table structure contains a pointer
94838 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
94883 ** in pParse->zArg[] and appends it to the list of arguments on the
94977 ** The parser calls this routine when it sees the first token
95189 ** invoke it now. If the module has not been registered, return an
95200 ** create a valid sqlite3_vtab if it returns SQLITE_OK. */
95209 ** This function is used to set the schema of a virtual table. It is only
95387 ** virtual module xSync() callback. It is illegal to write to
95493 ** array so that an OP_VBegin will get generated for it. Add pTab to the
95494 ** array if it is missing. If pTab is already in the array, this routine
95561 ** help it analyze the subexpressions of the WHERE clause. Each WHERE
95687 ** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask
95696 ** 57->5, 73->4. Or one of 719 other combinations might be used. It
95832 ** the db->mallocFailed flag so that higher-level functions can detect it.
96020 ** side of the comparison, it remains associated with the same side after
96106 ** it to be useful for optimising expression pX. Store this
96145 ** can be optimized using inequality constraints. Return TRUE if it is
96244 ** If it is then return TRUE. If not, return FALSE.
96322 ** A subterm is "indexable" if it is of the form
96325 ** A subterm is also indexable if it is an AND of two or more
96341 ** It might be the case that multiple tables are indexable. For example,
96424 /* Skip this term for now. We revisit it when we process the
96462 ** the all terms are of the form "table1.column=table2.column". It
96594 ** If the expression is of the form "<expr> <op> X" it gets commuted
96601 ** and the new term is marked with TERM_DYNAMIC (because it's pExpr
96602 ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it
96774 ** wildcard. But if we increment '@', that will push it into the
96873 ** clause. If it can, it returns 1. If pIdx cannot satisfy the
96887 ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if
97016 ** complexity. Because N is just a guess, it is no great tragedy if
97173 ** Return TRUE if the WHERE clause term pTerm is of a form where it
97195 ** and indexing is allows (if there is no NOT INDEXED clause) and it
97414 ** Allocate and populate an sqlite3_index_info structure. It is the
97527 ** Whether or not an error is returned, it is the responsibility of the
97578 ** everybody has finished with it.
97607 ** allocated and initialized, then allocate and initialize it now.
97620 ** details of pIdxInfo for the current invocation and pass it to
97645 ** on the current table. That way we only have to compute it once
97685 ** does not satisfy it, increase the cost of the scan accordingly. This
97694 ** inital value of lowestCost in this loop. If it is, then the
97816 ** aff applied to it, before returning. It is the responsibility of the
97817 ** caller to eventually release this structure by passing it to
97821 ** is an SQL variable that currently has a non-NULL value bound to it,
97823 ** affinity aff applied to it, instead.
97880 ** constraints (if any). A return value of 100 indicates that it is expected
98112 ** for the rowid index. For other indexes, it is true unless all the
98196 ** index for this query). If it is, set the WHERE_IDX_ONLY flag in
98258 ** It is critical that the notValid mask be used here instead of
98395 ** if it controls a LEFT OUTER JOIN and it did not originate in the ON
98404 ** The t2.z='ok' is disabled in the in (2) because it originates
98405 ** in the ON clause. The term is disabled in (3) because it is not part
98553 ** The only thing it does is allocate the pLevel->iMem memory cell and
98688 ** It is the responsibility of the caller to free the buffer when it is
98950 ** seek opcodes. It depends on a particular ordering of TK_xx
99011 ** left-most columns of the index. It may also contain
99208 ** If it is, jump to the next iteration of the loop.
99256 ** into the RowSet. If it is already present, control skips the
99326 ** over the top of the loop into the body of it. In this case the
99522 ** the WHERE clause, it might result in additional nested loops for
99543 ** make it to the "..." in the middle of the loop. After each "foreach",
99622 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
99664 ** When assigning bitmask values to FROM clause cursors, it must be
99675 ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful
99765 ** not be as small as it would be if the table really were the innermost
99783 ** The best strategy is to iterate through table t1 first. However it
99827 ** index if it uses any index at all */
99842 ** it is an "optimal" plan as defined above.
99898 ** INDEXED BY clause attached to it, that the named index is being
99910 ** if it find an index at all. */
100015 ** and the index used to access it (if any). If the table itself
100131 ** Set it.
100430 ** code the yytestcase() macro should be turned off. But it is useful
100465 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
100961 ** but it does not parse, the type of the token is changed to ID and
101046 ** It is sometimes called the "minor" token.
101581 ** being destroyed before it is finished parsing.
101661 ** is popped from the stack, then call it.
101727 ** independent of the look-ahead. If it is, return the action, otherwise
101792 ** independent of the look-ahead. If it is, return the action, otherwise
102253 ** in some cases when it is copied into the stack after the following
102264 ** that it has not been previously stressed... (SQLite ticket #2172)
103550 ** it is legal to shift the error symbol, then shift
103687 ** it is a keyword. If it is a keyword, the token code of that keyword is
103975 ** IdChar(X) will be true. Otherwise it is false.
104451 ** separating it out, the code will be automatically omitted from
104452 ** static links that do not use it.
104497 ** returns 1 if it ends in the START state and 0 if it ends
104754 ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface.
104786 ** RTREE library. All it does is declare the sqlite3RtreeInit() interface.
104818 ** ICU extension. All it does is declare the sqlite3IcuInit() interface.
104907 ** incomplete, it is required that:
104981 ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other
105026 ** been compiled correctly. It is important to run this code, but
105027 ** we don't want to run it too often and soak up CPU cycles for no
105028 ** reason. So we run it once during initialization.
105051 ** routine is not threadsafe. But it is safe to invoke this routine
105090 /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
105246 ** If pStart is not NULL then it is sz*cnt bytes of memory to use for
105416 ** database handle object, it does not close any savepoints that may be open
105432 ** if this is not the last copy of the function, do not invoke it. Multiple
105558 ** So it needs to be freed here. Todo: Why not roll the temp schema into
105699 ** If this routine returns non-zero, the lock is retried. If it
105782 ** that it is designed to be called by internal code. The difference is
106195 ** checkpointed. If an error is encountered it is returned immediately -
106484 ** It merely prevents new constructs that exceed the limit
106547 ** do not block illegal combinations here, it could trigger
106683 ** database it is 'NONE'. This matches the pager layer defaults.
106937 ** This function is now an anachronism. It used to be used to recover from a
106947 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
106997 ** no-op. It is retained for historical compatibility.
107253 ** as it existing before this routine was called.
107301 ** hard-coded to true or else it asserts if its argument is false.
107496 ** Add connection db to the blocked connections list. It is assumed
107497 ** that it is not already a part of the list.
107533 ** (call it pOther) in the same process was busy using the same shared
107596 ** to the user because it requires a lock that will not be available
107685 ** it means that instead of one callback with a large array of
107689 ** connections. But it is the best that can be done under the
107840 ** 234 at I is the next docid. It has one position 72 (72-2) and then
107886 ** making it efficient to directly access large doclists. The
107890 ** TODO(shess) It may be useful for blocking decisions to be more
107891 ** dynamic. For instance, it may make more sense to have a 2.5k leaf
107948 ** node requires more than ROOT_MAX bytes, it is flushed to %_segments
107950 ** within ROOT_MAX because it only needs space for 2 varints, the
108008 ** TODO(shess) That said, it would be nice to have a better query-side
108009 ** argument for MERGE_COUNT of 16. Also, it is possible/likely that
108022 ** will eventually overtake the earlier data and knock it out. The
108095 ** When an fts3 table is created, it passes any arguments passed to
108103 ** method is called. It returns an sqlite3_tokenizer_cursor object
108182 ** implementation. It is only required to be valid until the next call
108230 ** used in SQLite. We've modified it slightly to serve as a standalone
108264 ** Again, this structure is intended to be opaque, but it can't really
108265 ** be opaque because it is used by macros.
108366 ** make it a no-op.
108462 ** When the core wants to read from the virtual table, it creates a
108712 ** 32-bit integer before it is returned.
108784 ** as fts3GetDeltaVarint(): read a single varint and add it to *pVal.
108874 ** If *pRc is non-zero when this function is called, it is a no-op.
108971 ** If *pRc is non-zero when this function is called, it is a no-op.
109101 /* Check if it is an FTS4 special argument. */
109189 ** database. TODO: For xConnect(), it could verify that said tables exist.
109282 ** it would lead to an "unable to use function MATCH in the requested
109311 ** allocation succeeds, zero it and return SQLITE_OK. Otherwise,
109339 ** Position the pCsr->pStmt statement so that it is on the row
109496 ** It is possible that the range of returned leaf nodes does not contain
109497 ** the specified term or any terms for which it is a prefix. However, if the
109500 ** never loads leaf nodes into memory), it is not possible to be sure.
109564 ** start of a position-list. After it returns, *ppPoslist points to the
109569 ** routine advances *ppPoslist so that it points to the next docid in
109582 ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail
109587 ** pEnd once more so that it points to the byte immediately following the
109608 ** start of a column-list. After it returns, *ppPoslist points to the
109646 ** it is not possible to have a document with 2^31 terms.
109653 ** being parsed, or it may point to 1 byte past the end of the position-list
109686 ** returning (do not modify it if iCol==0). Return the total number of bytes
109777 ** This function is used to merge two position lists into one. When it is
109795 ** slots before it.
109883 ** iCol1 and iCol2) so that it points to either the 0x00 that marks the
110152 ** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
110401 /* If a new Fts3SegReader was allocated, add it to the array. */
110486 ** If the isPoslist argument is true, then it is assumed that the doclist
110487 ** contains a position-list following each docid. Otherwise, it is assumed
110646 /* This branch is taken if it is determined that loading the doclist
110733 ** is MERGE_POS_NEAR, or does not if it is MERGE_NEAR.
110902 ** The following is a helper function (and type) for fts3EvalExpr(). It
110904 ** in the expression. See the context it is called from in fts3EvalExpr()
110930 ** freeing the space when it has finished.
110949 ** See fts3EvalDeferred() for how it gets there.
110951 ** In the first case above, Fts3Cursor.doDeferred==0. In the second (if it is
111137 ** when the query includes very common tokens and it is deemed too expensive to
111251 /* In case the cursor has been used before, clear it now. */
111309 ** routine to find out if it has reached the end of a result set.
111376 ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
111760 ** FTS3 enabled database connection is closed). It frees the memory
111900 ** is defined, then it uses the new syntax. The differences between
111908 ** supported by the new syntax (it is replaced by the NOT operator).
111916 ** to zero causes the module to use the old syntax. If it is set to
111922 ** generator. This module does not use actually lemon, it uses a
111971 ** The standard isspace() can be awkward to use safely, because although it
111985 ** zero the memory before returning a pointer to it. If unsuccessful,
111999 ** single token and set *ppExpr to point to it. If the end of the buffer is
112000 ** reached before a token is found, set *ppExpr to zero. It is the
112002 ** Fts3Expr structure (if any) by passing it to sqlite3_free().
112319 ** TODO: Strangely, it is not possible to associate a column specifier
112322 ** first implemented. Whichever it was, this module duplicates the
112663 ** sqlite3_malloc(). It is the responsibility of the caller to use
112712 ** expression parser. It should be called as follows:
112826 ** We've modified it slightly to serve as a standalone hash table
112865 ** false if it should just use the supplied pointer.
112998 /* Resize the hash table so that it cantains "new_size" buckets.
113108 ** that matches pKey,nKey. Return the data for this element if it is
113331 ** 'Y' is a consonant unless it follows another consonant,
113332 ** in which case it is a vowel.
113335 ** is that 'y' is a consonant unless it is followed by another
113479 ** than 20 bytes if it contains no digits or more than 6 bytes if
113480 ** it contains digits) then word is truncated to 20 or 6 bytes
113737 /* z[] is now the stemmed word in reverse order. Flip it back
113880 ** If the <pointer> argument is specified, it must be a blob value
114211 ** This function is used for testing only, it is not included in the
114217 ** in the README.tokenizer file as an example, so it is important to
114574 ** tables. It also contains code to merge FTS3 b-tree segments. Some
114585 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
114586 ** of 920 bytes is allocated for it.
114589 ** it is always safe to read up to two varints from it without risking an
114751 ** If argument apVal is not NULL, then it must point to an array with
114925 ** not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. It can
115018 ** it is set to SQLITE_OK.
115182 ** operation. It adds entries for each term in the new record to the
115244 ** In FTS3, this is an error. It is an error to specify non-NULL values
115397 ** paBlob is non-NULL, then it is the responsibility of the caller to
115456 ** Close the blob handle at p->pSegments, if it is open. See comments above
115588 ** following two lines advance it to point one byte past the end of
115622 ** contains references to N documents, and is considering merging it with
115623 ** a large doclist (size X "average documents"), it may opt not to load
115650 ** data from the %_stat table to calculate it.
115680 /* Assume that a blob flows over onto overflow pages if it is larger
115929 ** version, it is assumed that each SegReader points to an entry in
115979 ** Argument apSegment is an array of nSegment elements. It is known that
116083 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
116157 /* If control flows to here, it was not possible to append zTerm to the
116159 ** If this is the first node in the tree, the term is added to it.
116161 ** Otherwise, the term is not added to the new node, it is left empty for
116215 ** Except, if pTree is a root node, do not write it to the database. Instead,
116288 ** and return it via the input/output variable *ppWriter in this case.
116347 /* The current leaf node is full. Write it out to the database. */
116360 ** In other words, it must be the prefix of zTerm 1 byte longer than
116380 ** the buffer to make it large enough.
116399 /* Save the current term so that it can be used to prefix-compress the next.
116454 /* The entire tree fits on the root node. Write it to the segdir table. */
116539 ** it:
116665 ** stored in the full-text index. It merges data contained in one or
116712 ** for, then advance each segment iterator until it points to a term of
117264 ** included, except that it only contains entries for a single row of the
117572 ** After it returns, *piPos contains the value of the next element of the
117718 ** pnToken is not NULL, then it is set to the number of tokens in all
117752 ** arguments so that it points to the first element with a value greater
117940 /* Now that it is known how many phrases there are, allocate and zero
118008 ** to grow the buffer until so that it is big enough to accomadate the
118111 ** append it to string buffer pOut.
118466 ** 1 if the iterator is at EOF or if it now points to the start of the
118586 ** If it is false, then assume that those fields that do not change between
119122 ** table that maps from the entries rowid to the id of the node that it
119140 ** of a record. For internal nodes it is the node number of a
119383 ** a single instance of the following structure is allocated. It is used
119493 ** to it. Otherwise, return 0.
119527 ** indicating that node has not yet been assigned a node number. It is
119560 ** increase its reference count and return it.
119693 ** If the node is dirty, write it out to the database.
119746 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
120175 ** already at EOF. It is against the rules to call the xNext() method of
120490 ** If it has been used before, ignore it.
120594 ** Return the amount cell p would grow by if it were unioned with pCell.
120711 ** is inserted into it. Resolve ties by choosing the entry with
121296 /* Allocate an array and populate it with a copy of pCell and
121339 ** nodeWrite(). Node pRight always needs a node number, as it was created
121435 ** want to do this as it leads to a memory leak when trying to delete
121491 /* Remove the node from the in-memory hash table and link it into
121539 ** the in-memory node image, so it cannot fail.
121544 ** number of cells, remove it from the tree. Otherwise, update the
121545 ** cell in the parent node so that it tightly contains the updated
121758 /* If azData[0] is not an SQL NULL value, it is the rowid of a
121800 ** it, schedule the contents of the child for reinsertion and
122335 ** the context object when it is no longer required. */
122641 ** pointer. This is not really necessary, but it is tidier than
122753 ** types to an SQLite database connection. It is intended to be called