mirror of
https://github.com/postgres/postgres.git
synced 2026-01-27 21:43:08 +03:00
Generalize parallel slot result handling.
Instead of having a hard-coded behavior that we ignore missing tables and report all other errors, let the caller decide what to do by setting a callback. Mark Dilger, reviewed and somewhat revised by me. The larger patch series of which this is a part has also had review from Peter Geoghegan, Andres Freund, Álvaro Herrera, Michael Paquier, and Amul Sul, but I don't know whether any of them have reviewed this bit specifically. Discussion: http://postgr.es/m/12ED3DA8-25F0-4B68-937D-D907CFBF08E7@enterprisedb.com Discussion: http://postgr.es/m/5F743835-3399-419C-8324-2D424237E999@enterprisedb.com Discussion: http://postgr.es/m/70655DF3-33CE-4527-9A4D-DDEB582B6BA0@enterprisedb.com
This commit is contained in:
@@ -15,12 +15,39 @@
|
||||
#include "fe_utils/connect_utils.h"
|
||||
#include "libpq-fe.h"
|
||||
|
||||
typedef bool (*ParallelSlotResultHandler) (PGresult *res, PGconn *conn,
|
||||
void *context);
|
||||
|
||||
typedef struct ParallelSlot
|
||||
{
|
||||
PGconn *connection; /* One connection */
|
||||
bool isFree; /* Is it known to be idle? */
|
||||
|
||||
/*
|
||||
* Prior to issuing a command or query on 'connection', a handler callback
|
||||
* function may optionally be registered to be invoked to process the
|
||||
* results, and context information may optionally be registered for use
|
||||
* by the handler. If unset, these fields should be NULL.
|
||||
*/
|
||||
ParallelSlotResultHandler handler;
|
||||
void *handler_context;
|
||||
} ParallelSlot;
|
||||
|
||||
static inline void
|
||||
ParallelSlotSetHandler(ParallelSlot *slot, ParallelSlotResultHandler handler,
|
||||
void *context)
|
||||
{
|
||||
slot->handler = handler;
|
||||
slot->handler_context = context;
|
||||
}
|
||||
|
||||
static inline void
|
||||
ParallelSlotClearHandler(ParallelSlot *slot)
|
||||
{
|
||||
slot->handler = NULL;
|
||||
slot->handler_context = NULL;
|
||||
}
|
||||
|
||||
extern ParallelSlot *ParallelSlotsGetIdle(ParallelSlot *slots, int numslots);
|
||||
|
||||
extern ParallelSlot *ParallelSlotsSetup(const ConnParams *cparams,
|
||||
@@ -31,5 +58,7 @@ extern void ParallelSlotsTerminate(ParallelSlot *slots, int numslots);
|
||||
|
||||
extern bool ParallelSlotsWaitCompletion(ParallelSlot *slots, int numslots);
|
||||
|
||||
extern bool TableCommandResultHandler(PGresult *res, PGconn *conn,
|
||||
void *context);
|
||||
|
||||
#endif /* PARALLEL_SLOT_H */
|
||||
|
||||
Reference in New Issue
Block a user