Overview

LaiRu 0.1 includes a first-pass MySQL driver accessed through Lasso’s inline() syntax. The DBAL boundary is defined so language-level inline behaviour has a stable integration point while MySQL compatibility work continues. FileMaker execution is represented at the boundary but remains parked.

Registering a Datasource

db_datasource('contacts')

Datasource connection details are supplied via configuration or environment. The runtime maps named inline parameters onto an internal InlineRequest and dispatches to the appropriate driver.

inline() Syntax

Search (SELECT)

inline(
  -database = 'contacts',
  -table    = 'people',
  -search,
  -lastname = 'Lovelace'
)

inline_result_row_count      // rows returned
inline_result_found_count    // total matching rows
inline_result_rows           // array of row maps

Pagination

inline(
  -database   = 'contacts',
  -table      = 'people',
  -search,
  -maxRecords = 20,
  -skipRecords = 40
)

Find all rows

inline(-database='contacts', -table='people', -findAll)

Add a record

inline(
  -database  = 'contacts',
  -table     = 'people',
  -add,
  -firstname = 'Ada',
  -lastname  = 'Lovelace'
)

Raw SQL

An explicit -sql parameter takes precedence over generated search SQL:

inline(
  -database = 'contacts',
  -sql      = 'SELECT id, name FROM people WHERE active = 1 ORDER BY name'
)

Prepared Statements

inline(
  -database = 'contacts',
  -sql      = 'SELECT id, name FROM people WHERE lastname = ?',
  -prepare,
  -params   = array('Lovelace')
)

Common scalar parameter and result types are supported. The binary protocol correctly handles unsigned integer column flags and TIME values (including hour-overflow and negative intervals).

Transactions

inline(-database='contacts', -begin)

inline(
  -database = 'contacts',
  -sql      = 'UPDATE accounts SET balance = balance - 100 WHERE id = 1'
)
inline(
  -database = 'contacts',
  -sql      = 'UPDATE accounts SET balance = balance + 100 WHERE id = 2'
)

inline(-database='contacts', -transaction='commit')
// or: -transaction='rollback'

inline_context

inline_context scopes default parameters so you don’t repeat them on every inline call inside the block:

inline_context(-database='contacts', -table='people') => {
  inline(-search, -lastname='Lovelace')
  // inline_result_rows available here
  inline(-add, -firstname='Charles', -lastname='Babbage')
}

Result Helpers

MethodReturns
inline_result_row_countNumber of rows returned.
inline_result_found_countTotal matching rows (for pagination).
inline_result_column_countNumber of columns.
inline_result_rowsArray of row maps.
inline_result_first_rowFirst row map.
inline_result_row(result, n)1-based row lookup.
inline_result_column_values(result, name)Array of values for a named column.
inline_result_column_namesColumn name array.
inline_result_table_namesTable name array.
inline_result_schema_namesSchema name array.
inline_result_qualified_column_namesFully qualified column names.
inline_result_columns_by_tableMap of table → column list.
inline_result_transaction_statusTransaction status map.
inline_result_in_transactionTrue if a transaction is active.

Connection Options

MySQL connections support TCP, unix socket, and TLS:

OptionDescription
TCPHostname and port connection.
Unix socketLocal socket path (Linux).
require_tlsEnforce TLS for TCP connections (OpenSSL-backed).
SET NAMESCharset configuration applied on connect.
SET time_zoneTimezone applied on connect.

Authentication methods supported

Connection Pooling

Pooling is off by default. db_pool_configure(n) enables handle reuse. Before returning a handle to the idle pool, LaiRu sends COM_RESET_CONNECTION and reapplies datasource session setup (charset, timezone, session variables). Handles are discarded — not pooled — when autocommit is off, a transaction is active, or reset fails.

db_pool_configure(8)    // enable pooling with max 8 idle handles
db_pool_stats           // map with 'pooled_handles', etc.
db_pool_config          // current pool configuration

For servers that do not support COM_RESET_CONNECTION, configure the datasource with the disconnect reset policy: handles are closed instead of pooled, while global pooling remains enabled for other datasources.