1 /* 2 ** 2007 May 7 3 ** 4 ** The author disclaims copyright to this source code. In place of 5 ** 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 ** @(#) $Id: sqliteLimit.h,v 1.10 2009/01/10 16:15:09 danielk1977 Exp $ 16 */ 17 18 /* 19 ** The maximum length of a TEXT or BLOB in bytes. This also 20 ** limits the size of a row in a table or index. 21 ** 22 ** The hard limit is the ability of a 32-bit signed integer 23 ** to count the size: 2^31-1 or 2147483647. 24 */ 25 #ifndef SQLITE_MAX_LENGTH 26 # define SQLITE_MAX_LENGTH 1000000000 27 #endif 28 29 /* 30 ** This is the maximum number of 31 ** 32 ** * Columns in a table 33 ** * Columns in an index 34 ** * Columns in a view 35 ** * Terms in the SET clause of an UPDATE statement 36 ** * Terms in the result set of a SELECT statement 37 ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement. 38 ** * Terms in the VALUES clause of an INSERT statement 39 ** 40 ** The hard upper limit here is 32676. Most database people will 41 ** tell you that in a well-normalized database, you usually should 42 ** not have more than a dozen or so columns in any table. And if 43 ** that is the case, there is no point in having more than a few 44 ** dozen values in any of the other situations described above. 45 */ 46 #ifndef SQLITE_MAX_COLUMN 47 # define SQLITE_MAX_COLUMN 2000 48 #endif 49 50 /* 51 ** The maximum length of a single SQL statement in bytes. 52 ** 53 ** It used to be the case that setting this value to zero would 54 ** turn the limit off. That is no longer true. It is not possible 55 ** to turn this limit off. 56 */ 57 #ifndef SQLITE_MAX_SQL_LENGTH 58 # define SQLITE_MAX_SQL_LENGTH 1000000000 59 #endif 60 61 /* 62 ** The maximum depth of an expression tree. This is limited to 63 ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might 64 ** want to place more severe limits on the complexity of an 65 ** expression. 66 ** 67 ** A value of 0 used to mean that the limit was not enforced. 68 ** But that is no longer true. The limit is now strictly enforced 69 ** at all times. 70 */ 71 #ifndef SQLITE_MAX_EXPR_DEPTH 72 # define SQLITE_MAX_EXPR_DEPTH 1000 73 #endif 74 75 /* 76 ** The maximum number of terms in a compound SELECT statement. 77 ** The code generator for compound SELECT statements does one 78 ** level of recursion for each term. A stack overflow can result 79 ** if the number of terms is too large. In practice, most SQL 80 ** never has more than 3 or 4 terms. Use a value of 0 to disable 81 ** any limit on the number of terms in a compount SELECT. 82 */ 83 #ifndef SQLITE_MAX_COMPOUND_SELECT 84 # define SQLITE_MAX_COMPOUND_SELECT 500 85 #endif 86 87 /* 88 ** The maximum number of opcodes in a VDBE program. 89 ** Not currently enforced. 90 */ 91 #ifndef SQLITE_MAX_VDBE_OP 92 # define SQLITE_MAX_VDBE_OP 25000 93 #endif 94 95 /* 96 ** The maximum number of arguments to an SQL function. 97 */ 98 #ifndef SQLITE_MAX_FUNCTION_ARG 99 # define SQLITE_MAX_FUNCTION_ARG 127 100 #endif 101 102 /* 103 ** The maximum number of in-memory pages to use for the main database 104 ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE 105 */ 106 #ifndef SQLITE_DEFAULT_CACHE_SIZE 107 # define SQLITE_DEFAULT_CACHE_SIZE 2000 108 #endif 109 #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE 110 # define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500 111 #endif 112 113 /* 114 ** The maximum number of attached databases. This must be between 0 115 ** and 30. The upper bound on 30 is because a 32-bit integer bitmap 116 ** is used internally to track attached databases. 117 */ 118 #ifndef SQLITE_MAX_ATTACHED 119 # define SQLITE_MAX_ATTACHED 10 120 #endif 121 122 123 /* 124 ** The maximum value of a ?nnn wildcard that the parser will accept. 125 */ 126 #ifndef SQLITE_MAX_VARIABLE_NUMBER 127 # define SQLITE_MAX_VARIABLE_NUMBER 999 128 #endif 129 130 /* Maximum page size. The upper bound on this value is 32768. This a limit 131 ** imposed by the necessity of storing the value in a 2-byte unsigned integer 132 ** and the fact that the page size must be a power of 2. 133 ** 134 ** If this limit is changed, then the compiled library is technically 135 ** incompatible with an SQLite library compiled with a different limit. If 136 ** a process operating on a database with a page-size of 65536 bytes 137 ** crashes, then an instance of SQLite compiled with the default page-size 138 ** limit will not be able to rollback the aborted transaction. This could 139 ** lead to database corruption. 140 */ 141 #ifndef SQLITE_MAX_PAGE_SIZE 142 # define SQLITE_MAX_PAGE_SIZE 32768 143 #endif 144 145 146 /* 147 ** The default size of a database page. 148 */ 149 #ifndef SQLITE_DEFAULT_PAGE_SIZE 150 # define SQLITE_DEFAULT_PAGE_SIZE 1024 151 #endif 152 #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE 153 # undef SQLITE_DEFAULT_PAGE_SIZE 154 # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE 155 #endif 156 157 /* 158 ** Ordinarily, if no value is explicitly provided, SQLite creates databases 159 ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain 160 ** device characteristics (sector-size and atomic write() support), 161 ** SQLite may choose a larger value. This constant is the maximum value 162 ** SQLite will choose on its own. 163 */ 164 #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE 165 # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192 166 #endif 167 #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE 168 # undef SQLITE_MAX_DEFAULT_PAGE_SIZE 169 # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE 170 #endif 171 172 173 /* 174 ** Maximum number of pages in one database file. 175 ** 176 ** This is really just the default value for the max_page_count pragma. 177 ** This value can be lowered (or raised) at run-time using that the 178 ** max_page_count macro. 179 */ 180 #ifndef SQLITE_MAX_PAGE_COUNT 181 # define SQLITE_MAX_PAGE_COUNT 1073741823 182 #endif 183 184 /* 185 ** Maximum length (in bytes) of the pattern in a LIKE or GLOB 186 ** operator. 187 */ 188 #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH 189 # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000 190 #endif 191