LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLGetCursorName.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 22 0.0 %
Date: 2024-10-04 20:04:04 Functions: 0 0 -

          Line data    Source code
       1             : /*
       2             :  * SPDX-License-Identifier: MPL-2.0
       3             :  *
       4             :  * This Source Code Form is subject to the terms of the Mozilla Public
       5             :  * License, v. 2.0.  If a copy of the MPL was not distributed with this
       6             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       7             :  *
       8             :  * Copyright 2024 MonetDB Foundation;
       9             :  * Copyright August 2008 - 2023 MonetDB B.V.;
      10             :  * Copyright 1997 - July 2008 CWI.
      11             :  */
      12             : 
      13             : /*
      14             :  * This code was created by Peter Harvey (mostly during Christmas 98/99).
      15             :  * This code is LGPL. Please ensure that this message remains in future
      16             :  * distributions and uses of this code (that's about all I get out of it).
      17             :  * - Peter Harvey pharvey@codebydesign.com
      18             :  *
      19             :  * This file has been modified for the MonetDB project.  See the file
      20             :  * Copyright in this directory for more information.
      21             :  */
      22             : 
      23             : /**********************************************************************
      24             :  * SQLGetCursorName()
      25             :  * CLI Compliance: ISO 92
      26             :  *
      27             :  * Author: Martin van Dinther, Sjoerd Mullender
      28             :  * Date  : 30 aug 2002
      29             :  *
      30             :  **********************************************************************/
      31             : 
      32             : #include "ODBCGlobal.h"
      33             : #include "ODBCStmt.h"
      34             : #include "ODBCUtil.h"
      35             : 
      36             : 
      37             : static SQLRETURN
      38           0 : MNDBGetCursorName(ODBCStmt *stmt,
      39             :                   SQLCHAR *CursorName,
      40             :                   SQLSMALLINT BufferLength,
      41             :                   SQLSMALLINT *NameLengthPtr)
      42             : {
      43           0 :         (void) CursorName;
      44           0 :         (void) BufferLength;
      45           0 :         (void) NameLengthPtr;
      46             : 
      47             :         /* TODO: implement the requested behavior when
      48             :          * SQLSetCursorName() is implemented */
      49             : 
      50             :         /* for now always return error */
      51             :         /* No cursor name available */
      52           0 :         addStmtError(stmt, "HY015", NULL, 0);
      53             : 
      54           0 :         return SQL_ERROR;
      55             : }
      56             : 
      57             : SQLRETURN SQL_API
      58             : SQLGetCursorName(SQLHSTMT StatementHandle,
      59             :                  SQLCHAR *CursorName,
      60             :                  SQLSMALLINT BufferLength,
      61             :                  SQLSMALLINT *NameLengthPtr)
      62             : {
      63           0 :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      64             : 
      65             : #ifdef ODBCDEBUG
      66           0 :         ODBCLOG("SQLGetCursorName %p %p %d %p\n",
      67             :                 StatementHandle, CursorName,
      68             :                 (int) BufferLength, NameLengthPtr);
      69             : #endif
      70             : 
      71           0 :         if (!isValidStmt(stmt))
      72             :                  return SQL_INVALID_HANDLE;
      73             : 
      74           0 :         clearStmtErrors(stmt);
      75             : 
      76           0 :         return MNDBGetCursorName(stmt, CursorName, BufferLength, NameLengthPtr);
      77             : }
      78             : 
      79             : SQLRETURN SQL_API
      80             : SQLGetCursorNameA(SQLHSTMT StatementHandle,
      81             :                   SQLCHAR *CursorName,
      82             :                   SQLSMALLINT BufferLength,
      83             :                   SQLSMALLINT *NameLengthPtr)
      84             : {
      85           0 :         return SQLGetCursorName(StatementHandle,
      86             :                                 CursorName,
      87             :                                 BufferLength,
      88             :                                 NameLengthPtr);
      89             : }
      90             : 
      91             : SQLRETURN SQL_API
      92             : SQLGetCursorNameW(SQLHSTMT StatementHandle,
      93             :                   SQLWCHAR *CursorName,
      94             :                   SQLSMALLINT BufferLength,
      95             :                   SQLSMALLINT *NameLengthPtr)
      96             : {
      97           0 :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      98           0 :         SQLRETURN rc;
      99           0 :         SQLSMALLINT n;
     100           0 :         SQLCHAR *cursor;
     101             : 
     102             : #ifdef ODBCDEBUG
     103           0 :         ODBCLOG("SQLGetCursorNameW %p %p %d %p\n",
     104             :                 StatementHandle, CursorName,
     105             :                 (int) BufferLength, NameLengthPtr);
     106             : #endif
     107             : 
     108           0 :         if (!isValidStmt(stmt))
     109             :                  return SQL_INVALID_HANDLE;
     110             : 
     111           0 :         clearStmtErrors(stmt);
     112             : 
     113           0 :         rc = MNDBGetCursorName(stmt, NULL, 0, &n);
     114           0 :         if (!SQL_SUCCEEDED(rc))
     115           0 :                 return rc;
     116             :         clearStmtErrors(stmt);
     117             :         n++;                    /* account for NUL byte */
     118             :         cursor = malloc(n);
     119             :         if (cursor == NULL) {
     120             :                 /* Memory allocation error */
     121             :                 addStmtError(stmt, "HY001", NULL, 0);
     122             :                 return SQL_ERROR;
     123             :         }
     124             :         rc = MNDBGetCursorName(stmt, cursor, BufferLength, &n);
     125             :         if (SQL_SUCCEEDED(rc))    {
     126             :                 fixWcharOut(rc, cursor, n, CursorName, BufferLength,
     127             :                             NameLengthPtr, 1, addStmtError, stmt);
     128             :         }
     129             :         free(cursor);
     130             : 
     131             :         return rc;
     132             : }

Generated by: LCOV version 1.14