Home | History | Annotate | Download | only in dist

Lines Matching refs:iT

52 ** underlying operating system supports it.  If the OS lacks
137 ** It used to be the case that setting this value to zero would
138 ** turn the limit off. That is no longer true. It is not possible
226 ** compile time. This is no longer permitted, on the grounds that it creates
338 ** if it is available, it requires an #include of specific headers
355 #else /* Generates a warning - but it always works */
381 ** It determines whether or not the features related to
397 ** pared it down to just these two.)
422 ** so it is omitted there. See ticket #2673.
425 ** implemented on some systems. So we avoid defining it at all
426 ** if it is already defined or if it is unneeded because we are
561 ** or constant definition does not appear in this file, then it is
614 ** that we have taken it all out and gone back to using simple
641 ** be larger than the release from which it is derived. Either Y will
734 ** the mutexes are omitted. Without the mutexes, it is not safe
738 ** So if speed is of utmost importance, it makes sense to disable
743 ** version of SQLite that it is linking against was compiled with
766 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
824 ** outstanding [prepared statements] or [BLOB handles], then it returns
841 ** This is legacy and deprecated. It is included for historical
858 ** sqlite3_exec() is not NULL, then it is invoked for each result row
982 ** The SQLITE_OK result code will never be extended. It will always
1073 ** argument to calls it makes to the xLock() and xUnlock() methods
1086 ** [sqlite3_io_methods] object it uses a combination of
1089 ** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
1139 ** may be invoked even if the xOpen reported that it failed. The
1160 ** PENDING, or EXCLUSIVE lock on the file. It returns true
1209 ** If xRead() returns SQLITE_IOERR_SHORT_READ it must also fill
1256 ** current transaction. This hint is not guaranteed to be accurate but it
1283 ** at the internal representation of an [sqlite3_mutex]. It only
1327 ** ^If a suffix is added to the zFilename parameter, it will
1334 ** filename if it needs to remember the filename for some reason.
1337 ** xFilename parameter is NULL it will also be the case that the
1344 ** If xOpen() opens a file read-only then it sets *pOutFlags to
1362 ** change the way it deals with files. For example, an application
1378 ** deleted when it is closed. ^The [SQLITE_OPEN_DELETEONCLOSE]
1387 ** be created, and that it is an error if it already exists.
1388 ** It is <i>not</i> used to indicate the file should be opened
1394 ** allocate the structure; it should just fill it in. Note that
1482 ** currently unused, though it might be used in a future release of
1508 ** between unlocked and EXCLUSIVE. It cannot transition between SHARED
1537 ** A call to sqlite3_initialize() is an "effective" call if it is
1539 ** the process, or if it is the first time sqlite3_initialize() is invoked
1544 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
1561 ** the library (perhaps it is unable to allocate a needed resource such
1562 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
1568 it has not be initialized
1573 ** it is recommended that applications always invoke sqlite3_initialize()
1593 ** are built into SQLite when it is compiled for Unix, Windows, or OS/2.
1613 ** applications and so this routine is usually not necessary. It is
1622 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1672 ** and passing it to [sqlite3_config]([SQLITE_CONFIG_MALLOC])
1690 ** xRealloc must be a no-op - it must not perform any allocation or
1710 ** it might allocate any require mutexes or initialize internal data
1716 ** SQLite holds the [SQLITE_MUTEX_STATIC_MASTER] mutex when it invokes
1718 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
1722 ** it is by default) and so the methods are automatically serialized.
1758 ** [threading mode] to Single-thread. In other words, it disables
1759 ** all mutexing and puts SQLite into a mode where it can only be used
1762 ** it is not possible to change the [threading mode] from its default
1769 ** [threading mode] to Multi-thread. In other words, it disables
1777 ** it is not possible to set the Multi-thread [threading mode] and
1793 ** it is not possible to set the Serialized [threading mode] and
1855 ** the host architecture. ^It is harmless, apart from the wasted memory,
1859 ** memory needs for the first N pages that it adds to cache. ^If additional
1920 ** object and uses it for page cache memory allocations.</dd>
1930 ** and a pointer to void. ^If the function pointer is not NULL, it is
1990 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
2039 ** encounters a constraint violation, it does not fail. The
2045 ** be successful even if it is subsequently rolled back.
2148 ** ^It is safe to call this routine from a thread different from the
2149 ** thread that is currently running the database operation. But it
2154 ** sqlite3_interrupt() is called, then it might not have an opportunity
2186 ** complete if it ends with a semicolon token and is not a prefix of a
2234 ** The presence of a busy handler does not guarantee that it will be invoked
2236 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
2239 ** it is trying to promote to a reserved lock and
2240 ** a second process is holding a reserved lock that it is trying
2242 ** because it is blocked by the second and the second process cannot
2243 ** proceed because it is blocked by the first. If both processes
2254 ** already hold a RESERVED lock on the database file, but it needs
2255 ** to promote this lock to EXCLUSIVE so that it can spill cache
2257 ** readers. ^If it is unable to promote the lock, then the in-memory
2323 ** It is not safe to pass a result table directly to [sqlite3_free()].
2358 ** it must pass the result table pointer to sqlite3_free_table() in order to
2366 ** to any internal data structures of SQLite. It uses only the public
2419 ** ^(The %q option works like %s in that it substitutes a null-terminated
2422 ** character it escapes that character and allows it to be inserted into
2428 ** char *zText = "It's a happy day!";
2443 ** INSERT INTO table1 VALUES('It''s a happy day!')
2450 ** INSERT INTO table1 VALUES('It's a happy day!');
2456 ** ^(The %Q option works like %q except it also adds single quotes around
2489 ** memory, it returns a NULL pointer. ^If the parameter N to
2495 ** that it might be reused. ^The sqlite3_free() routine is
2526 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
2545 ** a block of memory after it has been released using
2831 ** Whether or not an error occurs when it is opened, resources
2833 ** passing it to [sqlite3_close()] when it is no longer required.
2836 ** except that it accepts two additional parameters for additional control
2854 ** <dd>The database is opened for reading and writing, and is creates it if
2855 ** it does not already exist. This is the behavior that is always used for
2875 ** participate in [shared cache mode] even if it is enabled.
2881 ** It is recommended that when a database filename actually does begin with
2923 ** interface is the same except that it always returns the
2934 ** When the serialized [threading mode] is in use, it might be the
3000 ** ^Hence, to find the current value of a limit without changing it,
3086 ** To execute an SQL query, it must first be compiled into a byte-code
3099 ** first zero terminator. ^If nByte is non-negative, then it is the maximum
3118 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
3134 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
3136 ** statement and try to run it again.
3220 ** for the values it stores. ^Values stored in sqlite3_value objects
3227 ** whether or not it requires a protected sqlite3_value.
3238 ** for maximum code portability it is recommended that applications
3313 ** string after SQLite has finished with it. ^The destructor is called
3325 ** (just an integer to hold its size) while it is being processed.
3572 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3598 ** Perhaps it was called on a [prepared statement] that has
3600 ** previously returned [SQLITE_ERROR] or [SQLITE_DONE]. Or it could
3604 ** For all versions of SQLite up to and including 3.6.23.1, it was required
3775 ** and atof(). SQLite does not really use these functions. It has its
3801 ** of conversion are done in place when it is possible, but sometimes they
3865 ** resource leaks. It is a grievous error for the application to try to use
3866 ** a prepared statement after it has been finalized. Any use of a prepared
3867 ** statement after it has been finalized can result in undefined and
3957 ** then it is destructor for the application data pointer.
3962 ** ^When the destructor callback of the tenth parameter is invoked, it
3966 ** ^It is permitted to register multiple implementations of the same
4198 ** calls to sqlite3_get_auxdata() might return this data, if it has
4200 ** ^If it is not NULL, SQLite will invoke the destructor
4225 ** argument is SQLITE_STATIC, it means that the content pointer is constant
4226 ** and will never change. It does not need to be destroyed. ^The
4317 ** function as the destructor on the text or BLOB result when it has
4323 ** when it has finished using that result.
4327 ** from [sqlite3_malloc()] before it returns.
4432 ** themselves rather than expecting SQLite to deal with it for them.
4471 ** then it is passed the names of undefined collation sequences as strings
4514 ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
4573 ** It is not safe to read or modify this variable in more than one
4574 ** thread at a time. It is not safe to read or modify this variable
4577 ** It is intended that this variable be set once
4583 ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
4588 ** Hence, if this variable is modified directly, either it should be
4636 ** satisfies the conditions of this routine, it returns NULL.
4678 ** hook returning non-zero, just as it would be with any other rollback.
4766 ** cache setting should set it explicitly.
4795 ** below the limit, it will exceed the limit rather than generate
4859 ** table or NULL. ^If it is NULL, then all attached databases are searched
4965 ** to turn extension loading on and call it with onoff==0 to turn
4966 ** it back off again.
4991 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
5021 ** interface fixed, support it indefinitely, and remove this comment.
5043 ** ^The registration remains valid until it is replaced by a different
5045 ** of this structure must not change while it is registered with
5099 ** is usable) and false if it cannot.)^
5190 ** invoke the destructor function (if it is not NULL) when SQLite
5293 ** interface fixed, support it indefinitely, and remove this comment.
5322 ** and write access. ^If it is zero, the BLOB is opened for read access.
5323 ** ^It is not possible to open a column that is part of an index or primary
5324 ** key for writing. ^If [foreign key constraints] are enabled, it is
5339 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
5379 ** ^This function is used to move an existing blob handle so that it points
5387 ** it must exist and there must be either a blob or text value stored in
5389 ** it does not contain a blob or text value, or if another error occurs, an
5478 ** ^This function may only modify the contents of the BLOB; it is
5524 ** ^To make an existing VFS into the default VFS, register it again
5573 ** mutex and returns a pointer to it. ^If it returns NULL
5594 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
5596 ** cases where it really needs one. ^If a faster non-recursive mutex
5617 ** dynamic mutex that it allocates. The dynamic mutexes must not be in
5705 ** (i.e. it is acceptable to provide an implementation that segfaults if
5706 ** it is passed a NULL pointer).
5708 ** The xMutexInit() method must be threadsafe. ^It must be harmless to
5720 ** If xMutexInit fails in any way, it is expected to clean up after itself
5743 ** provides implementations for these routines when it is compiled
5753 ** versions of these routines, it should at least provide stubs that always
5758 ** clearly the mutex cannot be held if it does not exist. But the
5843 ** This interface is not for use by applications. It exists solely
5906 ** and it is possible that another thread might change the parameter
5987 ** <dd>This parameter records the deepest parser stack. It is only
6079 ** of times it has performed specific operations.)^ These counters can
6134 ** The sqlite3_pcache type is opaque. It is implemented by
6180 ** It can be used to clean up
6186 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
6206 ** false if it is used for an in-memory database. The cache implementation
6208 ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
6220 ** value; it is advisory only.
6229 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
6236 ** parameter to help it determined what action to take:
6241 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
6267 ** previously contains an entry associated with newKey, it must be
6280 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
6314 ** It is useful either for creating backups of databases or
6321 ** read-locked while it is actually being read; it is not locked
6373 ** from source to destination, then it returns [SQLITE_DONE].
6426 ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
6487 ** same time as another thread is invoking sqlite3_backup_step() it is
6509 ** when the connection currently holding the required lock relinquishes it.
6516 ** its current transaction, either by committing it or rolling it back.
6522 ** application receives an SQLITE_LOCKED error, it may call the
6559 ** single void* pointer that is passed to the callback when it is invoked.
6561 ** it an array of void* context pointers. The first argument passed to
6569 ** multiple times, it is invoked once with the set of void* context pointers
6599 ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
6650 ** a few hundred characters, it will be truncated to the length of the
6667 ** ^The first parameter passed to the callback function when it is invoked
6679 ** callback returns [SQLITE_ROW] or [SQLITE_DONE], or if it returns a value
6851 ** in the table, it is faster to do a linear search than to manage
6867 ** Again, this structure is intended to be opaque, but it can't really
6868 ** be opaque because it is used by macros.
7130 ** Provide a default value for SQLITE_TEMP_STORE in case it is not specified
7138 ** GCC does not define the offsetof() macro so we'll have to do it
7146 ** Check to see if this machine uses EBCDIC. (Yes, believe it or
7318 ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
7345 ** make it clear to human readers when a function parameter is deliberately
7350 ** if it knows that this is enforced elsewhere.
7353 ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
7433 /* TODO: This definition is just included so other modules compile. It
7440 ** it must be turned on for each database using "PRAGMA auto_vacuum = 1".
7762 ** it takes up less space.
7794 ** argument is P4_KEYINFO_HANDOFF, the passed in pointer is used. It still
7795 ** gets freed when the Vdbe is finalized so it still should be obtained
8139 ** Page number PAGER_MJ_PGNO is never used in an SQLite database (it is
8140 ** reserved for working around a windows/posix incompatibility). It is
8543 /* If the SET_FULLSYNC macro is not defined above, then make it
8567 ** Mcafee started using SQLite in their anti-virus product and it
8654 ** file format. Depending on how it is changed, you might not notice
8738 ** The sqliteInt.h header #includes this file so that it is available
8739 ** to all source files. We break it out in an effort to keep the code
8916 ** context. It is reset at start of sqlite3_exec.
8918 ** insert, update, or delete statement. It remains constant throughout the
8919 ** length of a statement and is then updated by OP_SetCounts. It keeps a
9024 ** unlock so that it can proceed.
9055 #define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */
9129 ** count on this object is decremented. When it reaches 0, the destructor
9254 ** If both CollSeq.xCmp and CollSeq.xCmp16 are NULL, it means that the
9328 ** connection handle passed to it via the xConnect() or xCreate() method
9339 ** table, it searches the list for the VTable that corresponds to the
9352 ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
9441 ** done as a macro so that it will be optimized out when virtual
9594 ** it means this is not a unique index. Otherwise it is a unique index
9688 ** Usually it is 16-bits. But if SQLITE_MAX_VARIABLE_NUMBER is greater
9689 ** than 32767 we have to make it 32-bit. 16-bit is preferred because
9690 ** it uses less memory in the Expr object, which is a big memory user
9734 ** it can be accessed after all aggregates are computed.
9746 ** If the Expr is of type OP_Column, and the table it is selecting from
9932 ** tables in a join to 32 instead of 64. But it also reduces the size
10002 ** It is included here only so that that compiler will know how big it
10008 ** is only used when wsFlags&WHERE_VIRTUALTABLE is true. It is never the
10386 ** to save the Parse.zAuthContext value so that it can be restored later.
10626 ** FTS4 is really an extension for FTS3. It is enabled using the
10635 ** The ctype.h header is needed for non-ASCII systems. It is also
11013 ** and decode of the integers in a record header. It is faster for the common
11014 ** case where the integer is a single byte. It is a little slower when the
11015 ** integer is two or more bytes. But overall it is faster.
11315 ** it might have been allocated by lookaside, except the allocation was
11316 ** too large or lookaside was already full. It is important to verify
11322 ** All of this is no-op for a production build. It only comes into
11533 ** the database page that contains the pending byte. It never attempts
11537 ** During testing, it is often desirable to move the pending byte to
11985 ** 6000 lines long) it was split up into several smaller files and
12013 ** If the VdbeCursor.isTriggerRow flag is set it means that this cursor is
12050 ** aRow might point to (ephemeral) data for the current row, or it might
12067 ** restoring the state of the VM to as it was before the sub-program
12072 ** overwritten, the VdbeFrame object is not freed immediately. Instead, it
12225 ** This structure is defined inside of vdbeInt.h because it uses substructures
12257 ** any virtual table method invocations made by the vdbe program. It is
12453 ** Add N to the value of a status record. It is assumed that the
12664 ** as part of the "Secure CRT". It is essentially equivalent to
13130 ** Assuming the current time value is UTC (a.k.a. GMT), shift it to
13644 sqlite3_int64 iT;
13651 sqlite3OsCurrentTimeInt64(db->pVfs, &iT);
13652 t = iT/1000 - 10000*(sqlite3_int64)21086676;
13999 ** Register a VFS with the system. It is harmless to register the same
14025 ** Unregister a VFS so that it is no longer accessible.
14148 ** This version of the memory allocator is the default. It is
14203 ** to obtain the memory it needs.
14210 ** This version of the memory allocator is the default. It is
14218 ** so that we can find it later using sqlite3MemSize().
14355 ** to obtain the memory it needs while adding lots of additional debugging
14447 ** sqlite3MallocAllow() decrements it.
14488 ** if they are incorrect it asserts.
14677 ** higher level code is using pointer to the old allocation, it is
14900 ** it is available. The mempool allocator is activated by calling
15012 ** Unlink the chunk at mem3.aPool[i] from list it is currently
15086 ** If the STATIC_MEM mutex is not already held, obtain it now. The mutex
15175 ** If it sees a chunk that is larger than mem3.iMaster, it replaces
15539 ** is not required to be threadsafe (it is not).
15633 ** it is not actually possible to reach this limit.
15701 ** Unlink the chunk at mem5.aPool[i] from list it is currently
15702 ** on. It should be found on mem5.aiFreelist[iLogsize].
15743 ** If the STATIC_MEM mutex is not already held, obtain it now. The mutex
16120 ** linkage. It returns a pointer to a static sqlite3_mem_methods
16247 ** until it can be obtained.
16257 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
16400 ** mutex and returns a pointer to it. If it returns NULL
16550 ** mutex and returns a pointer to it. If it returns NULL
16567 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
16569 ** cases where it really needs one. If a faster non-recursive mutex
16653 ** SQLite is careful to deallocate every mutex that it allocates.
16864 ** mutex and returns a pointer to it. If it returns NULL
16884 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
16886 ** cases where it really needs one. If a faster non-recursive mutex
16923 /* Use a recursive mutex if it is available */
16963 ** mutex that it allocates.
16989 ** is atomic - that it cannot be deceived into thinking self
17032 ** is atomic - that it cannot be deceived into thinking self
17175 ** API as long as we don't call it win running Win95/98/ME. A call to
17274 ** mutex and returns a pointer to it. If it returns NULL
17294 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
17296 ** cases where it really needs one. If a faster non-recursive mutex
17347 ** mutex that it allocates.
17390 ** The sqlite3_mutex_try() routine is very rarely used, and when it
17391 ** is used it is merely an optimization. So it is OK for it to always
17395 ** And some windows compilers complain if you try to use it without
17754 ** Allocate memory. This routine is like sqlite3_malloc() except that it
17795 ** is outstanding clearing it when the allocation is freed.
17804 ** This routine is similar to alloca() in that it is not intended
18059 ** failing, it fails consistently until mallocFailed is reset.
18067 ** In other words, if a subsequent malloc (ex: "b") worked, it is assumed
18236 ** The "printf" code that follows dates from the 1980's. It is in
18341 ** The following table is searched linearly, so it is good to put the
18446 ** first argument to "func". Use it for whatever you like.
18714 /* It makes more sense to use 0.5 */
18826 /* The converted number is in buf[] and zero terminated. Output it.
19029 ** Finish off a string by making sure it is zero-terminated.
19166 ** sqlite3_snprintf() works like snprintf() except that it ignores the
19190 ** We house it in a separate routine from sqlite3_log() to avoid using
19193 ** sqlite3_log() must render into a static buffer. It cannot dynamically
19194 ** allocate memory because it might be called while the memory allocator
19224 ** and segfaults if you give it a long long int.
19291 ** subtle problems on some systems that could cause problems. It is hard
19542 ** 0xd800 and 0xe000 then it is rendered as 0xfffd.
19550 ** for unicode values 0x80 and greater. It do not change over-length
19599 ** desiredEnc. It is an error if the string is already of the desired
19739 ** UTF-16 string stored in *pMem. If one is present, it is removed and
19741 ** byte-swapping, it just sets Mem.enc appropriately.
19802 ** Hence it is only available in debug builds.
19811 ** The translation is done in-place (since it is impossible for the
19859 ** arrange to call sqlite3DbFree() on the returned pointer when it is
19908 ** It checks that the primitives for serializing and deserializing
20005 ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
20014 ** -O option since it can result in incorrect output for programs
20044 ** The value returned will never be negative. Nor will it ever be greater
20059 ** If it is not NULL, string zFormat specifies the format of the
20069 ** zFormat and any string tokens that follow it are assumed to be
20201 ** Convert this string to a double and write it into *pResult.
20218 ** returns FALSE but it still converts the prefix and writes the result
20407 ** if it is too big (used as a negative).
20445 ** than 19 digits (thus guaranteeing that it is too large) */
20448 /* Less than 19 digits, so we know that it fits in 64 bits */
20539 ** bit clear. Except, if we get to the 9th byte, it stores the full
20701 /* we can skip this cause it was (effectively) done above in calc'ing s */
20849 ** slightly faster, but it is also larger and much harder to test.
20980 ** foolproof but it does provide some measure of protection against
20983 ** 1 it means that the db pointer is valid and 0 if it should not be
21119 /* Resize the hash table so that it cantains "new_size" buckets.
21137 ** a performance hit but it is not a fatal error. So mark the
21222 ** that matches pKey,nKey. Return the data for this element if it is
21485 ** embedded systems, and when it does the developers normally have bigger
21532 ** This file should be #included by the os_*.c files only. It is not a
21586 ** It uses the RDTSC opcode to read the cycle count value out of the
21643 ** of the debugging and testing utilities, but it should at
21936 ** transitions leaving the lock state different from what it started but
21948 ** It is not possible to lower the locking level one step at a time. You
22056 ** release it now.
22130 ** It is not possible for this routine to fail if the second argument
22207 ** SQLite code assumes this function cannot fail. It also assumes that
22473 #ifdef NDEBUG /* when debugging we want to make sure it is deleted */
22882 ** underlying operating system supports it. If the OS lacks
22980 ** opportunity to either close or reuse it.
23030 ** it is larger than the struct CrashFile defined in test6.c.
23062 ** This file should be #included by the os_*.c files only. It is not a
23116 ** It uses the RDTSC opcode to read the cycle count value out of the
23173 ** of the debugging and testing utilities, but it should at
23269 ** The DJGPP compiler environment looks mostly like Unix, but it
23272 ** DJGPP. But it is DOS - what did you expect?
23410 ** useful to the clients of the sqlite3 functions. Specifically, it is
23429 * introspection, in which it actually means what it says */
23450 * introspection, in which it actually means what it says */
23455 * it actually means what it says */
23485 ** The structure is reclaimed when the number of pointers to it drops to
23489 ** a performance-critical path, so it is sufficient to put these
23619 ** by the same process. It does not explicitly say so, but this implies
23620 ** that it overrides locks set by the same process using a different
23629 ** on fd2, it works. I would have expected the second lock to
23654 ** descriptor. It is now a structure that holds the integer file
23659 ** a reference count (so we will know when to delete it) and a "cnt"
23723 ** object keeps a count of the number of unixFile pointing to it.
23754 ** It is invoked after an error occurs in an OS function and errno has been
23755 ** set. It logs a message using sqlite3_log() containing the current value of
23786 ** may point to aErr[], or it may point to some static storage somewhere.
23790 ** If the code incorrectly assumes that it is the POSIX version that is
23916 ** around this problem (we consider it a bug in OS X, not SQLite)
23990 /* Otherwise see if some other process holds it.
24027 ** transitions leaving the lock state different from what it started but
24056 ** A process may only obtain a RESERVED lock after it has a SHARED lock.
24060 ** A process may only obtain a PENDING lock after it has obtained a
24207 /* The request was for a RESERVED or EXCLUSIVE lock. It is
24475 ** common to all locking schemes. It closes the directory and file
24479 ** It is *not* necessary to hold the mutex when this routine is called,
24531 ** descriptor to pInode->pUnused list. It will be automatically closed
24554 ** (ex: databases that are burned into CD-ROM, for example.) It can
24621 ** In dotfile locking, either a lock exists or it does not. So in this
24660 ** transitions leaving the lock state different from what it started but
24715 /* got it, set the type and return ok */
24835 /* Otherwise see if some other process holds it. */
24840 /* got the lock, unlock it */
24854 /* someone else might have it reserved */
24885 ** transitions leaving the lock state different from what it started but
24909 /* if we already have a lock, it is exclusive.
24926 /* got it, set the type and return ok */
25007 ** Semaphore locking is like dot-lock and flock in that it really only
25034 /* Otherwise see if some other process holds it. */
25049 /* we could have it if we want it */
25070 ** transitions leaving the lock state different from what it started but
25094 /* if we already have a lock, it is exclusive.
25108 /* got it, set the type and return ok */
25284 /* Otherwise see if some other process holds it.
25290 /* if we succeeded in taking the reserved lock, unlock it to restore
25294 /* if we failed to get the lock then someone else must have it */
25320 ** transitions leaving the lock state different from what it started but
25450 /* The request was for a RESERVED or EXCLUSIVE lock. It is
25627 ** descriptor to pInode->aPending. It will be automatically closed when
25688 ** NB: If you define USE_PREAD or USE_PREAD64, then it might also
25908 ** it work better.
25917 ** The idea behind dataOnly is that it should only write the file content
25926 ** So, we always use fdatasync() if it is available, regardless of
25933 ** the one below. It is replicated here solely to avoid cluttering
25968 ** It shouldn't be possible for fullfsync to fail on the local
25972 ** It'd be better to detect fullfsync support once and avoid
25978 /* fdatasync() on HFS+ doesn't yet flush the file size if it changed correctly
26050 ** A failed directory sync is not a big deal. So it seems
26078 ** file so that it consists of an integer number of chunks (i.e. the
26126 ** layers, we need to report this file size as zero even though it is
26147 ** If the user has configured a chunk-size for this file, it could be
26167 /* If the OS does not have posix_fallocate(), fake it. First use
26215 /* The pager calls this method to signal that it has done
26217 ** it hence it is OK for the transaction change counter to be
26240 ** SQLite code assumes this function cannot fail. It also assumes that
26413 ** This is not a VFS shared-memory method; it is a utility function called
26486 ** a new *-shm file is created, an attempt will be made to create it
26586 ** been allocated, it is allocated by this function.
26589 ** this call as described above, then it is mapped into this processes
26590 ** address space (if it is not already), *pp is set to point to the mapped
26605 /* If the shared-memory file has not yet been opened, open it now. */
26624 ** Check to see if it has been allocated (i.e. if the wal-index file is
26869 ** implement various file locking strategies. It also contains definitions
26998 ** The proxy locking method is a "super-method" in the sense that it
27000 ** it uses proxy, dot-file, AFP, and flock() locking methods on those
27038 ** for the database file "filePath". It then returns the sqlite3_io_methods
27104 ** for the database file "filePath". It then returns the sqlite3_io_methods
27230 ** findInodeInfo(). If this is the case, it is quite safe to close
27231 ** handle h - as it is guaranteed that no posix locks will be released
27246 /* AFP locking uses the file path so it needs to be included in
27273 /* Dotfile locking uses the file path so it needs to be included in
27290 /* Named semaphore locking uses the file path so it needs to be
27405 /* It's odd to simulate an io-error here, but really this is just
27415 ** name. If it is not, return SQLITE_ERROR.
27455 ** If a suitable file descriptor is found, then it is returned. If no
27462 ** vxworks would not benefit from the change (it might, we're not sure),
27463 ** but because no way to test it is currently available. It is better
27469 /* A stat() call may fail for various reasons. If this happens, it is
27471 ** For this reason, if an error occurs in the stat() call here, it is
27507 ** If the file being opened is a temporary file, it is always created with
27509 ** is a database or master journal file, it is created with the permissions
27731 /* It is safe to close fd at this point, because it is guaranteed not
27732 ** to be open on a database file. If it were open on a database file,
27733 ** it would not be safe to close as this would release any locks held
27778 ** on that file that are currently holding advisory locks on it,
27917 /* It's odd to simulate an io-error here, but really this is just
27956 ** message is available, it is written to zBufOut. If no error message
27979 ** We initialize x by assigning it a pointer to the dlsym() function.
28015 ** some users. Rather than argue, it seems easier just to initialize
28135 ** in the core. So this routine is never called. For now, it is merely
28153 ** Proxy locking is a "uber-locking-method" in this sense: It uses the
28211 ** host ID in it, the proxy path in the conch file will be used, otherwise
28220 ** Once a lock proxy is configured for a database connection, it can not
28221 ** be removed, however it may be switched to a different proxy path via
28243 ** If the conch file does not exist, or it's contents do not match the
28255 ** Requesting the lock proxy does not immediately take the conch, it is
28258 ** opening a connection to a database file does not take a lock on it.
28306 ** and local proxy files in it
28457 return SQLITE_IOERR_LOCK; /* even though it is the conch */
28494 /* Not always defined in the headers as it ought to be */
28534 ** it back. The newly created file's file descriptor is assigned to the
28564 /* write it out to the temporary break file */
28756 /* if the conch isn't writable and doesn't match, we can't take it */
29003 ** This routine find the filename associated with pFile and writes it
29029 ** Takes an already filled in unix file and alters it so all file locking
29219 ** transitions leaving the lock state different from what it started but
29303 /* restore the original locking context and pMethod then close it */
29354 ** more than that; it looks at the filesystem type that hosts the
29458 ** embedded systems, and when it does the developers normally have bigger
29511 ** This file should be #included by the os_*.c files only. It is not a
29565 ** It uses the RDTSC opcode to read the cycle count value out of the
29622 ** of the debugging and testing utilities, but it should at
29721 ** WinCE lacks native support for file locking so we have to fake it
29768 ** thereafter. It records whether the operating system is Win95
29790 ** API as long as we don't call it when running Win95/98/ME. A call to
30003 /* Replace the backslashes from the filename and lowercase it
30030 /* Set a flag that indicates we're the first to create the memory so it
30038 /* If we succeeded in making the shared memory handle, map it. */
30042 /* If mapping failed, close the shared memory handle and erase it */
30144 /* If no pending lock has been acquired, then acquire it */
30281 ** containing the lower 32-bits of the new file-offset. Or, if it fails,
30282 ** it returns INVALID_SET_FILE_POINTER. However according to MSDN,
30284 ** whether an error has actually occured, it is also necessary to call
30299 ** It is reported that an attempt to close a handle might sometimes
30301 ** for being unreasonable so I do not doubt that it might happen. If
30430 ** file so that it consists of an integer number of chunks (i.e. the
30438 /* SetEndOfFile() returns non-zero when successful, or zero when it fails. */
30597 ** transitions leaving the lock state different from what it started but
30609 ** It is not possible to lower the locking level one step at a time. You
30650 ** held by another reader process who will release it momentarily.
30709 ** release it now.
30764 ** It is not possible for this routine to fail if the second argument
30831 ** SQLite code assumes this function cannot fail. It also assumes that
31021 ** This is not a VFS shared-memory method; it is a utility function called
31353 ** been allocated, it is allocated by this function.
31356 ** this call as described above, then it is mapped into this processes
31357 ** address space (if it is not already), *pp is set to point to the mapped
31390 ** Check to see if it has been allocated (i.e. if the wal-index file is
31547 /* It's odd to simulate an io-error here, but really this is just
31568 ** it's important to not reference them for WINCE builds.
31586 ** name. If it is not, return SQLITE_ERROR.
31614 /* FormatMessage returns 0 on failure. Otherwise it
31639 ** it's important to not reference them for WINCE builds.
31774 ** created. SQLite doesn't use it to indicate "exclusive access"
31775 ** as it is usually understood.
31778 /* Creates a new file, only if it does not already exist. */
31779 /* If the file exists, it fails. */
31782 /* Open existing file, or create if it doesn't exist */
31785 /* Opens a file, only if it exists. */
31820 ** it's important to not reference them for WINCE builds.
31891 ** process has it open. Sometimes a virus scanner or indexing program
31892 ** will open a journal file shortly after it is created in order to do
31893 ** whatever it does. While this other process is holding the
31894 ** file open, we will be unable to delete it. To work around this
31926 ** it's important to not reference them for WINCE builds.
31973 ** as if it does not exist.
31992 ** it's important to not reference them for WINCE builds.
32048 /* It's odd to simulate an io-error here, but really this is just
32070 ** it's important to not reference them for WINCE builds.
32187 ** it's important to not reference them for WINCE builds.
32304 /* if SystemTimeToFileTime() fails, it returns zero. */
32351 ** it should be truncated. The return value of xGetLastError
32354 ** then it is not necessary to include the nul-terminator character
32358 ** on SQLite. It is fine to have an implementation that never
32366 ** However if an error message is supplied, it will be incorporated
32462 ** it will be aligned within the Bitvec struct. */
32605 /* completely fill the hash, then just add it without */
32614 /* there was a collision, check to see if it's already */
32615 /* in hash, if not, try to find a spot for it */
32621 /* we didn't find it in the hash. h points to the first */
32878 ** Check that the pCache->pSynced variable is set correctly. If it
33036 int createFlag, /* If true, create page if it does not exist already */
33047 ** allocate it now.
33122 ** reference count drops to 0, then it is made elible for recycling.
33150 ** page. This function deletes that reference, so after it returns the
33168 ** Make sure the page is marked as dirty. If it isn't dirty already,
33169 ** make it so.
33181 ** Make sure the page is marked as clean. If it isn't clean already,
33182 ** make it so.
33247 ** it must be that pgno==0.
33433 ** sqlite3_pcache interface). It also contains part of the implementation
33527 ** bytes of data are located directly before it in memory (i.e. the total
33577 ** such buffer exists or there is no space left in it, this function falls
33596 ** configured soft-heap-limit to be breached, it will be possible to
33675 ** The pointer is allowed to be NULL, which is prudent. But it turns out
33712 ** Return true if it desirable to avoid allocating a new page cache
33717 ** it is desirable to avoid allocating a new page cache entry because
33723 ** under memory pressure, then again it is desirable to avoid
33784 ** global LRU list, if is part of it. If pPage is not part of the global
33813 ** (PCache1.apHash structure) that it is currently stored in.
33972 ** copy of the requested page. If one is found, it is returned.
34001 ** then attempt to recycle a page from the LRU list. If it is the right
34099 /* It is an error to call this function if the page is already
34292 ** After all inserts are finished, it is possible to extract the
34320 ** a non-zero batch number, it will see all prior INSERTs.
34391 ** It must be the case that N is sufficient to make a Rowset. If not
34607 ** as deep as it needs to be in order to contain the entire list.
34629 ** Convert the list in p->pEntry into a sorted list if it is not
34631 ** convert it into a list too and merge it into the p->pEntry list.
34710 ** The pager is used to access a database disk file. It implements
34771 ** snapshot is like a read-transaction. It is the state of the database
34780 /* Read a page from the write-ahead log, if it is present. */
34844 ** automatically as soon as it is written when PRAGMA synchronous=OFF.
34851 ** (a) The original content of the page as it was at the beginning of
34887 ** Definition: Two databases (or the same database at two points it time)
34899 ** is called to restore the database file to the same size it was at
34902 ** invoke it.)
35001 ** it opens a read-transaction on the database and returns to state
35014 ** * Even if a read-transaction is not open, it is guaranteed that
35050 ** is opened (if it is not already open) and a header written to the
35051 ** start of it. The database file on disk has not been modified.
35056 ** to it, but the header has not been synced to disk.
35062 ** when it modifies the contents of the database file. WAL connections
35075 ** It is not possible for a WAL connection to enter this state.
35080 ** by finalizing the journal file. Once in WRITER_FINISHED state, it is
35094 ** SQLITE_IOERR_NOMEM) occurs at a point in the code that makes it
35103 ** At this point it would be dangerous to change back to READER state
35110 ** Once it has entered the ERROR state, any attempt to use the pager
35136 ** Condition (3) is necessary because it can be triggered by a read-only
35139 ** automatically attempt a rollback, as it assumes that an error in a
35178 ** (i.e. one of the SQLITE_IOERR subtypes), it is not clear whether or not
35184 ** at the system level, but it is never set to a more exclusive value.
35201 ** doesn't know it because of a previous error in xUnlock). If this happens
35204 ** without rolling it back.
35207 ** database in the ERROR state, Pager.eLock is set to UNKNOWN_LOCK. It
35211 ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
35212 it back. See function
35284 ** logic into thinking that it already has all the locks it will ever
35297 ** It is set to true when the change-counter field is updated, which
35299 ** It is cleared (set to false) whenever an exclusive lock is
35301 ** The changeCountDone flag is inspected. If it is true, the work of
35310 ** When PagerCommitPhaseOne() is called to commit a transaction, it may
35312 ** journal file before it is synced to disk.
35317 ** If a journal file does not contain a master-journal pointer, it is
35319 ** it does contain a master-journal pointer the journal file is finalized
35320 ** by truncating it to zero bytes, just as if the connection were
35343 ** while it is being traversed by code in pager_playback().
35363 ** It is valid in PAGER_READER and higher states (all states except for
35382 ** variable at the start of the transaction. It is used during rollback,
35387 ** the file on disk in pages. It is set to a copy of dbSize when the
35396 ** to measure the database file on disk, and then truncates it if required.
35416 ** The Pager.errCode variable is only ever used in PAGER_ERROR state. It
35521 ** was obtained from /dev/random. It is used only as a sanity check.
35529 ** journal and ignore it.
35577 ** Return 0 if it is not open, or non-zero (but not 1) if it is.
35628 ** as if it has an exclusive lock on the database file. It never updates
35641 ** this means an in-memory pager performs no IO at all, it cannot encounter
35644 ** return SQLITE_IOERR_NOMEM while the journal file is being written). It
35692 /* It is possible that if journal_mode=wal here that neither the
35795 ** Return true if it is necessary to write page *pPg into the sub-journal.
35861 ** called, do not modify it. See the comment above the #define of
35887 ** called, do not modify it unless the new locking state is EXCLUSIVE_LOCK.
35914 ** The optimization is also always enabled for temporary files. It is
35918 ** If the optimization cannot be used, 0 is returned. If it can be used,
35919 ** then the value returned is the size of the journal file when it
35992 ** end of the file and, if successful, copies it into memory supplied
36004 ** file, then it is copied into the buffer pointed to by zMaster. A
36008 ** If it is determined that no master journal file name is present
36089 ** after writing or truncating it.
36120 ** space than that limit allows for, truncate it now. There is no need
36185 ** file it may contain some garbage data. There are two scenarios
36223 /* In theory, it is only necessary to write the 28 bytes that the
36229 ** However it has been discovered that on some systems this pattern can
36465 /* It is not possible for a call to PcacheFetch() with createFlag==0 to
36483 ** if it is open and the pager is not in exclusive mode.
36521 ** in the ERROR state. Otherwise, it switches the pager to PAGER_OPEN
36527 ** closed (if it is open).
36593 ** it can safely move back to PAGER_OPEN state. This happens in both
36626 ** it were a hot-journal).
36650 ** This routine is never called in PAGER_ERROR state. If it is called
36652 ** exclusive than a RESERVED lock, it is a no-op.
36656 ** If the journal file is open, then it is "finalized". Once a journal
36657 ** file has been finalized it is not possible to use it to roll back a
36658 ** transaction. Nor will it be considered to be a hot-journal by this
36705 ** 1. After a successful hot-journal rollback, it is called with
36744 ** the database file, it will do so using an in-memory journal.
36804 ** will roll it back.
36831 ** This is not a real checksum. It is really just the sum of the
36841 ** It is much less likely that the two ends of the journal record will be
36883 ** If pDone is not NULL, then it is a record of pages that have already
36933 ** a hot-journal rollback. If it is a hot-journal rollback, the pager
36954 ** it could cause invalid data to be written into the journal. We need to
36955 ** detect this invalid data (with high probability) and ignore it.
36973 ** rollback, then don't bother to play it back again.
36998 ** pager cache if it exists and the main file. The page is then marked
37000 ** a hot-journal rollback, it is guaranteed that the page-cache is empty
37017 ** 2008-04-14: When attempting to vacuum a corrupt database file, it
37056 ** problem. When the page is next fetched by the b-tree layer, it
37068 ** requiring a journal-sync before it is written.
37095 ** as clean, since there will be no need to write it out to the
37100 ** unsynced portion of the main journal file, then it is not safe
37105 ** again within this transaction, it will be marked as dirty but
37106 ** the PGHDR_NEED_SYNC flag will not be set. It could then potentially
37132 ** This routine checks if it is possible to delete the master journal file,
37133 ** and does so if it is.
37138 ** When a master journal file is created, it is populated with the names
37151 ** each child journal, it checks if:
37223 ** Open it and check if it points at the master journal. If
37271 ** xTruncate() method to truncate it.
37273 ** Or, it might might be the case that the file on disk is smaller than
37275 ** you try to truncate a file to some size that is larger than it
37292 /* TODO: Is it safe to use Pager.dbFileSize here? */
37320 ** it is less than 32, or rounded down to MAX_SECTOR_SIZE if it
37344 ** the state it was in before we started making changes.
37371 ** failure occurred while the journal was being written, it could be the
37373 ** the extra entries had not yet made it safely to disk. In such a case,
37377 ** If the nRec value is 0xffffffff it means that nRec should be computed
37393 ** that might be a hot journal. Or, it could be that the journal is
37419 /* Read the master journal name from the journal, if it is present.
37424 ** TODO: Technically the following is an error because it assumes that
37449 ** it is corrupted, then a process must have failed while writing it.
37471 ** process and if this is the final header in the journal, then it means
37480 ** the journal, it means that the journal might contain additional
37519 ** first place so it is OK to simply abandon the rollback. */
37574 ** see if it is possible to delete the master journal.
37582 ** value. Reset it to the correct value for this process.
37667 ** it is discarded. Otherwise, if there are one or more outstanding
37741 /* Increment the value just read and write it back to byte 24. */
37759 ** Hence, if page 1 appears anywhere on the list, it will be the first page.
37804 ** This routine used to be called "pagerOpenSnapshot()" because it essentially
37817 ** transaction in locking_mode=EXCLUSIVE. So call it now. If we
37855 ** determine it based on the size of the database file. If the size
37891 ** not exist (by deleting it) if the database file is empty.
37964 ** rolled back the first time it is encountered in either journal.
37970 ** is reset to the value that it held at the start of the savepoint
37972 ** is played back. If one is encountered it is simply skipped.
37991 /* Set the database size back to the value it was before the savepoint
38099 ** it is theoretically possible, though very unlikely,
38102 ** when it is rolled back.
38172 ** delete the temporary file when it is closed.
38206 ** lock. It does *not* invoke the busy handler when upgrading from
38218 ** retried. If it returns zero, then the SQLITE_BUSY error is
38234 ** If the pager is in the error state when this function is called, it
38245 ** * the database is either not an in-memory database or it is
38263 /* It is not possible to do a full assert_pager_state() here, as this
38315 ** occurs. But other modules are free to use it too, as long as
38399 ** the pager. It returns the total number of pages in the database.
38451 ** b) if the page content were written at this time, it would not
38463 ** database image would become corrupt. It is therefore fortunate that
38480 ** function does not actually modify the database file on disk. It
38493 ** This function is called before attempting a hot-journal rollback. It
38498 ** Syncing a hot-journal to disk before attempting to roll it back ensures
38527 it back. If an error occurs during the rollback
38546 /* If it is open, sync the journal file before calling UnlockAndRollback.
38553 ** database and close the journal file without attempting to roll it
38554 ** back or finalize it. The next database user will have to do hot-journal
38613 ** been written following it. If the pager is operating in full-sync
38661 ** hot-journal rollback following recovery. It may roll back all
38663 ** out-of-date data that follows it. Database corruption.
38667 ** byte to the start of it to prevent it from being recognized.
38670 ** problematic header will occur, if it exists. aMagic is used
38694 ** it as a candidate for rollback.
38697 ** SAFE_APPEND property. Because in this case it is not possible
38757 ** is not yet open, it is created and opened before any data is
38762 ** a page is skipped if it meets either of the following criteria:
38784 /* If the file is a temp-file has not yet been opened, open it now. It
38857 ** Ensure that the sub-journal file is open. If it is already open, this
38878 ** It is the callers responsibility to use subjRequiresPage() to check
38879 ** that it is really required before calling this function.
38894 /* Open the sub-journal, if it has not already been opened */
38928 ** This function is called by the pcache layer when it has reached some
38962 ** lead to database corruption. In the current implementaton it
38964 ** while in the error state, hence it is impossible for this routine to
38993 ** the database image, it may need to be written to the sub-journal.
39010 ** data from the database file. This will be the copy of page X as it
39011 ** was when the transaction started, not as it was when "SAVEPOINT sp"
39015 ** sub-journal file now (if it is not already there), so that it will
39043 ** Allocate and initialize a new Pager object and put a pointer to it
39044 ** in *ppPager. The pager should eventually be freed by passing it
39051 ** all information is held in cache. It is never written to disk.
39059 ** operation of the pager. It should be passed some bitwise combination
39136 ** as it will not be possible to open the journal file or even
39242 /* If a temporary file is requested, it is not opened immediately.
39336 ** PAGER_SHARED state. It tests if there is a hot journal present in
39357 ** will not roll it back.
39398 /* Check the size of the database file. If it consists of 0 pages,
39418 ** it can be ignored.
39437 ** it might be due to the race condition described above and in
39439 ** This might be a false positive. But if it is, then the
39441 ** with it under an EXCLUSIVE lock where we do not need to
39457 ** It is illegal to call sqlite3PagerAcquire() until after this function
39459 ** this function is called, it is a no-op.
39510 ** database file, then it either needs to be played back or deleted.
39519 /* Get an EXCLUSIVE lock on the database file. At this point it is
39521 ** EXCLUSIVE lock. If it were, another process might open the
39539 /* If it is not already open and the file exists on disk, open the
39546 ** If the journal does not exist, it usually means that some
39547 ** other connection managed to get in and roll it back before
39548 ** this connection obtained the exclusive lock above. Or, it
39574 ** it back since the process that crashed and left the hot journal
39575 ** probably did not sync it and we are required to always sync
39576 ** the journal before playing it back.
39602 ** assert_pager_state() would fail now, as it should not be possible
39633 ** it can be neglected.
39702 ** successfully obtained, it is copied to *ppPage and SQLITE_OK returned.
39704 ** If the requested page is already in the cache, it is returned.
39713 ** data is left as it was when the page object was last used.
39721 ** If noContent is true, it means that we do not care about the contents
39743 ** in memory, this routine goes to disk to read it in whereas Lookup()
39744 ** just returns 0. This routine acquires a read-lock the first time it
39746 ** Since Lookup() never goes to disk, it never has to deal with locks
39812 ** It merely means that we might do some extra work to journal a
39852 ** Acquire a page if it is already in the in-memory cache. Do
39894 ** to the start of it. If there are active savepoints, open the sub-journal
39896 ** opened to write a rollback log for a transaction. It is not used
39897 ** when opening a hot journal file to roll it back.
39899 ** If the journal file is already open (as it may be in exclusive mode),
39929 /* Open the journal file if it is not already open. */
39987 ** has no effect if the sub-journal is already opened (as it may be when
40005 ** exclusive lock on the database is not already held, obtain it now.
40018 ** holds the write-lock. If possible, the upper layer will call it.
40037 ** when it has an open transaction, but never to DBMOD or FINISHED.
40073 ** It is never called in the ERROR state.
40093 ** rollback journal might not yet be open. Open it now if this is the case.
40096 ** Otherwise, if it were done after calling sqlite3PcacheMakeDirty(), then
40117 ** the transaction journal if it is not there already.
40179 /* If the statement journal is open and the page is not in it,
40182 ** in that it omits the checksums and the header.
40238 ** an integer power of 2. It sets variable pg1 to the identifier
40278 ** starting at pg1, then it needs to be set for all of them. Because
40304 ** to sqlite3PagerWrite(). In other words, return TRUE if it is ok
40314 ** A call to this routine tells the pager that it is not necessary to
40322 ** that it does not get written to disk.
40370 ** to this function. Otherwise, it is always set to zero.
40433 ** If successful, or if called on a pager for which it is a no-op, this
40453 ** If the EXCLUSIVE lock is already held or the attempt to obtain it is
40522 ** function has already been called, it is mostly a no-op. However, any
40538 /* The following block updates the change-counter. Exactly how it
40596 ** that it took at the start of the transaction. Otherwise, the
40634 ** atomic-update optimization is used it is almost certain that the
40636 ** on a system under memory pressure it is just possible that this is
40637 ** not the case. In this case it is likely enough that the redundant
40680 ** though, and if a failure occurs at this point it will eventually
40684 ** truncating or partially zeroing it, so that it cannot be used
40695 ** But if (due to a coding error elsewhere in the system) it does get
40737 ** it returns Pager.errCode immediately. No work is performed in this case.
40741 ** 1) It rolls back the journal file, restoring all database file and
40745 ** 2) It finalizes the journal file, so that it is not used for hot
40873 ** malloc failure occurs while populating it in the for(...) loop below.
40915 ** If it is SAVEPOINT_RELEASE, then release and destroy the savepoint with
40916 ** index iSavepoint. If it is SAVEPOINT_ROLLBACK, then rollback all changes
40928 ** the transaction or unlock the database, it just restores the
40963 /* Only truncate if it is an in-memory sub-journal. */
40972 ** If this is a temp-file, it is possible that the journal file has
41054 ** in the rollback journal, it is not put there by by this routine.
41060 ** A transaction must be active when this routine is called. It used to be
41067 ** is being committed. In this case, it is guaranteed that the database page
41071 ** occurs. Otherwise, it returns SQLITE_OK.
41098 ** <journal page X, then modify it in memory>
41103 ** If page X were not written to the sub-journal here, it would not
41127 ** can be written to. The caller has already promised not to write to it.
41135 /* If the cache contains a page with page-number pgno, remove it
41137 ** page pgno before the 'move' operation, it needs to be retained
41160 ** as the original page since it has already been allocated.
41179 ** this transaction, it may be written to the database file before
41180 ** it is synced into the journal file. This way, it may end up in
41265 ** only. We invoke it once here to suppress a compiler warning. */
41314 /* In this case we would like to delete the journal file. If it is
41320 ** while it is in use by some other client.
41361 ** Return TRUE if the pager is in a state where it is OK to change the
41388 ** uses it opaquely as an argument to sqlite3BackupRestart() and
41424 ** is obtained instead, immediately release it.
41480 ** is not already open, make an attempt to open it now. If successful,
41534 ** it may need to be checkpointed before the connection can switch to
41535 ** rollback mode. Open it now so this can happen.
41655 ** magic number in the first 4 bytes of the WAL is 0x377f0683 and it
41686 ** To read a page from the database (call it page number P), a reader
41687 ** first checks the WAL to see if it contains page P. If so, then the
41698 ** and ignores the newly appended content, it will see a consistent snapshot
41722 ** connection to it closes. Because the wal-index is transient, it can
41723 ** use an architecture-specific format; it does not have to be cross-platform.
41880 ** Or it can be 1 to represent a 65536-byte page. The latter case was
41914 ** a special case; its value is never used and it exists as a place-holder
42140 ** architecture, it returns the u32 value that results from interpreting
42141 ** the 4 bytes as a big-endian value. On a big-endian architecture, it
42206 ** The checksum on pWal->hdr is updated before it is written.
42222 ** This function encodes a single frame header and writes it to a buffer
42258 ** in aData[] is valid. If it is a valid frame, fill *piPage and
42335 ** A lock cannot be moved directly between shared and exclusive - it must go
42396 ** slot in the hash table is set to N, it refers to frame number
42490 ** the entry that corresponds to frame pWal->hdr.mxFrame. It is guaranteed
43031 ** WalIterator object when it has finished with it.
43043 ** it only runs if there is actually content in the log (mxFrame>0).
43128 ** it safe to delete the WAL since the new content will persist in the
43169 /*** TODO: Move this test out to the caller. Make it an assert() here ***/
43314 ** read it, which might result in inconsistency. A dirty read is detected
43335 ** meaning it is possible that an inconsistent snapshot is read
43405 /* If the first attempt failed, it might have been due to a race
43415 ** a WRITE lock, it can only mean that the header is corrupted and
43438 ** This is the value that walTryBeginRead returns when it needs to
43445 ** other transient condition. When that happens, it returns WAL_RETRY to
43446 ** indicate to the caller that it is safe to retry immediately.
43453 ** the case where the WAL is bypassed because it has been completely
43470 ** possibility is so small that it can be safely neglected, we believe.
43489 ** update values of the aReadMark[] array in the header, but if it does
43490 ** so it takes care to hold an exclusive lock on the corresponding
43509 ** during the few nanoseconds that it is holding the lock. In that case,
43510 ** it might take longer than normal for the lock to free.
43563 /* The WAL has been completely backfilled (or it is empty).
43570 /* It is not safe to allow the reader to continue here if frames
43581 ** it finished. Leaving a corrupt image in the database file.
43593 /* If we get this far, it means that the reader will want to use
43636 ** It is necessary to check that the wal-index header did not change
43637 ** between the time it was read and when the shared-lock was obtained
43648 ** blocking writers. It only guarantees that a dangerous checkpoint or
43670 ** it takes a snapshot of the state of the WAL and wal-index for the current
43707 ** Read a page from the WAL, if it is present in the WAL and if the
43806 /* If iRead is non-zero, then it is the log frame number that contains the
43845 ** the read transaction was started, then it is not possible for this
43902 ** other than SQLITE_OK, it is not invoked again and the error code is
43914 /* Restore the clients cache of the wal-index header to the state it
43929 ** If the upper layer is doing a rollback, it is guaranteed that there
43990 ** file (see sqlite3WalFrames()). It checks to see if, instead of appending
43991 ** to the current log file, it is possible to overwrite the start of the
43993 ** it sets pWal->hdr.mxFrame to 0. Otherwise, pWal->hdr.mxFrame is left
44017 ** In theory it would be Ok to update the cache of the header only
44081 /* See if it is possible to write these frames into the start of the
44082 ** log file, instead of appending to it at pWal->hdr.mxFrame.
44184 /* Append data to the wal-index. It is not necessary to lock the
44243 ** is already running a checkpoint, or maybe a recovery. But it might
44258 ** next time the pager opens a snapshot on this database it knows that
44305 ** not actually change anything. The pager uses this to see if it
44373 ** big and we want to break it down some. This packaged seemed like
44478 ** except that it applies to leaf nodes in a LEAFDATA tree. The maximum
44479 ** payload fraction for a LEAFDATA tree is always 100% (or 255) and it
44700 ** this object for every database file that it has open. This structure
44707 ** has it own instance of this object. But each instance of this object
44749 ** sharing the same database file, each connection has it own
44757 ** may not be modified once it is initially set as long as nRef>0.
44841 ** If a tree that appears to be taller than this is encountered, it is
44985 ** if the database supports auto-vacuum or not. Because it is used
44987 ** (sqliteMallocRaw), it is not possible to use conditional compilation.
45401 ** But if the value is zero, make it 65536.
45414 ** but the test harness needs to access it so we make it global for
45467 ** table with root page iRoot. Return 1 if it does and 0 if not.
45506 ** not loaded, then it is too difficult to actually check to see if
45516 ** written. For index b-trees, it is the root page of the associated
45551 ** Return true if it would be illegal for pBtree to write into the
45555 ** It is illegal for pBtree to write if some other Btree object that
45558 ** read-uncommitted flag set, then it is OK for the other object to
45673 /* This function should only be called on a sharable b-tree after it
45687 ** with table iTable, allocate one and link it into the list.
45719 ** transaction. If it does not, then the BtShared.isPending variable
45866 ** such a page is not even journalled (as it will not be modified,
45867 ** why bother journalling it?).
45870 ** from the database or written to the journal file (why should it
45871 ** be, if it is not at all meaningful?).
45877 ** it is moved to the free-list and it is also not journalled when it
45879 ** may be lost. In the event of a rollback, it may not be possible
45908 ** free-list for reuse. It returns false if it is safe to retrieve the
46040 ** Restore the cursor to the position it was in (or as close to as possible)
46069 ** Determine whether or not a cursor has moved from the position it
46120 ** so that it maps to type 'eType' and parent page number 'pgno'.
46549 ** the list that is large enough to accomadate it.
46634 ** freeblocks that overlapped cells. Nor does it detect when the
46682 /* If the cell content area begins with a freeblock, remove it. */
46737 ** guarantee that the page is well-formed. It only shows that
46783 ** returned if it does.
46847 ** Set up a raw page so that it looks like a database page holding
46899 ** If the noContent flag is set, it means that we do not care about
46951 ** Get a page from the pager and initialize it. This routine is just a
46955 ** If an error occurs, then the value *ppPage is set to is undefined. It
46956 ** may remain unchanged, or it may be set to an invalid value.
47014 /* pPage might not be a btree page; it might be an overflow page
47017 ** But no harm is done by this. And it is very important that
47040 ** be exclusively in memory, or it might use a disk-based memory cache.
47045 ** that is automatically destroyed when it is closed.
47320 ** Decrement the BtShared.nRef counter. When it reaches zero,
47323 ** false if it is still positive.
47410 ** it without having to hold the mutex.
47440 ** operate asynchronously - it will not stop to do fsync()s
47600 ** parameter is non-zero, then auto-vacuum mode is enabled. If zero, it
47701 ** in WAL mode. If the log is not already open, open it now. Then
47769 ** a cell. Make sure it is small enough so that at least minFanout
47903 /* If the btree is already in a write-transaction, or it
47951 ** reading page 1 it discovers that the page-size of the database
47998 /* If the db-size header field is incorrect (as it may be if an old
47999 ** client has been writing the database file), update it now. Doing
48018 ** the sub-journal is not already open, then it will be opened here.
48073 ** that it points to iTo. Parameter eType describes the type of pointer to
48171 /* If pDbPage was a btree-page, then it may have child pages and/or cells
48195 ** that it points at iFreePage. Also fix the pointer map entry for
48231 ** it returns SQLITE_DONE or an error, and that nFin is the
48233 ** process is complete. If nFin is zero, it is assumed that
48266 ** truncated to zero after this function returns, so it doesn't
48267 ** matter if it still contains some garbage entries.
48341 ** It performs a single unit of work towards an incremental vacuum.
48344 ** SQLITE_DONE is returned. If it is not finished, but no error occurred,
48394 /* It is not possible to create a database for which the final page
48439 ** causes a rollback journal to be created (if it does not already exist)
48533 ** are no active cursors, it also releases the read lock.
48579 ** in assert() expressions, so it is only compiled if NDEBUG is not
48610 ** or moved root pages, so it is not sufficient to
48637 ** are no active cursors, it also releases the read lock.
48718 ** SQL statements. It is illegal to open, release or rollback any
48763 ** iTable. If a read-only cursor is requested, it is assumed that
48787 ** root page of a b-tree. If it is not, then the cursor acquired
48790 ** It is assumed that the sqlite3BtreeCursorZero() has been called
48871 ** to zero. But it turns out that the apPage[] and aiIdx[] arrays
48941 ** BtCursor.info structure. If it is not already valid, call
48942 ** btreeParseCell() to fill it in.
49009 ** This routine cannot fail. It always returns SQLITE_OK.
49032 ** It might just as well be a procedure (returning void) but we continue
49046 ** linked list of overflow pages. If possible, it uses the auto-vacuum
49057 ** reference. It is the responsibility of the caller to call releasePage()
49155 ** buffer pBuf). If it is non-zero, a write (data copied from
49170 ** Once an overflow page-list cache has been allocated, it may be
49231 ** has not been allocated, allocate it now. The array is sized at
49240 /* nOvfl is always positive. If it were zero, fetchPayload would have
49249 ** directly to it.
49283 /* Need to read this page properly. It contains some of the
49363 ** the key if skipKey==0 and it points to the beginning of data if
49368 ** This routine is an optimization. It is common for the entire key
49373 ** the key/data and copy it into a preallocated buffer.
49543 ** If this function returns successfully, it may be assumed that the
49584 ** expected to open it on an index b-tree. Otherwise, if pKeyInfo is
49596 ** if the assumption were not true, and it is not possible for the flags
49622 ** entry to which it is currently pointing.
49644 ** page to which it is currently pointing. Notice the difference
49735 /* Move the cursor so that it points to an entry near the key
49743 ** left pointing at a leaf page which would hold the entry if it
50090 ** sqlite3PagerUnref() on the new page when it is done.
50102 ** anywhere on the free-list, then it is guarenteed to be returned. This
50159 ** is not true. Otherwise, it runs once for each trunk-page on the
50183 ** So extract the trunk page itself and use it as the newly
50202 ** to allocate, regardless of whether it has leaves.
50222 /* The trunk page is required by the caller but it contains
50378 ** It is assumed that the page is not already a part of the free-list.
50382 ** corresponding to page iPage handy, it may pass it as the second value.
50383 ** Otherwise, it may pass NULL.
50436 ** new free-list trunk page. Otherwise, it will become a leaf of the
50437 ** first trunk page in the current free-list. This block tests if it
50459 ** Note that the trunk page is not really full until it contains
50484 /* If control flows to this point, then it was not possible to add the
50556 ** So if there exists more than one reference to this page, then it
50558 ** It is helpful to detect this before calling freePage2(), as
50742 ** The cell content is not freed or deallocated. It is assumed that
50790 ** If the cell content will fit on the page, then put it there. If it
50793 ** in pPage->aOvfl[] and make it
50860 ** if it returns success */
51050 ** it is sometimes activated temporarily while debugging code responsible
51102 ** The performance of this function is not critical. It is only used by
51128 ** fairly obscure circumstances, even though it is a copy of initialized
51168 ** happens, it is the responsibility of the caller to invoke the correct
51171 ** If this routine fails for any reason, it might leave the database
51230 ** this overflow cell is present, it must be the cell with
51293 ** the cell within the parent, even though it has been dropped.
51295 ** four bytes of it, and this function does not need the first
51302 ** buffer. It will be copied out again as soon as the aSpace[] buffer
51616 ** bytes, then it may actually be smaller than this
51618 ** any cell). But it is important to pass the correct size to
51622 ** cells are at least 4 bytes. It only happens in b-trees used
51661 ** (it must be, as it was just reconstructed using assemblePage()). This
51801 ** page is then overwritten to make it an empty page with the right-child
51885 ** and copy the current contents of the root-page to it. The
51942 ** but it doesn't deal with overflow cells - just moves them to a
51944 ** has completed, it is safe to release the pSpace buffer used by
51952 /* If pFree is not NULL, it points to the pSpace buffer used
51955 ** new pSpace buffer, so it may be safely freed here. */
52039 ** operation - if it is not, the following is a no-op). */
52049 ** integer key to use. It then calls this function to actually insert the
52051 ** that the cursor is already where it needs to be and returns without
52052 ** doing any work. To avoid thwarting these optimizations, it is important
52116 ** happen while processing an "INSERT INTO ... SELECT" statement), it
52120 ** larger than the largest existing key, it is possible to insert the
52240 ** been corrected, so be it. Otherwise, after balancing the leaf node,
52241 ** walk the cursor up the tree to the internal node and balance it as
52324 ** allocated pgnoMove. If required (i.e. if it was not allocated
52480 ** is the root of a table b-tree - if it is not, the following call is
52520 /* It is illegal to drop a table if any cursors are open on the
52715 /* pPage is a leaf node. This loop navigates the cursor so that it
52716 ** points to the first interior cell that it points to the parent of
52933 ** 8. Make sure this page is at least 33% full or else it is
53270 ** open so it is safe to access without the BtShared mutex.
53283 ** open so it is safe to access without the BtShared mutex.
53349 ** allocated, it is returned as normal.
53387 ** if it is false.
53414 ** Only the data content may only be modified, it is not possible to
53557 ** Once it has been created using backup_init(), a single sqlite3_backup
53589 ** If the "temp" database is requested, it may need to be opened by this
53642 ** handle is not locked in this routine, but it is locked in
53773 ** If pFile is currently larger than iSize bytes, then truncate it to
53834 /* Lock the destination database, if it is not locked already. */
53843 ** one now. If a transaction is opened here, then it will be closed
53907 ** fix the size of the file. However it is important to call
54031 /* If a transaction is still open on the Btree, roll it back. */
54077 ** It is assumed that the mutex associated with the BtShared object
54086 /* The backup process p has already copied page iPage. But now it
54106 ** It is assumed that the mutex associated with the BtShared object
54233 ** current content of the cell is preserved. Otherwise, it may
54237 ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
54278 ** Make the given Mem object MEM_Dyn. In other words, make it so
54307 ** If the given Mem* has a zero-filled tail, turn it into an ordinary
54387 ** FIX ME: It would be better if sqlite3_snprintf() could do UTF-16.
54432 ** invoking an external callback, free it now. Calling this function
54501 /* minInt is correct here - not maxInt. It turns out that assigning
54503 it is what x86 hardware
54518 ** it into a integer and return that. If pMem represents an
54546 ** value. If it is a string or blob, try to convert it to a double.
54547 ** If it is a NULL, return 0.0.
54568 ** The MEM structure is already a MEM_Real. Try to also make it a
54588 ** true and could be omitted. But we leave it in because other
54611 ** Convert pMem so that it is of type MEM_Real.
54624 ** Convert pMem so that it has types MEM_Real or MEM_Int or both.
54845 ** If the string is too large (if it exceeds the SQLITE_LIMIT_LENGTH
54847 ** stored without allocating memory, then it is. If a memory allocation
54887 /* The following block sets the new values of Mem.z and Mem.xDel. It
54951 /* If one value is NULL, it is less than the other. If both values
55110 /* This function is only available internally, it is not part of the
55111 ** external API. It works in a similar way to sqlite3_value_text(),
55176 ** the value by passing it to sqlite3ValueFree() later on. If the expression
55302 ** that it uses the encoding "enc"
55330 ** a VDBE (or an "sqlite3_stmt" as it is known to the outside world.) Prior
55418 ** Resize the Vdbe.aOp array so that it is at least one op larger than
55419 ** it was.
55584 ** in a Vdbe main program and each of the sub-programs (triggers) it may
55585 ** invoke directly or indirectly. It should be used as follows:
55664 ** ABORT may be thrown, or false otherwise. Return true if it does
55761 ** the Vdbe passed as the first argument. It is the callers responsibility
55873 ** Change the P2 operand of instruction addr so that it points to
55882 ** If the input FuncDef structure is ephemeral, then free it. If
55944 ** opcodes contained within. If aOp is not NULL it is assumed to contain
55997 ** If n==P4_KEYINFO it means that zP4 is a pointer to a KeyInfo structure.
56002 ** caller should not free the allocation, it will be freed when the Vdbe is
56120 ** is readable but not writable, though it is cast to a writable value.
56263 ** will be used so that it can acquire mutexes on them all in sorted
56363 ** running the code, it invokes the callback once for each instruction.
56419 /* On the first call to sqlite3_step(), pSub will hold a NULL. It is
56609 ** NULL, it means that memory space has already been allocated and that
56646 ** After the VDBE has be prepped, it can be executed by one or more
56695 ** first time this function is called for a given VDBE, not when it is
56791 /* The pCx->pCursor will be close automatically, if it exists, by
56866 ** sorters that were left open. It also deletes the values of
56916 ** or SQLITE_TRANSIENT. If it is SQLITE_DYNAMIC, then the buffer pointed
56943 ** db. If a transaction is active, commit it. If there is a
56999 ** string, it means the main database is :memory: or a temp file. In
57015 ** IO error while deleting or truncating a journal file. It is unlikely,
57113 ** master journal file will be orphaned. But we cannot delete it,
57170 ** This is an internal self-check only - it is not an essential processing
57207 ** reorder rootpages. So it is not sufficient just to save
57209 ** so that it is never used again.
57223 ** close it now. Argument eOp must be either SAVEPOINT_ROLLBACK or
57224 ** SAVEPOINT_RELEASE. If it is SAVEPOINT_ROLLBACK, then the statement
57267 ** database handles deferred constraint counter to the value it had when
57279 ** that may be accessed by the VM passed as an argument. In doing so it
57311 ** an error message to it. Then return SQLITE_ERROR.
57332 ** SQLITE_MAGIC_RUN to SQLITE_MAGIC_HALT. It is harmless to
57336 ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it
57388 ** Even if the statement is read-only, it is important to perform
57553 ** To look at it another way, this routine resets the state of the
57561 /* If the VM did not run to completion or if it encountered an
57562 ** error, then it might not have been halted properly. So halt
57563 ** it now.
57709 ** Make sure the cursor p is ready to read or write the row to which it
57715 ** deleted out from under the cursor and if it has, mark the row as
57765 ** the blob of data that it corresponds to. In a table record, all serial
57849 ** (later): It is reported to me that the mixed-endian problem
57850 ** on ARM7 is an issue with GCC, not with the ARM7 chip. It seems
57897 ** buf. It is assumed that the caller has allocated sufficient space.
58064 ** VDbeParsedRecord structure if it is large enough. If it is
58085 int nOff; /* Increase pSpace by this much to 8-byte align it */
58088 ** We want to shift the pointer pSpace up such that it is 8-byte aligned.
58090 ** it by. If pSpace is already 8-byte aligned, nOff should be zero.
58152 It returns a negative, zero
58168 ** the header of pKey1 is ignored. It is assumed that pKey1 is
58197 ** We could initialize it, as shown here, to silence those complaints.
58252 ** the following assert(). If the assert() fails, it indicates a
58262 ** larger. As it happens, the pPKey2 will always be the longer
58279 ** Read the rowid (the last field in the record) and store it in *rowid.
58360 ** pUnpacked is either created without a rowid or is truncated so that it
58406 ** Set a flag in the vdbe to update the change counter when it is finalised
58440 ** 0 instead. Unless it is NULL, apply affinity aff (one of the SQLITE_AFF_*
58441 ** constants) to the value before returning it.
58463 ** Configure SQL variable iVar so that binding a new value to it signals
58510 ** Check on a Vdbe to make sure it has not been finalized. Log
58511 ** an error and return true if it has been finalized (or is otherwise
58512 ** invalid). Return false if it is ok.
58565 ** Terminate the current execution of an SQL statement and reset it
58566 ** back to its starting state so that it can be reused. A success code from
58664 ** result as a string or blob but if the string or blob is too large, it
58787 ** This function is called after a transaction has been committed. It
58830 /* Check that malloc() has not failed. If it has, return early. */
58965 ** pointer to it.
58974 ** pointer to it.
59055 ** deleted by calling the delete function specified when it was set.
59101 ** This function is deprecated. Do not use it for new code. It is
59133 ** it is, return a pointer to the Mem for the value of that column.
59286 ** 0 The column name as it should be displayed for output
59292 ** If the result is not a simple column reference (if it is an expression
59635 ** work but it results in the same answer.
59994 ** When this global variable is positive, it gets decremented once before
59998 ** This facility is used for testing purposes only. It does not function
60044 ** Test a register to see if it exceeds the current maximum blob size.
60045 ** If it does, record the new maximum blob size.
60054 ** Convert the given register into a string if it isn't one
60065 ** does not control the string, it might be deleted without the register
60066 ** knowing it.
60069 ** string that the register itself controls. In other words, it
60107 ** Allocate VdbeCursor number iCur. Return a pointer to it. Return NULL
60118 ** required for this VdbeCursor structure. It is convenient to use a
60169 ** looks like a number, convert it into a number. If it does not
60170 ** look like a number, leave it alone.
60234 ** is appropriate. But only do the conversion if it is possible without
60407 ** It uses the RDTSC opcode to read the cycle count value out of the
60464 ** of the debugging and testing utilities, but it should at
60480 ** sqlite3_interrupt() routine has been called. If it has been, then
60494 ** This function is only called from within an assert() expression. It
60538 ** will either invoke the busy callback (if there is one) or it will
61047 /* Call the progress callback if it is configured and the required number
61228 ** For errors, it can be some other value. If P1!=0 then P2 will determine
61234 ** If P4 is not null then it is an error message string.
61322 ** into an OP_String before it is executed for the first time.
61416 ** left holding a NULL. It is an error for register ranges
61496 ** with an SQLITE_ROW return code and it sets up the sqlite3_stmt
61511 ** transaction. It needs to be rolled back. */
61573 ** It is illegal for P1 and P3 to be the same register. Sometimes,
61960 ** If register P1 holds an integer convert it to a real value.
61980 ** If the value is numeric, convert it to a string using the
61984 ** A NULL value is not changed by this routine. It remains NULL.
62003 ** If the value is numeric, convert it to a string first.
62007 ** A NULL value is not changed by this routine. It remains NULL.
62027 ** If the value is text or blob, try to convert it to an using the
62031 ** A NULL value is not changed by this routine. It remains NULL.
62044 ** If the value is text or blob, try to convert it to an integer using the
62047 ** A NULL value is not changed by this routine. It remains NULL.
62061 ** If The value is currently an integer, convert it.
62062 ** If the value is text or blob, try to convert it to an integer using the
62065 ** A NULL value is not changed by this routine. It remains NULL.
62116 ** If neither operand is NULL the the result is the same as it would be if
62128 ** If neither operand is NULL the the result is the same as it would be if
62414 ** is considered true if it is numeric and non-zero. If the value
62420 ** is considered true if it has a numeric value of zero. If the value
62529 ** u.am.zRec is set to be the complete text of the record if it is available.
62532 ** might be available in the u.am.pC->aRow cache. Or it might not be.
62558 ** payload size, so it is impossible for u.am.payloadSize64 to be
62681 /* Scan the header and use it to fill in the u.am.aType[] and u.am.aOffset[]
62906 ** sqlite3VdbeMemGrow() could clobber the value before it is used).
63040 /* It is not possible to release (commit) a savepoint if there are
63041 ** active write statements. It is not possible to rollback a savepoint
63093 /* If it is a RELEASE, then destroy the savepoint being operated on
63094 ** too. If it is a ROLLBACK TO, then set the number of deferred
63259 ** Read cookie number P3 from database P1 and write it into register P2.
63331 ** schema version) and make sure it is equal to P2.
63391 ** It is an error for P1 to be negative.
63406 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
63409 ** value, it is set to the number of columns in the table.
63420 ** a KeyInfo structure (P4_KEYINFO). If it is a pointer to a KeyInfo
63423 ** value, it is set to the number of columns in the table, or to the
63426 ** This instruction works just like OpenRead except that it opens the cursor
63499 /* Since it performs no memory allocation or IO, the only values that
63527 ** if P4 is not 0. If P4 is not NULL, it points to a KeyInfo structure
63538 ** This opcode works the same as OP_OpenEphemeral. It has a
63565 /* If a transient index is required, create it by calling
63567 ** opening it. If a transient table is required, just use the
63641 ** Reposition cursor P1 so that it points to the smallest entry that
63654 ** Reposition cursor P1 so that it points to the smallest entry that
63667 ** Reposition cursor P1 so that it points to the largest entry that
63680 ** Reposition cursor P1 so that it points to the largest entry that
63713 ** blob, or NULL. But it needs to be an integer before we can do
63714 ** the seek, so covert it. */
63843 ** for P1 to move so that it points to the rowid given by P2.
64049 ** pointing to the record if it exists.
64155 ** it already exists in the table. If it does not exist, we have
64230 ** it finds one that is not previously used. */
64269 ** created if it doesn't already exist or the data for an existing
64277 ** sqlite3_last_insert_rowid() function (otherwise it is unmodified).
64293 ** may be NULL. If it is not NULL, then the update-hook
64385 ** record in the table. If it is left pointing at the next record, then
64386 ** the next Next instruction will be a no-op. Hence it is OK to delete
64392 ** P1 must not be pseudo-table. It has to be a real table with
64395 ** If P4 is not NULL, then it is the name of the table that P1 is
64396 ** pointing to. The update hook will be invoked, if it exists.
64425 ** below is always a no-op and cannot fail. We will run it anyhow, though,
64463 ** It is just copied onto the P2 register exactly as
64464 ** it is found in the database file.
64474 ** it is found in the database file.
64506 ** a no-op and can never fail. But we leave it in place as a safety.
64651 ** it increments an undocumented global variable used for testing.
64654 ** then rewinding that index and playing it back from beginning to
64704 ** Advance cursor P1 so that it points to the next key/data pair in its
64718 ** Back up cursor P1 so that it points to the previous key/data pair in its
64894 ** the result is false whereas it would be true with IdxGT.
64958 ** If AUTOVACUUM is enabled then it is possible that another root page
65102 ** then runs the new virtual machine. It is thus a re-entrant opcode.
65117 ** created by this VDBE, from the sqlite_master table. It only
65120 ** with the rest of the schema when it is required.
65124 ** read by this instruction) is currently held, it is necessary to
65341 ** the rowset object for P3, as it is guaranteed not to contain it,
65342 ** (b) when P4==-1 there is no need to insert the value, as it will
65345 ** previously inserted as part of set X (only if it was previously
65360 ** delete it now and initialize P1 with an empty rowset
65422 ** It is recursive invocation of triggers, at the SQL level, that is
65443 ** is already allocated. Otherwise, it must be initialized. */
65603 ** It is illegal to use this instruction on a register that does
65619 ** It is illegal to use this instruction on a register that does
65636 ** It is illegal to use this instruction on a register that does
65713 ** argument is not used by this opcode. It is only there to disambiguate
65785 ** is not called when the statement is prepared because it requires the
65877 ** machines to be created and run. It may not be called from within
65913 ** fails with an error code of SQLITE_SCHEMA if it is ever executed
65967 ** within a callback to a virtual table xSync() method. If it is, the error
66276 ** P1 is a boolean flag. If it is set to true and the xUpdate call
66391 ** This opcode records information from the optimizer. It is the
66420 ** of the program. It is only here for testing and debugging.
66421 ** On the other hand, it does burn CPU cycles every time through
66422 ** the evaluator loop. So we can leave it out when NDEBUG is defined.
66441 /* If we reach this point, it means that execution is finished with
66536 ** This function is used by both blob_open() and blob_reopen(). It seeks
66544 ** be set to point to a buffer containing an error message. It is the
66627 ** uses it to implement the blob_read(), blob_write() and
66712 ** column is not indexed, and that it is not part of a foreign key.
66713 ** It is against the rules to open a column to which either of these
66720 /* Check that the column is not part of an FK child key definition. It
66721 ** is not necessary to check if it is part of a parent key, as parent
66789 ** think that the table has one more column than it really
66791 ** always return an SQL NULL. This is useful because it means
67014 ** If it does not already exists, create and populate the on-disk file
67188 ** file has not yet been created, create it now.
67558 ** callback on p, but do invoke it on each FROM clause subquery
67694 ** allowing it to be repopulated by the memcpy() on the following line.
67722 ** value can be NULL if zDb is also NULL. If zTable is NULL it
67829 ** it is a new.* or old.* trigger argument reference
67934 ** Z is a string literal if it doesn't match any column names. In that
68216 ** to the AS-name of one of the terms of the expression list. If it is,
68256 ** as an indication to the caller that it should sort by the i-th column.
68632 ** re-evaluated for each reference to it.
69014 ** If the left hand expression has a collating sequence type, then it is
69020 ** it is not considered.
69071 ** expression depth allowed. If it is not, leave an error message in
69168 ** Construct a new expression node and return a pointer to it. Memory
69173 ** If dequote is true, then the token (if it exists) is dequoted.
69366 ** use it as the variable number */
69480 ** off if the expression is reduced. Note also that it does not work to
69481 ** make a EXPRDUP_REDUCE copy of a reduced expression. It is only legal
69780 ** NULL is returned. If non-NULL is returned, then it is guaranteed
69909 ** if it is a constant. Set *Walker.u.pi to 0 if the expression is
69967 ** and 0 if it involves variables or function calls.
69980 ** Return 0 if it involves variables or function calls or terms from
70003 ** in *pValue. If the expression is not an integer or if it is too big
70076 ** determine that it can never generate a NULL, then the OP_IsNull operation
70185 ** It's job is to find or create a b-tree structure that may be used
70206 ** to be unique - either because it is an INTEGER PRIMARY KEY or it
70284 ** be used in place of a temp-table, it must be ordered according
70290 ** it is not, it is not possible to use any index.
70393 /* This code must be run in its entirety every time it is encountered
70434 ** expression it is handled the same way. An ephemeral table is
70478 ** store it in the temporary table. If <expr> is a column, then use
70510 /* Evaluate the expression and insert it into the temp table */
70666 /* This branch runs if it is known at compile time that the RHS
70825 #if 0 /* This code wold remove the entry from the cache if it existed */
70838 /* Find an empty slot and replace it */
70901 ** to the state it was in N Pushes ago.
71065 ** register if it is convenient to do so. The calling function
71398 ** see if it is a column in a virtual table. This is done because
71535 /* If the column has REAL affinity, it may currently be stored as an
71536 ** integer. Use OP_RealAffinity to make sure it is really real. */
71558 ** X (if it exists) is in pExpr->pLeft.
71713 ** and modify the expression so that the next time it is evaluated,
71728 ** no way for a TK_REGISTER to exist here. But it seems prudent to
71911 ** Code it as such, taking care to do the common subexpression
72236 ** this routine is used, it does not hurt to get an extra 2 - that
72333 ** This is the xExprCallback for a tree walker. It is used to
72357 /* If we reach this point, it means that pExpr refers to a table
72400 ** because it was there before or because we just created it).
72652 ** parent table. It is passed three arguments:
72658 ** It returns the new CREATE TABLE statement. For example:
72818 ** allocated using sqlite3DbMalloc(). It is the responsibility of the
72819 ** caller to ensure that it is eventually freed.
72982 /* Make sure it is not a system table being altered, or a reserved name
73093 ** it with the new table name.
73288 ** to it. Routines called by the parser as the column definition
73397 ** If the sqlite_stat1 tables does not previously exist, it is created.
73399 ** is compiled with SQLITE_ENABLE_STAT2 defined, it is created.
73402 ** or it may be a NULL pointer. If it is not NULL, then all entries in
73439 /* The sqlite_stat[12] table does not exist. Create it. Note that a
73442 ** because the OpenWrite opcode below will be needing it. */
73557 ** not been populated. In this case populate it now. */
73615 ** store it. */
73682 ** If K>0 then it is always the case the D>0 so division by zero
73782 ** when it recognizes an ANALYZE command.
73937 ** read from it.
73942 ** table (if it is present) before returning.
74091 ** it treats the two expressions as literal strings 'abc' and 'def' instead of
74189 ** it to obtain the database schema. At this point the schema may
74253 ** we found it.
74406 ** statement only). For DETACH, set it to false (expire all existing
74621 ** systems that do not need this facility may omit it by recompiling
74667 ** SQLITE_OK is returned, it means that access is allowed. SQLITE_DENY
74733 ** is in pTabList or else it is the NEW or OLD table of a trigger.
74734 ** Check to see if it is OK to read this particular column.
74980 ** Note that if an error occurred, it might be the case that
75247 ** before the database closes. It is also called during a rollback
75333 ** This routine just deletes the data structure. It does not unlink
75334 ** the table data structure from the hash table. But it does destroy
75630 ** it does. The exception is if the statement being parsed was passed
75716 ** The record created does not contain anything yet. It will be replaced
75751 ** It is slightly faster than calling sqlite3StrICmp() directly, but
75754 ** WARNING: This macro is not compatible with the strcmp() family. It
76063 ** collation type was added. Correct this if it is the case.
76082 ** request it. If the collation factory does not supply such a sequence,
76119 ** changes. When a process first reads the schema it records the
76120 ** cookie. Thereafter, whenever it goes to access the database,
76121 ** it checks the cookie to make sure the schema has not changed
76122 ** since it was last read.
76124 ** This plan is not completely bullet-proof. It is possible for
76144 ** The estimate is conservative. It might be larger that what is
76165 ** then it is copied to the output buffer exactly as it is. Otherwise,
76166 ** it is quoted using double-quotes.
76270 ** it means we are reading the sqlite_master table because we just
76273 ** the sqlite_master table. We do not want to create it again.
76275 ** If the pSelect argument is not NULL, it means that this routine
76322 /* If the db->init.busy is 1 it means we are reading the SQL off the
76369 ** Once the SELECT has been coded by sqlite3Select(), it is in a
76374 ** as a schema-lock must have already been obtained to create it. Since
76589 ** a negative nCol, it means two or more views form a loop, like this:
76595 ** But the following test is still important as it does come up
76608 /* If we get this far, it means we need to compute the table names.
76727 ** is non-zero, then it is the root page number of a table moved to
76758 ** is not defined), then it is important to call OP_Destroy on the
76828 ** it is initialized.
76940 /* Drop any statistics from the sqlite_stat1 table, if it exists */
77117 ** if memRootPage is not negative, it means that the index is newly
77176 ** since sqlite3ReleaseTempRange() was called, it is safe to do so.
77320 ** If pName==0 it means that we are
77368 /* If pList==0, it means this routine was called to make a primary
77442 ** break backwards compatibility - it needs to be a warning.
77576 ** we don't want to recreate it.
77578 ** If pTblName==0 it means this index is generated as a primary key
77580 ** has just been created, it contains no data and the index initialization
77682 ** of the index. And so forth. It must always be the case that
77792 ** might be the same as the pArray parameter or it might be a different
77890 ** After the call above it would contain: A, B, nil, nil, nil.
77952 ** SrcList might be the same as the SrcList that was input or it might be
77956 ** If pDatabase is not null, it means that the table has an optional
78218 ** This function is called by the parser when it parses a command to create,
78274 ** It is important that all schema cookies be verified and all
78328 ** can be checked before any changes are made to the database, it is never
78342 ** If an abort occurs after some of these writes have completed, then it will
78351 ** The code generator calls this routine if is discovers that it is
78361 ** makes it more difficult to prove that the code is correct (in
78362 ** particular, it prevents us from writing an effective
78386 ** true if it does and false if it does not.
78622 ** If it is not NULL, then pColl must point to the database native encoding
78645 ** Call the collation factory to see if it can supply us with one.
78658 ** This routine is called on a collation sequence before it is used to
78659 ** check that it is defined. An undefined collation sequence exists when
78721 /* If a malloc() failure occurred in sqlite3HashInsert(), it will
78722 ** return the pColl pointer to be deleted (because it wasn't added
78910 ** install a new function. Whatever FuncDef structure is returned it will
78931 ** new entry to the hash table and return it.
78952 ** pointer itself, it just cleans up subsiduary resources (i.e. the contents
79044 ** Check to make sure the given table is writable. If it is not
79045 ** writable, generate an error message and return 1. If it is
79051 ** 1) It is a virtual table and no implementation of the xUpdate method
79053 ** 2) It is a system table (i.e. sqlite_master), this call is not
79071 sqlite3ErrorMsg(pParse,"cannot modify %s because it is a view",pTab->zName);
79174 /* duplicate the FROM clause as it is needed by both the DELETE/UPDATE tree
79274 /* If pTab is really a view, make sure it has been initialized.
79344 ** It is easier just to erase the whole table. Prior to version 3.6.5,
79491 ** (this can happen if a trigger program has already deleted it), do
79492 ** not attempt to delete it or fire any DELETE triggers. */
79525 /* Seek the cursor to the row to be deleted again. It may be that
79598 ** Generate code that will assemble an index key and put it in register
80178 ** in the list by making it the first character after '[' or '^'. A
80181 ** it the last character in the list.
80762 /* IMP: R-25361-16150 This function is omitted from SQLite by default. It
80862 ** that it returns NULL if it sums over no inputs. TOTAL returns
80864 ** SUM might return an integer if it never encounters a floating point
80866 ** it overflows an integer.
80942 ** sure it still operates correctly, verify that its count agrees with our
80978 ** sqlite3_user_data() function returns (void *)-1. For min() it
81102 ** it is appropriate to apply the LIKE optimization to that function
81277 ** or which row it is not satisfied for.
81282 ** Despite these problems, this approach is adopted as it seems simpler
81325 ** constraint counter is greater than zero, it returns SQLITE_CONSTRAINT
81389 ** Otherwise, it is set to point to an allocated array of size N, where
81434 /* If this is a non-composite (single column) foreign key, check if it
81531 ** Each time it is called, this function generates VDBE code to locate the
81592 ** will have INTEGER affinity applied to it, which may not be correct. */
81850 ** (b) The table is the child table of a deferred FK constraint and it is
82153 ** passed a pointer to the list of columns being modified. If it is a
82156 ** It returns a pointer to a Trigger structure containing a trigger
82174 ** The returned pointer is cached as part of the foreign key object. It
82224 /* Create the expression "OLD.zToCol = zFromCol". It is important
82325 /* Re-enable the lookaside buffer, if it was disabled earlier. */
82482 ** is managed along with the rest of the Index structure. It will be
82488 ** required, it is allocated and populated here. It is then stored as
82529 ** is required, it is allocated and populated here. It is then
82659 /* This routine is never called during trigger-generation. It is
82946 /* If pTab is really a view, make sure it has been initialized.
82956 * (b) that if it is a view then ON INSERT triggers exist
82987 ** sqlite_sequence table and store it in memory cell regAutoinc.
83014 ** On each invocation of the co-routine, it puts a single row of the
83017 ** the SELECT completes, it sets the EOF flag stored in regEof.
83030 /* Resolve the expressions in the SELECT statement and execute it. */
83062 ** and add it to a transient table srcTab. The code generated
83134 ** the index of the primary key as it appears in IDLIST, not as
83262 /* Cannot have triggers on a virtual table. If it were possible,
83510 ** INSERT statement. If rowidChng is false, it means that the rowid is
83696 ** when it is inserted.
83946 ** is happening when it is suppose to.
84166 /* If we get this far, it means either:
84650 ** it can get access to the sqlite3_api_routines structure
84949 ** not NULL before calling it.
85602 ** If the TEMP database is open, close it and mark the database schema
85668 /* TODO: Maybe it shouldn't be possible to change the ReadUncommitted
85803 ** pragma, make sure it is open.
86097 ** creates the database file. It is important that it is created
86163 ** page cache size value. It does not change the persistent
86188 ** Note that it is possible for the library compile-time options to
86703 ** database. If the database is not initialized, it is initialized now.
86706 ** has not already been initialized. In this case it sets the default
86717 ** new database files created using this database handle. It is only
86749 ** will be overwritten when the schema is next loaded. If it does not
86750 ** already exists, it will be created to use the new encoding value.
86783 ** The schema-cookie is usually only manipulated internally by SQLite. It
86793 ** The user-version is not used internally by SQLite. It may be used by
87089 /* If the SQL column is blank it means this is an index that
87204 ** on the b-tree database, open one now. If a transaction is opened, it
87240 ** For an attached db, it is an error if the encoding is not the same
87444 ** on the b-tree database, open one now. If a transaction is opened, it
87455 /* Read the schema cookie from the database. If it does not match the
87488 ** statements too, but it never hurts to play the odds).
87530 /* Check to verify that it is possible to get a read lock on all
87543 ** of the sqlite3BtreeEnterAll() in sqlite3LockAndPrepare()) so it
87550 ** but it does *not* override schema lock detection, so this all still
88138 ** defer the handling of t1.x=5, it will be processed immediately
88343 ** (example: "a IN (SELECT * FROM table)") but it has more than 1 result
88457 ** saving that record, use it as a key to delete elements from
88640 ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
88658 ** is a no-op. Otherwise, it adds a single row of output to the EQP result,
88668 ** false, or the second form if it is true.
88860 ** possible. However, it can still be true for statements like
88868 ** though it should really be "INTEGER".
88886 ** test case misc2.2.2) - it always evaluates to NULL.
89115 ** append a integer to the name so that it becomes unique.
89556 ** it is that we currently need.
89589 /* INTERSECT is different from the others since it requires
89590 ** two temporary tables. Hence it has its own case. Begin
89669 ** SELECT might also skip this part if it has no ORDER BY clause and
89734 ** If regPrev>0 then it is the first register in a vector that
90302 /* Reassembly the compound query so that it will be freed correctly
90331 ** changes to pExpr so that it refers directly to the source table
90407 ** execution. It returns 1 if it makes changes and 0 if no flattening
90477 ** (17) The sub-query is not a compound select, or it is a UNION ALL
90496 ** (20) If the sub-query is a compound select, then it must not use
90607 /* Restriction 17: If the sub-query is a compound SELECT, then it must
90647 ** 17 and 18 above) it must be a UNION ALL and the parent query must
90773 ** then expand the outer query to make space for it to hold all elements
90882 ** Analyze the SELECT statement passed as an argument to see if it
90884 ** it is, or 0 otherwise. At present, a query is considered to be
90889 ** 2. There is a single expression in the result set, and it is
91081 ** with the TK_ALL operator for each "*" that it found in the column list.
91097 ** If we get here it means the result set contains one or more "*"
91152 ** for virtual tables), do not include it in the expanded
91231 ** For additional information on what it means to "expand" a SELECT
91499 ** results each time it is invoked. The entry point
91555 ** DISTINCT so it can be removed too. */
91826 ** implement it. Allocate that sorting index now. If it turns out
91827 ** that we do not need it after all, the OpenEphemeral instruction
91855 ** it might be a single loop that uses an index to extract information
91948 ** over to a0,a1,a2. It then calls the output subroutine
92029 ** This statement is so common that it is optimized specially. The
92031 ** contains the data for table <tbl> or on one of its indexes. It
92046 ** there is such an index, and it has less columns than the table
92047 ** does, then we can assume that it consumes less space on disk and
92053 ** In practice the KeyInfo structure will not be used. It is only
92081 ** If it is, then ask the code in where.c to attempt to sort results
92098 ** satisfying the 'ORDER BY' clause than it does in other cases.
92391 ** the calling procedure is finished using it.
92517 ** To state it another way: This routine returns a list of all triggers
92546 ** This is called by the parser when it sees a CREATE TRIGGER statement
92689 ** INSTEAD OF trigger into a BEFORE trigger. It simplifies code
92805 ** The parser calls this routine when it finds a SELECT statement in
92848 ** The parser calls this routine when it sees an INSERT inside the
92881 ** a pointer to that trigger step. The parser calls this routine when it
92906 ** a pointer to that trigger step. The parser calls this routine when it
92943 ** same job as this routine except it takes a pointer to the trigger
93073 ** then return TRUE. If pIdList==NULL, then it is considered a
93075 ** it matches anything so always return true. Return false only
93122 ** trigger is in TEMP in which case it can refer to any other database it
93165 ** to fire had an explicit ON CONFLICT, then use it. Otherwise, use
93225 ** program. It is not used in production code, only for debugging.
93323 /* If one was specified, code the WHEN clause. If it evaluates to false
93383 /* It may be that this trigger has already been coded (or is in the
93499 ** or else it must be a TEMP trigger. */
93528 ** It is not possible to determine if the old.rowid or new.rowid column is
93529 ** accessed by triggers. The caller must always assume that it is.
93531 ** Parameter isNew must be either 1 or 0. If it is 0, then the mask returned
93617 ** complicated default expression value was provided, it is evaluated
94035 /* If it did not delete it, the row-trigger may still have modified
94164 ** it out of the ephemeral table before calling VUpdate.
94315 ** collapse free space, etc. It is modelled after the VACUUM command
94357 /* Save the current value of the database flags so that it can be
94372 ** can be set to 'off' for this file, as it is not recovered if a crash
94381 ** empty. Only the journal header is written. Apparently it takes more
94382 ** time to parse and run the PRAGMA to turn journalling off than it does
94401 ** to read the schema was concluded. Unlock it here so that this doesn't
94509 ** transaction is then committed, so the SQL level never knows it was
94564 ** was committed at the btree level). So it safe to end the transaction
94670 ** Lock the virtual table so that it cannot be disconnected.
94730 ** this makes it safe to access the sqlite3.pDisconnect list of any
94767 ** 2) By function vtabDisconnectAll(), when it adds a VTable entry to
94774 ** by multiple threads. It is thread-safe.
94798 ** Since it is a virtual-table, the Table structure contains a pointer
94845 ** The parser calls this routine when it first sees a CREATE VIRTUAL TABLE
94890 ** in pParse->zArg[] and appends it to the list of arguments on the
94984 ** The parser calls this routine when it sees the first token
95196 ** invoke it now. If the module has not been registered, return an
95207 ** create a valid sqlite3_vtab if it returns SQLITE_OK. */
95216 ** This function is used to set the schema of a virtual table. It is only
95394 ** virtual module xSync() callback. It is illegal to write to
95500 ** array so that an OP_VBegin will get generated for it. Add pTab to the
95501 ** array if it is missing. If pTab is already in the array, this routine
95568 ** help it analyze the subexpressions of the WHERE clause. Each WHERE
95694 ** If WhereMaskSet.ix[A]==B it means that The A-th bit of a Bitmask
95703 ** 57->5, 73->4. Or one of 719 other combinations might be used. It
95839 ** the db->mallocFailed flag so that higher-level functions can detect it.
96027 ** side of the comparison, it remains associated with the same side after
96113 ** it
96152 ** can be optimized using inequality constraints. Return TRUE if it is
96251 ** If it is then return TRUE. If not, return FALSE.
96329 ** A subterm is "indexable" if it is of the form
96332 ** A subterm is also indexable if it is an AND of two or more
96348 ** It might be the case that multiple tables are indexable. For example,
96431 /* Skip this term for now. We revisit it when we process the
96469 ** the all terms are of the form "table1.column=table2.column". It
96601 ** If the expression is of the form "<expr> <op> X" it gets commuted
96608 ** and the new term is marked with TERM_DYNAMIC (because it's pExpr
96609 ** needs to be freed with the WhereClause) and TERM_VIRTUAL (because it
96781 ** wildcard. But if we increment '@', that will push it into the
96880 ** clause. If it can, it returns 1. If pIdx cannot satisfy the
96894 ** set to 1 if the ORDER BY clause is all DESC and it is set to 0 if
97023 ** complexity. Because N is just a guess, it is no great tragedy if
97180 ** Return TRUE if the WHERE clause term pTerm is of a form where it
97202 ** and indexing is allows (if there is no NOT INDEXED clause) and it
97421 ** Allocate and populate an sqlite3_index_info structure. It is the
97534 ** Whether or not an error is returned, it is the responsibility of the
97585 ** everybody has finished with it.
97614 ** allocated and initialized, then allocate and initialize it now.
97627 ** details of pIdxInfo for the current invocation and pass it to
97652 ** on the current table. That way we only have to compute it once
97692 ** does not satisfy it, increase the cost of the scan accordingly. This
97701 ** inital value of lowestCost in this loop. If it is, then the
97823 ** aff applied to it, before returning. It is the responsibility of the
97824 ** caller to eventually release this structure by passing it to
97828 ** is an SQL variable that currently has a non-NULL value bound to it,
97830 ** affinity aff applied to it, instead.
97887 ** constraints (if any). A return value of 100 indicates that it is expected
98119 ** for the rowid index. For other indexes, it is true unless all the
98203 ** index for this query). If it is, set the WHERE_IDX_ONLY flag in
98265 ** It is critical that the notValid mask be used here instead of
98402 ** if it controls a LEFT OUTER JOIN and it did not originate in the ON
98411 ** The t2.z='ok' is disabled in the in (2) because it originates
98412 ** in the ON clause. The term is disabled in (3) because it is not part
98560 ** The only thing it does is allocate the pLevel->iMem memory cell and
98695 ** It is the responsibility of the caller to free the buffer when it is
98957 ** seek opcodes. It depends on a particular ordering of TK_xx
99018 ** left-most columns of the index. It may also contain
99215 ** If it is, jump to the next iteration of the loop.
99263 ** into the RowSet. If it is already present, control skips the
99333 ** over the top of the loop into the body of it. In this case the
99529 ** the WHERE clause, it might result in additional nested loops for
99550 ** make it to the "..." in the middle of the loop. After each "foreach",
99629 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
99671 ** When assigning bitmask values to FROM clause cursors, it must be
99682 ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful
99772 ** not be as small as it would be if the table really were the innermost
99790 ** The best strategy is to iterate through table t1 first. However it
99834 ** index if it uses any index at all */
99849 ** it is an "optimal" plan as defined above.
99905 it, that the named index is being
99917 ** if it find an index at all. */
100022 ** and the index used to access it (if any). If the table itself
100138 ** Set it.
100437 ** code the yytestcase() macro should be turned off. But it is useful
100472 ** is equal to YY_SHIFT_USE_DFLT, it means that the action is not in the table
100968 ** but it does not parse, the type of the token is changed to ID and
101053 ** It is sometimes called the "minor" token.
101588 ** being destroyed before it is finished parsing.
101668 ** is popped from the stack, then call it.
101734 ** independent of the look-ahead. If it is, return the action, otherwise
101799 ** independent of the look-ahead. If it is, return the action, otherwise
102260 ** in some cases when it is copied into the stack after the following
102271 ** that it has not been previously stressed... (SQLite ticket #2172)
103557 ** it is legal to shift the error symbol, then shift
103694 ** it is a keyword. If it is a keyword, the token code of that keyword is
103982 ** IdChar(X) will be true. Otherwise it is false.
104458 ** separating it out, the code will be automatically omitted from
104459 ** static links that do not use it.
104504 ** returns 1 if it ends in the START state and 0 if it ends
104761 ** FTS3 library. All it does is declare the sqlite3Fts3Init() interface.
104793 ** RTREE library. All it does is declare the sqlite3RtreeInit() interface.
104825 ** ICU extension. All it does is declare the sqlite3IcuInit() interface.
104914 ** incomplete, it is required that:
104988 ** sqlite3_os_init() when it invokes sqlite3_vfs_register(), but other
105033 ** been compiled correctly. It is important to run this code, but
105034 ** we don't want to run it too often and soak up CPU cycles for no
105035 ** reason. So we run it once during initialization.
105058 ** routine is not threadsafe. But it is safe to invoke this routine
105097 /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
105253 ** If pStart is not NULL then it is sz*cnt bytes of memory to use for
105423 ** database handle object, it does not close any savepoints that may be open
105439 ** if this is not the last copy of the function, do not invoke it. Multiple
105571 ** So it needs to be freed here. Todo: Why not roll the temp schema into
105712 ** If this routine returns non-zero, the lock is retried. If it
105795 ** that it is designed to be called by internal code. The difference is
106208 ** checkpointed. If an error is encountered it is returned immediately -
106497 ** It merely prevents new constructs that exceed the limit
106560 ** do not block illegal combinations here, it could trigger
106696 ** database it is 'NONE'. This matches the pager layer defaults.
106965 ** This function is now an anachronism. It used to be used to recover from a
106975 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
107025 ** no-op. It is retained for historical compatibility.
107281 ** as it existing before this routine was called.
107329 ** hard-coded to true or else it asserts if its argument is false.
107524 ** Add connection db to the blocked connections list. It is assumed
107525 ** that it is not already a part of the list.
107561 ** (call it pOther) in the same process was busy using the same shared
107624 ** to the user because it requires a lock that will not be available
107713 ** it means that instead of one callback with a large array of
107717 ** connections. But it is the best that can be done under the
107868 ** 234 at I is the next docid. It has one position 72 (72-2) and then
107914 ** making it efficient to directly access large doclists. The
107918 ** TODO(shess) It may be useful for blocking decisions to be more
107919 ** dynamic. For instance, it may make more sense to have a 2.5k leaf
107976 ** node requires more than ROOT_MAX bytes, it is flushed to %_segments
107978 ** within ROOT_MAX because it only needs space for 2 varints, the
108036 ** TODO(shess) That said, it would be nice to have a better query-side
108037 ** argument for MERGE_COUNT of 16. Also, it is possible/likely that
108050 ** will eventually overtake the earlier data and knock it out. The
108123 ** When an fts3 table is created, it passes any arguments passed to
108131 ** method is called. It returns an sqlite3_tokenizer_cursor object
108210 ** implementation. It is only required to be valid until the next call
108258 ** used in SQLite. We've modified it slightly to serve as a standalone
108292 ** Again, this structure is intended to be opaque, but it can't really
108293 ** be opaque because it is used by macros.
108394 ** make it a no-op.
108490 ** When the core wants to read from the virtual table, it creates a
108740 ** 32-bit integer before it is returned.
108812 ** as fts3GetDeltaVarint(): read a single varint and add it to *pVal.
108902 ** If *pRc is non-zero when this function is called, it is a no-op.
108999 ** If *pRc is non-zero when this function is called, it is a no-op.
109129 /* Check if it is an FTS4 special argument. */
109217 ** database. TODO: For xConnect(), it could verify that said tables exist.
109310 ** it would lead to an "unable to use function MATCH in the requested
109339 ** allocation succeeds, zero it and return SQLITE_OK. Otherwise,
109367 ** Position the pCsr->pStmt statement so that it is on the row
109524 ** It is possible that the range of returned leaf nodes does not contain
109525 ** the specified term or any terms for which it is a prefix. However, if the
109528 ** never loads leaf nodes into memory), it is not possible to be sure.
109592 ** start of a position-list. After it returns, *ppPoslist points to the
109597 ** routine advances *ppPoslist so that it points to the next docid in
109610 ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail
109615 ** pEnd once more so that it points to the byte immediately following the
109636 ** start of a column-list. After it returns, *ppPoslist points to the
109674 ** it is not possible to have a document with 2^31 terms.
109681 ** being parsed, or it may point to 1 byte past the end of the position-list
109714 ** returning (do not modify it if iCol==0). Return the total number of bytes
109805 ** This function is used to merge two position lists into one. When it is
109823 ** slots before it.
109911 ** iCol1 and iCol2) so that it points to either the 0x00 that marks the
110180 ** If an OOM error occurs, return SQLITE_NOMEM. In this case it is
110429 /* If a new Fts3SegReader was allocated, add it to the array. */
110514 ** If the isPoslist argument is true, then it is assumed that the doclist
110515 ** contains a position-list following each docid. Otherwise, it is assumed
110674 /* This branch is taken if it is determined that loading the doclist
110761 ** is MERGE_POS_NEAR, or does not if it is MERGE_NEAR.
110930 ** The following is a helper function (and type) for fts3EvalExpr(). It
110932 ** in the expression. See the context it is called from in fts3EvalExpr()
110958 ** freeing the space when it has finished.
110977 ** See fts3EvalDeferred() for how it gets there.
110979 ** In the first case above, Fts3Cursor.doDeferred==0. In the second (if it is
111165 ** when the query includes very common tokens and it is deemed too expensive to
111279 /* In case the cursor has been used before, clear it now. */
111337 ** routine to find out if it has reached the end of a result set.
111404 ** FTS3 virtual tables. It is invoked by SQLite each time a row is to be
111788 ** FTS3 enabled database connection is closed). It frees the memory
111931 ** is defined, then it uses the new syntax. The differences between
111939 ** supported by the new syntax (it is replaced by the NOT operator).
111947 ** to zero causes the module to use the old syntax. If it is set to
111953 ** generator. This module does not use actually lemon, it uses a
112002 ** The standard isspace() can be awkward to use safely, because although it
112016 ** zero the memory before returning a pointer to it. If unsuccessful,
112030 ** single token and set *ppExpr to point to it. If the end of the buffer is
112031 ** reached before a token is found, set *ppExpr to zero. It is the
112033 ** Fts3Expr structure (if any) by passing it to sqlite3_free().
112350 ** TODO: Strangely, it is not possible to associate a column specifier
112353 ** first implemented. Whichever it was, this module duplicates the
112694 ** sqlite3_malloc(). It is the responsibility of the caller to use
112743 ** expression parser. It should be called as follows:
112857 ** We've modified it slightly to serve as a standalone hash table
112896 ** false if it should just use the supplied pointer.
113029 /* Resize the hash table so that it cantains "new_size" buckets.
113139 ** that matches pKey,nKey. Return the data for this element if it is
113362 ** 'Y' is a consonant unless it follows another consonant,
113363 ** in which case it is a vowel.
113366 ** is that 'y' is a consonant unless it is followed by another
113510 ** than 20 bytes if it contains no digits or more than 6 bytes if
113511 ** it contains digits) then word is truncated to 20 or 6 bytes
113768 /* z[] is now the stemmed word in reverse order. Flip it back
113911 ** If the <pointer> argument is specified, it must be a blob value
114242 ** This function is used for testing only, it is not included in the
114248 ** in the README.tokenizer file as an example, so it is important to
114605 ** tables. It also contains code to merge FTS3 b-tree segments. Some
114616 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
114617 ** of 920 bytes is allocated for it.
114620 ** it is always safe to read up to two varints from it without risking an
114782 ** If argument apVal is not NULL, then it must point to an array with
114956 ** not what users expect when they get SQLITE_LOCKED_SHAREDCACHE. It can
115049 ** it is set to SQLITE_OK.
115213 ** operation. It adds entries for each term in the new record to the
115275 ** In FTS3, this is an error. It is an error to specify non-NULL values
115428 ** paBlob is non-NULL, then it is the responsibility of the caller to
115487 ** Close the blob handle at p->pSegments, if it is open. See comments above
115619 ** following two lines advance it to point one byte past the end of
115653 ** contains references to N documents, and is considering merging it with
115654 ** a large doclist (size X "average documents"), it may opt not to load
115681 ** data from the %_stat table to calculate it.
115711 /* Assume that a blob flows over onto overflow pages if it is larger
115960 ** version, it is assumed that each SegReader points to an entry in
116010 ** Argument apSegment is an array of nSegment elements. It is known that
116114 ** Add term zTerm to the SegmentNode. It is guaranteed that zTerm is larger
116188 /* If control flows to here, it was not possible to append zTerm to the
116190 ** If this is the first node in the tree, the term is added to it.
116192 ** Otherwise, the term is not added to the new node, it is left empty for
116246 ** Except, if pTree is a root node, do not write it to the database. Instead,
116319 ** and return it via the input/output variable *ppWriter in this case.
116378 /* The current leaf node is full. Write it out to the database. */
116391 ** In other words, it must be the prefix of zTerm 1 byte longer than
116411 ** the buffer to make it large enough.
116430 /* Save the current term so that it can be used to prefix-compress the next.
116485 /* The entire tree fits on the root node. Write it to the segdir table. */
116570 ** it:
116696 ** stored in the full-text index. It merges data contained in one or
116743 ** for, then advance each segment iterator until it points to a term of
117295 ** included, except that it only contains entries for a single row of the
117603 ** After it returns, *piPos contains the value of the next element of the
117749 ** pnToken is not NULL, then it is set to the number of tokens in all
117783 ** arguments so that it points to the first element with a value greater
117971 /* Now that it is known how many phrases there are, allocate and zero
118039 ** to grow the buffer until so that it is big enough to accomadate the
118142 ** append it to string buffer pOut.
118497 ** 1 if the iterator is at EOF or if it now points to the start of the
118617 ** If it is false, then assume that those fields that do not change between
119153 ** table that maps from the entries rowid to the id of the node that it
119171 ** of a record. For internal nodes it is the node number of a
119414 ** a single instance of the following structure is allocated. It is used
119524 ** to it. Otherwise, return 0.
119558 ** indicating that node has not yet been assigned a node number. It is
119591 ** increase its reference count and return it.
119724 ** If the node is dirty, write it out to the database.
119777 ** node pNode. If pNode is a leaf node, this is a rowid. If it is
120206 ** already at EOF. It is against the rules to call the xNext() method of
120521 ** If it has been used before, ignore it.
120625 ** Return the amount cell p would grow by if it were unioned with pCell.
120742 ** is inserted into it. Resolve ties by choosing the entry with
121327 /* Allocate an array and populate it with a copy of pCell and
121370 ** nodeWrite(). Node pRight always needs a node number, as it was created
121466 ** want to do this as it leads to a memory leak when trying to delete
121522 /* Remove the node from the in-memory hash table and link it into
121570 ** the in-memory node image, so it cannot fail.
121575 ** number of cells, remove it from the tree. Otherwise, update the
121576 ** cell in the parent node so that it tightly contains the updated
121789 /* If azData[0] is not an SQL NULL value, it is the rowid of a
121831 ** it, schedule the contents of the child for reinsertion and
122366 ** the context object when it is no longer required. */
122672 ** pointer. This is not really necessary, but it is tidier than
122784 ** types to an SQLite database connection. It is intended to be called