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.
000064  **
000065  ** A value of 0 used to mean that the limit was not enforced.
000066  ** But that is no longer true.  The limit is now strictly enforced
000067  ** at all times.
000068  */
000069  #ifndef SQLITE_MAX_EXPR_DEPTH
000070  # define SQLITE_MAX_EXPR_DEPTH 1000
000071  #endif
000072  
000073  /*
000074  ** The maximum number of terms in a compound SELECT statement.
000075  ** The code generator for compound SELECT statements does one
000076  ** level of recursion for each term.  A stack overflow can result
000077  ** if the number of terms is too large.  In practice, most SQL
000078  ** never has more than 3 or 4 terms.  Use a value of 0 to disable
000079  ** any limit on the number of terms in a compount SELECT.
000080  */
000081  #ifndef SQLITE_MAX_COMPOUND_SELECT
000082  # define SQLITE_MAX_COMPOUND_SELECT 500
000083  #endif
000084  
000085  /*
000086  ** The maximum number of opcodes in a VDBE program.
000087  ** Not currently enforced.
000088  */
000089  #ifndef SQLITE_MAX_VDBE_OP
000090  # define SQLITE_MAX_VDBE_OP 25000
000091  #endif
000092  
000093  /*
000094  ** The maximum number of arguments to an SQL function.
000095  */
000096  #ifndef SQLITE_MAX_FUNCTION_ARG
000097  # define SQLITE_MAX_FUNCTION_ARG 127
000098  #endif
000099  
000100  /*
000101  ** The suggested maximum number of in-memory pages to use for
000102  ** the main database table and for temporary tables.
000103  **
000104  ** IMPLEMENTATION-OF: R-30185-15359 The default suggested cache size is -2000,
000105  ** which means the cache size is limited to 2048000 bytes of memory.
000106  ** IMPLEMENTATION-OF: R-48205-43578 The default suggested cache size can be
000107  ** altered using the SQLITE_DEFAULT_CACHE_SIZE compile-time options.
000108  */
000109  #ifndef SQLITE_DEFAULT_CACHE_SIZE
000110  # define SQLITE_DEFAULT_CACHE_SIZE  -2000
000111  #endif
000112  
000113  /*
000114  ** The default number of frames to accumulate in the log file before
000115  ** checkpointing the database in WAL mode.
000116  */
000117  #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
000118  # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT  1000
000119  #endif
000120  
000121  /*
000122  ** The maximum number of attached databases.  This must be between 0
000123  ** and 125.  The upper bound of 125 is because the attached databases are
000124  ** counted using a signed 8-bit integer which has a maximum value of 127
000125  ** and we have to allow 2 extra counts for the "main" and "temp" databases.
000126  */
000127  #ifndef SQLITE_MAX_ATTACHED
000128  # define SQLITE_MAX_ATTACHED 10
000129  #endif
000130  
000131  
000132  /*
000133  ** The maximum value of a ?nnn wildcard that the parser will accept.
000134  */
000135  #ifndef SQLITE_MAX_VARIABLE_NUMBER
000136  # define SQLITE_MAX_VARIABLE_NUMBER 999
000137  #endif
000138  
000139  /* Maximum page size.  The upper bound on this value is 65536.  This a limit
000140  ** imposed by the use of 16-bit offsets within each page.
000141  **
000142  ** Earlier versions of SQLite allowed the user to change this value at
000143  ** compile time. This is no longer permitted, on the grounds that it creates
000144  ** a library that is technically incompatible with an SQLite library 
000145  ** compiled with a different limit. If a process operating on a database 
000146  ** with a page-size of 65536 bytes crashes, then an instance of SQLite 
000147  ** compiled with the default page-size limit will not be able to rollback 
000148  ** the aborted transaction. This could lead to database corruption.
000149  */
000150  #ifdef SQLITE_MAX_PAGE_SIZE
000151  # undef SQLITE_MAX_PAGE_SIZE
000152  #endif
000153  #define SQLITE_MAX_PAGE_SIZE 65536
000154  
000155  
000156  /*
000157  ** The default size of a database page.
000158  */
000159  #ifndef SQLITE_DEFAULT_PAGE_SIZE
000160  # define SQLITE_DEFAULT_PAGE_SIZE 4096
000161  #endif
000162  #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
000163  # undef SQLITE_DEFAULT_PAGE_SIZE
000164  # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
000165  #endif
000166  
000167  /*
000168  ** Ordinarily, if no value is explicitly provided, SQLite creates databases
000169  ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
000170  ** device characteristics (sector-size and atomic write() support),
000171  ** SQLite may choose a larger value. This constant is the maximum value
000172  ** SQLite will choose on its own.
000173  */
000174  #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
000175  # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
000176  #endif
000177  #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
000178  # undef SQLITE_MAX_DEFAULT_PAGE_SIZE
000179  # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
000180  #endif
000181  
000182  
000183  /*
000184  ** Maximum number of pages in one database file.
000185  **
000186  ** This is really just the default value for the max_page_count pragma.
000187  ** This value can be lowered (or raised) at run-time using that the
000188  ** max_page_count macro.
000189  */
000190  #ifndef SQLITE_MAX_PAGE_COUNT
000191  # define SQLITE_MAX_PAGE_COUNT 1073741823
000192  #endif
000193  
000194  /*
000195  ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
000196  ** operator.
000197  */
000198  #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
000199  # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
000200  #endif
000201  
000202  /*
000203  ** Maximum depth of recursion for triggers.
000204  **
000205  ** A value of 1 means that a trigger program will not be able to itself
000206  ** fire any triggers. A value of 0 means that no trigger programs at all 
000207  ** may be executed.
000208  */
000209  #ifndef SQLITE_MAX_TRIGGER_DEPTH
000210  # define SQLITE_MAX_TRIGGER_DEPTH 1000
000211  #endif