000001  /*
000002  ** 2007 May 7
000003  **
000004  ** The author disclaims copyright to this source code.  In place of
000005  ** a legal notice, here is a blessing:
000006  **
000007  **    May you do good and not evil.
000008  **    May you find forgiveness for yourself and forgive others.
000009  **    May you share freely, never taking more than you give.
000010  **
000011  *************************************************************************
000012  **
000013  ** This file defines various limits of what SQLite can process.
000014  */
000015  
000016  /*
000017  ** The maximum length of a TEXT or BLOB in bytes.   This also
000018  ** limits the size of a row in a table or index.
000019  **
000020  ** The hard limit is the ability of a 32-bit signed integer
000021  ** to count the size: 2^31-1 or 2147483647.
000022  */
000023  #ifndef SQLITE_MAX_LENGTH
000024  # define SQLITE_MAX_LENGTH 1000000000
000025  #endif
000026  
000027  /*
000028  ** This is the maximum number of
000029  **
000030  **    * Columns in a table
000031  **    * Columns in an index
000032  **    * Columns in a view
000033  **    * Terms in the SET clause of an UPDATE statement
000034  **    * Terms in the result set of a SELECT statement
000035  **    * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
000036  **    * Terms in the VALUES clause of an INSERT statement
000037  **
000038  ** The hard upper limit here is 32676.  Most database people will
000039  ** tell you that in a well-normalized database, you usually should
000040  ** not have more than a dozen or so columns in any table.  And if
000041  ** that is the case, there is no point in having more than a few
000042  ** dozen values in any of the other situations described above.
000043  */
000044  #ifndef SQLITE_MAX_COLUMN
000045  # define SQLITE_MAX_COLUMN 2000
000046  #endif
000047  
000048  /*
000049  ** The maximum length of a single SQL statement in bytes.
000050  **
000051  ** It used to be the case that setting this value to zero would
000052  ** turn the limit off.  That is no longer true.  It is not possible
000053  ** to turn this limit off.
000054  */
000055  #ifndef SQLITE_MAX_SQL_LENGTH
000056  # define SQLITE_MAX_SQL_LENGTH 1000000000
000057  #endif
000058  
000059  /*
000060  ** The maximum depth of an expression tree. This is limited to
000061  ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
000062  ** want to place more severe limits on the complexity of an
000063  ** expression. A value of 0 means that there is no limit.
000064  */
000065  #ifndef SQLITE_MAX_EXPR_DEPTH
000066  # define SQLITE_MAX_EXPR_DEPTH 1000
000067  #endif
000068  
000069  /*
000070  ** The maximum number of terms in a compound SELECT statement.
000071  ** The code generator for compound SELECT statements does one
000072  ** level of recursion for each term.  A stack overflow can result
000073  ** if the number of terms is too large.  In practice, most SQL
000074  ** never has more than 3 or 4 terms.  Use a value of 0 to disable
000075  ** any limit on the number of terms in a compound SELECT.
000076  */
000077  #ifndef SQLITE_MAX_COMPOUND_SELECT
000078  # define SQLITE_MAX_COMPOUND_SELECT 500
000079  #endif
000080  
000081  /*
000082  ** The maximum number of opcodes in a VDBE program.
000083  ** Not currently enforced.
000084  */
000085  #ifndef SQLITE_MAX_VDBE_OP
000086  # define SQLITE_MAX_VDBE_OP 250000000
000087  #endif
000088  
000089  /*
000090  ** The maximum number of arguments to an SQL function.
000091  */
000092  #ifndef SQLITE_MAX_FUNCTION_ARG
000093  # define SQLITE_MAX_FUNCTION_ARG 127
000094  #endif
000095  
000096  /*
000097  ** The suggested maximum number of in-memory pages to use for
000098  ** the main database table and for temporary tables.
000099  **
000100  ** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,
000101  ** which means the cache size is limited to 2048000 bytes of memory.
000102  ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
000103  ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
000104  */
000105  #ifndef SQLITE_DEFAULT_CACHE_SIZE
000106  # define SQLITE_DEFAULT_CACHE_SIZE  -2000
000107  #endif
000108  
000109  /*
000110  ** The default number of frames to accumulate in the log file before
000111  ** checkpointing the database in WAL mode.
000112  */
000113  #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
000114  # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000
000115  #endif
000116  
000117  /*
000118  ** The maximum number of attached databases.  This must be between 0
000119  ** and 125.  The upper bound of 125 is because the attached databases are
000120  ** counted using a signed 8-bit integer which has a maximum value of 127
000121  ** and we have to allow 2 extra counts for the "main" and "temp" databases.
000122  */
000123  #ifndef SQLITE_MAX_ATTACHED
000124  # define SQLITE_MAX_ATTACHED 10
000125  #endif
000126  
000127  
000128  /*
000129  ** The maximum value of a ?nnn wildcard that the parser will accept.
000130  ** If the value exceeds 32767 then extra space is required for the Expr
000131  ** structure.  But otherwise, we believe that the number can be as large
000132  ** as a signed 32-bit integer can hold.
000133  */
000134  #ifndef SQLITE_MAX_VARIABLE_NUMBER
000135  # define SQLITE_MAX_VARIABLE_NUMBER 32766
000136  #endif
000137  
000138  /* Maximum page size.  The upper bound on this value is 65536.  This a limit
000139  ** imposed by the use of 16-bit offsets within each page.
000140  **
000141  ** Earlier versions of SQLite allowed the user to change this value at
000142  ** compile time. This is no longer permitted, on the grounds that it creates
000143  ** a library that is technically incompatible with an SQLite library
000144  ** compiled with a different limit. If a process operating on a database
000145  ** with a page-size of 65536 bytes crashes, then an instance of SQLite
000146  ** compiled with the default page-size limit will not be able to rollback
000147  ** the aborted transaction. This could lead to database corruption.
000148  */
000149  #ifdef SQLITE_MAX_PAGE_SIZE
000150  # undef SQLITE_MAX_PAGE_SIZE
000151  #endif
000152  #define SQLITE_MAX_PAGE_SIZE 65536
000153  
000154  
000155  /*
000156  ** The default size of a database page.
000157  */
000158  #ifndef SQLITE_DEFAULT_PAGE_SIZE
000159  # define SQLITE_DEFAULT_PAGE_SIZE 4096
000160  #endif
000161  #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
000162  # undef SQLITE_DEFAULT_PAGE_SIZE
000163  # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
000164  #endif
000165  
000166  /*
000167  ** Ordinarily, if no value is explicitly provided, SQLite creates databases
000168  ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
000169  ** device characteristics (sector-size and atomic write() support),
000170  ** SQLite may choose a larger value. This constant is the maximum value
000171  ** SQLite will choose on its own.
000172  */
000173  #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
000174  # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
000175  #endif
000176  #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
000177  # undef SQLITE_MAX_DEFAULT_PAGE_SIZE
000178  # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
000179  #endif
000180  
000181  
000182  /*
000183  ** Maximum number of pages in one database file.
000184  **
000185  ** This is really just the default value for the max_page_count pragma.
000186  ** This value can be lowered (or raised) at run-time using that the
000187  ** max_page_count macro.
000188  */
000189  #ifndef SQLITE_MAX_PAGE_COUNT
000190  # define SQLITE_MAX_PAGE_COUNT 1073741823
000191  #endif
000192  
000193  /*
000194  ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
000195  ** operator.
000196  */
000197  #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
000198  # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
000199  #endif
000200  
000201  /*
000202  ** Maximum depth of recursion for triggers.
000203  **
000204  ** A value of 1 means that a trigger program will not be able to itself
000205  ** fire any triggers. A value of 0 means that no trigger programs at all
000206  ** may be executed.
000207  */
000208  #ifndef SQLITE_MAX_TRIGGER_DEPTH
000209  # define SQLITE_MAX_TRIGGER_DEPTH 1000
000210  #endif