drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 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. |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | /* |
| 17 | ** The maximum length of a TEXT or BLOB in bytes. This also |
| 18 | ** limits the size of a row in a table or index. |
| 19 | ** |
| 20 | ** The hard limit is the ability of a 32-bit signed integer |
| 21 | ** to count the size: 2^31-1 or 2147483647. |
| 22 | */ |
| 23 | #ifndef SQLITE_MAX_LENGTH |
| 24 | # define SQLITE_MAX_LENGTH 1000000000 |
| 25 | #endif |
| 26 | |
| 27 | /* |
| 28 | ** This is the maximum number of |
| 29 | ** |
| 30 | ** * Columns in a table |
| 31 | ** * Columns in an index |
| 32 | ** * Columns in a view |
| 33 | ** * Terms in the SET clause of an UPDATE statement |
| 34 | ** * Terms in the result set of a SELECT statement |
| 35 | ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement. |
| 36 | ** * Terms in the VALUES clause of an INSERT statement |
| 37 | ** |
| 38 | ** The hard upper limit here is 32676. Most database people will |
| 39 | ** tell you that in a well-normalized database, you usually should |
| 40 | ** not have more than a dozen or so columns in any table. And if |
| 41 | ** that is the case, there is no point in having more than a few |
| 42 | ** dozen values in any of the other situations described above. |
| 43 | */ |
| 44 | #ifndef SQLITE_MAX_COLUMN |
| 45 | # define SQLITE_MAX_COLUMN 2000 |
| 46 | #endif |
| 47 | |
| 48 | /* |
| 49 | ** The maximum length of a single SQL statement in bytes. |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 50 | ** |
| 51 | ** It used to be the case that setting this value to zero would |
| 52 | ** turn the limit off. That is no longer true. It is not possible |
| 53 | ** to turn this limit off. |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 54 | */ |
| 55 | #ifndef SQLITE_MAX_SQL_LENGTH |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 56 | # define SQLITE_MAX_SQL_LENGTH 1000000000 |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 57 | #endif |
| 58 | |
| 59 | /* |
| 60 | ** The maximum depth of an expression tree. This is limited to |
| 61 | ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might |
| 62 | ** want to place more severe limits on the complexity of an |
drh | bb4957f | 2008-03-20 14:03:29 +0000 | [diff] [blame] | 63 | ** expression. |
| 64 | ** |
| 65 | ** A value of 0 used to mean that the limit was not enforced. |
| 66 | ** But that is no longer true. The limit is now strictly enforced |
| 67 | ** at all times. |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 68 | */ |
| 69 | #ifndef SQLITE_MAX_EXPR_DEPTH |
| 70 | # define SQLITE_MAX_EXPR_DEPTH 1000 |
| 71 | #endif |
| 72 | |
| 73 | /* |
| 74 | ** The maximum number of terms in a compound SELECT statement. |
| 75 | ** The code generator for compound SELECT statements does one |
| 76 | ** level of recursion for each term. A stack overflow can result |
| 77 | ** if the number of terms is too large. In practice, most SQL |
| 78 | ** never has more than 3 or 4 terms. Use a value of 0 to disable |
| 79 | ** any limit on the number of terms in a compount SELECT. |
| 80 | */ |
| 81 | #ifndef SQLITE_MAX_COMPOUND_SELECT |
| 82 | # define SQLITE_MAX_COMPOUND_SELECT 500 |
| 83 | #endif |
| 84 | |
| 85 | /* |
| 86 | ** The maximum number of opcodes in a VDBE program. |
| 87 | ** Not currently enforced. |
| 88 | */ |
| 89 | #ifndef SQLITE_MAX_VDBE_OP |
drh | 1cb0266 | 2017-03-17 22:50:16 +0000 | [diff] [blame] | 90 | # define SQLITE_MAX_VDBE_OP 250000000 |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 91 | #endif |
| 92 | |
| 93 | /* |
| 94 | ** The maximum number of arguments to an SQL function. |
| 95 | */ |
| 96 | #ifndef SQLITE_MAX_FUNCTION_ARG |
danielk1977 | a7c17af | 2009-01-07 16:15:42 +0000 | [diff] [blame] | 97 | # define SQLITE_MAX_FUNCTION_ARG 127 |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 98 | #endif |
| 99 | |
| 100 | /* |
drh | 9d356fb | 2015-02-27 20:28:08 +0000 | [diff] [blame] | 101 | ** The suggested maximum number of in-memory pages to use for |
| 102 | ** the main database table and for temporary tables. |
| 103 | ** |
drh | 3767026 | 2016-03-23 13:46:05 +0000 | [diff] [blame] | 104 | ** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000, |
| 105 | ** which means the cache size is limited to 2048000 bytes of memory. |
drh | e0e8429 | 2015-02-27 21:53:35 +0000 | [diff] [blame] | 106 | ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be |
| 107 | ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 108 | */ |
| 109 | #ifndef SQLITE_DEFAULT_CACHE_SIZE |
drh | 9458086 | 2016-03-04 04:01:43 +0000 | [diff] [blame] | 110 | # define SQLITE_DEFAULT_CACHE_SIZE -2000 |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 111 | #endif |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 112 | |
| 113 | /* |
dan | 5a299f9 | 2010-05-03 11:05:08 +0000 | [diff] [blame] | 114 | ** The default number of frames to accumulate in the log file before |
| 115 | ** checkpointing the database in WAL mode. |
| 116 | */ |
| 117 | #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT |
| 118 | # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000 |
| 119 | #endif |
| 120 | |
| 121 | /* |
drh | 083e581 | 2008-03-26 15:56:22 +0000 | [diff] [blame] | 122 | ** The maximum number of attached databases. This must be between 0 |
drh | 9878fef | 2016-03-04 03:43:10 +0000 | [diff] [blame] | 123 | ** and 125. The upper bound of 125 is because the attached databases are |
| 124 | ** counted using a signed 8-bit integer which has a maximum value of 127 |
| 125 | ** and we have to allow 2 extra counts for the "main" and "temp" databases. |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 126 | */ |
| 127 | #ifndef SQLITE_MAX_ATTACHED |
| 128 | # define SQLITE_MAX_ATTACHED 10 |
| 129 | #endif |
| 130 | |
| 131 | |
| 132 | /* |
| 133 | ** The maximum value of a ?nnn wildcard that the parser will accept. |
| 134 | */ |
| 135 | #ifndef SQLITE_MAX_VARIABLE_NUMBER |
| 136 | # define SQLITE_MAX_VARIABLE_NUMBER 999 |
| 137 | #endif |
| 138 | |
drh | b2eced5 | 2010-08-12 02:41:12 +0000 | [diff] [blame] | 139 | /* Maximum page size. The upper bound on this value is 65536. This a limit |
| 140 | ** imposed by the use of 16-bit offsets within each page. |
danielk1977 | 7cbd589 | 2009-01-10 16:15:09 +0000 | [diff] [blame] | 141 | ** |
dan | 5a9e07e | 2010-08-18 15:25:17 +0000 | [diff] [blame] | 142 | ** Earlier versions of SQLite allowed the user to change this value at |
| 143 | ** compile time. This is no longer permitted, on the grounds that it creates |
| 144 | ** a library that is technically incompatible with an SQLite library |
| 145 | ** compiled with a different limit. If a process operating on a database |
| 146 | ** with a page-size of 65536 bytes crashes, then an instance of SQLite |
| 147 | ** compiled with the default page-size limit will not be able to rollback |
| 148 | ** the aborted transaction. This could lead to database corruption. |
drh | f54cc03 | 2007-11-05 14:30:22 +0000 | [diff] [blame] | 149 | */ |
dan | 5a9e07e | 2010-08-18 15:25:17 +0000 | [diff] [blame] | 150 | #ifdef SQLITE_MAX_PAGE_SIZE |
| 151 | # undef SQLITE_MAX_PAGE_SIZE |
drh | f54cc03 | 2007-11-05 14:30:22 +0000 | [diff] [blame] | 152 | #endif |
dan | 5a9e07e | 2010-08-18 15:25:17 +0000 | [diff] [blame] | 153 | #define SQLITE_MAX_PAGE_SIZE 65536 |
drh | f54cc03 | 2007-11-05 14:30:22 +0000 | [diff] [blame] | 154 | |
| 155 | |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 156 | /* |
| 157 | ** The default size of a database page. |
| 158 | */ |
| 159 | #ifndef SQLITE_DEFAULT_PAGE_SIZE |
drh | 9878fef | 2016-03-04 03:43:10 +0000 | [diff] [blame] | 160 | # define SQLITE_DEFAULT_PAGE_SIZE 4096 |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 161 | #endif |
drh | f54cc03 | 2007-11-05 14:30:22 +0000 | [diff] [blame] | 162 | #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE |
| 163 | # undef SQLITE_DEFAULT_PAGE_SIZE |
| 164 | # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE |
| 165 | #endif |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 166 | |
danielk1977 | 9663b8f | 2007-08-24 11:52:28 +0000 | [diff] [blame] | 167 | /* |
| 168 | ** Ordinarily, if no value is explicitly provided, SQLite creates databases |
| 169 | ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain |
| 170 | ** device characteristics (sector-size and atomic write() support), |
| 171 | ** SQLite may choose a larger value. This constant is the maximum value |
drh | 85b623f | 2007-12-13 21:54:09 +0000 | [diff] [blame] | 172 | ** SQLite will choose on its own. |
danielk1977 | 9663b8f | 2007-08-24 11:52:28 +0000 | [diff] [blame] | 173 | */ |
| 174 | #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE |
| 175 | # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192 |
| 176 | #endif |
drh | f54cc03 | 2007-11-05 14:30:22 +0000 | [diff] [blame] | 177 | #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE |
| 178 | # undef SQLITE_MAX_DEFAULT_PAGE_SIZE |
| 179 | # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 180 | #endif |
| 181 | |
drh | f54cc03 | 2007-11-05 14:30:22 +0000 | [diff] [blame] | 182 | |
drh | c551dd8 | 2007-06-19 15:23:48 +0000 | [diff] [blame] | 183 | /* |
| 184 | ** Maximum number of pages in one database file. |
| 185 | ** |
| 186 | ** This is really just the default value for the max_page_count pragma. |
| 187 | ** This value can be lowered (or raised) at run-time using that the |
| 188 | ** max_page_count macro. |
| 189 | */ |
| 190 | #ifndef SQLITE_MAX_PAGE_COUNT |
| 191 | # define SQLITE_MAX_PAGE_COUNT 1073741823 |
| 192 | #endif |
| 193 | |
| 194 | /* |
| 195 | ** Maximum length (in bytes) of the pattern in a LIKE or GLOB |
| 196 | ** operator. |
| 197 | */ |
| 198 | #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH |
| 199 | # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000 |
| 200 | #endif |
drh | 417168a | 2009-09-07 18:14:02 +0000 | [diff] [blame] | 201 | |
| 202 | /* |
| 203 | ** Maximum depth of recursion for triggers. |
dan | f589450 | 2009-10-07 18:41:19 +0000 | [diff] [blame] | 204 | ** |
| 205 | ** A value of 1 means that a trigger program will not be able to itself |
| 206 | ** fire any triggers. A value of 0 means that no trigger programs at all |
| 207 | ** may be executed. |
drh | 417168a | 2009-09-07 18:14:02 +0000 | [diff] [blame] | 208 | */ |
| 209 | #ifndef SQLITE_MAX_TRIGGER_DEPTH |
| 210 | # define SQLITE_MAX_TRIGGER_DEPTH 1000 |
| 211 | #endif |