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

Generated by: LCOV version 1.14