LCOV - code coverage report
Current view: top level - src/include/fe_utils - parallel_slot.h (source / functions) Coverage Total Hit
Test: Code coverage Lines: 0.0 % 12 0
Test Date: 2026-01-26 10:56:24 Functions: 0.0 % 3 0
Legend: Lines:     hit not hit

            Line data    Source code
       1              : /*-------------------------------------------------------------------------
       2              :  *
       3              :  *      parallel_slot.h
       4              :  *              Parallel support for bin/scripts/
       5              :  *
       6              :  *      Copyright (c) 2003-2026, PostgreSQL Global Development Group
       7              :  *
       8              :  *      src/include/fe_utils/parallel_slot.h
       9              :  *
      10              :  *-------------------------------------------------------------------------
      11              :  */
      12              : #ifndef PARALLEL_SLOT_H
      13              : #define PARALLEL_SLOT_H
      14              : 
      15              : #include "fe_utils/connect_utils.h"
      16              : #include "libpq-fe.h"
      17              : 
      18              : typedef bool (*ParallelSlotResultHandler) (PGresult *res, PGconn *conn,
      19              :                                                                                    void *context);
      20              : 
      21              : typedef struct ParallelSlot
      22              : {
      23              :         PGconn     *connection;         /* One connection */
      24              :         bool            inUse;                  /* Is the slot being used? */
      25              : 
      26              :         /*
      27              :          * Prior to issuing a command or query on 'connection', a handler callback
      28              :          * function may optionally be registered to be invoked to process the
      29              :          * results, and context information may optionally be registered for use
      30              :          * by the handler.  If unset, these fields should be NULL.
      31              :          */
      32              :         ParallelSlotResultHandler handler;
      33              :         void       *handler_context;
      34              : } ParallelSlot;
      35              : 
      36              : typedef struct ParallelSlotArray
      37              : {
      38              :         int                     numslots;
      39              :         ConnParams *cparams;
      40              :         const char *progname;
      41              :         bool            echo;
      42              :         const char *initcmd;
      43              :         ParallelSlot slots[FLEXIBLE_ARRAY_MEMBER];
      44              : } ParallelSlotArray;
      45              : 
      46              : static inline void
      47            0 : ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler,
      48              :                                            void *context)
      49              : {
      50            0 :         slot->handler = handler;
      51            0 :         slot->handler_context = context;
      52            0 : }
      53              : 
      54              : static inline void
      55            0 : ParallelSlotClearHandler(ParallelSlot *slot)
      56              : {
      57            0 :         slot->handler = NULL;
      58            0 :         slot->handler_context = NULL;
      59            0 : }
      60              : 
      61              : static inline void
      62            0 : ParallelSlotSetIdle(ParallelSlot *slot)
      63              : {
      64            0 :         slot->inUse = false;
      65            0 :         ParallelSlotClearHandler(slot);
      66            0 : }
      67              : 
      68              : extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlotArray *sa,
      69              :                                                                                   const char *dbname);
      70              : 
      71              : extern ParallelSlotArray *ParallelSlotsSetup(int numslots, ConnParams *cparams,
      72              :                                                                                          const char *progname, bool echo,
      73              :                                                                                          const char *initcmd);
      74              : 
      75              : extern void ParallelSlotsAdoptConn(ParallelSlotArray *sa, PGconn *conn);
      76              : 
      77              : extern void ParallelSlotsTerminate(ParallelSlotArray *sa);
      78              : 
      79              : extern bool ParallelSlotsWaitCompletion(ParallelSlotArray *sa);
      80              : 
      81              : extern bool TableCommandResultHandler(PGresult *res, PGconn *conn,
      82              :                                                                           void *context);
      83              : 
      84              : #endif                                                  /* PARALLEL_SLOT_H */
        

Generated by: LCOV version 2.3.2-1