MCPcopy Create free account
hub / github.com/apache/arrow / SQLFreeHandle

Function SQLFreeHandle

cpp/src/arrow/flight/sql/odbc/odbc_api.cc:139–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

137}
138
139SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle) {
140 ARROW_LOG(DEBUG) << "SQLFreeHandle called with type: " << type
141 << ", handle: " << handle;
142 switch (type) {
143 case SQL_HANDLE_ENV: {
144 using ODBC::ODBCEnvironment;
145
146 ODBCEnvironment* environment = reinterpret_cast<ODBCEnvironment*>(handle);
147
148 if (!environment) {
149 return SQL_INVALID_HANDLE;
150 }
151
152 delete environment;
153
154 return SQL_SUCCESS;
155 }
156
157 case SQL_HANDLE_DBC: {
158 using ODBC::ODBCConnection;
159
160 ODBCConnection* conn = reinterpret_cast<ODBCConnection*>(handle);
161
162 if (!conn) {
163 return SQL_INVALID_HANDLE;
164 }
165
166 // `ReleaseConnection` does the equivalent of `delete`.
167 // `ReleaseConnection` removes the connection `shared_ptr` from the `std::vector` of
168 // connections, and the `shared_ptr` is automatically destructed afterwards.
169 conn->ReleaseConnection();
170
171 return SQL_SUCCESS;
172 }
173
174 case SQL_HANDLE_STMT: {
175 using ODBC::ODBCStatement;
176
177 ODBCStatement* statement = reinterpret_cast<ODBCStatement*>(handle);
178
179 if (!statement) {
180 return SQL_INVALID_HANDLE;
181 }
182
183 statement->ReleaseStatement();
184
185 return SQL_SUCCESS;
186 }
187
188 case SQL_HANDLE_DESC: {
189 using ODBC::ODBCDescriptor;
190
191 ODBCDescriptor* descriptor = reinterpret_cast<ODBCDescriptor*>(handle);
192
193 if (!descriptor) {
194 return SQL_INVALID_HANDLE;
195 }
196

Callers 7

SQLFreeStmtFunction · 0.70
FreeEnvConnHandlesMethod · 0.50
TearDownMethod · 0.50
TYPED_TESTFunction · 0.50
TYPED_TESTFunction · 0.50
TESTFunction · 0.50
TYPED_TESTFunction · 0.50

Calls 3

ReleaseConnectionMethod · 0.80
ReleaseStatementMethod · 0.80
ReleaseDescriptorMethod · 0.80

Tested by 6

FreeEnvConnHandlesMethod · 0.40
TearDownMethod · 0.40
TYPED_TESTFunction · 0.40
TYPED_TESTFunction · 0.40
TESTFunction · 0.40
TYPED_TESTFunction · 0.40