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

Generated by: LCOV version 1.14