-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Summary
SQLite's mathematical functions are disabled by default and require the SQLITE_ENABLE_MATH_FUNCTIONS compile-time flag to be enabled. This proposal enables this flag in ProxySQL's SQLite build configuration to provide users with access to mathematical functions in SQL queries through ProxySQL's SQLite interface.
Background
ProxySQL uses SQLite for:
- Admin interface queries
- Query rules processing
- Statistics and monitoring data storage
- Internal configuration storage
Currently, SQLite is compiled without SQLITE_ENABLE_MATH_FUNCTIONS, meaning functions like sin(), cos(), log(), pow(), sqrt(), etc., are unavailable in SQL queries.
Benefits
- Enhanced SQL Capabilities: Users can perform mathematical operations directly in SQL queries
- Statistical Calculations: Enable more complex query rules and data transformations
- Standard SQLite Feature: Aligns with SQLite's standard feature set
- No Breaking Changes: Purely additive functionality
- Minimal Impact: Small binary size increase (~few KB)
Functions Enabled
- Trigonometric:
sin(),cos(),tan(),asin(),acos(),atan() - Logarithmic:
log(),log10(),ln() - Exponential:
exp(),power()/pow() - Other:
sqrt(),abs(),floor(),ceil(),round(), etc.
Implementation
Add -DSQLITE_ENABLE_MATH_FUNCTIONS to SQLite compilation flags in deps/Makefile:
# Current
-DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_DLL=1
# Proposed
-DSQLITE_ENABLE_MEMORY_MANAGEMENT -DSQLITE_ENABLE_JSON1 -DSQLITE_DLL=1 -DSQLITE_ENABLE_MATH_FUNCTIONSTesting
- Verify mathematical functions work in admin SQLite interface
- Ensure backward compatibility with existing queries
- Test sample queries using math functions
Related
This change has already been implemented in branch v3.0-misc251220 for evaluation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels