sql_render Interface

interface

Tokenise one source line. Always succeeds for well-formed tokens; reports SQR_INVALID with errmsg (carrying the offending column) for an unterminated string or a stray character. toks(1:ntok) are the tokens; a trailing TK_EOF is not appended (callers use ntok). Parse one statement. Recursive descent into sql_stmt_t. A trailing ; is permitted. Reports SQR_INVALID with a column-anchored errmsg on a syntax error. Execute one parsed statement against an open database, choosing an index-driven or scan-driven plan as appropriate, and fill res. Engine errors propagate through stat/errmsg. db is target because the transaction façade the executor calls needs it. Convenience: lex + parse + execute one source line. Equivalent to sql_parse then sql_exec. Render a result to a formatted unit: an aligned table for a SELECT, a "N row(s)" line for DML, or the message for DDL. Used by the REPL; tests inspect sql_result_t directly instead.


public module subroutine sql_render(res, unit)

Arguments

Type IntentOptional Attributes Name
type(sql_result_t), intent(in) :: res

Result to print

integer, intent(in) :: unit

Output unit