summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorJan de Visser <jan@de-visser.net>2021-07-19 19:48:46 -0400
committerAndreas Kling <kling@serenityos.org>2021-08-21 22:03:30 +0200
commitd074a601dfdb3cdbb50b83c142db85d079da475f (patch)
treeb8d38114467b1fffb6e86ab0c3701f004ea7dfaa /Userland/Services
parent230118c4b28b89bb692375624203d8487f04a862 (diff)
downloadserenity-d074a601dfdb3cdbb50b83c142db85d079da475f.zip
LibSQL+SQLServer: Bare bones INSERT and SELECT statements
This patch provides very basic, bare bones implementations of the INSERT and SELECT statements. They are *very* limited: - The only variant of the INSERT statement that currently works is SELECT INTO schema.table (column1, column2, ....) VALUES (value11, value21, ...), (value12, value22, ...), ... where the values are literals. - The SELECT statement is even more limited, and is only provided to allow verification of the INSERT statement. The only form implemented is: SELECT * FROM schema.table These statements required a bit of change in the Statement::execute API. Originally execute only received a Database object as parameter. This is not enough; we now pass an ExecutionContext object which contains the Database, the current result set, and the last Tuple read from the database. This object will undoubtedly evolve over time. This API change dragged SQLServer::SQLStatement into the patch. Another API addition is Expression::evaluate. This method is, unsurprisingly, used to evaluate expressions, like the values in the INSERT statement. Finally, a new test file is added: TestSqlStatementExecution, which tests the currently implemented statements. As the number and flavour of implemented statements grows, this test file will probably have to be restructured.
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/SQLServer/SQLStatement.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Services/SQLServer/SQLStatement.cpp b/Userland/Services/SQLServer/SQLStatement.cpp
index d8610d9480..413acd75da 100644
--- a/Userland/Services/SQLServer/SQLStatement.cpp
+++ b/Userland/Services/SQLServer/SQLStatement.cpp
@@ -66,7 +66,9 @@ void SQLStatement::execute()
report_error(maybe_error.value());
return;
}
- m_result = m_statement->execute(*connection()->database());
+ VERIFY(!connection()->database().is_null());
+ SQL::AST::ExecutionContext context { connection()->database().release_nonnull() };
+ m_result = m_statement->execute(context);
if (m_result->error().code != SQL::SQLErrorCode::NoError) {
report_error(m_result->error());
return;