@@ -41,9 +41,10 @@ using util::ThrowIfNotOK;
4141
4242namespace {
4343
44- void ClosePreparedStatementIfAny (std::shared_ptr<PreparedStatement>& prepared_statement) {
44+ void ClosePreparedStatementIfAny (std::shared_ptr<PreparedStatement>& prepared_statement,
45+ const FlightCallOptions& options) {
4546 if (prepared_statement != nullptr ) {
46- ThrowIfNotOK (prepared_statement->Close ());
47+ ThrowIfNotOK (prepared_statement->Close (options ));
4748 prepared_statement.reset ();
4849 }
4950}
@@ -66,6 +67,10 @@ FlightSqlStatement::FlightSqlStatement(const Diagnostics& diagnostics,
6667 call_options_.timeout = TimeoutDuration{-1 };
6768}
6869
70+ FlightSqlStatement::~FlightSqlStatement () {
71+ ClosePreparedStatementIfAny (prepared_statement_, call_options_);
72+ }
73+
6974bool FlightSqlStatement::SetAttribute (StatementAttributeId attribute,
7075 const Attribute& value) {
7176 switch (attribute) {
@@ -97,7 +102,7 @@ boost::optional<Statement::Attribute> FlightSqlStatement::GetAttribute(
97102
98103boost::optional<std::shared_ptr<ResultSetMetadata>> FlightSqlStatement::Prepare (
99104 const std::string& query) {
100- ClosePreparedStatementIfAny (prepared_statement_);
105+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
101106
102107 Result<std::shared_ptr<PreparedStatement>> result =
103108 sql_client_.Prepare (call_options_, query);
@@ -113,7 +118,8 @@ boost::optional<std::shared_ptr<ResultSetMetadata>> FlightSqlStatement::Prepare(
113118bool FlightSqlStatement::ExecutePrepared () {
114119 assert (prepared_statement_.get () != nullptr );
115120
116- Result<std::shared_ptr<FlightInfo>> result = prepared_statement_->Execute ();
121+ Result<std::shared_ptr<FlightInfo>> result =
122+ prepared_statement_->Execute (call_options_);
117123 ThrowIfNotOK (result.status ());
118124
119125 current_result_set_ = std::make_shared<FlightSqlResultSet>(
@@ -124,7 +130,7 @@ bool FlightSqlStatement::ExecutePrepared() {
124130}
125131
126132bool FlightSqlStatement::Execute (const std::string& query) {
127- ClosePreparedStatementIfAny (prepared_statement_);
133+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
128134
129135 Result<std::shared_ptr<FlightInfo>> result = sql_client_.Execute (call_options_, query);
130136 ThrowIfNotOK (result.status ());
@@ -146,7 +152,7 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetTables(
146152 const std::string* catalog_name, const std::string* schema_name,
147153 const std::string* table_name, const std::string* table_type,
148154 const ColumnNames& column_names) {
149- ClosePreparedStatementIfAny (prepared_statement_);
155+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
150156
151157 std::vector<std::string> table_types;
152158
@@ -199,7 +205,7 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetTables_V3(
199205std::shared_ptr<ResultSet> FlightSqlStatement::GetColumns_V2 (
200206 const std::string* catalog_name, const std::string* schema_name,
201207 const std::string* table_name, const std::string* column_name) {
202- ClosePreparedStatementIfAny (prepared_statement_);
208+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
203209
204210 Result<std::shared_ptr<FlightInfo>> result = sql_client_.GetTables (
205211 call_options_, catalog_name, schema_name, table_name, true , nullptr );
@@ -220,7 +226,7 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetColumns_V2(
220226std::shared_ptr<ResultSet> FlightSqlStatement::GetColumns_V3 (
221227 const std::string* catalog_name, const std::string* schema_name,
222228 const std::string* table_name, const std::string* column_name) {
223- ClosePreparedStatementIfAny (prepared_statement_);
229+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
224230
225231 Result<std::shared_ptr<FlightInfo>> result = sql_client_.GetTables (
226232 call_options_, catalog_name, schema_name, table_name, true , nullptr );
@@ -239,7 +245,7 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetColumns_V3(
239245}
240246
241247std::shared_ptr<ResultSet> FlightSqlStatement::GetTypeInfo_V2 (int16_t data_type) {
242- ClosePreparedStatementIfAny (prepared_statement_);
248+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
243249
244250 Result<std::shared_ptr<FlightInfo>> result = sql_client_.GetXdbcTypeInfo (call_options_);
245251 ThrowIfNotOK (result.status ());
@@ -257,7 +263,7 @@ std::shared_ptr<ResultSet> FlightSqlStatement::GetTypeInfo_V2(int16_t data_type)
257263}
258264
259265std::shared_ptr<ResultSet> FlightSqlStatement::GetTypeInfo_V3 (int16_t data_type) {
260- ClosePreparedStatementIfAny (prepared_statement_);
266+ ClosePreparedStatementIfAny (prepared_statement_, call_options_ );
261267
262268 Result<std::shared_ptr<FlightInfo>> result = sql_client_.GetXdbcTypeInfo (call_options_);
263269 ThrowIfNotOK (result.status ());
0 commit comments