Module limits

Module limits 

Source
Expand description

Execution limits and safeguards

This module defines limits to prevent infinite loops, stack overflow, and runaway queries. These limits follow industry best practices established by SQLite and other production databases.

§Design Philosophy

These limits serve multiple purposes:

  1. Safety: Prevent crashes from stack overflow or infinite recursion
  2. Performance: Kill runaway queries that would hang the system
  3. Debugging: Provide clear error messages when limits are exceeded
  4. Compatibility: Match SQLite’s limit philosophy for consistency

§Limit Values

Default values are chosen conservatively to allow legitimate queries while catching pathological cases. They can be adjusted based on real-world usage patterns.

Constants§

MAX_COMPOUND_SELECT
Maximum number of compound SELECT terms
MAX_EXPRESSION_DEPTH
Maximum depth of expression tree evaluation (subqueries, nested expressions)
MAX_LOOP_ITERATIONS
Maximum number of iterations in a single loop (e.g., WHERE filtering)
MAX_MEMORY_BYTES
MAX_QUERY_EXECUTION_SECONDS
Maximum execution time for a single query (in seconds)
MAX_RECURSIVE_CTE_ITERATIONS
Maximum number of iterations for recursive CTEs
MAX_ROWS_PROCESSED
Maximum number of rows to process in a single query execution
MAX_TABLES_IN_JOIN
Maximum number of tables in a single join operation
MEMORY_WARNING_BYTES