LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLSetCursorName.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 24 0.0 %
Date: 2024-11-15 19:37:45 Functions: 0 1 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             :  * SQLSetCursorName()
      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 : MNDBSetCursorName(ODBCStmt *stmt,
      39             :                   const SQLCHAR *CursorName,
      40             :                   SQLSMALLINT NameLength)
      41             : {
      42           0 :         fixODBCstring(CursorName, NameLength, SQLSMALLINT,
      43             :                       addStmtError, stmt, return SQL_ERROR);
      44             : 
      45             : #ifdef ODBCDEBUG
      46           0 :         ODBCLOG("\"%.*s\"\n", (int) NameLength, (char *) CursorName);
      47             : #endif
      48             : 
      49           0 :         if (stmt->State >= EXECUTED0) {
      50             :                 /* Invalid cursor state */
      51           0 :                 addStmtError(stmt, "24000", NULL, 0);
      52           0 :                 return SQL_ERROR;
      53             :         }
      54             : 
      55             :         /* TODO: implement the requested behavior */
      56             :         /* Note: when cursor names are to be implemented the SQL
      57             :          * parser & executor must also be able to use it. */
      58             : 
      59             :         /* for now always return error */
      60             :         /* Driver does not support this function */
      61           0 :         addStmtError(stmt, "IM001", NULL, 0);
      62             : 
      63           0 :         return SQL_ERROR;
      64             : }
      65             : 
      66             : SQLRETURN SQL_API
      67             : SQLSetCursorName(SQLHSTMT StatementHandle,
      68             :                  SQLCHAR *CursorName,
      69             :                  SQLSMALLINT NameLength)
      70             : {
      71           0 :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      72             : 
      73             : #ifdef ODBCDEBUG
      74           0 :         ODBCLOG("SQLSetCursorName %p ", StatementHandle);
      75             : #endif
      76             : 
      77           0 :         if (!isValidStmt(stmt))
      78             :                  return SQL_INVALID_HANDLE;
      79             : 
      80           0 :         clearStmtErrors(stmt);
      81             : 
      82           0 :         return MNDBSetCursorName(stmt, CursorName, NameLength);
      83             : }
      84             : 
      85             : SQLRETURN SQL_API
      86             : SQLSetCursorNameA(SQLHSTMT StatementHandle,
      87             :                   SQLCHAR *CursorName,
      88             :                   SQLSMALLINT NameLength)
      89             : {
      90           0 :         return SQLSetCursorName(StatementHandle, CursorName, NameLength);
      91             : }
      92             : 
      93             : SQLRETURN SQL_API
      94             : SQLSetCursorNameW(SQLHSTMT StatementHandle,
      95             :                   SQLWCHAR *CursorName,
      96             :                   SQLSMALLINT NameLength)
      97             : {
      98           0 :         ODBCStmt *stmt = (ODBCStmt *) StatementHandle;
      99           0 :         SQLRETURN rc;
     100           0 :         SQLCHAR *cursor;
     101             : 
     102             : #ifdef ODBCDEBUG
     103           0 :         ODBCLOG("SQLSetCursorNameW %p ", StatementHandle);
     104             : #endif
     105             : 
     106           0 :         if (!isValidStmt(stmt))
     107             :                  return SQL_INVALID_HANDLE;
     108             : 
     109           0 :         clearStmtErrors(stmt);
     110             : 
     111           0 :         fixWcharIn(CursorName, NameLength, SQLCHAR, cursor,
     112             :                    addStmtError, stmt, return SQL_ERROR);
     113             : 
     114           0 :         rc = MNDBSetCursorName(stmt, cursor, SQL_NTS);
     115             : 
     116           0 :         if (cursor)
     117           0 :                 free(cursor);
     118             : 
     119             :         return rc;
     120             : }

Generated by: LCOV version 1.14