LCOV - code coverage report
Current view: top level - src/odbc/unittests - t0002.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 23 23 100.0 %
Date: 2025-01-18 11:50:39 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : 
       3             : int
       4           8 : main(void)
       5             : {
       6           8 :         HSTMT old_odbc_stmt = SQL_NULL_HSTMT;
       7             : 
       8           8 :         odbc_connect();
       9             : 
      10           8 :         odbc_command("if object_id('tempdb..#odbctestdata') is not null drop table #odbctestdata");
      11             : 
      12           8 :         odbc_command("create table #odbctestdata (i int)");
      13           8 :         odbc_command("insert #odbctestdata values (123)");
      14             : 
      15             :         /*
      16             :          * now we allocate another statement, select, get all results
      17             :          * then make another query with first select and drop this statement
      18             :          * result should not disappear (required for DBD::ODBC)
      19             :          */
      20           8 :         SWAP_STMT(old_odbc_stmt);
      21           8 :         CHKAllocStmt(&odbc_stmt, "S");
      22             : 
      23           8 :         odbc_command("select * from #odbctestdata where 0=1");
      24             : 
      25           8 :         CHKFetch("No");
      26             : 
      27           8 :         CHKCloseCursor("SI");
      28             : 
      29           8 :         SWAP_STMT(old_odbc_stmt);
      30           8 :         odbc_command("select * from #odbctestdata");
      31           8 :         SWAP_STMT(old_odbc_stmt);
      32             : 
      33             :         /* drop first statement .. data should not disappear */
      34           8 :         CHKFreeStmt(SQL_DROP, "S");
      35           8 :         odbc_stmt = SQL_NULL_HSTMT;
      36           8 :         SWAP_STMT(old_odbc_stmt);
      37             : 
      38           8 :         CHKFetch("SI");
      39             : 
      40           8 :         CHKFetch("No");
      41             : 
      42           8 :         CHKCloseCursor("SI");
      43             : 
      44           8 :         odbc_command("drop table #odbctestdata");
      45             : 
      46           8 :         odbc_disconnect();
      47             : 
      48           8 :         printf("Done.\n");
      49             :         return 0;
      50             : }

Generated by: LCOV version 1.13