LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLGetCursorName.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 10 0.0 %
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             :  * SQLGetCursorName()
      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 "ODBCStmt.h"
      30             : #include "ODBCUtil.h"
      31             : 
      32             : 
      33             : static SQLRETURN
      34             : MNDBGetCursorName(ODBCStmt *stmt,
      35             :                   SQLCHAR *CursorName,
      36             :                   SQLSMALLINT BufferLength,
      37             :                   SQLSMALLINT *NameLengthPtr)
      38             : {
      39             :         (void) CursorName;
      40             :         (void) BufferLength;
      41             :         (void) NameLengthPtr;
      42             : 
      43             :         /* TODO: implement the requested behavior when
      44             :          * SQLSetCursorName() is implemented */
      45             : 
      46             :         /* for now always return error */
      47             :         /* No cursor name available */
      48           0 :         addStmtError(stmt, "HY015", NULL, 0);
      49             : 
      50             :         return SQL_ERROR;
      51             : }
      52             : 
      53             : SQLRETURN SQL_API
      54             : SQLGetCursorName(SQLHSTMT StatementHandle,
      55             :                  SQLCHAR *CursorName,
      56             :                  SQLSMALLINT BufferLength,
      57             :                  SQLSMALLINT *NameLengthPtr)
      58             : {
      59             :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      60             : 
      61             : #ifdef ODBCDEBUG
      62           0 :         ODBCLOG("SQLGetCursorName %p %p %d %p\n",
      63             :                 StatementHandle, CursorName,
      64             :                 (int) BufferLength, NameLengthPtr);
      65             : #endif
      66             : 
      67           0 :         if (!isValidStmt(stmt))
      68             :                  return SQL_INVALID_HANDLE;
      69             : 
      70           0 :         clearStmtErrors(stmt);
      71             : 
      72           0 :         return MNDBGetCursorName(stmt, CursorName, BufferLength, NameLengthPtr);
      73             : }
      74             : 
      75             : SQLRETURN SQL_API
      76             : SQLGetCursorNameA(SQLHSTMT StatementHandle,
      77             :                   SQLCHAR *CursorName,
      78             :                   SQLSMALLINT BufferLength,
      79             :                   SQLSMALLINT *NameLengthPtr)
      80             : {
      81           0 :         return SQLGetCursorName(StatementHandle,
      82             :                                 CursorName,
      83             :                                 BufferLength,
      84             :                                 NameLengthPtr);
      85             : }
      86             : 
      87             : SQLRETURN SQL_API
      88             : SQLGetCursorNameW(SQLHSTMT StatementHandle,
      89             :                   SQLWCHAR *CursorName,
      90             :                   SQLSMALLINT BufferLength,
      91             :                   SQLSMALLINT *NameLengthPtr)
      92             : {
      93             :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      94             :         SQLRETURN rc;
      95             :         SQLSMALLINT n;
      96             :         SQLCHAR *cursor;
      97             : 
      98             : #ifdef ODBCDEBUG
      99           0 :         ODBCLOG("SQLGetCursorNameW %p %p %d %p\n",
     100             :                 StatementHandle, CursorName,
     101             :                 (int) BufferLength, NameLengthPtr);
     102             : #endif
     103             : 
     104           0 :         if (!isValidStmt(stmt))
     105             :                  return SQL_INVALID_HANDLE;
     106             : 
     107           0 :         clearStmtErrors(stmt);
     108             : 
     109             :         rc = MNDBGetCursorName(stmt, NULL, 0, &n);
     110             :         if (!SQL_SUCCEEDED(rc))
     111           0 :                 return rc;
     112             :         clearStmtErrors(stmt);
     113             :         n++;                    /* account for NUL byte */
     114             :         cursor = malloc(n);
     115             :         if (cursor == NULL) {
     116             :                 /* Memory allocation error */
     117             :                 addStmtError(stmt, "HY001", NULL, 0);
     118             :                 return SQL_ERROR;
     119             :         }
     120             :         rc = MNDBGetCursorName(stmt, cursor, BufferLength, &n);
     121             :         if (SQL_SUCCEEDED(rc))    {
     122             :                 fixWcharOut(rc, cursor, n, CursorName, BufferLength,
     123             :                             NameLengthPtr, 1, addStmtError, stmt);
     124             :         }
     125             :         free(cursor);
     126             : 
     127             :         return rc;
     128             : }

Generated by: LCOV version 1.14