Thanks to visit codestin.com
Credit goes to chromium.googlesource.com

blob: ec774889b5deb15d5fd34454e4738cceccc32373 [file] [log] [blame]
drhc551dd82007-06-19 15:23:481/*
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*************************************************************************
larrybrbc917382023-06-07 08:40:3112**
drhc551dd82007-06-19 15:23:4813** This file defines various limits of what SQLite can process.
drhc551dd82007-06-19 15:23:4814*/
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
drh4ddeccf2024-11-08 20:57:4526#define SQLITE_MIN_LENGTH 30 /* Minimum value for the length limit */
drhc551dd82007-06-19 15:23:4827
28/*
29** This is the maximum number of
30**
31** * Columns in a table
32** * Columns in an index
33** * Columns in a view
34** * Terms in the SET clause of an UPDATE statement
35** * Terms in the result set of a SELECT statement
36** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
37** * Terms in the VALUES clause of an INSERT statement
38**
drhce250072025-02-21 17:03:2239** The hard upper limit here is 32767. Most database people will
drhc551dd82007-06-19 15:23:4840** tell you that in a well-normalized database, you usually should
41** not have more than a dozen or so columns in any table. And if
42** that is the case, there is no point in having more than a few
43** dozen values in any of the other situations described above.
drhcc803b22025-02-21 20:35:3744**
45** An index can only have SQLITE_MAX_COLUMN columns from the user
46** point of view, but the underlying b-tree that implements the index
47** might have up to twice as many columns in a WITHOUT ROWID table,
48** since must also store the primary key at the end. Hence the
49** column count for Index is u16 instead of i16.
drhc551dd82007-06-19 15:23:4850*/
drhce250072025-02-21 17:03:2251#if !defined(SQLITE_MAX_COLUMN)
drhc551dd82007-06-19 15:23:4852# define SQLITE_MAX_COLUMN 2000
drhce250072025-02-21 17:03:2253#elif SQLITE_MAX_COLUMN>32767
54# error SQLITE_MAX_COLUMN may not exceed 32767
drhc551dd82007-06-19 15:23:4855#endif
56
57/*
58** The maximum length of a single SQL statement in bytes.
drhbb4957f2008-03-20 14:03:2959**
60** It used to be the case that setting this value to zero would
61** turn the limit off. That is no longer true. It is not possible
62** to turn this limit off.
drhc551dd82007-06-19 15:23:4863*/
64#ifndef SQLITE_MAX_SQL_LENGTH
drhbb4957f2008-03-20 14:03:2965# define SQLITE_MAX_SQL_LENGTH 1000000000
drhc551dd82007-06-19 15:23:4866#endif
67
68/*
larrybrbc917382023-06-07 08:40:3169** The maximum depth of an expression tree. This is limited to
70** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
71** want to place more severe limits on the complexity of an
dan6c3b4b02020-08-20 16:25:2672** expression. A value of 0 means that there is no limit.
drhc551dd82007-06-19 15:23:4873*/
74#ifndef SQLITE_MAX_EXPR_DEPTH
75# define SQLITE_MAX_EXPR_DEPTH 1000
76#endif
77
78/*
79** The maximum number of terms in a compound SELECT statement.
80** The code generator for compound SELECT statements does one
81** level of recursion for each term. A stack overflow can result
82** if the number of terms is too large. In practice, most SQL
83** never has more than 3 or 4 terms. Use a value of 0 to disable
larrybrbc917382023-06-07 08:40:3184** any limit on the number of terms in a compound SELECT.
drhc551dd82007-06-19 15:23:4885*/
86#ifndef SQLITE_MAX_COMPOUND_SELECT
87# define SQLITE_MAX_COMPOUND_SELECT 500
88#endif
89
90/*
91** The maximum number of opcodes in a VDBE program.
92** Not currently enforced.
93*/
94#ifndef SQLITE_MAX_VDBE_OP
drh1cb02662017-03-17 22:50:1695# define SQLITE_MAX_VDBE_OP 250000000
drhc551dd82007-06-19 15:23:4896#endif
97
98/*
99** The maximum number of arguments to an SQL function.
drh35d302c2024-12-12 15:11:27100**
101** This value has a hard upper limit of 32767 due to storage
102** constraints (it needs to fit inside a i16). We keep it
103** lower than that to prevent abuse.
drhc551dd82007-06-19 15:23:48104*/
105#ifndef SQLITE_MAX_FUNCTION_ARG
drh35d302c2024-12-12 15:11:27106# define SQLITE_MAX_FUNCTION_ARG 1000
drhc551dd82007-06-19 15:23:48107#endif
108
109/*
drh9d356fb2015-02-27 20:28:08110** The suggested maximum number of in-memory pages to use for
111** the main database table and for temporary tables.
112**
drh37670262016-03-23 13:46:05113** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,
114** which means the cache size is limited to 2048000 bytes of memory.
drhe0e84292015-02-27 21:53:35115** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
116** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
drhc551dd82007-06-19 15:23:48117*/
118#ifndef SQLITE_DEFAULT_CACHE_SIZE
drh94580862016-03-04 04:01:43119# define SQLITE_DEFAULT_CACHE_SIZE -2000
drhc551dd82007-06-19 15:23:48120#endif
drhc551dd82007-06-19 15:23:48121
122/*
dan5a299f92010-05-03 11:05:08123** The default number of frames to accumulate in the log file before
124** checkpointing the database in WAL mode.
125*/
126#ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
127# define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
128#endif
129
130/*
drh083e5812008-03-26 15:56:22131** The maximum number of attached databases. This must be between 0
drh9878fef2016-03-04 03:43:10132** and 125. The upper bound of 125 is because the attached databases are
133** counted using a signed 8-bit integer which has a maximum value of 127
134** and we have to allow 2 extra counts for the "main" and "temp" databases.
drhc551dd82007-06-19 15:23:48135*/
136#ifndef SQLITE_MAX_ATTACHED
137# define SQLITE_MAX_ATTACHED 10
138#endif
139
140
141/*
142** The maximum value of a ?nnn wildcard that the parser will accept.
drhefdba1a2020-02-12 20:50:20143** If the value exceeds 32767 then extra space is required for the Expr
144** structure. But otherwise, we believe that the number can be as large
145** as a signed 32-bit integer can hold.
drhc551dd82007-06-19 15:23:48146*/
147#ifndef SQLITE_MAX_VARIABLE_NUMBER
drhefdba1a2020-02-12 20:50:20148# define SQLITE_MAX_VARIABLE_NUMBER 32766
drhc551dd82007-06-19 15:23:48149#endif
150
drhb2eced52010-08-12 02:41:12151/* Maximum page size. The upper bound on this value is 65536. This a limit
152** imposed by the use of 16-bit offsets within each page.
danielk19777cbd5892009-01-10 16:15:09153**
dan5a9e07e2010-08-18 15:25:17154** Earlier versions of SQLite allowed the user to change this value at
155** compile time. This is no longer permitted, on the grounds that it creates
larrybrbc917382023-06-07 08:40:31156** a library that is technically incompatible with an SQLite library
157** compiled with a different limit. If a process operating on a database
158** with a page-size of 65536 bytes crashes, then an instance of SQLite
159** compiled with the default page-size limit will not be able to rollback
dan5a9e07e2010-08-18 15:25:17160** the aborted transaction. This could lead to database corruption.
drhf54cc032007-11-05 14:30:22161*/
dan5a9e07e2010-08-18 15:25:17162#ifdef SQLITE_MAX_PAGE_SIZE
163# undef SQLITE_MAX_PAGE_SIZE
drhf54cc032007-11-05 14:30:22164#endif
dan5a9e07e2010-08-18 15:25:17165#define SQLITE_MAX_PAGE_SIZE 65536
drhf54cc032007-11-05 14:30:22166
167
drhc551dd82007-06-19 15:23:48168/*
169** The default size of a database page.
170*/
171#ifndef SQLITE_DEFAULT_PAGE_SIZE
drh9878fef2016-03-04 03:43:10172# define SQLITE_DEFAULT_PAGE_SIZE 4096
drhc551dd82007-06-19 15:23:48173#endif
drhf54cc032007-11-05 14:30:22174#if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
175# undef SQLITE_DEFAULT_PAGE_SIZE
176# define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
177#endif
drhc551dd82007-06-19 15:23:48178
danielk19779663b8f2007-08-24 11:52:28179/*
180** Ordinarily, if no value is explicitly provided, SQLite creates databases
181** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
182** device characteristics (sector-size and atomic write() support),
183** SQLite may choose a larger value. This constant is the maximum value
drh85b623f2007-12-13 21:54:09184** SQLite will choose on its own.
danielk19779663b8f2007-08-24 11:52:28185*/
186#ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
187# define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
188#endif
drhf54cc032007-11-05 14:30:22189#if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
190# undef SQLITE_MAX_DEFAULT_PAGE_SIZE
191# define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
drhc551dd82007-06-19 15:23:48192#endif
193
drhf54cc032007-11-05 14:30:22194
drhc551dd82007-06-19 15:23:48195/*
196** Maximum number of pages in one database file.
197**
198** This is really just the default value for the max_page_count pragma.
199** This value can be lowered (or raised) at run-time using that the
200** max_page_count macro.
201*/
202#ifndef SQLITE_MAX_PAGE_COUNT
drh433e9042024-01-03 15:49:04203# define SQLITE_MAX_PAGE_COUNT 0xfffffffe /* 4294967294 */
drhc551dd82007-06-19 15:23:48204#endif
205
206/*
207** Maximum length (in bytes) of the pattern in a LIKE or GLOB
208** operator.
209*/
210#ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
211# define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
212#endif
drh417168a2009-09-07 18:14:02213
214/*
215** Maximum depth of recursion for triggers.
danf5894502009-10-07 18:41:19216**
217** A value of 1 means that a trigger program will not be able to itself
larrybrbc917382023-06-07 08:40:31218** fire any triggers. A value of 0 means that no trigger programs at all
danf5894502009-10-07 18:41:19219** may be executed.
drh417168a2009-09-07 18:14:02220*/
221#ifndef SQLITE_MAX_TRIGGER_DEPTH
222# define SQLITE_MAX_TRIGGER_DEPTH 1000
223#endif