blob: 77d78589a9c212b7f69507e2bec0d5c5c8f03a21 [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.
14**
danielk19777cbd5892009-01-10 16:15:09 +000015** @(#) $Id: sqliteLimit.h,v 1.10 2009/01/10 16:15:09 danielk1977 Exp $
drhc551dd82007-06-19 15:23:48 +000016*/
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.
drhbb4957f2008-03-20 14:03:29 +000052**
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.
drhc551dd82007-06-19 15:23:48 +000056*/
57#ifndef SQLITE_MAX_SQL_LENGTH
drhbb4957f2008-03-20 14:03:29 +000058# define SQLITE_MAX_SQL_LENGTH 1000000000
drhc551dd82007-06-19 15:23:48 +000059#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
drhbb4957f2008-03-20 14:03:29 +000065** 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.
drhc551dd82007-06-19 15:23:48 +000070*/
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
danielk1977a7c17af2009-01-07 16:15:42 +000099# define SQLITE_MAX_FUNCTION_ARG 127
drhc551dd82007-06-19 15:23:48 +0000100#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/*
drh083e5812008-03-26 15:56:22 +0000114** 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.
drhc551dd82007-06-19 15:23:48 +0000117*/
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
drhf54cc032007-11-05 14:30:22 +0000130/* 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.
danielk19777cbd5892009-01-10 16:15:09 +0000133**
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.
drhf54cc032007-11-05 14:30:22 +0000140*/
141#ifndef SQLITE_MAX_PAGE_SIZE
142# define SQLITE_MAX_PAGE_SIZE 32768
143#endif
144
145
drhc551dd82007-06-19 15:23:48 +0000146/*
147** The default size of a database page.
148*/
149#ifndef SQLITE_DEFAULT_PAGE_SIZE
150# define SQLITE_DEFAULT_PAGE_SIZE 1024
151#endif
drhf54cc032007-11-05 14:30:22 +0000152#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
drhc551dd82007-06-19 15:23:48 +0000156
danielk19779663b8f2007-08-24 11:52:28 +0000157/*
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
drh85b623f2007-12-13 21:54:09 +0000162** SQLite will choose on its own.
danielk19779663b8f2007-08-24 11:52:28 +0000163*/
164#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
165# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
166#endif
drhf54cc032007-11-05 14:30:22 +0000167#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
drhc551dd82007-06-19 15:23:48 +0000170#endif
171
drhf54cc032007-11-05 14:30:22 +0000172
drhc551dd82007-06-19 15:23:48 +0000173/*
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
drh417168a2009-09-07 18:14:02 +0000191
192/*
193** Maximum depth of recursion for triggers.
danf5894502009-10-07 18:41:19 +0000194**
195** A value of 1 means that a trigger program will not be able to itself
196** fire any triggers. A value of 0 means that no trigger programs at all
197** may be executed.
drh417168a2009-09-07 18:14:02 +0000198*/
199#ifndef SQLITE_MAX_TRIGGER_DEPTH
shane0cab1412009-09-10 02:54:48 +0000200#if defined(SQLITE_SMALL_STACK)
201# define SQLITE_MAX_TRIGGER_DEPTH 10
202#else
drh417168a2009-09-07 18:14:02 +0000203# define SQLITE_MAX_TRIGGER_DEPTH 1000
204#endif
shane0cab1412009-09-10 02:54:48 +0000205#endif