LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLDisconnect.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 13 16 81.2 %
Date: 2021-10-13 02:24:04 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       5             :  *
       6             :  * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V.
       7             :  */
       8             : 
       9             : /*
      10             :  * This code was created by Peter Harvey (mostly during Christmas 98/99).
      11             :  * This code is LGPL. Please ensure that this message remains in future
      12             :  * distributions and uses of this code (thats about all I get out of it).
      13             :  * - Peter Harvey pharvey@codebydesign.com
      14             :  *
      15             :  * This file has been modified for the MonetDB project.  See the file
      16             :  * Copyright in this directory for more information.
      17             :  */
      18             : 
      19             : /**********************************************************************
      20             :  * SQLDisconnect
      21             :  * CLI Compliance: ISO 92
      22             :  *
      23             :  * Author: Martin van Dinther, Sjoerd Mullender
      24             :  * Date  : 30 aug 2002
      25             :  *
      26             :  **********************************************************************/
      27             : 
      28             : #include "ODBCGlobal.h"
      29             : #include "ODBCDbc.h"
      30             : #include "ODBCStmt.h"
      31             : 
      32             : SQLRETURN SQL_API
      33             : SQLDisconnect(SQLHDBC ConnectionHandle)
      34             : {
      35             :         ODBCDbc *dbc = (ODBCDbc *) ConnectionHandle;
      36             : 
      37             : #ifdef ODBCDEBUG
      38           2 :         ODBCLOG("SQLDisconnect %p\n", ConnectionHandle);
      39             : #endif
      40             : 
      41           2 :         if (!isValidDbc(dbc))
      42             :                 return SQL_INVALID_HANDLE;
      43             : 
      44           2 :         clearDbcErrors(dbc);
      45             : 
      46             :         /* check connection state, should be connected */
      47           2 :         if (!dbc->Connected) {
      48             :                 /* Connection does not exist */
      49           0 :                 addDbcError(dbc, "08003", NULL, 0);
      50           0 :                 return SQL_ERROR;
      51             :         }
      52             : 
      53           2 :         while (dbc->FirstStmt != NULL)
      54           0 :                 if (ODBCFreeStmt_(dbc->FirstStmt) == SQL_ERROR)
      55             :                         return SQL_ERROR;
      56             : 
      57             :         /* client waves goodbye */
      58           2 :         mapi_disconnect(dbc->mid);
      59           2 :         mapi_destroy(dbc->mid);
      60             : 
      61           2 :         dbc->mid = NULL;
      62           2 :         dbc->cachelimit = 0;
      63           2 :         dbc->Mdebug = 0;
      64           2 :         dbc->Connected = false;
      65           2 :         dbc->has_comment = false;
      66             : 
      67           2 :         return SQL_SUCCESS;
      68             : }

Generated by: LCOV version 1.14