Fun 0.41.5
The programming language that makes you have fun!
Loading...
Searching...
No Matches
query.c File Reference

Implements the OP_SQLITE_QUERY opcode (conditional build). More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 free_value (vh)
 free_value (vsql)
 if (!h||!h->db||!sql)
 if (sqlite3_prepare_v2(h->db, sql, -1, &stmt, NULL) !=SQLITE_OK)
 free (sql)
 while (sqlite3_step(stmt)==SQLITE_ROW)
 sqlite3_finalize (stmt)
 push_value (vm, rows)

Variables

case OP_SQLITE_QUERY
Value vh = pop_value(vm)
int hid = (int)vh.i
char * sql = value_to_string_alloc(&vsql)
SqlHandleh = sql_reg_get(hid)
sqlite3_stmt * stmt = NULL
Value rows = make_array_from_values(NULL, 0)
int ncols = sqlite3_column_count(stmt)
 break

Detailed Description

Implements the OP_SQLITE_QUERY opcode (conditional build).

Prepares and steps through a SQLite statement to produce an array of row maps when FUN_WITH_SQLITE is enabled. Returns an empty array otherwise.

OP_SQLITE_QUERY: (handle:int, sql:string) -> array<map<string,any>>

Definition in file query.c.

Function Documentation

◆ free()

free ( sql )

◆ free_value() [1/2]

free_value ( vh )

◆ free_value() [2/2]

free_value ( vsql )

◆ if() [1/2]

if ( !h||!h->db||! sql)

Definition at line 29 of file query.c.

◆ if() [2/2]

if ( sqlite3_prepare_v2(h->db, sql, -1, &stmt, NULL) ! = SQLITE_OK)

Definition at line 35 of file query.c.

◆ push_value()

push_value ( vm ,
rows  )

◆ sqlite3_finalize()

sqlite3_finalize ( stmt )

◆ while()

while ( sqlite3_step(stmt) = = SQLITE_ROW)

Definition at line 43 of file query.c.

Variable Documentation

◆ break

break

Definition at line 82 of file query.c.

◆ h

Definition at line 28 of file query.c.

◆ hid

int hid = (int)vh.i

Definition at line 24 of file query.c.

◆ ncols

int ncols = sqlite3_column_count(stmt)

Definition at line 42 of file query.c.

◆ OP_SQLITE_QUERY

case OP_SQLITE_QUERY

Definition at line 20 of file query.c.

◆ rows

Value rows = make_array_from_values(NULL, 0)

Definition at line 41 of file query.c.

◆ sql

char* sql = value_to_string_alloc(&vsql)

Definition at line 25 of file query.c.

◆ stmt

sqlite3_stmt* stmt = NULL

Definition at line 34 of file query.c.

◆ vh

Value vh = pop_value(vm)

Definition at line 23 of file query.c.