reldb 0.1.0
Recreational SQLite
Loading...
Searching...
No Matches
compiler.c
Go to the documentation of this file.
1
5
6#include "compiler.h"
7#include <string.h>
8#include <stdlib.h>
9
12{
13 if (0 == strcmp(inbuf->buffer, ".exit")) {
14 close_input_buffer(inbuf);
15 exit(EXIT_SUCCESS);
16 } else {
17 return META_COMMAND_UNRECOGNISED_CMD;
18 }
19}
20
23{
24 if (0 == strncmp(inbuf->buffer, "insert", 6)) {
25 stmt->type = STATEMENT_INSERT;
26 return PREPARE_SUCCESS;
27 }
28 if (0 == strcmp(inbuf->buffer, "select")) {
29 stmt->type = STATEMENT_SELECT;
30 return PREPARE_SUCCESS;
31 }
32
33 return PREPARE_UNRECOGNIZED_STATEMENT;
34}
MetaCmdRes do_meta_cmd(InputBuffer *inbuf)
Parses and executes non-SQL meta-commands (commands starting with '.').
Definition compiler.c:11
PrepareRes prepare_statement(InputBuffer *inbuf, Statement *stmt)
The "Compiler": parses raw string input into an executable Statement.
Definition compiler.c:22
SQL text parsing and meta-command routing.
void close_input_buffer(InputBuffer *input_buffer)
Frees the memory associated with an InputBuffer.
Definition inputbuffer.c:72
PrepareRes
Result codes for the SQL statement compiler.
Definition statement.h:16
MetaCmdRes
Result codes for meta-command execution.
Definition statement.h:10
A structure to hold dynamically allocated string input data.
Definition inputbuffer.h:24
char * buffer
Definition inputbuffer.h:27
A parsed SQL statement ready for execution by the VM.
Definition statement.h:31