LCOV - code coverage report
Current view: top level - src/odbc/unittests - hidden.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 21 25 84.0 %
Date: 2024-04-18 21:21:48 Functions: 1 1 100.0 %

          Line data    Source code
       1             : /* Testing result column numbers having hidden columns */
       2             : /* Test from Sebastien Flaesch */
       3             : 
       4             : #include "common.h"
       5             : 
       6             : int
       7           8 : main(int argc, char **argv)
       8             : {
       9           8 :         SQLSMALLINT cnt = 0;
      10           8 :         int failed = 0;
      11             : 
      12           8 :         odbc_use_version3 = 1;
      13           8 :         odbc_connect();
      14             : 
      15           8 :         odbc_command("CREATE TABLE #t1 ( k INT, c CHAR(10), vc VARCHAR(10) )");
      16           8 :         odbc_command("CREATE TABLE #tmp1 (i NUMERIC(10,0) IDENTITY PRIMARY KEY, b VARCHAR(20) NULL, c INT NOT NULL)");
      17             : 
      18             :         /* test hidden column with FOR BROWSE */
      19           8 :         odbc_reset_statement();
      20             : 
      21           8 :         odbc_command("SELECT c, b FROM #tmp1");
      22             : 
      23           8 :         CHKNumResultCols(&cnt, "S");
      24             : 
      25           8 :         if (cnt != 2) {
      26           0 :                 fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt);
      27           0 :                 failed = 1;
      28             :         }
      29           8 :         odbc_reset_statement();
      30             : 
      31             :         /* test hidden column with cursors*/
      32           8 :         odbc_check_cursor();
      33             : 
      34           6 :         CHKSetStmtAttr(SQL_ATTR_CURSOR_SCROLLABLE, (SQLPOINTER) SQL_NONSCROLLABLE, SQL_IS_UINTEGER, "S");
      35           6 :         CHKSetStmtAttr(SQL_ATTR_CURSOR_SENSITIVITY, (SQLPOINTER) SQL_SENSITIVE, SQL_IS_UINTEGER, "S");
      36             : 
      37           6 :         CHKPrepare(T("SELECT * FROM #t1"), SQL_NTS, "S");
      38             : 
      39           6 :         CHKExecute("S");
      40             : 
      41           6 :         CHKNumResultCols(&cnt, "S");
      42             : 
      43           6 :         if (cnt != 3) {
      44           0 :                 fprintf(stderr, "Wrong number of columns in result set: %d\n", (int) cnt);
      45           0 :                 failed = 1;
      46             :         }
      47             : 
      48           6 :         odbc_disconnect();
      49             : 
      50           6 :         return failed ? 1: 0;
      51             : }

Generated by: LCOV version 1.13