2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-14 12:52:17 +00:00
Files
mysql/test/integration/close_statement.cpp
2020-06-29 17:17:11 +01:00

42 lines
1.3 KiB
C++

//
// Copyright (c) 2019-2020 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#include "integration_test_common.hpp"
using namespace boost::mysql::test;
BOOST_AUTO_TEST_SUITE(test_close_statement)
BOOST_MYSQL_NETWORK_TEST(existing_or_closed_statement, network_fixture, network_ssl_gen)
{
this->connect(sample.ssl);
auto* net = sample.net;
// Prepare a statement
auto stmt = net->prepare_statement(this->conn, "SELECT * FROM empty_table");
stmt.validate_no_error();
// Verify it works fine
auto exec_result = net->execute_statement(stmt.value, {});
exec_result.validate_no_error();
exec_result.value.fetch_all(); // clean all packets sent for this execution
// Close the statement
auto close_result = net->close_statement(stmt.value);
close_result.validate_no_error();
// Close it again
close_result = net->close_statement(stmt.value);
close_result.validate_no_error();
// Verify close took effect
exec_result = net->execute_statement(stmt.value, {});
exec_result.validate_error(boost::mysql::errc::unknown_stmt_handler, {"unknown prepared statement"});
}
BOOST_AUTO_TEST_SUITE_END() // test_close_statement