LCOV - code coverage report
Current view: top level - src/interfaces/ecpg/test/thread - descriptor.pgc (source / functions) Coverage Total Hit
Test: PostgreSQL 20devel Lines: 100.0 % 12 12
Test Date: 2026-07-03 19:57:34 Functions: 100.0 % 2 2
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 80.0 % 10 8

             Branch data     Line data    Source code
       1                 :             : #ifdef WIN32
       2                 :             : #define WIN32_LEAN_AND_MEAN
       3                 :             : #include <windows.h>
       4                 :             : #include <process.h>
       5                 :             : #include <locale.h>
       6                 :             : #else
       7                 :             : #include <pthread.h>
       8                 :             : #endif
       9                 :             : #include <stdio.h>
      10                 :             : 
      11                 :             : #define THREADS     16
      12                 :             : #define REPEATS     50000
      13                 :             : 
      14                 :             : EXEC SQL include sqlca;
      15                 :             : EXEC SQL whenever sqlerror sqlprint;
      16                 :             : EXEC SQL whenever not found sqlprint;
      17                 :             : 
      18                 :             : #if defined(WIN32)
      19                 :             : static unsigned __stdcall fn(void* arg)
      20                 :             : #else
      21                 :          32 : static void* fn(void* arg)
      22                 :             : #endif
      23                 :             : {
      24                 :             :     int i;
      25                 :             : 
      26         [ +  + ]:     1600032 :     for (i = 1; i <= REPEATS; ++i)
      27                 :             :     {
      28                 :     1600000 :         EXEC SQL ALLOCATE DESCRIPTOR mydesc;
      29         [ -  + ]:     1600000 :         EXEC SQL DEALLOCATE DESCRIPTOR mydesc;
      30         [ -  + ]:     1600000 :     }
      31                 :             : 
      32                 :          32 :     return 0;
      33                 :             : }
      34                 :             : 
      35                 :           2 : int main(void)
      36                 :             : {
      37                 :             :     int i;
      38                 :             : #ifdef WIN32
      39                 :             :     HANDLE threads[THREADS];
      40                 :             : #else
      41                 :             :     pthread_t threads[THREADS];
      42                 :             : #endif
      43                 :             : 
      44                 :             : #ifdef WIN32
      45                 :             :     for (i = 0; i < THREADS; ++i)
      46                 :             :     {
      47                 :             :         unsigned id;
      48                 :             :         threads[i] = (HANDLE)_beginthreadex(NULL, 0, fn, NULL, 0, &id);
      49                 :             :     }
      50                 :             : 
      51                 :             :     WaitForMultipleObjects(THREADS, threads, TRUE, INFINITE);
      52                 :             :     for (i = 0; i < THREADS; ++i)
      53                 :             :         CloseHandle(threads[i]);
      54                 :             : #else
      55         [ +  + ]:          34 :     for (i = 0; i < THREADS; ++i)
      56                 :          32 :         pthread_create(&threads[i], NULL, fn, NULL);
      57         [ +  + ]:          34 :     for (i = 0; i < THREADS; ++i)
      58                 :          32 :         pthread_join(threads[i], NULL);
      59                 :             : #endif
      60                 :             : 
      61                 :           2 :     return 0;
      62                 :             : }
        

Generated by: LCOV version 2.0-1