WASM Procedures: API Reference (Planned Design)
Documentation Home > User Guides > Features > API Reference
Overview
Planned API reference for the upcoming HeliosDB WASM Procedures feature, including SQL statements, host functions, and error codes. The SQL statements below are the planned syntax and are not accepted by the current server.
Related Sections:
- Host Functions - Detailed host function documentation
- Procedure Management - Managing procedures
- Language SDKs - SDK-specific APIs
API Reference
SQL Statements
CREATE PROCEDURE
-- Planned syntax for the upcoming WASM procedures feature; the current server does not accept it.CREATE [OR REPLACE] PROCEDURE name (params)[RETURNS type]LANGUAGE wasm[SECURITY PROFILE 'profile'][WITH (options)]AS source;Options:
precompile: boolean - Precompile modulecompilation_tier: ‘interpreter’ | ‘baseline’ | ‘optimizing’fuel_metering: boolean - Enable fuel meteringfuel_limit: integer - Fuel limitprofiling: boolean - Enable profilingdebug_mode: boolean - Enable debug mode
ALTER PROCEDURE
-- Planned syntax for the upcoming WASM procedures feature; the current server does not accept it.ALTER PROCEDURE name SET SOURCE '/path/to/new.wasm' | SET SECURITY PROFILE 'profile' | SET log_level = 'level' | SET option = value;DROP PROCEDURE
DROP PROCEDURE [IF EXISTS] name [CASCADE];CALL
CALL procedure_name(args);SELECT procedure_name(args);Host Function Reference
The WASM host links its functions in the env import module:
heliosdb_execute, heliosdb_begin_tx, heliosdb_commit_tx,
heliosdb_rollback_tx, heliosdb_storage_write, heliosdb_log,
heliosdb_query, heliosdb_storage_read, heliosdb_fetch_rows and
heliosdb_emit_event. There are no HTTP, metrics or capability-request host
functions. Signatures, return codes and the matching Go SDK calls are in
Host Functions.
Error Codes
| Code | Name | Description |
|---|---|---|
| 01000 | WASM_COMPILATION_ERROR | Failed to compile WASM module |
| 01001 | WASM_INSTANTIATION_ERROR | Failed to instantiate module |
| 01002 | WASM_EXECUTION_ERROR | Procedure execution failed |
| 01003 | WASM_TIMEOUT | Execution exceeded time limit |
| 01004 | WASM_MEMORY_EXCEEDED | Memory limit exceeded |
| 01005 | WASM_FUEL_EXHAUSTED | Fuel limit exhausted |
| 01006 | WASM_SECURITY_VIOLATION | Security capability violation |
| 01007 | WASM_PERMISSION_DENIED | Permission denied |
| 01008 | WASM_INVALID_PARAMETER | Invalid parameter |
| 01009 | WASM_MODULE_NOT_FOUND | Procedure not found |
System Catalogs
heliosdb_procedures
Information about all procedures:
SELECT * FROM heliosdb_procedures;Columns:
name: Procedure namelanguage: ‘wasm’security_profile: Security profile namesize_bytes: WASM module sizecreated_at: Creation timestamplast_modified: Last modification timestampversion: Current version
heliosdb_procedure_metrics
Performance metrics:
SELECT * FROM heliosdb_procedure_metrics;Columns:
procedure_name: Procedure nametotal_calls: Total number of callssuccessful_calls: Successful executionsfailed_calls: Failed executionssuccess_rate: Success rate percentageavg_execution_time_ms: Average execution timemin_execution_time_ms: Minimum execution timemax_execution_time_ms: Maximum execution timep50_execution_time_ms: 50th percentilep95_execution_time_ms: 95th percentilep99_execution_time_ms: 99th percentile
heliosdb_procedure_errors
Error tracking:
SELECT * FROM heliosdb_procedure_errors;Columns:
procedure_name: Procedure nameerror_message: Error messageerror_count: Number of occurrenceslast_occurrence: Last occurrence timestampstack_trace: Stack trace (if available)source_location: Source code location
heliosdb_procedure_logs
Procedure logs:
SELECT * FROM heliosdb_procedure_logs;Columns:
timestamp: Log timestampprocedure_name: Procedure namelog_level: Log level (trace, debug, info, warn, error)message: Log messageexecution_id: Execution identifier
heliosdb_wasm_cache_stats
Module cache statistics:
SELECT * FROM heliosdb_wasm_cache_stats;Columns:
cached_modules: Number of cached modulescache_hits: Cache hitscache_misses: Cache misseshit_rate: Hit rate percentageevictions: Number of evictions
heliosdb_wasm_pool_stats
Instance pool statistics:
SELECT * FROM heliosdb_wasm_pool_stats;Columns:
procedure_name: Procedure namepool_size: Configured pool sizeavailable_instances: Available instancesin_use_instances: Instances in usetotal_acquisitions: Total acquisitionsavg_acquisition_time_ms: Average acquisition time
Configuration Parameters
Global Settings
-- Cache configurationSET heliosdb.wasm_module_cache_size = 1000;SET heliosdb.wasm_module_cache_ttl = 3600;SET heliosdb.wasm_module_cache_enabled = true;
-- Pool configurationSET heliosdb.wasm_instance_pool_size = 10;SET heliosdb.wasm_instance_max_age_seconds = 300;SET heliosdb.wasm_instance_max_executions = 1000;
-- Memory configurationSET heliosdb.wasm_memory_pool_size_mb = 1024;SET heliosdb.wasm_memory_pooling_enabled = true;
-- Logging configurationSET heliosdb.procedure_log_level = 'info';SET heliosdb.procedure_log_retention_days = 30;
-- Execution limitsSET heliosdb.wasm_default_fuel_limit = 1000000000;SET heliosdb.wasm_default_memory_limit_mb = 512;SET heliosdb.wasm_default_timeout_ms = 30000;Procedure-Specific Settings
-- Planned syntax for the upcoming WASM procedures feature; the current server does not accept it.ALTER PROCEDURE my_procedure SET fuel_limit = 10000000000 SET fuel_metering = false SET compilation_tier = 'optimizing' SET profiling = true SET debug_mode = false SET log_level = 'info';Key Takeaways
- Complete SQL API: Full DDL support for procedure management
- Rich Host Functions: 40+ host functions across 8 categories
- System Catalogs: Comprehensive metadata and metrics
- Error Codes: Standardized error codes for diagnostics
- Configuration: Flexible global and per-procedure settings
Quick Reference
Create Procedure:
-- Planned syntax for the upcoming WASM procedures feature; the current server does not accept it.CREATE PROCEDURE name(params) RETURNS type LANGUAGE wasm AS source;Call Procedure:
SELECT procedure_name(args);View Metrics:
SELECT * FROM heliosdb_procedure_metrics WHERE procedure_name = 'name';View Errors:
SELECT * FROM heliosdb_procedure_errors WHERE procedure_name = 'name';Next Steps
- Host Functions - Detailed host function documentation
- Language SDKs - SDK-specific APIs
- Conclusion - Summary and resources
Navigation: ← Migration Guide | Index | Conclusion →