2
0

Batch uses statement cache.

This streamlines Queue's interface as well.
This commit is contained in:
Jack Christensen
2019-08-24 23:34:54 -05:00
parent 6508934508
commit 64b07f0d66
5 changed files with 201 additions and 156 deletions
+6 -12
View File
@@ -8,10 +8,8 @@ import (
)
type batchItem struct {
query string
arguments []interface{}
parameterOIDs []uint32
resultFormatCodes []int16
query string
arguments []interface{}
}
// Batch queries are a way of bundling multiple queries together to avoid
@@ -20,15 +18,11 @@ type Batch struct {
items []*batchItem
}
// Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement. parameterOIDs and
// resultFormatCodes should be nil if query is a prepared statement. Otherwise, parameterOIDs are required if there are
// parameters and resultFormatCodes are required if there is a result.
func (b *Batch) Queue(query string, arguments []interface{}, parameterOIDs []uint32, resultFormatCodes []int16) {
// Queue queues a query to batch b. query can be an SQL query or the name of a prepared statement.
func (b *Batch) Queue(query string, arguments ...interface{}) {
b.items = append(b.items, &batchItem{
query: query,
arguments: arguments,
parameterOIDs: parameterOIDs,
resultFormatCodes: resultFormatCodes,
query: query,
arguments: arguments,
})
}