Skip to content

Commit

Permalink
Fixing problem with batch queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Shaw committed Jun 11, 2018
1 parent 5ce6f32 commit 71b77ae
Showing 1 changed file with 31 additions and 29 deletions.
60 changes: 31 additions & 29 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,41 +274,43 @@ func (h *Handler) Run() error {
// execute buf
if execute || h.buf.Ready() || res.Exec != metacmd.ExecNone {
// intercept batch query
typ, end, batch := drivers.IsBatchQueryPrefix(h.u, h.buf.Prefix)
switch {
case h.batch && batch:
fmt.Fprintf(stderr, "error: cannot perform %s in existing batch", typ)
fmt.Fprintln(stderr)
continue
if h.u != nil {
typ, end, batch := drivers.IsBatchQueryPrefix(h.u, h.buf.Prefix)
switch {
case h.batch && batch:
fmt.Fprintf(stderr, "error: cannot perform %s in existing batch", typ)
fmt.Fprintln(stderr)
continue

// cannot use \g* while accumulating statements for batch queries
case h.batch && typ != h.batchEnd && res.Exec != metacmd.ExecNone:
fmt.Fprintf(stderr, "error: cannot force batch execution", typ)
fmt.Fprintln(stderr)
continue
// cannot use \g* while accumulating statements for batch queries
case h.batch && typ != h.batchEnd && res.Exec != metacmd.ExecNone:
fmt.Fprint(stderr, "error: cannot force batch execution")
fmt.Fprintln(stderr)
continue

case batch:
h.batch, h.batchEnd = true, end
case batch:
h.batch, h.batchEnd = true, end

case h.batch:
var lend string
if len(h.last) != 0 {
lend = "\n"
}
case h.batch:
var lend string
if len(h.last) != 0 {
lend = "\n"
}

// append to last
h.last += lend + h.buf.String()
h.lastPrefix = h.buf.Prefix
h.lastRaw += lend + h.buf.RawString()
h.buf.Reset(nil)
// append to last
h.last += lend + h.buf.String()
h.lastPrefix = h.buf.Prefix
h.lastRaw += lend + h.buf.RawString()
h.buf.Reset(nil)

// break
if h.batchEnd != typ {
continue
}
// break
if h.batchEnd != typ {
continue
}

h.lastPrefix = h.batchEnd
h.batch, h.batchEnd = false, ""
h.lastPrefix = h.batchEnd
h.batch, h.batchEnd = false, ""
}
}

if h.buf.Len != 0 {
Expand Down

0 comments on commit 71b77ae

Please sign in to comment.