LCOV - code coverage report
Current view: top level - clients/odbc/driver - SQLCopyDesc.c (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 23 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             :  * SQLCopyDesc()
      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             : 
      31             : 
      32             : SQLRETURN SQL_API
      33             : SQLCopyDesc(SQLHDESC SourceDescHandle,
      34             :             SQLHDESC TargetDescHandle)
      35             : {
      36             :         ODBCDesc *src = (ODBCDesc *) SourceDescHandle;
      37             :         ODBCDesc *dst = (ODBCDesc *) TargetDescHandle;
      38             : 
      39             : #ifdef ODBCDEBUG
      40           0 :         ODBCLOG("SQLCopyDesc %p %p\n",
      41             :                 SourceDescHandle, TargetDescHandle);
      42             : #endif
      43             : 
      44           0 :         if (!isValidDesc(src))
      45             :                 return SQL_INVALID_HANDLE;
      46             : 
      47           0 :         if (!isValidDesc(dst))
      48             :                 return SQL_INVALID_HANDLE;
      49             : 
      50           0 :         if (isIRD(dst)) {
      51             :                 /* Cannot modify an implementation row descriptor */
      52           0 :                 addDescError(src, "HY016", NULL, 0);
      53           0 :                 return SQL_ERROR;
      54             :         }
      55             : 
      56           0 :         clearDescErrors(src);
      57             : 
      58           0 :         if (isIRD(src)) {
      59           0 :                 if (src->Stmt->State == INITED) {
      60             :                         /* Associated statement is not prepared */
      61           0 :                         addDescError(src, "HY007", NULL, 0);
      62           0 :                         return SQL_ERROR;
      63             :                 }
      64           0 :                 if (src->Stmt->State == PREPARED0 ||
      65             :                     src->Stmt->State == EXECUTED0) {
      66             :                         /* Invalid cursor state */
      67           0 :                         addDescError(src, "24000", NULL, 0);
      68           0 :                         return SQL_ERROR;
      69             :                 }
      70             :         }
      71             : 
      72             :         /* copy sql_desc_count and allocate space for descr. records */
      73           0 :         setODBCDescRecCount(dst, src->sql_desc_count);
      74             : 
      75             :         /* don't copy sql_desc_alloc_type */
      76           0 :         dst->sql_desc_array_size = src->sql_desc_array_size;
      77           0 :         dst->sql_desc_array_status_ptr = src->sql_desc_array_status_ptr;
      78           0 :         dst->sql_desc_bind_offset_ptr = src->sql_desc_bind_offset_ptr;
      79           0 :         dst->sql_desc_bind_type = src->sql_desc_bind_type;
      80           0 :         dst->sql_desc_rows_processed_ptr = src->sql_desc_rows_processed_ptr;
      81           0 :         if (src->descRec)
      82           0 :                 memcpy(dst->descRec, src->descRec,
      83           0 :                        src->sql_desc_count * sizeof(*src->descRec));
      84             : 
      85             :         return SQL_SUCCESS;
      86             : }

Generated by: LCOV version 1.14