2
0

Add SendBatch to pool

This commit is contained in:
Jack Christensen
2019-04-25 15:07:35 -05:00
parent 00d123a944
commit 7b1272d254
13 changed files with 170 additions and 29 deletions
+4 -4
View File
@@ -683,7 +683,7 @@ func (c *Conn) QueryRow(ctx context.Context, sql string, args ...interface{}) Ro
// SendBatch sends all queued queries to the server at once. All queries are run in an implicit transaction unless
// explicit transaction control statements are executed.
func (c *Conn) SendBatch(ctx context.Context, b *Batch) *BatchResults {
func (c *Conn) SendBatch(ctx context.Context, b *Batch) BatchResults {
batch := &pgconn.Batch{}
for _, bi := range b.items {
@@ -698,7 +698,7 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) *BatchResults {
args, err := convertDriverValuers(bi.arguments)
if err != nil {
return &BatchResults{err: err}
return &batchResults{err: err}
}
paramFormats := make([]int16, len(args))
@@ -707,7 +707,7 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) *BatchResults {
paramFormats[i] = chooseParameterFormatCode(c.ConnInfo, parameterOIDs[i], args[i])
paramValues[i], err = newencodePreparedStatementArgument(c.ConnInfo, parameterOIDs[i], args[i])
if err != nil {
return &BatchResults{err: err}
return &batchResults{err: err}
}
}
@@ -739,7 +739,7 @@ func (c *Conn) SendBatch(ctx context.Context, b *Batch) *BatchResults {
mrr := c.pgConn.ExecBatch(ctx, batch)
return &BatchResults{
return &batchResults{
conn: c,
mrr: mrr,
}