mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
SQLServer: Parse SQL a single time to actually "prepare" the statement
One of the benefits of prepared statements is that the SQL string is parsed just once and re-used. This updates SQLStatement to do just that and store the parsed result.
This commit is contained in:
parent
83bb25611e
commit
b13527b8b2
5 changed files with 40 additions and 39 deletions
|
@ -54,15 +54,21 @@ void ConnectionFromClient::disconnect(int connection_id)
|
|||
Messages::SQLServer::PrepareStatementResponse ConnectionFromClient::prepare_statement(int connection_id, DeprecatedString const& sql)
|
||||
{
|
||||
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::prepare_statement(connection_id: {}, sql: '{}')", connection_id, sql);
|
||||
|
||||
auto database_connection = DatabaseConnection::connection_for(connection_id);
|
||||
if (database_connection) {
|
||||
auto statement_id = database_connection->prepare_statement(sql);
|
||||
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::prepare_statement -> statement_id = {}", statement_id);
|
||||
return { statement_id };
|
||||
} else {
|
||||
if (!database_connection) {
|
||||
dbgln("Database connection has disappeared");
|
||||
return { -1 };
|
||||
}
|
||||
|
||||
auto result = database_connection->prepare_statement(sql);
|
||||
if (result.is_error()) {
|
||||
dbgln_if(SQLSERVER_DEBUG, "Could not parse SQL statement: {}", result.error().error_string());
|
||||
return { -1 };
|
||||
}
|
||||
|
||||
dbgln_if(SQLSERVER_DEBUG, "ConnectionFromClient::prepare_statement -> statement_id = {}", result.value());
|
||||
return { result.value() };
|
||||
}
|
||||
|
||||
void ConnectionFromClient::execute_statement(int statement_id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue