LCOV - code coverage report
Current view: top level - src/include/fe_utils - parallel_slot.h (source / functions) Hit Total Coverage
Test: PostgreSQL 17devel Lines: 8 8 100.0 %
Date: 2024-05-19 07:11:14 Functions: 2 2 100.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-2024, 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       22636 : ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler,
      48             :                        void *context)
      49             : {
      50       22636 :     slot->handler = handler;
      51       22636 :     slot->handler_context = context;
      52       22636 : }
      53             : 
      54             : static inline void
      55       22626 : ParallelSlotClearHandler(ParallelSlot *slot)
      56             : {
      57       22626 :     slot->handler = NULL;
      58       22626 :     slot->handler_context = NULL;
      59       22626 : }
      60             : 
      61             : extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlotArray *sa,
      62             :                                           const char *dbname);
      63             : 
      64             : extern ParallelSlotArray *ParallelSlotsSetup(int numslots, ConnParams *cparams,
      65             :                                              const char *progname, bool echo,
      66             :                                              const char *initcmd);
      67             : 
      68             : extern void ParallelSlotsAdoptConn(ParallelSlotArray *sa, PGconn *conn);
      69             : 
      70             : extern void ParallelSlotsTerminate(ParallelSlotArray *sa);
      71             : 
      72             : extern bool ParallelSlotsWaitCompletion(ParallelSlotArray *sa);
      73             : 
      74             : extern bool TableCommandResultHandler(PGresult *res, PGconn *conn,
      75             :                                       void *context);
      76             : 
      77             : #endif                          /* PARALLEL_SLOT_H */

Generated by: LCOV version 1.14