sqliteLimit.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /*
  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. */
  15. /*
  16. ** The maximum length of a TEXT or BLOB in bytes. This also
  17. ** limits the size of a row in a table or index.
  18. **
  19. ** The hard limit is the ability of a 32-bit signed integer
  20. ** to count the size: 2^31-1 or 2147483647.
  21. */
  22. #ifndef SQLITE_MAX_LENGTH
  23. # define SQLITE_MAX_LENGTH 1000000000
  24. #endif
  25. /*
  26. ** This is the maximum number of
  27. **
  28. ** * Columns in a table
  29. ** * Columns in an index
  30. ** * Columns in a view
  31. ** * Terms in the SET clause of an UPDATE statement
  32. ** * Terms in the result set of a SELECT statement
  33. ** * Terms in the GROUP BY or ORDER BY clauses of a SELECT statement.
  34. ** * Terms in the VALUES clause of an INSERT statement
  35. **
  36. ** The hard upper limit here is 32676. Most database people will
  37. ** tell you that in a well-normalized database, you usually should
  38. ** not have more than a dozen or so columns in any table. And if
  39. ** that is the case, there is no point in having more than a few
  40. ** dozen values in any of the other situations described above.
  41. */
  42. #ifndef SQLITE_MAX_COLUMN
  43. # define SQLITE_MAX_COLUMN 2000
  44. #endif
  45. /*
  46. ** The maximum length of a single SQL statement in bytes.
  47. **
  48. ** It used to be the case that setting this value to zero would
  49. ** turn the limit off. That is no longer true. It is not possible
  50. ** to turn this limit off.
  51. */
  52. #ifndef SQLITE_MAX_SQL_LENGTH
  53. # define SQLITE_MAX_SQL_LENGTH 1000000000
  54. #endif
  55. /*
  56. ** The maximum depth of an expression tree. This is limited to
  57. ** some extent by SQLITE_MAX_SQL_LENGTH. But sometime you might
  58. ** want to place more severe limits on the complexity of an
  59. ** expression.
  60. **
  61. ** A value of 0 used to mean that the limit was not enforced.
  62. ** But that is no longer true. The limit is now strictly enforced
  63. ** at all times.
  64. */
  65. #ifndef SQLITE_MAX_EXPR_DEPTH
  66. # define SQLITE_MAX_EXPR_DEPTH 1000
  67. #endif
  68. /*
  69. ** The maximum number of terms in a compound SELECT statement.
  70. ** The code generator for compound SELECT statements does one
  71. ** level of recursion for each term. A stack overflow can result
  72. ** if the number of terms is too large. In practice, most SQL
  73. ** never has more than 3 or 4 terms. Use a value of 0 to disable
  74. ** any limit on the number of terms in a compount SELECT.
  75. */
  76. #ifndef SQLITE_MAX_COMPOUND_SELECT
  77. # define SQLITE_MAX_COMPOUND_SELECT 500
  78. #endif
  79. /*
  80. ** The maximum number of opcodes in a VDBE program.
  81. ** Not currently enforced.
  82. */
  83. #ifndef SQLITE_MAX_VDBE_OP
  84. # define SQLITE_MAX_VDBE_OP 25000
  85. #endif
  86. /*
  87. ** The maximum number of arguments to an SQL function.
  88. */
  89. #ifndef SQLITE_MAX_FUNCTION_ARG
  90. # define SQLITE_MAX_FUNCTION_ARG 127
  91. #endif
  92. /*
  93. ** The maximum number of in-memory pages to use for the main database
  94. ** table and for temporary tables. The SQLITE_DEFAULT_CACHE_SIZE
  95. */
  96. #ifndef SQLITE_DEFAULT_CACHE_SIZE
  97. # define SQLITE_DEFAULT_CACHE_SIZE 2000
  98. #endif
  99. #ifndef SQLITE_DEFAULT_TEMP_CACHE_SIZE
  100. # define SQLITE_DEFAULT_TEMP_CACHE_SIZE 500
  101. #endif
  102. /*
  103. ** The default number of frames to accumulate in the log file before
  104. ** checkpointing the database in WAL mode.
  105. */
  106. #ifndef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
  107. # define SQLITE_DEFAULT_WAL_AUTOCHECKPOINT 1000
  108. #endif
  109. /*
  110. ** The maximum number of attached databases. This must be between 0
  111. ** and 62. The upper bound on 62 is because a 64-bit integer bitmap
  112. ** is used internally to track attached databases.
  113. */
  114. #ifndef SQLITE_MAX_ATTACHED
  115. # define SQLITE_MAX_ATTACHED 10
  116. #endif
  117. /*
  118. ** The maximum value of a ?nnn wildcard that the parser will accept.
  119. */
  120. #ifndef SQLITE_MAX_VARIABLE_NUMBER
  121. # define SQLITE_MAX_VARIABLE_NUMBER 999
  122. #endif
  123. /* Maximum page size. The upper bound on this value is 65536. This a limit
  124. ** imposed by the use of 16-bit offsets within each page.
  125. **
  126. ** Earlier versions of SQLite allowed the user to change this value at
  127. ** compile time. This is no longer permitted, on the grounds that it creates
  128. ** a library that is technically incompatible with an SQLite library
  129. ** compiled with a different limit. If a process operating on a database
  130. ** with a page-size of 65536 bytes crashes, then an instance of SQLite
  131. ** compiled with the default page-size limit will not be able to rollback
  132. ** the aborted transaction. This could lead to database corruption.
  133. */
  134. #ifdef SQLITE_MAX_PAGE_SIZE
  135. # undef SQLITE_MAX_PAGE_SIZE
  136. #endif
  137. #define SQLITE_MAX_PAGE_SIZE 65536
  138. /*
  139. ** The default size of a database page.
  140. */
  141. #ifndef SQLITE_DEFAULT_PAGE_SIZE
  142. # define SQLITE_DEFAULT_PAGE_SIZE 1024
  143. #endif
  144. #if SQLITE_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
  145. # undef SQLITE_DEFAULT_PAGE_SIZE
  146. # define SQLITE_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
  147. #endif
  148. /*
  149. ** Ordinarily, if no value is explicitly provided, SQLite creates databases
  150. ** with page size SQLITE_DEFAULT_PAGE_SIZE. However, based on certain
  151. ** device characteristics (sector-size and atomic write() support),
  152. ** SQLite may choose a larger value. This constant is the maximum value
  153. ** SQLite will choose on its own.
  154. */
  155. #ifndef SQLITE_MAX_DEFAULT_PAGE_SIZE
  156. # define SQLITE_MAX_DEFAULT_PAGE_SIZE 8192
  157. #endif
  158. #if SQLITE_MAX_DEFAULT_PAGE_SIZE>SQLITE_MAX_PAGE_SIZE
  159. # undef SQLITE_MAX_DEFAULT_PAGE_SIZE
  160. # define SQLITE_MAX_DEFAULT_PAGE_SIZE SQLITE_MAX_PAGE_SIZE
  161. #endif
  162. /*
  163. ** Maximum number of pages in one database file.
  164. **
  165. ** This is really just the default value for the max_page_count pragma.
  166. ** This value can be lowered (or raised) at run-time using that the
  167. ** max_page_count macro.
  168. */
  169. #ifndef SQLITE_MAX_PAGE_COUNT
  170. # define SQLITE_MAX_PAGE_COUNT 1073741823
  171. #endif
  172. /*
  173. ** Maximum length (in bytes) of the pattern in a LIKE or GLOB
  174. ** operator.
  175. */
  176. #ifndef SQLITE_MAX_LIKE_PATTERN_LENGTH
  177. # define SQLITE_MAX_LIKE_PATTERN_LENGTH 50000
  178. #endif
  179. /*
  180. ** Maximum depth of recursion for triggers.
  181. **
  182. ** A value of 1 means that a trigger program will not be able to itself
  183. ** fire any triggers. A value of 0 means that no trigger programs at all
  184. ** may be executed.
  185. */
  186. #ifndef SQLITE_MAX_TRIGGER_DEPTH
  187. # define SQLITE_MAX_TRIGGER_DEPTH 1000
  188. #endif