blob: faf80d4378d60267640fdadf995494abe6426c89 [file] [log] [blame]
drhc551dd82007-06-19 15:23:48 +00001/*
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.
drhc551dd82007-06-19 15:23:48 +000014*/
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.
drhbb4957f2008-03-20 14:03:29 +000050**
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.
drhc551dd82007-06-19 15:23:48 +000054*/
55#ifndef SQLITE_MAX_SQL_LENGTH
drhbb4957f2008-03-20 14:03:29 +000056# define SQLITE_MAX_SQL_LENGTH 1000000000
drhc551dd82007-06-19 15:23:48 +000057#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
drhbb4957f2008-03-20 14:03:29 +000063** 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.
drhc551dd82007-06-19 15:23:48 +000068*/
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
90# define SQLITE_MAX_VDBE_OP 25000
91#endif
92
93/*
94** The maximum number of arguments to an SQL function.
95*/
96#ifndef SQLITE_MAX_FUNCTION_ARG
danielk1977a7c17af2009-01-07 16:15:42 +000097# define SQLITE_MAX_FUNCTION_ARG 127
drhc551dd82007-06-19 15:23:48 +000098#endif
99
100/*
101** The maximum number of in-memory pages to use for the main database
102** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
103*/
104#ifndef SQLITE_DEFAULT_CACHE_SIZE
105# define SQLITE_DEFAULT_CACHE_SIZE 2000
106#endif
107#ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
108# define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
109#endif
110
111/*
drh083e5812008-03-26 15:56:22 +0000112** The maximum number of attached databases. This must be between 0
113** and 30. The upper bound on 30 is because a 32-bit integer bitmap
114** is used internally to track attached databases.
drhc551dd82007-06-19 15:23:48 +0000115*/
116#ifndef SQLITE_MAX_ATTACHED
117# define SQLITE_MAX_ATTACHED 10
118#endif
119
120
121/*
122** The maximum value of a ?nnn wildcard that the parser will accept.
123*/
124#ifndef SQLITE_MAX_VARIABLE_NUMBER
125# define SQLITE_MAX_VARIABLE_NUMBER 999
126#endif
127
drhf54cc032007-11-05 14:30:22 +0000128/* Maximum page size. The upper bound on this value is 32768. This a limit
129** imposed by the necessity of storing the value in a 2-byte unsigned integer
130** and the fact that the page size must be a power of 2.
danielk19777cbd5892009-01-10 16:15:09 +0000131**
132** If this limit is changed, then the compiled library is technically
133** incompatible with an SQLite library compiled with a different limit. If
134** a process operating on a database with a page-size of 65536 bytes
135** crashes, then an instance of SQLite compiled with the default page-size
136** limit will not be able to rollback the aborted transaction. This could
137** lead to database corruption.
drhf54cc032007-11-05 14:30:22 +0000138*/
139#ifndef SQLITE_MAX_PAGE_SIZE
140# define SQLITE_MAX_PAGE_SIZE 32768
141#endif
142
143
drhc551dd82007-06-19 15:23:48 +0000144/*
145** The default size of a database page.
146*/
147#ifndef SQLITE_DEFAULT_PAGE_SIZE
148# define SQLITE_DEFAULT_PAGE_SIZE 1024
149#endif
drhf54cc032007-11-05 14:30:22 +0000150#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
151# undef SQLITE_DEFAULT_PAGE_SIZE
152# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
153#endif
drhc551dd82007-06-19 15:23:48 +0000154
danielk19779663b8f2007-08-24 11:52:28 +0000155/*
156** Ordinarily, if no value is explicitly provided, SQLite creates databases
157** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
158** device characteristics (sector-size and atomic write() support),
159** SQLite may choose a larger value. This constant is the maximum value
drh85b623f2007-12-13 21:54:09 +0000160** SQLite will choose on its own.
danielk19779663b8f2007-08-24 11:52:28 +0000161*/
162#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
163# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
164#endif
drhf54cc032007-11-05 14:30:22 +0000165#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
166# undef SQLITE_MAX_DEFAULT_PAGE_SIZE
167# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
drhc551dd82007-06-19 15:23:48 +0000168#endif
169
drhf54cc032007-11-05 14:30:22 +0000170
drhc551dd82007-06-19 15:23:48 +0000171/*
172** Maximum number of pages in one database file.
173**
174** This is really just the default value for the max_page_count pragma.
175** This value can be lowered (or raised) at run-time using that the
176** max_page_count macro.
177*/
178#ifndef SQLITE_MAX_PAGE_COUNT
179# define SQLITE_MAX_PAGE_COUNT 1073741823
180#endif
181
182/*
183** Maximum length (in bytes) of the pattern in a LIKE or GLOB
184** operator.
185*/
186#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
187# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
188#endif
drh417168a2009-09-07 18:14:02 +0000189
190/*
191** Maximum depth of recursion for triggers.
danf5894502009-10-07 18:41:19 +0000192**
193** A value of 1 means that a trigger program will not be able to itself
194** fire any triggers. A value of 0 means that no trigger programs at all
195** may be executed.
drh417168a2009-09-07 18:14:02 +0000196*/
197#ifndef SQLITE_MAX_TRIGGER_DEPTH
198# define SQLITE_MAX_TRIGGER_DEPTH 1000
199#endif