blob: 182575c6c8e2439833d4fae770ce987998a93fde [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**
drhbb4957f2008-03-20 14:03:29 +000015** @(#) $Id: sqliteLimit.h,v 1.7 2008/03/20 14:03:29 drh 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
99# define SQLITE_MAX_FUNCTION_ARG 100
100#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/*
114** The maximum number of attached databases. This must be at least 2
115** in order to support the main database file (0) and the file used to
116** hold temporary tables (1). And it must be less than 32 because
117** we use a bitmask of databases with a u32 in places (for example
118** the Parse.cookieMask field).
119*/
120#ifndef SQLITE_MAX_ATTACHED
121# define SQLITE_MAX_ATTACHED 10
122#endif
123
124
125/*
126** The maximum value of a ?nnn wildcard that the parser will accept.
127*/
128#ifndef SQLITE_MAX_VARIABLE_NUMBER
129# define SQLITE_MAX_VARIABLE_NUMBER 999
130#endif
131
drhf54cc032007-11-05 14:30:22 +0000132/* Maximum page size. The upper bound on this value is 32768. This a limit
133** imposed by the necessity of storing the value in a 2-byte unsigned integer
134** and the fact that the page size must be a power of 2.
135*/
136#ifndef SQLITE_MAX_PAGE_SIZE
137# define SQLITE_MAX_PAGE_SIZE 32768
138#endif
139
140
drhc551dd82007-06-19 15:23:48 +0000141/*
142** The default size of a database page.
143*/
144#ifndef SQLITE_DEFAULT_PAGE_SIZE
145# define SQLITE_DEFAULT_PAGE_SIZE 1024
146#endif
drhf54cc032007-11-05 14:30:22 +0000147#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
148# undef SQLITE_DEFAULT_PAGE_SIZE
149# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
150#endif
drhc551dd82007-06-19 15:23:48 +0000151
danielk19779663b8f2007-08-24 11:52:28 +0000152/*
153** Ordinarily, if no value is explicitly provided, SQLite creates databases
154** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
155** device characteristics (sector-size and atomic write() support),
156** SQLite may choose a larger value. This constant is the maximum value
drh85b623f2007-12-13 21:54:09 +0000157** SQLite will choose on its own.
danielk19779663b8f2007-08-24 11:52:28 +0000158*/
159#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
160# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
161#endif
drhf54cc032007-11-05 14:30:22 +0000162#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
163# undef SQLITE_MAX_DEFAULT_PAGE_SIZE
164# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
drhc551dd82007-06-19 15:23:48 +0000165#endif
166
drhf54cc032007-11-05 14:30:22 +0000167
drhc551dd82007-06-19 15:23:48 +0000168/*
169** Maximum number of pages in one database file.
170**
171** This is really just the default value for the max_page_count pragma.
172** This value can be lowered (or raised) at run-time using that the
173** max_page_count macro.
174*/
175#ifndef SQLITE_MAX_PAGE_COUNT
176# define SQLITE_MAX_PAGE_COUNT 1073741823
177#endif
178
179/*
180** Maximum length (in bytes) of the pattern in a LIKE or GLOB
181** operator.
182*/
183#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
184# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
185#endif