MCPcopy
hub / github.com/jackc/pgx / StartPipeline

Method StartPipeline

pgconn/pgconn.go:2426–2460  ·  view source on GitHub ↗

StartPipeline switches the connection to pipeline mode and returns a *Pipeline. In pipeline mode requests can be sent to the server without waiting for a response. Close must be called on the returned *Pipeline to return the connection to normal mode. While in pipeline mode, no methods that communic

(ctx context.Context)

Source from the content-addressed store, hash-verified

2424//
2425// Prefer ExecBatch when only sending one group of queries at once.
2426func (pgConn *PgConn) StartPipeline(ctx context.Context) *Pipeline {
2427 if err := pgConn.lock(); err != nil {
2428 pipeline := &Pipeline{
2429 closed: true,
2430 err: err,
2431 }
2432 pipeline.state.Init()
2433
2434 return pipeline
2435 }
2436
2437 pgConn.resultReader = ResultReader{closed: true}
2438
2439 pgConn.pipeline = Pipeline{
2440 conn: pgConn,
2441 ctx: ctx,
2442 }
2443 pgConn.pipeline.state.Init()
2444
2445 pipeline := &pgConn.pipeline
2446
2447 if ctx != context.Background() {
2448 select {
2449 case <-ctx.Done():
2450 pipeline.closed = true
2451 pipeline.err = newContextAlreadyDoneError(ctx)
2452 pgConn.unlock()
2453 return pipeline
2454 default:
2455 }
2456 pgConn.contextWatcher.Watch(ctx)
2457 }
2458
2459 return pipeline
2460}
2461
2462// SendPrepare is the pipeline version of *PgConn.Prepare.
2463func (p *Pipeline) SendPrepare(name, sql string, paramOIDs []uint32) {

Calls 5

lockMethod · 0.95
unlockMethod · 0.95
InitMethod · 0.80
WatchMethod · 0.80