xref: /sqlite-3.40.0/src/sqliteLimit.h (revision 6e41aa0b)
1c551dd80Sdrh /*
2c551dd80Sdrh ** 2007 May 7
3c551dd80Sdrh **
4c551dd80Sdrh ** The author disclaims copyright to this source code.  In place of
5c551dd80Sdrh ** a legal notice, here is a blessing:
6c551dd80Sdrh **
7c551dd80Sdrh **    May you do good and not evil.
8c551dd80Sdrh **    May you find forgiveness for yourself and forgive others.
9c551dd80Sdrh **    May you share freely, never taking more than you give.
10c551dd80Sdrh **
11c551dd80Sdrh *************************************************************************
12c551dd80Sdrh **
13c551dd80Sdrh ** This file defines various limits of what SQLite can process.
14c551dd80Sdrh **
15*6e41aa0bSdrh ** @(#) $Id: sqliteLimit.h,v 1.4 2007/12/11 20:04:15 drh Exp $
16c551dd80Sdrh */
17c551dd80Sdrh 
18c551dd80Sdrh /*
19c551dd80Sdrh ** The maximum length of a TEXT or BLOB in bytes.   This also
20c551dd80Sdrh ** limits the size of a row in a table or index.
21c551dd80Sdrh **
22c551dd80Sdrh ** The hard limit is the ability of a 32-bit signed integer
23c551dd80Sdrh ** to count the size: 2^31-1 or 2147483647.
24c551dd80Sdrh */
25c551dd80Sdrh #ifndef SQLITE_MAX_LENGTH
26c551dd80Sdrh # define SQLITE_MAX_LENGTH 1000000000
27c551dd80Sdrh #endif
28c551dd80Sdrh 
29c551dd80Sdrh /*
30c551dd80Sdrh ** This is the maximum number of
31c551dd80Sdrh **
32c551dd80Sdrh **    * Columns in a table
33c551dd80Sdrh **    * Columns in an index
34c551dd80Sdrh **    * Columns in a view
35c551dd80Sdrh **    * Terms in the SET clause of an UPDATE statement
36c551dd80Sdrh **    * Terms in the result set of a SELECT statement
37c551dd80Sdrh **    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
38c551dd80Sdrh **    * Terms in the VALUES clause of an INSERT statement
39c551dd80Sdrh **
40c551dd80Sdrh ** The hard upper limit here is 32676.  Most database people will
41c551dd80Sdrh ** tell you that in a well-normalized database, you usually should
42c551dd80Sdrh ** not have more than a dozen or so columns in any table.  And if
43c551dd80Sdrh ** that is the case, there is no point in having more than a few
44c551dd80Sdrh ** dozen values in any of the other situations described above.
45c551dd80Sdrh */
46c551dd80Sdrh #ifndef SQLITE_MAX_COLUMN
47c551dd80Sdrh # define SQLITE_MAX_COLUMN 2000
48c551dd80Sdrh #endif
49c551dd80Sdrh 
50c551dd80Sdrh /*
51c551dd80Sdrh ** The maximum length of a single SQL statement in bytes.
52*6e41aa0bSdrh ** The hard limit is 1 million.
53c551dd80Sdrh */
54c551dd80Sdrh #ifndef SQLITE_MAX_SQL_LENGTH
55c551dd80Sdrh # define SQLITE_MAX_SQL_LENGTH 1000000
56c551dd80Sdrh #endif
57c551dd80Sdrh 
58c551dd80Sdrh /*
59c551dd80Sdrh ** The maximum depth of an expression tree. This is limited to
60c551dd80Sdrh ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
61c551dd80Sdrh ** want to place more severe limits on the complexity of an
62c551dd80Sdrh ** expression. A value of 0 (the default) means do not enforce
63c551dd80Sdrh ** any limitation on expression tree depth.
64c551dd80Sdrh */
65c551dd80Sdrh #ifndef SQLITE_MAX_EXPR_DEPTH
66c551dd80Sdrh # define SQLITE_MAX_EXPR_DEPTH 1000
67c551dd80Sdrh #endif
68c551dd80Sdrh 
69c551dd80Sdrh /*
70c551dd80Sdrh ** The maximum number of terms in a compound SELECT statement.
71c551dd80Sdrh ** The code generator for compound SELECT statements does one
72c551dd80Sdrh ** level of recursion for each term.  A stack overflow can result
73c551dd80Sdrh ** if the number of terms is too large.  In practice, most SQL
74c551dd80Sdrh ** never has more than 3 or 4 terms.  Use a value of 0 to disable
75c551dd80Sdrh ** any limit on the number of terms in a compount SELECT.
76c551dd80Sdrh */
77c551dd80Sdrh #ifndef SQLITE_MAX_COMPOUND_SELECT
78c551dd80Sdrh # define SQLITE_MAX_COMPOUND_SELECT 500
79c551dd80Sdrh #endif
80c551dd80Sdrh 
81c551dd80Sdrh /*
82c551dd80Sdrh ** The maximum number of opcodes in a VDBE program.
83c551dd80Sdrh ** Not currently enforced.
84c551dd80Sdrh */
85c551dd80Sdrh #ifndef SQLITE_MAX_VDBE_OP
86c551dd80Sdrh # define SQLITE_MAX_VDBE_OP 25000
87c551dd80Sdrh #endif
88c551dd80Sdrh 
89c551dd80Sdrh /*
90c551dd80Sdrh ** The maximum number of arguments to an SQL function.
91c551dd80Sdrh */
92c551dd80Sdrh #ifndef SQLITE_MAX_FUNCTION_ARG
93c551dd80Sdrh # define SQLITE_MAX_FUNCTION_ARG 100
94c551dd80Sdrh #endif
95c551dd80Sdrh 
96c551dd80Sdrh /*
97c551dd80Sdrh ** The maximum number of in-memory pages to use for the main database
98c551dd80Sdrh ** table and for temporary tables.  The SQLITE_DEFAULT_CACHE_SIZE
99c551dd80Sdrh */
100c551dd80Sdrh #ifndef SQLITE_DEFAULT_CACHE_SIZE
101c551dd80Sdrh # define SQLITE_DEFAULT_CACHE_SIZE  2000
102c551dd80Sdrh #endif
103c551dd80Sdrh #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
104c551dd80Sdrh # define SQLITE_DEFAULT_TEMP_CACHE_SIZE  500
105c551dd80Sdrh #endif
106c551dd80Sdrh 
107c551dd80Sdrh /*
108c551dd80Sdrh ** The maximum number of attached databases.  This must be at least 2
109c551dd80Sdrh ** in order to support the main database file (0) and the file used to
110c551dd80Sdrh ** hold temporary tables (1).  And it must be less than 32 because
111c551dd80Sdrh ** we use a bitmask of databases with a u32 in places (for example
112c551dd80Sdrh ** the Parse.cookieMask field).
113c551dd80Sdrh */
114c551dd80Sdrh #ifndef SQLITE_MAX_ATTACHED
115c551dd80Sdrh # define SQLITE_MAX_ATTACHED 10
116c551dd80Sdrh #endif
117c551dd80Sdrh 
118c551dd80Sdrh 
119c551dd80Sdrh /*
120c551dd80Sdrh ** The maximum value of a ?nnn wildcard that the parser will accept.
121c551dd80Sdrh */
122c551dd80Sdrh #ifndef SQLITE_MAX_VARIABLE_NUMBER
123c551dd80Sdrh # define SQLITE_MAX_VARIABLE_NUMBER 999
124c551dd80Sdrh #endif
125c551dd80Sdrh 
126f54cc035Sdrh /* Maximum page size.  The upper bound on this value is 32768.  This a limit
127f54cc035Sdrh ** imposed by the necessity of storing the value in a 2-byte unsigned integer
128f54cc035Sdrh ** and the fact that the page size must be a power of 2.
129f54cc035Sdrh */
130f54cc035Sdrh #ifndef SQLITE_MAX_PAGE_SIZE
131f54cc035Sdrh # define SQLITE_MAX_PAGE_SIZE 32768
132f54cc035Sdrh #endif
133f54cc035Sdrh 
134f54cc035Sdrh 
135c551dd80Sdrh /*
136c551dd80Sdrh ** The default size of a database page.
137c551dd80Sdrh */
138c551dd80Sdrh #ifndef SQLITE_DEFAULT_PAGE_SIZE
139c551dd80Sdrh # define SQLITE_DEFAULT_PAGE_SIZE 1024
140c551dd80Sdrh #endif
141f54cc035Sdrh #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
142f54cc035Sdrh # undef SQLITE_DEFAULT_PAGE_SIZE
143f54cc035Sdrh # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
144f54cc035Sdrh #endif
145c551dd80Sdrh 
1469663b8f9Sdanielk1977 /*
1479663b8f9Sdanielk1977 ** Ordinarily, if no value is explicitly provided, SQLite creates databases
1489663b8f9Sdanielk1977 ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
1499663b8f9Sdanielk1977 ** device characteristics (sector-size and atomic write() support),
1509663b8f9Sdanielk1977 ** SQLite may choose a larger value. This constant is the maximum value
1519663b8f9Sdanielk1977 ** SQLite will choose on it's own.
1529663b8f9Sdanielk1977 */
1539663b8f9Sdanielk1977 #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
1549663b8f9Sdanielk1977 # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
1559663b8f9Sdanielk1977 #endif
156f54cc035Sdrh #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
157f54cc035Sdrh # undef SQLITE_MAX_DEFAULT_PAGE_SIZE
158f54cc035Sdrh # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
159c551dd80Sdrh #endif
160c551dd80Sdrh 
161f54cc035Sdrh 
162c551dd80Sdrh /*
163c551dd80Sdrh ** Maximum number of pages in one database file.
164c551dd80Sdrh **
165c551dd80Sdrh ** This is really just the default value for the max_page_count pragma.
166c551dd80Sdrh ** This value can be lowered (or raised) at run-time using that the
167c551dd80Sdrh ** max_page_count macro.
168c551dd80Sdrh */
169c551dd80Sdrh #ifndef SQLITE_MAX_PAGE_COUNT
170c551dd80Sdrh # define SQLITE_MAX_PAGE_COUNT 1073741823
171c551dd80Sdrh #endif
172c551dd80Sdrh 
173c551dd80Sdrh /*
174c551dd80Sdrh ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
175c551dd80Sdrh ** operator.
176c551dd80Sdrh */
177c551dd80Sdrh #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
178c551dd80Sdrh # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
179c551dd80Sdrh #endif
180