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 | |
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. |
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. |
54 | */ |
55 | #ifndef SQLITE_MAX_SQL_LENGTH |
56 | # define SQLITE_MAX_SQL_LENGTH 1000000000 |
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 |
63 | ** expression. A value of 0 means that there is no limit. |
64 | */ |
65 | #ifndef SQLITE_MAX_EXPR_DEPTH |
66 | # define SQLITE_MAX_EXPR_DEPTH 1000 |
67 | #endif |
68 | |
69 | /* |
70 | ** The maximum number of terms in a compound SELECT statement. |
71 | ** The code generator for compound SELECT statements does one |
72 | ** level of recursion for each term. A stack overflow can result |
73 | ** if the number of terms is too large. In practice, most SQL |
74 | ** never has more than 3 or 4 terms. Use a value of 0 to disable |
75 | ** any limit on the number of terms in a compount SELECT. |
76 | */ |
77 | #ifndef SQLITE_MAX_COMPOUND_SELECT |
78 | # define SQLITE_MAX_COMPOUND_SELECT 500 |
79 | #endif |
80 | |
81 | /* |
82 | ** The maximum number of opcodes in a VDBE program. |
83 | ** Not currently enforced. |
84 | */ |
85 | #ifndef SQLITE_MAX_VDBE_OP |
86 | # define SQLITE_MAX_VDBE_OP 250000000 |
87 | #endif |
88 | |
89 | /* |
90 | ** The maximum number of arguments to an SQL function. |
91 | */ |
92 | #ifndef SQLITE_MAX_FUNCTION_ARG |
93 | # define SQLITE_MAX_FUNCTION_ARG 127 |
94 | #endif |
95 | |
96 | /* |
97 | ** The suggested maximum number of in-memory pages to use for |
98 | ** the main database table and for temporary tables. |
99 | ** |
100 | ** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000, |
101 | ** which means the cache size is limited to 2048000 bytes of memory. |
102 | ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be |
103 | ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options. |
104 | */ |
105 | #ifndef SQLITE_DEFAULT_CACHE_SIZE |
106 | # define SQLITE_DEFAULT_CACHE_SIZE -2000 |
107 | #endif |
108 | |
109 | /* |
110 | ** The default number of frames to accumulate in the log file before |
111 | ** checkpointing the database in WAL mode. |
112 | */ |
113 | #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT |
114 | # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000 |
115 | #endif |
116 | |
117 | /* |
118 | ** The maximum number of attached databases. This must be between 0 |
119 | ** and 125. The upper bound of 125 is because the attached databases are |
120 | ** counted using a signed 8-bit integer which has a maximum value of 127 |
121 | ** and we have to allow 2 extra counts for the "main" and "temp" databases. |
122 | */ |
123 | #ifndef SQLITE_MAX_ATTACHED |
124 | # define SQLITE_MAX_ATTACHED 10 |
125 | #endif |
126 | |
127 | |
128 | /* |
129 | ** The maximum value of a ?nnn wildcard that the parser will accept. |
130 | ** If the value exceeds 32767 then extra space is required for the Expr |
131 | ** structure. But otherwise, we believe that the number can be as large |
132 | ** as a signed 32-bit integer can hold. |
133 | */ |
134 | #ifndef SQLITE_MAX_VARIABLE_NUMBER |
135 | # define SQLITE_MAX_VARIABLE_NUMBER 32766 |
136 | #endif |
137 | |
138 | /* Maximum page size. The upper bound on this value is 65536. This a limit |
139 | ** imposed by the use of 16-bit offsets within each page. |
140 | ** |
141 | ** Earlier versions of SQLite allowed the user to change this value at |
142 | ** compile time. This is no longer permitted, on the grounds that it creates |
143 | ** a library that is technically incompatible with an SQLite library |
144 | ** compiled with a different limit. If a process operating on a database |
145 | ** with a page-size of 65536 bytes crashes, then an instance of SQLite |
146 | ** compiled with the default page-size limit will not be able to rollback |
147 | ** the aborted transaction. This could lead to database corruption. |
148 | */ |
149 | #ifdef SQLITE_MAX_PAGE_SIZE |
150 | # undef SQLITE_MAX_PAGE_SIZE |
151 | #endif |
152 | #define SQLITE_MAX_PAGE_SIZE 65536 |
153 | |
154 | |
155 | /* |
156 | ** The default size of a database page. |
157 | */ |
158 | #ifndef SQLITE_DEFAULT_PAGE_SIZE |
159 | # define SQLITE_DEFAULT_PAGE_SIZE 4096 |
160 | #endif |
161 | #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE |
162 | # undef SQLITE_DEFAULT_PAGE_SIZE |
163 | # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE |
164 | #endif |
165 | |
166 | /* |
167 | ** Ordinarily, if no value is explicitly provided, SQLite creates databases |
168 | ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain |
169 | ** device characteristics (sector-size and atomic write() support), |
170 | ** SQLite may choose a larger value. This constant is the maximum value |
171 | ** SQLite will choose on its own. |
172 | */ |
173 | #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE |
174 | # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192 |
175 | #endif |
176 | #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE |
177 | # undef SQLITE_MAX_DEFAULT_PAGE_SIZE |
178 | # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE |
179 | #endif |
180 | |
181 | |
182 | /* |
183 | ** Maximum number of pages in one database file. |
184 | ** |
185 | ** This is really just the default value for the max_page_count pragma. |
186 | ** This value can be lowered (or raised) at run-time using that the |
187 | ** max_page_count macro. |
188 | */ |
189 | #ifndef SQLITE_MAX_PAGE_COUNT |
190 | # define SQLITE_MAX_PAGE_COUNT 1073741823 |
191 | #endif |
192 | |
193 | /* |
194 | ** Maximum length (in bytes) of the pattern in a LIKE or GLOB |
195 | ** operator. |
196 | */ |
197 | #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH |
198 | # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000 |
199 | #endif |
200 | |
201 | /* |
202 | ** Maximum depth of recursion for triggers. |
203 | ** |
204 | ** A value of 1 means that a trigger program will not be able to itself |
205 | ** fire any triggers. A value of 0 means that no trigger programs at all |
206 | ** may be executed. |
207 | */ |
208 | #ifndef SQLITE_MAX_TRIGGER_DEPTH |
209 | # define SQLITE_MAX_TRIGGER_DEPTH 1000 |
210 | #endif |
211 | |