LCOV - code coverage report
Current view: top level - src/odbc/unittests - reexec.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 23 23 100.0 %
Date: 2025-11-11 14:30:15 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : 
       3             : /* Re-execute a prepared SELECT after SQLCloseCursor failed to fecth all rows */
       4             : 
       5             : static void
       6          20 : Test(bool direct)
       7             : {
       8          20 :         const char *sql = "SELECT a.name, b.name FROM sysobjects a, sysobjects b";
       9             :         int fetched;
      10             : 
      11          20 :         if (!direct) {
      12          10 :                 CHKPrepare(T(sql), SQL_NTS, "S");
      13          10 :                 CHKExecute("S");
      14             :         } else {
      15          10 :                 CHKExecDirect(T(sql), SQL_NTS, "S");
      16             :         }
      17             : 
      18         400 :         for (fetched = 0; CHKFetch("SNo") != SQL_NO_DATA && fetched < 20; ++fetched)
      19         400 :                 continue;
      20          20 :         CHKCloseCursor("SI");
      21             : 
      22          20 :         if (!direct) {
      23          10 :                 printf("Re-executing prepared statement...\n");
      24          10 :                 CHKExecute("S");
      25             :         } else {
      26          10 :                 printf("Re-executing statement...\n");
      27          10 :                 CHKExecDirect(T(sql), SQL_NTS, "S");
      28             :         }
      29             : 
      30          20 :         odbc_reset_statement();
      31          20 : }
      32             : 
      33          10 : TEST_MAIN()
      34             : {
      35          10 :         odbc_use_version3 = true;
      36          10 :         odbc_connect();
      37             : 
      38          10 :         Test(false);
      39          10 :         Test(true);
      40             : 
      41          10 :         odbc_disconnect();
      42          10 :         return 0;
      43             : }

Generated by: LCOV version 1.13