Library Reference¶
The following is the full API reference generated from the C++ source documentation.
-
struct AlterStmt : public xmdb::SQL::Stmt¶
- #include <ast.hpp>
Base class for ALTER statements.
Subclassed by xmdb::SQL::AlterUserStmt
Public Types
-
class AlterUserNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing a user property alteration.
-
struct AlterUserStmt : public xmdb::SQL::AlterStmt¶
- #include <ast.hpp>
Represents an ALTER USER statement.
Public Members
Public Static Functions
-
static inline AlterUserStmt *alloc(ok::Allocator *allocator, Token token, ok::StringView name, ok::Slice<SetClause> set_clauses)¶
Allocates a new AlterUserStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
name – The name of the user.
set_clauses – The changes to apply.
- Returns:
Pointer to the new AlterUserStmt.
-
static inline AlterUserStmt *alloc(ok::Allocator *allocator, Token token, ok::StringView name, ok::Slice<SetClause> set_clauses)¶
-
class ArgParser¶
Public Functions
-
ArgParser &string(const char *name, const char **dest, const char *description, const char *default_value = nullptr)¶
-
ArgParser &integer(const char *name, S64 *dest, const char *description, ok::Optional<S64> default_value = {})¶
-
bool parse()¶
-
void help()¶
-
void dealloc()¶
-
inline ~ArgParser()¶
Private Functions
-
ArgParser &string(const char *name, const char **dest, const char *description, const char *default_value = nullptr)¶
-
class AtomicNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing a collection of operations that must be performed atomically.
Public Functions
-
struct BinaryOpExpr : public xmdb::SQL::Expr¶
- #include <ast.hpp>
Represents a binary operation expression.
Public Types
Public Members
Public Static Functions
-
static inline BinaryOpExpr *alloc(ok::Allocator *allocator, Token token, Kind kind, Expr *lhs, Expr *rhs)¶
Allocates a new BinaryOpExpr.
- Parameters:
allocator – The allocator to use.
token – The associated token.
kind – The kind of binary operation.
lhs – Left-hand side operand.
rhs – Right-hand side operand.
- Returns:
Pointer to the new BinaryOpExpr.
-
static inline BinaryOpExpr *alloc(ok::Allocator *allocator, Token token, Kind kind, Expr *lhs, Expr *rhs)¶
-
struct BTreeIndex¶
- #include <BTreeIndex.hpp>
A B-Tree index for efficient key-value lookups and storage.
Public Functions
-
void insert(U64 key)¶
Inserts a key into the index.
- Parameters:
key – The key to insert.
-
bool contains(U64 key)¶
Checks if the index contains a specific key.
- Parameters:
key – The key to look for.
- Returns:
true if found, false otherwise.
-
bool remove(U64 key)¶
Removes a key from the index.
- Parameters:
key – The key to remove.
- Returns:
true if successful, false otherwise.
-
bool first_constructed()¶
Checks if the index was just first_constructed.
- Returns:
true if it was first_constructed, false otherwise.
-
UZ order()¶
Gets the order of the B-Tree.
- Returns:
The order.
-
U64 height()¶
Gets the height of the B-Tree.
- Returns:
The height.
-
U64 node_count()¶
Gets the total number of nodes in the B-Tree.
- Returns:
The node count.
-
U64 total_kv_count()¶
Gets the total number of key-value pairs in the index.
- Returns:
The KV count.
-
bool reset()¶
Resets the index, clearing all data.
- Returns:
true if successful, false otherwise.
Public Members
-
void *pImpl¶
Pointer to the internal implementation.
Public Static Functions
-
static ok::Optional<ok::File::OpenError> create(ok::Allocator *allocator, ok::StringView state_filename, BTreeIndex *index)¶
Creates a new BTreeIndex from a state file.
- Parameters:
allocator – The allocator to use.
state_filename – The path to the state file.
index – Pointer to store the resulting index.
- Returns:
An optional open error if the operation failed.
-
static BTreeIndex create(ok::Allocator *allocator, ok::File state_file)¶
Creates a BTreeIndex from an already open state file.
- Parameters:
allocator – The allocator to use.
state_file – The open state file.
- Returns:
The resulting BTreeIndex.
-
void insert(U64 key)¶
-
struct BTreeState¶
Public Functions
-
inline void free() const¶
-
inline bool remove(U64 key)¶
-
inline void save_header_to_disk()¶
-
inline void insert(U64 key)¶
-
inline void free() const¶
-
struct CallExpr : public xmdb::SQL::Expr¶
- #include <ast.hpp>
Represents a function call expression.
Public Members
Public Static Functions
-
static inline CallExpr *alloc(ok::Allocator *allocator, Token token, Expr *fn, ok::Slice<Expr*> args)¶
Allocates a new CallExpr.
- Parameters:
allocator – The allocator to use.
token – The associated token.
fn – The function expression.
args – The arguments to the function call.
- Returns:
Pointer to the new CallExpr.
-
static inline CallExpr *alloc(ok::Allocator *allocator, Token token, Expr *fn, ok::Slice<Expr*> args)¶
-
class CallNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing a function call.
-
struct CatalogDBEntry¶
-
struct CatalogHeader¶
-
struct CatalogTableEntry¶
-
struct CatalogUserEntry¶
-
struct ChunkIndices¶
- #include <image.hpp>
Stores indices of image chunks.
Public Members
-
U8 count¶
The number of chunk indices.
-
U32 items[MAX_DISK_IMAGE_CHUNKS_COUNT]¶
The chunk indices.
-
U8 count¶
-
struct ColumnAttribute¶
- #include <DBTable.hpp>
Attributes of a column.
Public Members
-
ImageColumnState image_state¶
State for image columns.
-
union xmdb::ColumnAttribute u¶
-
ImageColumnState image_state¶
-
class ColumnDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
A DBValue representing a column in a specific table.
Public Functions
-
inline ColumnDBValue(SQL::Type type, ColumnLayout layout, DBTable *table)¶
Constructs a new ColumnDBValue.
- Parameters:
type – The SQL type of the column.
layout – The layout of the column.
table – The table the column belongs to.
-
inline DBTable *table()¶
Gets the table this column value belongs to.
- Returns:
Pointer to the table.
-
inline ColumnLayout layout()¶
Gets the layout of the column.
- Returns:
The column layout.
-
inline ColumnDBValue(SQL::Type type, ColumnLayout layout, DBTable *table)¶
-
class ColumnDescriptor¶
- #include <TableStream.hpp>
Describes a column in a row.
Public Functions
-
explicit ColumnDescriptor(RowDescriptor &row_desc, U64 index)¶
Constructs a new ColumnDescriptor.
- Parameters:
row_desc – Reference to the row descriptor this column belongs to.
index – The index of the column.
-
inline U64 index() const¶
Gets the column index.
- Returns:
The index.
-
explicit ColumnDescriptor(RowDescriptor &row_desc, U64 index)¶
-
struct ColumnLayout¶
- #include <ColumnLayout.hpp>
Layout information for a single column in a table record.
-
struct ColumnStream¶
-
class CompareDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
A DBValue representing a comparison between two other values.
-
struct CompiledQuery¶
- #include <ir.hpp>
Represents a compiled SQL query in IR.
Public Members
-
Slice<IRInstruction> instructions¶
The instructions.
-
Slice<String> strings¶
The strings.
-
Slice<S64> integers¶
The integers.
-
Slice<TableSchema*> schemas¶
The schemas.
-
Slice<IRInstruction> instructions¶
-
struct ComputationStream¶
-
class ConcatDBValue : public xmdb::PairDBValue¶
- #include <DBValue.hpp>
A DBValue representing the concatenation of two values.
-
struct Config¶
-
struct ConnectionData¶
-
class ConstDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
A DBValue representing a constant (literal) value.
Public Types
Public Functions
-
inline explicit ConstDBValue(S64 i)¶
Constructs a constant integer value.
- Parameters:
i – The integer value.
-
inline explicit ConstDBValue(ok::String *s)¶
Constructs a constant string value.
- Parameters:
s – Pointer to the string value.
-
inline explicit ConstDBValue(bool b)¶
Constructs a constant boolean value.
- Parameters:
b – The boolean value.
-
inline S64 as_int() const¶
Retrieves the value as an integer.
- Returns:
The integer value.
-
inline bool as_bool() const¶
Retrieves the value as a boolean.
- Returns:
The boolean value.
-
inline explicit ConstDBValue(S64 i)¶
-
struct CreateDatabaseStmt : public xmdb::SQL::CreateStmt¶
- #include <ast.hpp>
Represents a CREATE DATABASE statement.
Public Static Functions
-
static inline CreateDatabaseStmt *alloc(ok::Allocator *allocator, Token token, ok::String name)¶
Allocates a new CreateDatabaseStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
name – The name of the database.
- Returns:
Pointer to the new CreateDatabaseStmt.
-
static inline CreateDatabaseStmt *alloc(ok::Allocator *allocator, Token token, ok::String name)¶
-
struct CreateStmt : public xmdb::SQL::Stmt¶
- #include <ast.hpp>
Base class for CREATE statements.
Subclassed by xmdb::SQL::CreateDatabaseStmt, xmdb::SQL::CreateTableStmt, xmdb::SQL::CreateUserStmt
Public Types
-
struct CreateTableStmt : public xmdb::SQL::CreateStmt¶
- #include <ast.hpp>
Represents a CREATE TABLE statement.
Public Members
Public Static Functions
-
static inline CreateTableStmt *alloc(ok::Allocator *allocator, Token token, ok::String name, ok::Slice<ok::String> column_names, ok::Slice<ok::String> column_types)¶
Allocates a new CreateTableStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
name – The name of the table.
column_names – The names of the columns.
column_types – The types of the columns.
- Returns:
Pointer to the new CreateTableStmt.
-
static inline CreateTableStmt *alloc(ok::Allocator *allocator, Token token, ok::String name, ok::Slice<ok::String> column_names, ok::Slice<ok::String> column_types)¶
-
struct CreateUserStmt : public xmdb::SQL::CreateStmt¶
- #include <ast.hpp>
Represents a CREATE USER statement.
Public Static Functions
-
static inline CreateUserStmt *alloc(ok::Allocator *allocator, Token token, ok::String name)¶
Allocates a new CreateUserStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
name – The name of the user.
- Returns:
Pointer to the new CreateUserStmt.
-
static inline CreateUserStmt *alloc(ok::Allocator *allocator, Token token, ok::String name)¶
-
struct DBConnection¶
- #include <DBConnection.hpp>
Represents an active connection to a database.
Public Functions
-
explicit DBConnection(DBPool *pool, DBDescriptor *db, DBUser *user)¶
Constructs a new DBConnection.
- Parameters:
pool – The database pool this connection belongs to.
db – The database descriptor for this connection.
user – The user associated with this connection.
-
void execute(SQL::TypedCompiledQuery *query, QueryResults *results)¶
Executes a compiled SQL query.
- Parameters:
query – The compiled query to execute.
results – Pointer to a structure where results will be stored.
-
void close()¶
Closes the connection and releases resources.
-
explicit DBConnection(DBPool *pool, DBDescriptor *db, DBUser *user)¶
-
struct DBDescriptor¶
- #include <DBDescriptor.hpp>
Describes a database and manages its tables and users.
Public Functions
-
inline void add_user(DBUser *user)¶
Adds a user to the database.
- Parameters:
user – The user to add.
-
inline Optional<DBUser*> find_user(StringView name)¶
Finds a user by name.
- Parameters:
name – The name of the user to find.
- Returns:
An optional containing the user if found, or empty otherwise.
-
DBTable *create_new_table(ok::Allocator *allocator, ok::StringView name, DBTable::Flags flags, UZ column_count, ok::Slice<ok::StringView> column_names, ok::Slice<SQL::ColumnType> column_types)¶
Creates a new table in the database.
- Parameters:
allocator – The allocator to use for the table.
name – The name of the table.
flags – The table flags (e.g., storage type).
column_count – The number of columns in the table.
column_names – The names of the columns.
column_types – The types of the columns.
- Returns:
A pointer to the newly created table.
-
Result<DBTable*, ok::String> load_existing_table(ok::Allocator *allocator, ok::StringView name, DBTable::Flags flags, UZ column_count, ok::Slice<ok::StringView> column_names, ok::Slice<SQL::ColumnType> column_types)¶
Loads an existing table from disk.
- Parameters:
allocator – The allocator to use for the table.
name – The name of the table.
flags – The table flags (e.g., storage type).
column_count – The number of columns in the table.
column_names – The names of the columns.
column_types – The types of the columns.
- Returns:
A result with an allocated table on success, an error string otherwise.
Public Members
-
DBDescriptor *next¶
Pointer to the next database descriptor in a list.
Public Static Functions
-
static DBDescriptor *alloc(ok::Allocator *allocator, ok::StringView name)¶
Allocates a new DBDescriptor.
- Parameters:
allocator – The allocator to use for the descriptor.
name – The name of the database.
- Returns:
A pointer to the newly allocated DBDescriptor.
-
inline void add_user(DBUser *user)¶
-
struct DBPool¶
- #include <DBPool.hpp>
Manages a pool of databases and execution contexts.
Public Types
Values:
-
enumerator F_EPHEMERAL¶
No catalog data will be loaded or stored.
-
enumerator F_EPHEMERAL¶
-
using Flags = U16¶
Public Functions
-
DBPool(ok::Allocator *allocator, Flags flags = 0)¶
Constructs a new DBPool.
- Parameters:
allocator – The allocator to use for pool resources.
flags – Flags for this pool.
-
DBDescriptor *get_db(StringView name)¶
Retrieves a database descriptor by name.
- Parameters:
name – The name of the database.
- Returns:
A pointer to the database descriptor, or nullptr if not found.
-
DBDescriptor *create_db(StringView name)¶
Creates a new database with the given name.
- Parameters:
name – The name of the new database.
- Returns:
A pointer to the newly created database descriptor.
-
QueryExecutionContext *rent_empty_execution_context(DBDescriptor *db, DBUser *user)¶
Rents an empty execution context for a specific database and user.
- Parameters:
db – The database to use for execution.
user – The user associated with the execution.
- Returns:
A pointer to the rented execution context.
-
void return_execution_context(QueryExecutionContext *context)¶
Returns an execution context to the pool.
- Parameters:
context – The execution context to return.
Public Members
-
QueryExecutionContext *execution_contexts¶
List of available execution contexts.
-
DBDescriptor *db_descriptors¶
List of database descriptors.
-
struct DBRecord¶
- #include <DBRecord.hpp>
Represents a single record (row) in a database table.
-
struct DBSchema¶
- #include <ir.hpp>
Represents a database schema in the IR.
Public Functions
-
inline TableSchema *alloc_table_schema(Optional<String> name, bool typed)¶
Allocates a new TableSchema within this DBSchema.
- Parameters:
name – The name of the table.
typed – Whether the schema is typed.
- Returns:
Pointer to the new TableSchema.
Public Members
-
U32 table_schema_count¶
Number of table schemas.
-
Allocator *allocator¶
The allocator.
-
TableSchema *table_schemas¶
Pointer to the array of table schemas.
-
String name¶
Name of the database.
-
Table<String, U32> table_schemas_index¶
Mapping of names to indices.
-
inline TableSchema *alloc_table_schema(Optional<String> name, bool typed)¶
-
struct DBState¶
- #include <state.hpp>
Represents the persistent state of a database table.
Public Members
-
DBStateHeader header¶
The state header.
-
DBStateHeader header¶
-
class DBTable¶
- #include <DBTable.hpp>
Represents a database table, managing its metadata and data.
Public Types
Table flags indicating its nature and storage.
Values:
-
enumerator F_ANON¶
Anonymous table.
-
enumerator F_PERSIST¶
Persistent table (stored on disk).
-
enumerator F_PROXY¶
Proxy table (values are held externally).
-
enumerator F_EPHEMERAL¶
Ephemeral table (temporary).
-
enumerator F_ANON¶
-
using Flags = U16¶
Public Functions
-
DBTable(ok::Allocator *allocator, Flags flags, ok::StringView name, UZ column_count, ok::StringView *column_names, SQL::ColumnType *column_types)¶
Constructs a new DBTable.
- Parameters:
allocator – The allocator to use.
flags – The table flags.
name – The name of the table.
column_count – The number of columns.
column_names – The names of the columns.
column_types – The types of the columns.
-
DBTable(ok::Allocator *allocator, Flags flags, ok::StringView name, UZ column_count, ok::StringView *column_names, SQL::ColumnType *column_types, ColumnAttribute *column_attributes)¶
Constructs a new DBTable.
- Parameters:
allocator – The allocator to use.
flags – The table flags.
name – The name of the table.
column_count – The number of columns.
column_names – The names of the columns.
column_types – The types of the columns.
column_attributes – The attributes of the columns.
-
inline UZ columns_count() const¶
Gets the number of columns in the table.
- Returns:
The column count.
-
inline ok::Slice<ok::StringView> columns_names()¶
Gets the names of the columns.
- Returns:
A slice of column names.
-
inline ok::Slice<SQL::ColumnType> columns_types()¶
Gets the types of the columns.
- Returns:
A slice of column types.
-
inline TableLayout layout() const¶
Gets the table layout.
- Returns:
The layout.
-
inline UZ rows_count()¶
Gets the total number of rows in the table.
- Returns:
The row count.
-
inline void set_proxy_rows_count(UZ x)¶
Sets the row count for a proxy table.
- Parameters:
x – The row count.
-
inline void set_proxy_column_values(ok::Slice<DBValue*> values)¶
Sets the values for a proxy table’s columns.
- Parameters:
values – A slice of pointers to DBValue.
-
inline ok::Slice<DBValue*> proxy_column_values()¶
Gets the column values for a proxy table.
- Returns:
A slice of pointers to DBValue.
-
inline BTreeIndex *index()¶
Gets the B-Tree index for a persistent table.
- Returns:
Pointer to the index.
-
inline void set_index(BTreeIndex index)¶
Sets the B-Tree index for the table.
- Parameters:
index – The index to set.
-
inline void set_state(DBState state)¶
Sets the persistence state for the table.
- Parameters:
state – The state to set.
-
inline ok::Slice<ColumnAttribute> column_attributes()¶
Gets the attributes for each column.
- Returns:
A slice of column attributes.
Private Members
-
U16 m_flags¶
-
UZ m_columns_count¶
-
SQL::ColumnType *m_columns_types¶
-
TableLayout m_layout¶
-
ColumnAttribute *m_column_attributes¶
-
UZ m_proxy_rows_count¶
-
BTreeIndex m_index¶
-
class DBTableOutlet¶
- #include <DBTable.hpp>
Acts as an outlet for a DBTable, providing access to its columns as streams.
Public Functions
-
inline explicit DBTableOutlet(DBTable *table)¶
Constructs a new DBTableOutlet.
- Parameters:
table – The table to act as an outlet for.
-
inline DBTableStream column_stream(ok::Allocator *allocator, UZ i)¶
Creates a stream for a specific column in the table.
- Parameters:
allocator – The allocator to use for the stream.
i – The column index.
- Returns:
The resulting DBTableStream.
-
inline explicit DBTableOutlet(DBTable *table)¶
-
class DBTableStream¶
- #include <DBTable.hpp>
Provides a stream-like interface for pulling values out of different sources i.e. a DBTable or DBValue.
Public Types
Public Functions
-
inline explicit DBTableStream(ok::Allocator *allocator, ConstDBValue constant)¶
Constructs a DBTableStream from a constant value.
- Parameters:
allocator – The allocator to use.
constant – The constant value.
-
inline DBTableStream(ok::Allocator *allocator, Computation comp, void *arg)¶
Constructs a DBTableStream from a computation function.
- Parameters:
allocator – The allocator to use.
comp – The computation function.
arg – The argument to pass to the computation function.
-
inline DBTableStream(ok::Allocator *allocator, DBTable *table, UZ column_index)¶
Constructs a DBTableStream from a table column.
- Parameters:
allocator – The allocator to use.
table – The table to stream from.
column_index – The index of the column to stream.
Public Static Functions
-
static DBTableStream from_value(ok::Allocator *allocator, DBValue *value)¶
Creates a DBTableStream from a DBValue.
- Parameters:
allocator – The allocator to use.
value – The value to stream from.
- Returns:
The resulting stream.
-
inline explicit DBTableStream(ok::Allocator *allocator, ConstDBValue constant)¶
-
struct DBUser¶
- #include <DBUser.hpp>
Represents a database user with specific permissions.
Public Functions
Public Members
-
SHA256Digest sha256_password_digest¶
The SHA-256 digest of the user’s password.
-
U8 perm¶
The user’s permissions bitfield.
-
SHA256Digest sha256_password_digest¶
-
class DBValue¶
- #include <DBValue.hpp>
Abstract base class for database values used in query planning and execution.
Subclassed by xmdb::ColumnDBValue, xmdb::CompareDBValue, xmdb::ConstDBValue, xmdb::DelayedDBValue, xmdb::ImageDataDBValue, xmdb::NoneDBValue, xmdb::PairDBValue
Public Types
Public Functions
-
DBValue() = delete¶
Public Static Functions
-
DBValue() = delete¶
-
class DelayedDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
A DBValue whose underlying value is determined later during execution.
Public Functions
-
inline explicit DelayedDBValue()¶
Constructs a new DelayedDBValue.
-
inline explicit DelayedDBValue()¶
-
struct DeleteStmt : public xmdb::SQL::Stmt¶
- #include <ast.hpp>
Represents a DELETE statement.
Public Members
Public Static Functions
-
static inline DeleteStmt *alloc(ok::Allocator *allocator, Token token, Expr *table, ok::Optional<Expr*> filter)¶
Allocates a new DeleteStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
table – The table expression.
filter – The filter expression.
- Returns:
Pointer to the new DeleteStmt.
-
static inline DeleteStmt *alloc(ok::Allocator *allocator, Token token, Expr *table, ok::Optional<Expr*> filter)¶
-
class DeleteTableNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing a table deletion.
-
struct DiskHeader¶
Public Members
-
U64 magic¶
-
U16 version¶
-
U64 index_nodes_count¶
-
U64 kv_count¶
-
U64 payload_length¶
-
U64 height¶
Public Static Functions
-
static inline DiskHeader *alloc(ok::Allocator *allocator)¶
-
U64 magic¶
-
struct DiskNode¶
Public Members
-
bool is_leaf¶
-
bool is_root¶
-
U64 keys_count¶
-
U64 keys[BTREE_MAX_KEYS]¶
-
U64 children[BTREE_MAX_CHILDREN]¶
-
bool is_leaf¶
-
class DiskStore : public xmdb::Store¶
- #include <TableStream.hpp>
Disk-based storage backend.
-
struct DropStmt : public xmdb::SQL::Stmt¶
- #include <ast.hpp>
Represents a DROP statement.
Public Types
Public Members
Public Static Functions
-
static inline DropStmt *alloc(ok::Allocator *allocator, Token token, Target target, ok::String name)¶
Allocates a new DropStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
target – The target of the DROP operation.
name – The name of the target.
- Returns:
Pointer to the new DropStmt.
-
static inline DropStmt *alloc(ok::Allocator *allocator, Token token, Target target, ok::String name)¶
-
class EmitQueryNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing the emission of a query’s result set.
Public Functions
-
inline EmitQueryNode(Allocator *allocator, Slice<DBTable*> queried_tables, Slice<StringView> column_names, Slice<DBValue*> column_values, Slice<SQL::ColumnType> column_types)¶
-
inline EmitQueryNode(Allocator *allocator, Slice<DBTable*> queried_tables, Slice<StringView> column_names, Slice<DBValue*> column_values, Slice<SQL::ColumnType> column_types)¶
-
struct ErrorWithSourceLocation¶
- #include <util.hpp>
Represents an error message paired with its source location.
Public Members
-
SourceLocation location¶
The location in the source code where the error occurred.
-
SourceLocation location¶
-
struct Expr¶
- #include <ast.hpp>
Base class for all SQL expressions in the AST.
Subclassed by xmdb::SQL::BinaryOpExpr, xmdb::SQL::CallExpr, xmdb::SQL::IdentifierExpr, xmdb::SQL::IntegerExpr, xmdb::SQL::SelectExpr, xmdb::SQL::StarExpr, xmdb::SQL::StringExpr
Public Types
-
enum Type¶
Types of SQL expressions.
Values:
-
enumerator IDENT¶
Identifier.
-
enumerator INTEGER_LIT¶
Integer literal.
-
enumerator STRING_LIT¶
String literal.
-
enumerator TRUE_LIT¶
Boolean TRUE literal.
-
enumerator FALSE_LIT¶
Boolean FALSE literal.
-
enumerator NULL_LIT¶
NULL literal.
-
enumerator BINARY_OP¶
Binary operation.
-
enumerator SELECT¶
SELECT expression.
-
enumerator STAR¶
Star (‘*’) expression.
-
enumerator CALL¶
Function call expression.
-
enumerator IDENT¶
Public Functions
-
U64 ok_hash_value() const¶
Computes a hash value for the expression.
- Returns:
The hash value.
Public Members
Public Static Functions
-
static inline Expr *alloc_true(ok::Allocator *allocator, Token token)¶
Allocates a TRUE literal expression.
- Parameters:
allocator – The allocator to use.
token – The associated token.
- Returns:
Pointer to the new Expr.
-
enum Type¶
-
struct FileLogger : public xmdb::Logger¶
- #include <Logger.hpp>
A logger that outputs to a FILE* handle.
Public Functions
-
inline FileLogger(LogLevel lvl, FILE *file)¶
Constructs a new FileLogger.
- Parameters:
lvl – The minimum log level.
file – The file to log to.
-
inline FileLogger(LogLevel lvl, FILE *file)¶
-
struct FixedString¶
- #include <FixedString.hpp>
A string with a fixed maximum size, suitable for storage in table records.
Public Functions
Public Members
-
U8 count¶
Current number of characters in the string.
-
U8 count¶
-
struct FlagSpec¶
-
struct FunctionSignature¶
- #include <type_check.hpp>
Signature of a SQL function.
-
struct HttpServerState¶
-
struct IdentifierExpr : public xmdb::SQL::Expr¶
- #include <ast.hpp>
Represents an identifier expression (e.g. column name).
Public Static Functions
-
static inline IdentifierExpr *alloc(ok::Allocator *allocator, Token token, ok::StringView value)¶
Allocates a new IdentifierExpr.
- Parameters:
allocator – The allocator to use.
token – The associated token.
value – The identifier string.
- Returns:
Pointer to the new IdentifierExpr.
-
static inline IdentifierExpr *alloc(ok::Allocator *allocator, Token token, ok::StringView value)¶
-
class ImageDataDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
A DBValue representing raw image data.
Public Functions
-
inline ImageDataDBValue(U32 width, U32 height, ok::Slice<U8> data, PixelFormat format)¶
Constructs an image data value.
- Parameters:
width – The width of the image.
height – The height of the image.
data – The raw pixel data.
format – The pixel format.
-
inline U32 width()¶
Gets the width of the image.
- Returns:
The width.
-
inline U32 height()¶
Gets the height of the image.
- Returns:
The height.
-
inline PixelFormat format()¶
Gets the pixel format.
- Returns:
The format.
-
inline ImageDataDBValue(U32 width, U32 height, ok::Slice<U8> data, PixelFormat format)¶
-
class InsertNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing an insertion of rows into a table.
-
struct InsertStmt : public xmdb::SQL::Stmt¶
- #include <ast.hpp>
Represents an INSERT statement.
Public Members
Public Static Functions
-
static inline InsertStmt *alloc(ok::Allocator *allocator, Token token, ok::StringView table_name, ok::Slice<ok::String> columns, ok::Slice<Expr*> values, ok::Slice<uint32_t> values_counts)¶
Allocates a new InsertStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
table_name – The name of the table.
columns – The names of the columns.
values – The values to insert.
values_counts – The number of values per row.
- Returns:
Pointer to the new InsertStmt.
-
static inline InsertStmt *alloc(ok::Allocator *allocator, Token token, ok::StringView table_name, ok::Slice<ok::String> columns, ok::Slice<Expr*> values, ok::Slice<uint32_t> values_counts)¶
-
struct IntegerExpr : public xmdb::SQL::Expr¶
- #include <ast.hpp>
Represents an integer literal expression.
Public Members
-
int64_t value¶
The integer value.
Public Static Functions
-
static inline IntegerExpr *alloc(ok::Allocator *allocator, Token token, int64_t value)¶
Allocates a new IntegerExpr.
- Parameters:
allocator – The allocator to use.
token – The associated token.
value – The integer value.
- Returns:
Pointer to the new IntegerExpr.
-
int64_t value¶
-
struct IrContext¶
- #include <ir.hpp>
Context for compiling AST to IR.
Public Functions
-
IrContext() = default¶
-
inline explicit IrContext(Allocator *allocator, StringView source)¶
Constructs a new IrContext.
- Parameters:
allocator – The allocator to use.
source – The original SQL source.
-
inline DBSchema *active_db_schema()¶
Gets the active database schema.
- Returns:
Pointer to the active DBSchema.
-
inline Optional<TableSchema*> get_table_schema(U8 db_schema_id, StringView table_name)¶
Retrieves a TableSchema by its name within a database.
- Parameters:
db_schema_id – The ID of the database schema.
table_name – The name of the table.
- Returns:
Optional pointer to the TableSchema.
-
inline Optional<TableSchema*> get_table_schema_by_id(U32 id)¶
Retrieves a TableSchema by instruction ID.
- Parameters:
id – The instruction ID.
- Returns:
Optional pointer to the TableSchema.
-
inline TableSchema *alloc_table_schema(U8 db_schema_id, Optional<String> table_name, bool typed)¶
Allocates a new TableSchema.
- Parameters:
db_schema_id – The database schema ID.
table_name – The name of the table.
typed – Whether the schema is typed.
- Returns:
Pointer to the new TableSchema.
-
inline U32 current_table_id() const¶
Gets the ID of the current table.
- Returns:
The table ID.
-
inline void push_namespace(Namespace ns)¶
Pushes a new namespace.
- Parameters:
ns – The namespace to push.
-
inline void push_table(U32 table_id)¶
Pushes a table namespace.
- Parameters:
table_id – The ID of the table.
-
inline void pop_namespace()¶
Pops the current namespace.
-
IrContext() = default¶
-
template<typename T>
struct IRContractAdder¶
-
template<>
struct IRContractAdder<S64>¶
-
template<>
struct IRContractAdder<StringView>¶
-
template<>
struct IRContractAdder<TableSchema*>¶ Public Static Functions
-
static inline U32 add(IREmitter *emitter, TableSchema *schema)¶
-
static inline U32 add(IREmitter *emitter, TableSchema *schema)¶
-
template<>
struct IRContractAdder<U32>¶
-
template<typename T>
struct IRContractGetter¶ - #include <ir.hpp>
Template for getting operand values from the emitter store.
-
template<>
struct IRContractGetter<S64>¶
-
template<>
struct IRContractGetter<StringView>¶
-
template<>
struct IRContractGetter<TableSchema*>¶ Public Static Functions
-
template<typename Store>
static inline TableSchema *get(Store *emitter, U32 op)¶ Retrieves a table schema pointer from the emitter.
- Parameters:
emitter – The emitter.
op – The operand index.
- Returns:
The table schema pointer.
-
template<typename Store>
-
template<>
struct IRContractGetter<U32>¶
-
struct IREmitter¶
- #include <ir.hpp>
Emits IR instructions during compilation.
Public Functions
-
IREmitter() = default¶
-
inline explicit IREmitter(Allocator *allocator)¶
Constructs a new IREmitter.
- Parameters:
allocator – The allocator to use.
-
inline U32 gen_temp()¶
Generates a new unique temporary variable name.
- Returns:
Index of the name in the strings pool.
-
inline U32 add_string(String string)¶
Adds a string to the strings pool.
- Parameters:
string – The string to add.
- Returns:
The index of the string.
-
inline U32 add_string(StringView sv)¶
Adds a string view to the strings pool.
- Parameters:
sv – The string view to add.
- Returns:
The index of the string.
-
inline U32 add_int(S64 integer)¶
Adds an integer to the integers pool.
- Parameters:
integer – The integer to add.
- Returns:
The index of the integer.
-
inline U32 add_schema(TableSchema *schema)¶
Adds a table schema to the schemas pool.
- Parameters:
schema – The schema to add.
- Returns:
The index of the schema.
-
inline U32 add_instruction(IRInstruction instr)¶
Appends an instruction to the IR.
- Parameters:
instr – The instruction to add.
- Returns:
The index of the instruction.
Public Members
-
Allocator *allocator¶
The allocator.
-
U32 temps_count = 0¶
Count of temporary variables.
-
List<IRInstruction> instructions¶
The list of instructions.
-
List<String> strings¶
The string pool.
-
List<S64> integers¶
The integer pool.
-
List<TableSchema*> schemas¶
The schema pool.
-
IREmitter() = default¶
-
struct IRInstruction¶
- #include <ir.hpp>
Represents a single instruction in the IR.
Public Functions
-
inline bool is_table_generating() const¶
Checks if the instruction generates a new table.
- Returns:
true if table-generating, false otherwise.
Public Members
-
IRInstructionOperator op¶
The opcode.
-
U32 operand1¶
First operand.
-
U32 operand2¶
Second operand.
-
U32 operand3¶
Third operand.
-
inline bool is_table_generating() const¶
-
struct Lexer¶
- #include <Lexer.hpp>
Lexical analyzer for SQL source code.
Public Functions
-
inline explicit Lexer(String source)¶
Constructs a Lexer from an ok::String.
- Parameters:
source – The source string.
-
inline explicit Lexer(StringView source)¶
Constructs a Lexer from an ok::StringView.
- Parameters:
source – The source string view.
-
Optional<Token> next()¶
Retrieves the next token from the source.
- Returns:
An optional containing the next token, or empty if end of source.
-
template<typename F>
inline StringView take_while(F pred)¶ Consumes characters while a predicate is true and returns them as a view.
- Template Parameters:
F – Type of the predicate function.
- Parameters:
pred – The predicate function.
- Returns:
A string view of the consumed characters.
-
template<typename F>
inline void skip_while(F pred)¶ Skips characters while a predicate is true.
- Template Parameters:
F – Type of the predicate function.
- Parameters:
pred – The predicate function.
-
inline void skip_whitespace()¶
Skips all whitespace characters.
-
inline explicit Lexer(String source)¶
-
struct Logger¶
- #include <Logger.hpp>
Abstract base class for loggers.
Subclassed by xmdb::FileLogger
-
struct MallocAllocator : public ok::Allocator¶
- #include <util.hpp>
An allocator that uses standard malloc/free for memory management.
-
class NativeLibrary¶
-
Public Static Functions
-
struct Node¶
-
class Node¶
- #include <QueryGraph.hpp>
Base class for nodes in the query graph.
Subclassed by xmdb::QueryGraph::AlterUserNode, xmdb::QueryGraph::AtomicNode, xmdb::QueryGraph::CallNode, xmdb::QueryGraph::DeleteTableNode, xmdb::QueryGraph::EmitQueryNode, xmdb::QueryGraph::InsertNode, xmdb::QueryGraph::ReadNode, xmdb::QueryGraph::WriteColumnNode, xmdb::QueryGraph::WriteNode
Public Types
-
enum class Type¶
Types of nodes in the graph.
Values:
-
enumerator READ¶
Read data from disk.
-
enumerator WRITE¶
Write data to disk.
-
enumerator ALTER_USER¶
Alter user properties.
-
enumerator ATOMIC¶
A group of atomic operations.
-
enumerator WRITE_COLUMN¶
Write a value to a column.
-
enumerator CALL¶
Call a function.
-
enumerator INSERT¶
Insert rows into a table.
-
enumerator EMIT_QUERY¶
Emit query results.
-
enumerator DELETE_TABLE¶
Delete a table.
-
enumerator READ¶
-
enum class Type¶
-
class NoneDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
A DBValue representing “no value”.
Public Functions
-
inline NoneDBValue()¶
-
inline NoneDBValue()¶
-
template<typename K, typename V>
class OrderedMap¶ - #include <OrderedMap.hpp>
A map that maintains the order of elements as they were inserted.
- Template Parameters:
K – The type of keys.
V – The type of values.
Public Functions
-
OrderedMap(ok::Allocator *allocator, U64 capacity = kDefaultCapacity)¶
Constructs a new OrderedMap.
- Parameters:
allocator – The allocator to use.
capacity – The initial capacity of the map.
Private Static Attributes
-
static constexpr U64 kDefaultCapacity = 47¶
-
struct PagedSeekList¶
- #include <PagedSeekList.hpp>
Provides paged access to a file, allowing efficient seeking and reading.
Public Functions
-
PagedSeekList(ok::Allocator *allocator, ok::File file, UZ page_size)¶
Constructs a new PagedSeekList.
- Parameters:
allocator – The allocator to use for page buffers.
file – The backing file to read from.
page_size – The size of each page in bytes.
-
inline void advance(UZ n)¶
Advances the current file offset.
- Parameters:
n – The number of bytes to advance.
-
ok::Optional<ok::File::ReadError> get_data(U8 **out_data, UZ requested)¶
Retrieves data at the current file offset.
- Parameters:
out_data – Pointer to store the address of the data.
requested – The number of bytes requested.
- Returns:
An optional read error if the operation failed.
-
ok::Optional<ok::File::ReadError> load_page(UZ offset, U8 **result, UZ *bytes_avail)¶
Loads a page of data from the file.
- Parameters:
offset – The file offset to load from.
result – Pointer to store the address of the loaded page.
bytes_avail – Pointer to store the number of bytes available in the page.
- Returns:
An optional read error if the operation failed.
-
bool is_at_end()¶
Checks if the current offset is at the end of the file.
- Returns:
true if at the end, false otherwise.
-
void reset()¶
Resets the file offset and page state to the beginning.
Public Members
-
U8 *current_page = nullptr¶
Pointer to the currently loaded page.
-
UZ current_page_avail = 0¶
Number of bytes available in the current page.
-
UZ page_offset = 0¶
The file offset of the current page.
-
UZ file_offset = 0¶
The current logical offset in the file.
-
UZ page_size¶
The size of each page.
-
PagedSeekList(ok::Allocator *allocator, ok::File file, UZ page_size)¶
-
class PairDBValue : public xmdb::DBValue¶
- #include <DBValue.hpp>
Base class for values that consist of a pair of other values.
Subclassed by xmdb::ConcatDBValue
Public Functions
-
PairDBValue() = delete¶
-
PairDBValue() = delete¶
-
struct Parser¶
- #include <Parser.hpp>
Parses SQL source code into an Abstract Syntax Tree (AST).
Public Functions
-
explicit Parser(ok::ArenaAllocator *allocator, StringView source)¶
Constructs a new Parser.
- Parameters:
allocator – The arena allocator to use for AST nodes.
source – The SQL source string to parse.
-
Optional<Stmt*> stmt()¶
Parses a single SQL statement.
- Returns:
An optional pointer to the parsed Stmt, or empty on failure.
-
Optional<InsertStmt*> insert_stmt()¶
Parses an INSERT statement.
-
Optional<UpdateStmt*> update_stmt()¶
Parses an UPDATE statement.
-
Optional<DeleteStmt*> delete_stmt()¶
Parses a DELETE statement.
-
Optional<CreateStmt*> create_stmt()¶
Parses a CREATE statement.
-
bool try_expect(Token::Type type)¶
Attempts to consume the current token if it matches a specific type.
- Returns:
true if consumed, false otherwise.
-
Optional<Token> expect(Token::Type type)¶
Expects the current token to match a specific type and consumes it. On failure sets the error value.
- Returns:
An optional containing the consumed token, or empty on failure.
-
Optional<Token> get_cur_token_or_signal_eof()¶
Gets the current token or signals EOF error if no more tokens.
-
void set_eof()¶
Manually sets the parser state to EOF.
-
inline bool is_eof() const¶
Checks if the parser has reached the end of the token stream.
-
explicit Parser(ok::ArenaAllocator *allocator, StringView source)¶
-
class Plugin¶
- #include <Plugin.hpp>
A representation of a dynamic library with specific exported functions and structure.
Public Functions
-
void unload()¶
-
ok::Optional<PluginCapability> get_capability(ok::StringView name) const¶
-
template<typename T, typename ...Args>
T use_capability(PluginCapability capability, Args&&... args)¶
Public Static Functions
Private Types
-
using LoadHook = int (*)(void*)¶
-
using UnloadHook = void (*)(void*)¶
-
using InstallHook = void (*)(void*, const char*, const char***, void***, int*)¶
-
using GetLastErrorHook = const char *(*)(void*)¶
-
using CapabilitiesList = ok::List<ok::Pair<ok::StringView, NativeSymbol>>¶
Private Functions
-
inline Plugin(const NativeLibrary *native_lib, void *plugin_state, UnloadHook unload_hook, InstallHook install_hook, GetLastErrorHook get_last_error_hook, CapabilitiesList capabilities)¶
Private Members
-
const NativeLibrary *m_native_lib¶
-
void *m_plugin_state¶
-
ok::Optional<UnloadHook> m_unload_hook¶
-
InstallHook m_install_hook¶
-
ok::Optional<GetLastErrorHook> m_get_last_error_hook¶
-
CapabilitiesList m_capabilities¶
-
bool m_installed = {}¶
-
void unload()¶
-
class PluginCapability¶
Public Functions
-
inline PluginCapability(ok::StringView name, NativeSymbol symbol)¶
-
inline NativeSymbol symbol() const¶
-
inline PluginCapability(ok::StringView name, NativeSymbol symbol)¶
-
class PluginManager¶
-
struct Png¶
- #include <Png.hpp>
Represents a PNG image with its header and metadata.
Public Members
-
PixelFormat format¶
The pixel format of the image.
-
ChunkIndices indices¶
Indices of disk chunks comprising full PNG image.
-
PixelFormat format¶
-
struct PositionalSpec¶
-
struct QueryExecutionContext¶
- #include <QueryExecutionContext.hpp>
Context for executing a database query, managing variables, tables, and operations. Note that the execution context does not actually perform any work (despite it’s name) besides setting up all data that is required for a query to be executed. It only appends new nodes to the query_graph field.
Public Functions
-
DBValue *fetch_var(U32 index)¶
Fetches a variable value by index.
- Parameters:
index – The variable index.
- Returns:
Pointer to the DBValue.
-
void put_var(U32 index, StringView name, DBValue *value)¶
Puts a value into a variable.
- Parameters:
index – The variable index.
name – The variable name.
value – Pointer to the DBValue.
-
DBValue *fetch_column(DBTable *table, StringView column_name)¶
Fetches a value from a table column.
- Parameters:
table – The table to fetch from.
column_name – The name of the column.
- Returns:
Pointer to the DBValue.
-
void emit_column(DBTable *table, DBValue *value, StringView column_name)¶
Emits a column value for a query result.
- Parameters:
table – The table being emitted from.
value – Pointer to the value.
column_name – The name of the column in the result.
-
DBTable *fetch_table(StringView name)¶
Fetches a table by name.
- Parameters:
name – The table name.
- Returns:
Pointer to the DBTable.
-
DBTable *fetch_table(U32 index)¶
Fetches a table by index.
- Parameters:
index – The table index.
- Returns:
Pointer to the DBTable.
-
void put_table(U32 index, DBTable *table)¶
Stores a table by index.
- Parameters:
index – The table index.
table – Pointer to the DBTable.
-
void create_table(StringView name, SQL::TableSchema *schema)¶
Creates a new table based on a schema.
- Parameters:
name – The table name.
schema – Pointer to the table schema.
-
DBTable *emit_query(U32 index, SQL::ColumnType *column_types)¶
Emits the results of a query as a new table.
- Parameters:
index – The query index.
column_types – Pointer to the types of the emitted columns.
- Returns:
Pointer to the resulting DBTable.
-
void insert_column(StringView column_name, DBValue *value)¶
Prepares a column value for insertion.
- Parameters:
column_name – The name of the column.
value – Pointer to the value.
-
void insert_row()¶
Signals that a row is ready to be inserted.
-
void commit_insert(DBTable *table)¶
Commits pending row insertions to a table.
- Parameters:
table – The table to insert into.
-
void update_column(DBTable *table, StringView column_name, DBValue *value)¶
Prepares a column update.
- Parameters:
table – The table to update.
column_name – The column to update.
value – Pointer to the new value.
-
void commit_update()¶
Commits pending updates.
-
void create_user(StringView name)¶
Creates a new database user.
- Parameters:
name – The user name.
-
void alter_user_property(StringView user_name, StringView property_name, DBValue *value)¶
Prepares an alteration to a user property.
- Parameters:
user_name – The name of the user.
property_name – The property to alter.
value – Pointer to the new property value.
-
void commit_alter_user()¶
Commits pending user alterations.
-
DBValue *compare(DBValue *lhs, DBValue *rhs)¶
Compares two values.
- Parameters:
lhs – Left-hand side value.
rhs – Right-hand side value.
- Returns:
Pointer to a DBValue representing the comparison result.
-
void prepare_call_arg(DBValue *arg)¶
Prepares an argument for a function call.
- Parameters:
arg – Pointer to the argument value.
-
DBValue *call(StringView fn_name, U64 args_count)¶
Calls a built-in function.
- Parameters:
fn_name – The function name.
args_count – The number of arguments.
- Returns:
Pointer to the result DBValue.
-
void sync_state()¶
Syncs changed state (DBPool) to disk.
Warning
If the call to DBPool::sync_to_disk fails, this method will use ‘longjmp’ to transfer control to a safe point.
Public Members
-
QueryExecutionContext *next¶
Pointer to the next context in a pool.
-
StaticStorage *static_storage¶
Pointer to global static storage.
-
QueryGraph query_graph¶
The graph of operations to perform.
-
List<StringView> insert_column_names¶
Pending column names for insertion.
-
Optional<QueryGraph::AtomicNode*> alter_user_atomic_node¶
Atomic node for user alterations.
-
DBDescriptor *current_db¶
The database being queried.
-
Optional<ErrorWithSourceLocation> error¶
Error information if execution failed.
-
jmp_buf jmpbuf¶
Jump buffer for error handling.
-
DBValue *fetch_var(U32 index)¶
-
class QueryGraph¶
- #include <QueryGraph.hpp>
Represents a graph of operations to be performed on the database.
Public Functions
-
inline explicit QueryGraph(ok::Allocator *allocator)¶
Constructs a new QueryGraph.
- Parameters:
allocator – The allocator to use for nodes.
-
inline ok::Optional<Node*> root_node() const¶
Gets the root node of the graph.
- Returns:
An optional pointer to the root node.
-
inline ReadNode *read(U64 offset, U64 size)¶
Adds a read node to the graph.
- Returns:
The added node.
-
inline WriteNode *write(U64 offset, U64 size)¶
Adds a write node to the graph.
- Returns:
The added node.
-
inline AtomicNode *atomic()¶
Adds an atomic node to the graph.
- Returns:
The added node.
-
inline WriteColumnNode *write_column(DBTable *table, UZ idx, DBValue *value)¶
Adds a write column node to the graph.
- Returns:
The added node.
-
inline CallNode *call(ok::Allocator *allocator, ok::StringView fn_name, Slice<DBValue*> args)¶
Adds a function call node to the graph.
- Returns:
The added node.
-
inline EmitQueryNode *emit_query(Allocator *allocator, Slice<DBTable*> queried_tables, Slice<StringView> column_names, Slice<DBValue*> column_values, Slice<SQL::ColumnType> column_types)¶
Adds an emit query node to the graph.
- Returns:
The added node.
-
inline DeleteTableNode *delete_table(DBTable *table)¶
Adds a delete table node to the graph.
- Returns:
The added node.
-
inline InsertNode *insert(DBTable *table, Slice<StringView> names, Slice<DBValue*> values, UZ rows_count)¶
Adds an insert node to the graph.
- Returns:
The added node.
-
void reset()¶
Resets the query graph, clearing all nodes.
- Returns:
The added node.
-
inline explicit QueryGraph(ok::Allocator *allocator)¶
-
struct QueryResults¶
- #include <DBConnection.hpp>
Stores the results of a database query.
Public Members
-
Optional<ErrorWithSourceLocation> error¶
Error information if the query failed.
-
Optional<ErrorWithSourceLocation> error¶
-
class ReadNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing a disk read operation.
-
template<typename TOk, typename TError>
class Result¶ - #include <Result.hpp>
A template class representing either a success value or an error value.
- Template Parameters:
TOk – The type of the success value.
TError – The type of the error value.
Public Functions
-
inline Result(const TError &error)¶
Constructs an error Result.
- Parameters:
error – The error value.
-
TOk &unwrap()¶
Unwraps the success value. Panics if the Result is an error.
- Returns:
Reference to the success value.
-
const TOk &unwrap() const¶
Unwraps the success value (const version). Panics if the Result is an error.
- Returns:
Const reference to the success value.
-
TOk &unwrap_unchecked()¶
Unwraps the success value without checking if it’s an error.
- Returns:
Reference to the success value.
-
const TOk &unwrap_unchecked() const¶
Unwraps the success value without checking if it’s an error (const version).
- Returns:
Const reference to the success value.
-
TError &error()¶
Retrieves the error value. Panics if the Result is success.
- Returns:
Reference to the error value.
-
const TError &error() const¶
Retrieves the error value (const version). Panics if the Result is success.
- Returns:
Const reference to the error value.
-
TError &error_unchecked()¶
Retrieves the error value without checking if it’s a success.
- Returns:
Reference to the error value.
-
const TError &error_unchecked() const¶
Retrieves the error value without checking if it’s a success (const version).
- Returns:
Const reference to the error value.
-
template<typename TResult, typename TOkFn, typename TErrorFn>
TResult match(TOkFn ok_fn, TErrorFn error_fn)¶ Matches the result using provided functions for success and error cases.
- Template Parameters:
TResult – The return type of the matching functions.
TOkFn – Type of the success function.
TErrorFn – Type of the error function.
- Parameters:
ok_fn – Function to call on success.
error_fn – Function to call on error.
- Returns:
The result of the called function.
-
class RowDescriptor¶
- #include <TableStream.hpp>
Describes a row in a table.
Public Functions
-
inline ok::Slice<ColumnDescriptor> column_descriptors() const¶
Gets the collection of column descriptors.
- Returns:
A slice of column descriptors.
Private Members
-
ok::Slice<ColumnDescriptor> m_column_descriptors¶
-
inline ok::Slice<ColumnDescriptor> column_descriptors() const¶
-
struct SDFile¶
- #include <SDFile.hpp>
SD (self-destructing) file is accessible only to the current process and gets deleted on process exit.
Public Members
-
int fd¶
The file descriptor.
-
int fd¶
-
struct SelectExpr : public xmdb::SQL::Expr¶
- #include <ast.hpp>
Represents a SELECT expression (subquery).
Public Members
Public Static Functions
-
static inline SelectExpr *alloc(ok::Allocator *allocator, Token token, ok::Slice<Expr*> exprs, Expr *table)¶
Allocates a new SelectExpr.
- Parameters:
allocator – The allocator to use.
token – The associated token.
exprs – The expressions being selected.
table – The source table expression.
- Returns:
Pointer to the new SelectExpr.
-
static inline SelectExpr *alloc(ok::Allocator *allocator, Token token, ok::Slice<Expr*> exprs, Expr *table)¶
-
template<UZ... Xs>
struct Seq¶
-
template<UZ Counter, UZ Max, UZ... Ints>
struct SeqLoop¶
-
struct SHA256Digest¶
- #include <hash.hpp>
Represents a SHA-256 hash digest.
Public Functions
-
inline bool operator==(const SHA256Digest &other) const¶
Public Static Attributes
-
static constexpr UZ SIZE = 32¶
Size of the digest in bytes.
-
inline bool operator==(const SHA256Digest &other) const¶
-
struct SourceLocation¶
- #include <SourceLocation.hpp>
Represents a location within a source file.
Public Functions
-
inline bool operator==(const SourceLocation &other) const¶
-
inline bool operator==(const SourceLocation &other) const¶
-
struct StaticStorage¶
- #include <StaticStorage.hpp>
Global storage for built-in functions and other static data.
-
struct Stmt¶
- #include <ast.hpp>
Base class for all SQL statements in the AST.
Subclassed by xmdb::SQL::AlterStmt, xmdb::SQL::CreateStmt, xmdb::SQL::DeleteStmt, xmdb::SQL::DropStmt, xmdb::SQL::ExprStmt, xmdb::SQL::InsertStmt, xmdb::SQL::UpdateStmt, xmdb::SQL::UseStmt
Public Types
-
enum Type¶
Types of SQL statements.
Values:
-
enumerator USE¶
USE statement.
-
enumerator INSERT¶
INSERT statement.
-
enumerator UPDATE¶
UPDATE statement.
-
enumerator DELETE¶
DELETE statement.
-
enumerator DROP¶
DROP statement.
-
enumerator CREATE¶
CREATE statement.
-
enumerator EXPR¶
Expression statement.
-
enumerator ALTER¶
ALTER statement.
-
enumerator USE¶
-
enum Type¶
-
struct StmtGraph¶
Public Functions
-
inline explicit StmtGraph(Allocator *allocator)¶
-
inline U32 add_expr_node(Expr *expr, StmtGraphNode node)¶
-
inline U32 add_stmt_node(StmtGraphNode node)¶
-
inline explicit StmtGraph(Allocator *allocator)¶
-
struct StmtGraphNode¶
Public Types
Public Functions
-
inline bool is_visited() const¶
-
inline void make_visited()¶
-
inline const char *type_pretty() const¶
Public Static Functions
-
static inline StmtGraphNode expr(Type type, Expr *value, Slice<U32> edges)
-
static inline StmtGraphNode stmt(Type type, Stmt *stmt, Slice<U32> edges)
-
inline bool is_visited() const¶
-
class Store¶
- #include <TableStream.hpp>
Base class for table storage backends.
Subclassed by xmdb::DiskStore
Protected Types
Protected Functions
-
struct StreamPair¶
-
struct StringExpr : public xmdb::SQL::Expr¶
- #include <ast.hpp>
Represents a string literal expression.
Public Static Functions
-
static inline StringExpr *alloc(ok::Allocator *allocator, Token token, ok::String value)¶
Allocates a new StringExpr.
- Parameters:
allocator – The allocator to use.
token – The associated token.
value – The string value.
- Returns:
Pointer to the new StringExpr.
-
static inline StringExpr *alloc(ok::Allocator *allocator, Token token, ok::String value)¶
-
struct TableLayout¶
- #include <ColumnLayout.hpp>
Layout information for an entire table record.
Public Members
-
UZ primary_key_index¶
The index of the primary key column.
-
ok::Slice<ColumnLayout> columns¶
The collection of column layouts.
-
UZ primary_key_index¶
-
struct TableObject¶
-
struct TableSchema¶
- #include <ir.hpp>
Represents the schema of a table in the IR.
Public Functions
-
inline bool find_column(StringView name) const¶
Checks if a column with the given name exists in the schema.
- Parameters:
name – The column name to search for.
- Returns:
true if found, false otherwise.
Public Members
-
List<Optional<String>> columns_names¶
The names of the columns.
-
Optional<List<ColumnType>> columns_types¶
The types of the columns (if typed).
Public Static Functions
-
static inline TableSchema untyped(Allocator *a)¶
Creates an untyped table schema.
- Parameters:
a – The allocator to use.
- Returns:
The new TableSchema.
-
static inline TableSchema typed(Allocator *a)¶
Creates a typed table schema.
- Parameters:
a – The allocator to use.
- Returns:
The new TableSchema.
-
inline bool find_column(StringView name) const¶
-
template<typename A, typename B, typename C>
struct Triple¶ - #include <ir.hpp>
Helper for three values.
-
struct TypedCompiledQuery¶
- #include <type_check.hpp>
Result of compiling and type-checking a query.
Public Members
-
CompiledQuery untyped¶
The underlying untyped compiled query.
-
Table<U32, TypedTableSchema> table_types¶
Mapping of instruction IDs to their resulting table schemas.
-
CompiledQuery untyped¶
-
struct TypedTableSchema¶
- #include <type_check.hpp>
Schema for a table with typed columns.
-
struct TypingContext¶
- #include <type_check.hpp>
Context for the type-checking phase.
Public Functions
-
TypingContext(Allocator *allocator, StringView source)¶
Constructs a new TypingContext.
- Parameters:
allocator – The allocator to use.
source – The original SQL source.
Public Members
-
Allocator *allocator¶
The allocator.
-
Table<U32, TypedTableSchema> table_types¶
Mapping of instruction IDs to table schemas.
-
Table<StringView, FunctionSignature> function_signatures¶
Mapping of function names to signatures.
-
List<U32> emitted_columns¶
Pending IDs of values emitted as columns of a query.
-
List<U32> call_args¶
IDs of values used as function arguments.
-
List<StringView> insert_column_names¶
Pending column names for insertion.
-
List<U32> insert_column_values¶
Pending value instruction IDs for insertion.
-
StringView source¶
The original SQL source (for error reporting).
-
Optional<ErrorWithSourceLocation> error¶
Error information if type checking failed.
-
TypingContext(Allocator *allocator, StringView source)¶
-
struct UpdateStmt : public xmdb::SQL::Stmt¶
- #include <ast.hpp>
Represents an UPDATE statement.
Public Members
Public Static Functions
-
static inline UpdateStmt *alloc(ok::Allocator *allocator, Token token, Expr *table, ok::Slice<ok::String> columns, ok::Slice<Expr*> values, ok::Optional<Expr*> filter)¶
Allocates a new UpdateStmt.
- Parameters:
allocator – The allocator to use.
token – The associated token.
table – The table expression.
columns – The columns to update.
values – The new values.
filter – The filter expression.
- Returns:
Pointer to the new UpdateStmt.
-
static inline UpdateStmt *alloc(ok::Allocator *allocator, Token token, Expr *table, ok::Slice<ok::String> columns, ok::Slice<Expr*> values, ok::Optional<Expr*> filter)¶
-
class Value¶
- #include <Value.hpp>
Represents a concrete value of a specific SQL type.
Public Types
Public Functions
-
Value() = delete¶
-
inline S64 as_int()¶
Retrieves the value as an integer.
- Returns:
The integer value.
-
inline bool as_bool()¶
Retrieves the value as a boolean.
- Returns:
The boolean value.
-
inline FixedString as_string()¶
Retrieves the value as a FixedString.
- Returns:
The fixed string.
-
inline const FixedString *as_string_ptr() const¶
Retrieves the value as a pointer to FixedString.
- Returns:
Const pointer to the fixed string.
-
inline ImageChunk *as_chunk()¶
Retrieves the value as an ImageChunk pointer.
- Returns:
Pointer to the image chunk.
Public Static Functions
-
static inline Value integer(S64 value)¶
Creates an integer value.
- Parameters:
value – The integer.
- Returns:
The resulting Value.
-
static inline Value boolean(bool value)¶
Creates a boolean value.
- Parameters:
value – The boolean.
- Returns:
The resulting Value.
-
static inline Value string(ok::Allocator *a, FixedString s)¶
Creates a string value.
- Parameters:
a – The allocator to use for storing the string.
s – The fixed string.
- Returns:
The resulting Value.
-
static inline Value image_chunk(ok::Allocator *a, U64 x, U64 y, U64 width, U64 height, ok::Slice<U8> data, PixelFormat format)¶
Creates an image chunk value.
- Parameters:
a – The allocator to use.
x – X-coordinate.
y – Y-coordinate.
width – Width.
height – Height.
data – Raw pixel data.
format – Pixel format.
- Returns:
The resulting Value.
-
static inline Value big_string(ok::Allocator *allocator, ok::StringView data)¶
Creates a “big string” value.
- Parameters:
allocator – The allocator to use.
data – String data.
- Returns:
The resulting Value.
-
static inline Value greater()¶
Creates a “greater than” comparison result (integer 1).
- Returns:
The resulting Value.
-
Value() = delete¶
-
struct WebArenaAllocator : public ok::Allocator¶
- #include <util.hpp>
An allocator that uses a web_arena for memory management.
Public Functions
-
inline explicit WebArenaAllocator(web_arena *impl)¶
Constructs a new WebArenaAllocator.
- Parameters:
impl – Pointer to the web_arena implementation.
-
inline void *raw_alloc(UZ size) override¶
-
inline void raw_dealloc(void *ptr, UZ size) override¶
-
inline void *raw_resize(void *ptr, UZ old_size, UZ new_size) override¶
Public Members
-
web_arena *impl¶
The underlying web_arena.
-
inline explicit WebArenaAllocator(web_arena *impl)¶
-
class WriteColumnNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing an update to a table column.
Public Functions
-
inline UZ idx()¶
-
inline UZ idx()¶
-
class WriteNode : public xmdb::QueryGraph::Node¶
- #include <QueryGraph.hpp>
Node representing a disk write operation.
-
namespace ok¶
-
namespace literals¶
-
namespace xmdb¶
Typedefs
-
using BTreeStateFlags = U16¶
Enums
Values:
-
enumerator FLAG_FIRST_CONSTRUCTION¶
-
enumerator FLAG_FIRST_CONSTRUCTION¶
-
enum DBUserPermissions¶
Permissions available for a database user.
Values:
-
enumerator XMDB_ENUM_USER_PERMISSIONS¶
-
enumerator XMDB_ENUM_USER_PERMISSIONS¶
-
enum class PixelFormat¶
Supported pixel formats for image data.
Values:
-
enumerator RGB¶
Red, Green, Blue pixel components, 1 byte for each one.
-
enumerator RGB¶
-
enum class LogLevel¶
Severity levels for logging.
Values:
-
enumerator DEBUG¶
Fine-grained informational events that are most useful to debug an application.
-
enumerator INFO¶
Informational messages that highlight the progress of the application at coarse-grained level.
-
enumerator WARN¶
Potentially harmful situations.
-
enumerator ERROR¶
Error events that might still allow the application to continue running.
-
enumerator NONE¶
Turns off logging.
-
enumerator DEBUG¶
Functions
-
Result<UZ, ok::String> catalog_save(ok::Allocator *allocator, DBPool *pool, ok::StringView filename)¶
-
Result<UZ, ok::String> catalog_load(ok::Allocator *allocator, DBPool *pool, ok::StringView filename)¶
-
static inline UZ table_record_size(TableLayout layout)¶
-
bool compile_and_execute_source(ok::ArenaAllocator *arena, DBConnection *connection, StringView source, QueryResults *results, String *error)¶
Compiles and executes SQL source code.
- Parameters:
arena – The allocator for temporary data during compilation and execution.
connection – The database connection to execute the query on.
source – The SQL source string to execute.
results – Pointer to a structure to store the query results.
error – Pointer to a string to store error messages if execution fails.
- Returns:
true if compilation and execution succeeded, false otherwise.
-
void populate_ir_context_from_pool(SQL::IrContext *ctx, DBPool *pool)¶
Populates the provided IrContext from a DBPool, providing information about existing databases, users and tables.
- Parameters:
ctx – The IR context.
pool – The database pool.
-
static inline ColumnType type_to_column_type(Type type)¶
-
static void execute_instruction(TypedCompiledQuery *query, UZ i, QueryExecutionContext *ctx, DBConnection *conn)¶
-
template<>
DBValue *cpp_to_db_value<ImageChunk>(ok::Allocator *allocator, const ImageChunk &image_chunk)¶
-
template<typename ...Args>
consteval UZ args_count()¶
-
template<typename Return, typename ...Args, UZ... I>
Result<Return, ErrorWithSourceLocation> call_impl(SourceLocation location, ok::Allocator *allocator, XMDB_BUILTIN_FUNCTION_SIG_NAME(fn_ptr, Return, Args...), ok::Array<DBValue*, sizeof...(Args)> raw_args, Seq<I...>)¶
-
template<typename Return, typename ...Args>
Result<Return, ErrorWithSourceLocation> call(SourceLocation location, ok::Allocator *allocator, XMDB_BUILTIN_FUNCTION_SIG_NAME(fn_ptr, Return, Args...), ok::Array<DBValue*, sizeof...(Args)> raw_args)¶
-
static void flush_buffer(QueryExecutionContext *ctx, DBTable *table, ok::Slice<DBRecord> record_buffer)¶
-
static void run_single_node(QueryExecutionContext *ctx, QueryGraph::Node *node)¶
-
static bool create_file_based_on_table_flags(DBTable::Flags flags, ok::String filename, ok::File *out_file)¶
-
DBRecord db_record_create(ok::Allocator *allocator, TableLayout layout)¶
Creates a new DBRecord with a buffer sized according to the table layout.
- Parameters:
allocator – The allocator to use for the buffer.
layout – The layout of the table.
- Returns:
The newly created DBRecord.
-
ColumnAttribute get_attribute_for_column_type(SQL::ColumnType column_type)¶
Gets an attribute for a column type.
- Parameters:
column_type – The column type.
- Returns:
The column attribute.
-
static TypeLayout type_layout(SQL::ColumnType type)¶
-
static ColumnLayout *compute_columns_layout(ok::Allocator *allocator, UZ columns_count, SQL::ColumnType *columns_types)¶
-
FixedString create_fixed_string(ok::StringView sv)¶
Creates a FixedString from an ok::StringView.
- Parameters:
sv – The string view to convert.
- Returns:
The resulting FixedString.
-
static inline bool operator==(const FixedString &lhs, const ok::StringView &rhs)¶
-
static U32 rotr32(U32 x, U32 n)¶
-
static void process_chunk(U32 *h, const U8 *chunk)¶
-
SHA256Digest sha256_digest(ok::StringView sv)¶
Computes the SHA-256 digest of a string view.
- Parameters:
sv – The string view to hash.
- Returns:
The resulting SHA256Digest.
-
U8 format_pixel_size_in_bytes(PixelFormat format)¶
Retrieves the size of a single pixel in bytes for a given format.
- Parameters:
format – The pixel format.
- Returns:
The size in bytes.
-
static bool check_logger()¶
-
void set_logger(Logger *logger)¶
Sets the global logger instance.
- Parameters:
logger – Pointer to the logger to use.
-
void set_log_level(LogLevel level)¶
Sets the global log level.
- Parameters:
level – The log level to set.
-
bool sd_file_create(ok::StringView filename, SDFile *out)¶
Creates a new SDFile with the given filename.
- Parameters:
filename – The name of the file to create.
out – Pointer to store the resulting SDFile.
- Returns:
true if successful, false otherwise.
-
bool db_state_create(ok::File file, DBState *out)¶
Creates a new table state in the given file.
- Parameters:
file – The file to use.
out – Pointer to store the resulting DBState.
- Returns:
true if successful, false otherwise.
-
bool db_state_sync(DBState *state)¶
Synchronizes the table state to disk.
- Parameters:
state – Pointer to the state to sync.
- Returns:
true if successful, false otherwise.
-
bool db_state_reset(DBState *state)¶
Resets the table state.
- Parameters:
state – Pointer to the state to reset.
- Returns:
true if successful, false otherwise.
-
Result<DBState, ok::String> db_state_load(ok::Allocator *allocator, ok::File file)¶
Tries to load a DBState from an open file.
- Parameters:
allocator – The allocator to use for error strings.
file – The file to use.
- Returns:
A loaded DBState on success, an error string otherwise.
-
bool image_state_create(ok::File file, ImageColumnState *out)¶
Creates a new image column state in the given file.
- Parameters:
file – The file to use.
out – Pointer to store the resulting ImageColumnState.
- Returns:
true if successful, false otherwise.
-
Result<ImageColumnState, ok::String> image_state_load(ok::Allocator *allocator, ok::File file)¶
Loads an existing image column state from an open file.
- Parameters:
allocator – The allocator to use for error strings.
file – The file to use.
- Returns:
Loaded ImageColumnState on success, an error string otherwise.
-
bool image_state_sync(ImageColumnState *state)¶
Synchronizes the image column state to disk.
- Parameters:
state – Pointer to the state to sync.
- Returns:
true if successful, false otherwise.
-
XMDB_DECLARE_BUILTIN_FUNCTION(RGB, ImageChunk, U32 width, U32 height, ok::StringView hex_data)¶
-
StaticStorage *make_or_get_static_storage()¶
Retrieves the global StaticStorage instance, creating it if it doesn’t exist.
- Returns:
Pointer to the StaticStorage instance.
- void dief (const char *fmt,...) OK_ATTRIBUTE_PRINTF(1
Terminates the program with a formatted error message.
- Parameters:
fmt – The format string.
... – The format arguments.
-
ok::String to_hex_string(ok::Allocator *allocator, ok::Slice<U8> bytes)¶
Converts a slice of bytes to a hexadecimal string.
- Parameters:
allocator – The allocator to use for the string.
bytes – The bytes to convert.
- Returns:
The hexadecimal string.
-
ok::Optional<ok::Slice<U8>> from_hex_string(ok::Allocator *allocator, ok::StringView sv)¶
Converts a hexadecimal string back to a slice of bytes.
- Parameters:
allocator – The allocator to use for the resulting slice.
sv – The hexadecimal string.
- Returns:
An optional slice of bytes if conversion succeeded.
Variables
-
constexpr U64 CATALOG_VERSION = 1¶
-
constexpr U64 BTREE_PAGE_SIZE = 4096¶
-
constexpr U16 BTREE_HEADER_VERSION = 1¶
-
constexpr U64 BTREE_HEADER_MAGIC = ((U64)'x' << 56) | ((U64)'m' << 48) | ((U64)'d' << 40) | ((U64)'b' << 32)¶
-
constexpr U64 BTREE_HEADER_LENGTH = BTREE_PAGE_SIZE¶
-
constexpr U64 BTREE_ORDER = 128¶
-
constexpr auto BTREE_MAX_KEYS = BTREE_ORDER * 2 - 1¶
-
constexpr auto BTREE_MAX_CHILDREN = BTREE_ORDER * 2¶
-
constexpr auto DB_STATE_HEADER_LENGTH = sizeof(DBStateHeader)¶
-
constexpr UZ DB_RECORD_BUFFER_CAPACITY = 32¶
-
constexpr bool chunk_images = false¶
-
static constexpr U32 K[64] = {0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,}¶
-
static constexpr U32 INIT[8] = {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19,}¶
-
constexpr UZ MAX_DISK_IMAGE_SIZE = GiB(4)¶
-
constexpr UZ MAX_DISK_IMAGE_CHUNK_SIZE = MiB(64)¶
-
constexpr UZ MAX_DISK_IMAGE_CHUNK_DATA_SIZE = MAX_DISK_IMAGE_CHUNK_SIZE - sizeof(DiskImageChunk)¶
-
constexpr UZ MAX_DISK_IMAGE_CHUNKS_COUNT = MAX_DISK_IMAGE_SIZE / MAX_DISK_IMAGE_CHUNK_SIZE¶
-
constexpr UZ MAX_IMAGE_DATA_SIZE = MAX_DISK_IMAGE_CHUNK_DATA_SIZE * MAX_DISK_IMAGE_CHUNKS_COUNT¶
-
static bool global_logger_init = false¶
-
constexpr U64 DB_STATE_HEADER_MAGIC = ((U64)'s' << 56) | ((U64)'x' << 48) | ((U64)'m' << 40) | ((U64)'d' << 32) | ((U64)'b' << 24)¶
-
constexpr UZ IMAGE_COLUMN_STATE_HEADER_SIZE = sizeof(ImageColumnStateHeader)¶
- static char quad_to_hex_table [] = {[0] = '0',[1] = '1',[2] = '2',[3] = '3',[4] = '4',[5] = '5',[6] = '6',[7] = '7',[8] = '8',[9] = '9',[10] = 'A',[11] = 'B',[12] = 'C',[13] = 'D',[14] = 'E',[15] = 'F',}
-
using BTreeStateFlags = U16¶
-
namespace argparser¶
-
namespace log¶
Namespace containing logging functions.
Functions
- void log (LogLevel level, const char *fmt,...) OK_ATTRIBUTE_PRINTF(2
Logs a message with a specific level.
- Parameters:
level – The log level.
fmt – The format string.
... – The format arguments.
- void debug (const char *fmt,...) OK_ATTRIBUTE_PRINTF(1
Logs a debug message.
- Parameters:
fmt – The format string.
... – The format arguments.
- void info (const char *fmt,...) OK_ATTRIBUTE_PRINTF(1
Logs an info message.
- Parameters:
fmt – The format string.
... – The format arguments.
- void warn (const char *fmt,...) OK_ATTRIBUTE_PRINTF(1
Logs a warning message.
- Parameters:
fmt – The format string.
... – The format arguments.
- void error (const char *fmt,...) OK_ATTRIBUTE_PRINTF(1
Logs an error message.
- Parameters:
fmt – The format string.
... – The format arguments.
-
namespace plugin¶
-
namespace server¶
-
Functions
-
Optional<ConnectionData*> get_connection_data(ConnectionId id)¶
-
void init_connection_state()¶
-
static void free_connection_data(ConnectionData *data)¶
-
ConnectionId gen_connection(xmdb::DBDescriptor *db, xmdb::DBUser *user)¶
-
void free_connection(ConnectionId)¶
-
DECLARE_HANDLER(connect_handler)¶
-
DECLARE_HANDLER(run_query_handler)¶
-
DECLARE_HANDLER(get_db_objects_handler)¶
-
void run_http_server(U16 port)¶
-
ok::Slice<TableObject> get_db_table_objects(ok::Allocator *allocator, DBDescriptor *db)¶
Variables
-
static ConnectionId last_connection_id = 0¶
-
static ok::Table<ConnectionId, ConnectionData*> db_connections_table = ok::Table<ConnectionId, ConnectionData*>::alloc(&shared_alloc)¶
-
static ConnectionData *connection_free_list¶
-
static constexpr S64 SECOND = 1¶
-
Optional<ConnectionData*> get_connection_data(ConnectionId id)¶
-
namespace SQL¶
-
Enums
-
enum class ColumnType¶
Supported types for table columns.
Values:
-
enumerator X¶
-
enumerator XMDB_ENUM_COLUMN_TYPES¶
-
enumerator X¶
-
enum Type¶
Supported SQL data types.
Values:
-
enumerator TYPE_INT¶
Integer.
-
enumerator TYPE_STRING¶
String.
-
enumerator TYPE_PNG¶
PNG image data.
-
enumerator TYPE_IMAGE_CHUNK¶
A chunk of an image.
-
enumerator TYPE_BOOL¶
Boolean.
-
enumerator TYPE_NULL¶
NULL value.
-
enumerator TYPE_TABLE¶
A database table.
-
enumerator TYPE_FLOAT¶
Single-precision floating point.
-
enumerator TYPE_DOUBLE¶
Double-precision floating point.
-
enumerator TYPE_INT¶
Functions
-
__attribute__((constructor)) void init_global_state()¶
-
void init_global_state()
Initializes the global state for the SQL subsystem (e.g., token tables).
-
const char *column_type_to_string(ColumnType type)¶
Converts a ColumnType to its string representation.
- Parameters:
type – The column type.
- Returns:
The name of the column type.
-
ok::Optional<ColumnType> parse_column_type(ok::StringView sv)¶
Parses a column type from a string view.
- Parameters:
sv – The string view to parse.
- Returns:
The parsed ColumnType, or empty if unknown.
- static inline ENUM_IR_CONTRACTS bool compile_use_stmt (UseStmt *stmt, IrContext *ctx)
-
static Optional<U32> compile_ident(IdentifierExpr *ident, IrContext *ctx)¶
-
static inline bool parse_type(StringView input, Token where, IrContext *ctx, ColumnType *out)¶
-
static inline bool compile_create_stmt(CreateStmt *stmt, IrContext *ctx)¶
-
static StmtGraph build_insert_stmt_graph(Allocator *allocator, InsertStmt *stmt)¶
-
StmtGraph build_update_stmt_graph(Allocator *allocator, UpdateStmt *stmt)¶
-
static StmtGraph build_delete_stmt_graph(Allocator *allocator, DeleteStmt *stmt)¶
-
const char *stringify_op(StringView op)¶
-
const char *stringify_op(S64 op)¶
-
const char *stringify_op(TableSchema *op)¶
-
String stringify_ir(Allocator *allocator, CompiledQuery *query)¶
Stringifies a compiled query.
- Parameters:
allocator – The allocator to use for the string.
query – The compiled query.
- Returns:
The human-readable IR string.
-
bool ir_compile_query(Query *in_query, IrContext *ctx, CompiledQuery *out_query)¶
Compiles a query AST to IR.
- Parameters:
in_query – The input query AST.
ctx – The IR context.
out_query – Pointer to store the compiled query.
- Returns:
true if successful, false otherwise.
-
static inline const char *ir_instruction_operator_name(IRInstructionOperator op)¶
Gets the name of an IR instruction operator.
- Parameters:
op – The instruction operator.
- Returns:
The name string.
-
static inline SourceLocation locate_token(StringView source, Token token)¶
Calculates the source location of a given token.
- Parameters:
source – The full source string.
token – The token to locate.
- Returns:
The source location information.
-
inline StringView token_type_to_string_view(Token::Type type)¶
Converts a token type to its human-readable string representation.
- Parameters:
type – The token type.
- Returns:
A string view of the type name.
-
Optional<SelectExpr*> parse_select_expr(Parser *p)¶
-
static inline bool find_column(TypedTableSchema schema, StringView name, Type *type)¶
-
static void error_on(TypingContext *ctx, Token token, String message)¶
-
Type column_type_to_type(ColumnType col_type)¶
Converts a ColumnType to a Type.
- Parameters:
col_type – The column type.
- Returns:
The corresponding data type.
-
bool is_image(Type type)¶
Checks if a type represents image data.
- Parameters:
type – The type to check.
- Returns:
true if it’s an image type, false otherwise.
-
const char *type_name(Type type)¶
Gets the human-readable name of a type.
- Parameters:
type – The type.
- Returns:
The name string.
-
static inline bool type_check_ir_instruction(U32 ip, CompiledQuery *ir_emitter, TypingContext *ctx)¶
-
bool type_check_query(CompiledQuery *query, TypingContext *ctx, TypedCompiledQuery *out)¶
Type checks a compiled query.
- Parameters:
query – The compiled query to check.
ctx – The typing context.
out – Pointer to store the resulting TypedCompiledQuery.
- Returns:
true if successful, false otherwise.
-
template<>
Type cpp_to_tt<ImageChunk>()¶
-
static inline String format_error(ok::Allocator *allocator, SourceLocation location, ok::StringView message)¶
Formats an error message with its source location.
- Parameters:
allocator – The allocator to use for the resulting string.
location – The source location of the error.
message – The error message.
- Returns:
The formatted error string.
Variables
- const char * column_type_to_string_table [] = {#define X(type)XMDB_ENUM_COLUMN_TYPES}
-
TokenTable token_table = {}¶
- StringView token_types_pretty [] = {#define X(str, tok)XMDB_ENUM_SQL_TOKENS}
-
enum class ColumnType¶
-
namespace SQL
- file ArgParser.cpp
- #include “ArgParser.hpp”
- file ArgParser.hpp
- #include <Core/ok.hpp>#include <Core/util.hpp>
- file BTreeIndex.cpp
- #include “BTreeIndex.hpp”#include “Logger.hpp”#include “constants.hpp”
- file BTreeIndex.hpp
- #include “ok.hpp”
- file catalog.cpp
- #include “catalog.hpp”#include “DBPool.hpp”#include “DBDescriptor.hpp”#include “FixedString.hpp”#include “Logger.hpp”
- file catalog.hpp
- #include “ok.hpp”#include “state.hpp”
- file ColumnLayout.hpp
- file constants.hpp
- #include “state.hpp”
- file Core.cpp
- #include “Core.hpp”#include <SQL/SQL.hpp>#include <SQL/util.hpp>
- file Core.hpp
- #include “DBConnection.hpp”
- file DBConnection.cpp
- #include “DBConnection.hpp”#include “Logger.hpp”#include “DBRecord.hpp”#include “constants.hpp”#include “Result.hpp”#include “image.hpp”#include “Png.hpp”#include <SQL/ir.hpp>#include <SQL/util.hpp>#include <csetjmp>
Defines
-
X(name, ret, ...)¶
-
X(name, ret, ...)¶
- file DBConnection.hpp
- #include <SQL/ir.hpp>#include “DBPool.hpp”#include “ok.hpp”
- file DBDescriptor.cpp
- #include “DBDescriptor.hpp”#include “new.hpp”#include “Logger.hpp”#include “SDFile.hpp”#include “state.hpp”
- file DBDescriptor.hpp
- #include “DBTable.hpp”#include “DBUser.hpp”
- file DBPool.cpp
- #include “DBPool.hpp”#include “Logger.hpp”#include “catalog.hpp”
- file DBPool.hpp
- #include “DBValue.hpp”#include “DBTable.hpp”#include “ok.hpp”#include “QueryExecutionContext.hpp”
- file DBRecord.cpp
- #include “DBRecord.hpp”#include “FixedString.hpp”
- file DBRecord.hpp
- #include “ok.hpp”#include “Value.hpp”
- file DBTable.cpp
- #include “DBTable.hpp”#include “FixedString.hpp”#include “new.hpp”#include “Logger.hpp”#include “Png.hpp”#include “constants.hpp”
- file DBTable.hpp
- #include “BTreeIndex.hpp”#include “DBValue.hpp”#include “ColumnLayout.hpp”#include “ok.hpp”#include “Value.hpp”#include “state.hpp”
- file DBUser.cpp
- #include “DBUser.hpp”
- file DBUser.hpp
- #include “hash.hpp”#include “ok.hpp”
- file DBValue.cpp
- #include “DBValue.hpp”
- file DBValue.hpp
- #include <SQL/type_check.hpp>#include “ColumnLayout.hpp”#include “image.hpp”
- file FixedString.cpp
- #include “FixedString.hpp”
- file FixedString.hpp
- #include “ok.hpp”
- file hash.cpp
- #include “hash.hpp”#include <cstring>
- file hash.hpp
- #include “ok.hpp”
- file image.cpp
- #include “image.hpp”
- file image.hpp
- #include “constants.hpp”
- file Logger.cpp
- #include “Logger.hpp”
Defines
-
LOG(lvl)¶
-
LOG(lvl)¶
- file Logger.hpp
- #include “ok.hpp”
Defines
-
XMDB_FIXME(msg)¶
-
XMDB_FIXME(msg)¶
- file new.hpp
- #include “ok.hpp”
- file numeric.hpp
- file ok.cpp
- #include “ok.hpp”
Defines
-
OK_IMPLEMENTATION¶
-
OK_IMPLEMENTATION¶
- file OrderedMap.hpp
- #include “numeric.hpp”
- file PagedSeekList.hpp
- #include “ok.hpp”
- file Png.hpp
- #include “image.hpp”
- file QueryExecutionContext.cpp
- #include “QueryExecutionContext.hpp”#include “new.hpp”#include “Logger.hpp”#include “constants.hpp”#include “Png.hpp”
Defines
-
X(p, _unused)
-
X(p, _unused)
- file QueryExecutionContext.hpp
- #include <csetjmp>#include “util.hpp”#include “DBDescriptor.hpp”#include “DBTable.hpp”#include “DBValue.hpp”#include “DBRecord.hpp”#include “QueryGraph.hpp”#include “StaticStorage.hpp”
- file QueryGraph.cpp
- #include “QueryGraph.hpp”#include “Logger.hpp”#include “new.hpp”
- file QueryGraph.hpp
- #include “ok.hpp”#include “new.hpp”#include “DBValue.hpp”#include “DBTable.hpp”
- file Result.hpp
- file SDFile.cpp
- #include “SDFile.hpp”#include “Logger.hpp”
- file SDFile.hpp
- #include “ok.hpp”
- file SourceLocation.hpp
- #include “ok.hpp”
- file state.cpp
- #include “state.hpp”#include “Logger.hpp”#include “Result.hpp”
- file state.hpp
- #include “ok.hpp”#include “Result.hpp”
- file StaticStorage.cpp
- #include “StaticStorage.hpp”#include “util.hpp”#include “Result.hpp”#include <SQL/ir.hpp>
- file StaticStorage.hpp
- #include “ok.hpp”
- file TableStream.hpp
- #include “PagedSeekList.hpp”#include “constants.hpp”#include “ok.hpp”
- file util.cpp
- #include “util.hpp”#include “ok.hpp”
- file Value.hpp
- #include <SQL/type_check.hpp>#include “ColumnLayout.hpp”#include “FixedString.hpp”#include “image.hpp”
- file NativeLibrary.cpp
- #include “NativeLibrary.hpp”#include “util.hpp”
- file NativeLibrary.hpp
- #include <Core/ok.hpp>#include <Core/Result.hpp>
- file Plugin.cpp
- #include “Plugin.hpp”#include <Core/new.hpp>#include “util.hpp”
- file Plugin.hpp
- #include <Core/ok.hpp>#include <Core/Result.hpp>#include “NativeLibrary.hpp”
- file PluginManager.cpp
- #include “PluginManager.hpp”
- file PluginManager.hpp
- #include <Core/ok.hpp>#include “Plugin.hpp”
- file util.hpp
- #include “SourceLocation.hpp”#include “ok.hpp”#include <common.h>
Defines
-
TRY(x)¶
-
TRY(x)¶
- file util.hpp
- #include <Core/ok.hpp>
- file util.hpp
- #include “Lexer.hpp”
- file Config.cpp
- #include “Config.hpp”#include <Core/util.hpp>#include <ArgParser/ArgParser.hpp>
- file Config.hpp
- #include <Core/ok.hpp>
- file connection.cpp
- #include “connection.hpp”
- file connection.hpp
- #include <Core/DBConnection.hpp>
- file http.cpp
- #include <cmath>#include <Core/Core.hpp>#include <Core/DBDescriptor.hpp>#include <Core/ok.hpp>#include <http.h>#include <log.h>#include “connection.hpp”#include “http.hpp”#include “obj.hpp”
- file http.hpp
- file main.cpp
- #include <cmath>#include <ArgParser/ArgParser.hpp>#include <Core/ok.hpp>#include <Core/util.hpp>#include <Core/hash.hpp>#include <Core/Result.hpp>#include <Core/image.hpp>#include <Core/Logger.hpp>#include <SQL/ir.hpp>#include <http.h>
- file main.cpp
- #include <SQL/ir.hpp>#include <SQL/SQL.hpp>#include <SQL/Parser.hpp>#include <SQL/util.hpp>#include <Core/util.hpp>#include <ArgParser/ArgParser.hpp>
Functions
-
void h(int code, const char *msg = nullptr)¶
-
void err(const char *why, xmdb::ErrorWithSourceLocation error)¶
-
int main(int argc, char **argv)
Variables
- const char * help_message ="ir SOURCE - Usage\n\n""\tSOURCE - xmdb SQL source.\n"
-
void h(int code, const char *msg = nullptr)¶
- file main.cpp
- #include <Core/ok.hpp>#include <Core/DBPool.hpp>#include <Core/DBConnection.hpp>#include <Core/Core.hpp>#include <Core/Logger.hpp>#include <SQL/global_state.hpp>#include “connection.hpp”#include “http.hpp”#include “Config.hpp”
Functions
-
int main(int argc, char **argv)
-
int main(int argc, char **argv)
- file obj.cpp
- #include “obj.hpp”
- file obj.hpp
- #include <Core/ok.hpp>#include <Core/DBDescriptor.hpp>#include <SQL/ir.hpp>
- file ast.cpp
- #include “ast.hpp”#include <Core/ok.hpp>
- file ast.hpp
- #include <Core/ok.hpp>#include “Lexer.hpp”
- file constructor_linux.cpp
- #include “Lexer.hpp”
Defines
-
X(str, kw)
-
X(str, kw)
- file global_state.hpp
- file ir.cpp
- #include <Core/ok.hpp>#include <Core/util.hpp>#include “ir.hpp”
Defines
-
X(type)
-
X(type)
-
INSTR_VAR_0(name)¶
-
INSTR_VAR_1(name, t1)¶
-
INSTR_VAR_2(name, t1, t2)¶
-
INSTR_0(name)¶
-
INSTR_1(name, t1)¶
-
INSTR_2(name, t1, t2)¶
-
INSTR_3(name, t1, t2, t3)¶
-
INSTR_VAR_2(name, t1, t2)
-
INSTR_VAR_1(name, t1)
-
INSTR_VAR_0(name)
-
INSTR_0(name)
-
INSTR_1(name, t1)
-
INSTR_2(name, t1, t2)
-
INSTR_3(name, t1, t2, t3)
-
X(type)
- file ir.hpp
- #include <Core/ok.hpp>#include <Core/util.hpp>#include <Core/image.hpp>#include “ast.hpp”
Defines
-
XMDB_ENUM_COLUMN_TYPES¶
-
X(type)
-
ENUM_IR_CONTRACTS¶
-
INSTR_0(instr)
-
INSTR_VAR_0(instr)
-
INSTR_1(instr, _op1)
-
INSTR_VAR_1(instr, _op1)
-
INSTR_2(instr, _op1, _op2)
-
INSTR_VAR_2(instr, _op1, _op2)
-
INSTR_3(instr, _op1, _op2, _op3)
-
INSTR_VAR_3(instr, _op1, _op2, _op3)¶
-
INSTR_0(instr)
-
INSTR_VAR_0(instr)
-
INSTR_1(instr, _op1)
-
INSTR_VAR_1(instr, _op1)
-
INSTR_2(instr, _op1, _op2)
-
INSTR_VAR_2(instr, _op1, _op2)
-
INSTR_3(instr, _op1, _op2, _op3)
-
INSTR_VAR_3(instr, _op1, _op2, _op3)
-
XMDB_ENUM_BUILTIN_FUNCTIONS¶
-
XMDB_BUILTIN_FUNCTION_SIG_NAME(name, ret, ...)¶
-
XMDB_BUILTIN_FUNCTION_SIG(ret, ...)¶
-
INSTR_VAR_0(name)
-
INSTR_VAR_1(name, t1)
-
INSTR_VAR_2(name, t1, t2)
-
INSTR_0(name)
-
INSTR_1(name, t1)
-
INSTR_2(name, t1, t2)
-
INSTR_3(name, t1, t2, t3)
-
XMDB_ENUM_COLUMN_TYPES¶
- file Lexer.cpp
- #include “Lexer.hpp”#include <cctype>
Defines
-
X(str, tok)
-
X(str, tok)
- file Lexer.hpp
- #include <Core/ok.hpp>#include <Core/SourceLocation.hpp>#include <stddef.h>
- file Parser.cpp
- #include “Parser.hpp”#include <Core/ok.hpp>#include <Core/util.hpp>#include <SQL/ast.hpp>
Defines
-
SET_TOKEN_MISMATCH(p, got, ...)¶
-
SET_TOKEN_MISMATCH(p, got, ...)¶
- file Parser.hpp
- #include <Core/SourceLocation.hpp>#include <Core/util.hpp>#include “Lexer.hpp”#include “ast.hpp”
- file SQL.cpp
- #include “SQL.hpp”#include “Parser.hpp”#include “type_check.hpp”#include “util.hpp”
- file SQL.hpp
- #include “type_check.hpp”
SQL convenience routines.
- file type_check.cpp
- #include “type_check.hpp”#include <SQL/ir.hpp>
Defines
-
X(fn_name, ret_type, ...)
-
X(fn_name, ret_type, ...)
- file type_check.hpp
- #include <Core/SourceLocation.hpp>#include <Core/util.hpp>#include “ir.hpp”
- file wasm_module.cpp
- #include “stb_sprintf.h”#include <Core/ok.hpp>#include <SQL/constructor_linux.cpp>#include <SQL/util.hpp>#include <SQL/Lexer.cpp>#include <SQL/Parser.cpp>
- group SQL_API
- dir src/ArgParser
- dir src/CLI
- dir src/Core
- dir src/IR
- dir src/Plugin
- dir src/Server
- dir src/SQL
- dir src
- dir src/WASMParser