Team Ai
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 10mo agoView on Hugging Face
0likes
sqliteLimit.h245 linesDownload Raw Back to src
1/*2** 2007 May 73**4** The author disclaims copyright to this source code.  In place of5** a legal notice, here is a blessing:6**7**    May you do good and not evil.8**    May you find forgiveness for yourself and forgive others.9**    May you share freely, never taking more than you give.10**11*************************************************************************12**13** This file defines various limits of what SQLite can process.14*/15 16/*17** The maximum length of a TEXT or BLOB in bytes.   This also18** limits the size of a row in a table or index.19**20** The hard limit is the ability of a 32-bit signed integer21** to count the size: 2^31-1 or 2147483647.22*/23#ifndef SQLITE_MAX_LENGTH24# define SQLITE_MAX_LENGTH 100000000025#endif26#define SQLITE_MIN_LENGTH 30   /* Minimum value for the length limit */27 28/*29** This is the maximum number of30**31**    * Columns in a table32**    * Columns in an index33**    * Columns in a view34**    * Terms in the SET clause of an UPDATE statement35**    * Terms in the result set of a SELECT statement36**    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.37**    * Terms in the VALUES clause of an INSERT statement38**39** The hard upper limit here is 32767.  Most database people will40** tell you that in a well-normalized database, you usually should41** not have more than a dozen or so columns in any table.  And if42** that is the case, there is no point in having more than a few43** dozen values in any of the other situations described above.44**45** An index can only have SQLITE_MAX_COLUMN columns from the user46** point of view, but the underlying b-tree that implements the index47** might have up to twice as many columns in a WITHOUT ROWID table,48** since must also store the primary key at the end.  Hence the49** column count for Index is u16 instead of i16.50*/51#if !defined(SQLITE_MAX_COLUMN)52# define SQLITE_MAX_COLUMN 200053#elif SQLITE_MAX_COLUMN>3276754# error SQLITE_MAX_COLUMN may not exceed 3276755#endif56 57/*58** The maximum length of a single SQL statement in bytes.59**60** It used to be the case that setting this value to zero would61** turn the limit off.  That is no longer true.  It is not possible62** to turn this limit off.63**64** The hard limit is the largest possible 32-bit signed integer less65** 1024, or 2147482624.66*/67#ifndef SQLITE_MAX_SQL_LENGTH68# define SQLITE_MAX_SQL_LENGTH 100000000069#endif70 71/*72** The maximum depth of an expression tree. The expression tree depth73** is also limited indirectly by SQLITE_MAX_SQL_LENGTH and by74** SQLITE_MAX_PARSER_DEPTH.  Reducing the maximum complexity of75** expressions can help prevent excess memory usage by hostile SQL.76**77** A value of 0 for this compile-time option causes all expression78** depth limiting code to be omitted.79*/80#ifndef SQLITE_MAX_EXPR_DEPTH81# define SQLITE_MAX_EXPR_DEPTH 100082#endif83 84/*85** The maximum depth of the LALR(1) stack used in the parser that86** interprets SQL inputs. The parser stack depth can also be limited87** indirectly by SQLITE_MAX_SQL_LENGTH.  Limiting the parser stack88** depth can help prevent excess memory usage and excess CPU stack89** usage when processing hostile SQL.90**91** Prior to version 3.45.0 (2024-01-15), the parser stack was92** hard-coded to 100 entries, and that worked fine for almost all93** applications.  So the upper bound on this limit need not be large.94*/95#ifndef SQLITE_MAX_PARSER_DEPTH96# define SQLITE_MAX_PARSER_DEPTH 250097#endif98 99/*100** The maximum number of terms in a compound SELECT statement.101** The code generator for compound SELECT statements does one102** level of recursion for each term.  A stack overflow can result103** if the number of terms is too large.  In practice, most SQL104** never has more than 3 or 4 terms.  Use a value of 0 to disable105** any limit on the number of terms in a compound SELECT.106*/107#ifndef SQLITE_MAX_COMPOUND_SELECT108# define SQLITE_MAX_COMPOUND_SELECT 500109#endif110 111/*112** The maximum number of opcodes in a VDBE program.113** Not currently enforced.114*/115#ifndef SQLITE_MAX_VDBE_OP116# define SQLITE_MAX_VDBE_OP 250000000117#endif118 119/*120** The maximum number of arguments to an SQL function.121**122** This value has a hard upper limit of 32767 due to storage123** constraints (it needs to fit inside a i16).  We keep it124** lower than that to prevent abuse.125*/126#ifndef SQLITE_MAX_FUNCTION_ARG127# define SQLITE_MAX_FUNCTION_ARG 1000128#endif129 130/*131** The suggested maximum number of in-memory pages to use for132** the main database table and for temporary tables.133**134** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,135** which means the cache size is limited to 2048000 bytes of memory.136** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be137** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.138*/139#ifndef SQLITE_DEFAULT_CACHE_SIZE140# define SQLITE_DEFAULT_CACHE_SIZE  -2000141#endif142 143/*144** The default number of frames to accumulate in the log file before145** checkpointing the database in WAL mode.146*/147#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT148# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000149#endif150 151/*152** The maximum number of attached databases.  This must be between 0153** and 125.  The upper bound of 125 is because the attached databases are154** counted using a signed 8-bit integer which has a maximum value of 127155** and we have to allow 2 extra counts for the "main" and "temp" databases.156*/157#ifndef SQLITE_MAX_ATTACHED158# define SQLITE_MAX_ATTACHED 10159#endif160 161 162/*163** The maximum value of a ?nnn wildcard that the parser will accept.164** If the value exceeds 32767 then extra space is required for the Expr165** structure.  But otherwise, we believe that the number can be as large166** as a signed 32-bit integer can hold.167*/168#ifndef SQLITE_MAX_VARIABLE_NUMBER169# define SQLITE_MAX_VARIABLE_NUMBER 32766170#endif171 172/* Maximum page size.  The upper bound on this value is 65536.  This a limit173** imposed by the use of 16-bit offsets within each page.174**175** Earlier versions of SQLite allowed the user to change this value at176** compile time. This is no longer permitted, on the grounds that it creates177** a library that is technically incompatible with an SQLite library178** compiled with a different limit. If a process operating on a database179** with a page-size of 65536 bytes crashes, then an instance of SQLite180** compiled with the default page-size limit will not be able to rollback181** the aborted transaction. This could lead to database corruption.182*/183#ifdef SQLITE_MAX_PAGE_SIZE184# undef SQLITE_MAX_PAGE_SIZE185#endif186#define SQLITE_MAX_PAGE_SIZE 65536187 188 189/*190** The default size of a database page.191*/192#ifndef SQLITE_DEFAULT_PAGE_SIZE193# define SQLITE_DEFAULT_PAGE_SIZE 4096194#endif195#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE196# undef SQLITE_DEFAULT_PAGE_SIZE197# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE198#endif199 200/*201** Ordinarily, if no value is explicitly provided, SQLite creates databases202** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain203** device characteristics (sector-size and atomic write() support),204** SQLite may choose a larger value. This constant is the maximum value205** SQLite will choose on its own.206*/207#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE208# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192209#endif210#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE211# undef SQLITE_MAX_DEFAULT_PAGE_SIZE212# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE213#endif214 215 216/*217** Maximum number of pages in one database file.218**219** This is really just the default value for the max_page_count pragma.220** This value can be lowered (or raised) at run-time using the221** max_page_count macro.222*/223#ifndef SQLITE_MAX_PAGE_COUNT224# define SQLITE_MAX_PAGE_COUNT 0xfffffffe /* 4294967294 */225#endif226 227/*228** Maximum length (in bytes) of the pattern in a LIKE or GLOB229** operator.230*/231#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH232# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000233#endif234 235/*236** Maximum depth of recursion for triggers.237**238** A value of 1 means that a trigger program will not be able to itself239** fire any triggers. A value of 0 means that no trigger programs at all240** may be executed.241*/242#ifndef SQLITE_MAX_TRIGGER_DEPTH243# define SQLITE_MAX_TRIGGER_DEPTH 1000244#endif245