LCOV - code coverage report
Current view: top level - src/odbc/unittests - cursor2.c (source / functions) Hit Total Coverage
Test: FreeTDS coverage Lines: 18 18 100.0 %
Date: 2025-01-18 12:13:41 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "common.h"
       2             : 
       3             : /*
       4             :  * 1) Test cursor do not give error for statement that do not return rows
       5             :  * 2) Test cursor returns results on language RPCs
       6             :  */
       7             : 
       8             : static char software_version[] = "$Id: cursor2.c,v 1.12 2011-07-12 10:16:59 freddy77 Exp $";
       9             : static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
      10             : 
      11             : int
      12           8 : main(int argc, char *argv[])
      13             : {
      14             :         SQLTCHAR sqlstate[6];
      15             :         SQLTCHAR msg[256];
      16             : 
      17           8 :         odbc_connect();
      18           8 :         odbc_check_cursor();
      19             : 
      20           6 :         odbc_command("CREATE TABLE #cursor2_test (i INT)");
      21             : 
      22           6 :         odbc_reset_statement();
      23           6 :         CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_DYNAMIC, SQL_IS_INTEGER, "S");
      24             : 
      25             :         /* this should not fail or return warnings */
      26           6 :         odbc_command("DROP TABLE #cursor2_test");
      27             : 
      28           6 :         CHKGetDiagRec(SQL_HANDLE_STMT, odbc_stmt, 1, sqlstate, NULL, msg, TDS_VECTOR_SIZE(msg), NULL, "No");
      29             : 
      30             : 
      31           6 :         odbc_reset_statement();
      32           6 :         odbc_command_with_result(odbc_stmt, "if object_id('sp_test') is not null drop proc sp_test");
      33           6 :         odbc_command("create proc sp_test @name varchar(30) as select 0 as pippo select 1 as 'test', @name as 'nome'");
      34             : 
      35           6 :         odbc_reset_statement();
      36           6 :         CHKSetStmtAttr(SQL_ATTR_CURSOR_TYPE, (SQLPOINTER) SQL_CURSOR_STATIC, SQL_IS_INTEGER, "S");
      37             : 
      38           6 :         odbc_command(" exec sp_test 'ciao'");
      39             : 
      40           6 :         CHKFetch("S");
      41             : 
      42           6 :         odbc_reset_statement();
      43           6 :         odbc_command("drop proc sp_test");
      44             : 
      45           6 :         odbc_disconnect();
      46             :         
      47             :         return 0;
      48             : }

Generated by: LCOV version 1.13