浏览代码

Handle unlogged and counter batches as well

Staņislavs Koikovs 11 年之前
父节点
当前提交
9de086929b
共有 1 个文件被更改,包括 5 次插入6 次删除
  1. 5 6
      conn.go

+ 5 - 6
conn.go

@@ -368,14 +368,13 @@ func (c *Conn) executeQuery(qry *Query) *Iter {
 		PageSize:  qry.pageSize,
 		PageState: qry.pageState,
 	}
-	stmtType := op.Stmt
-	if n := strings.IndexFunc(stmtType, unicode.IsSpace); n >= 0 {
-		stmtType = strings.ToLower(stmtType[:n])
+	var stmtType string
+	if n := strings.IndexFunc(op.Stmt, unicode.IsSpace); n >= 0 {
+		stmtType = strings.ToLower(op.Stmt[:n])
 		switch stmtType {
 		case "begin":
-			stmtTail := strings.TrimSpace(op.Stmt[n:])
-			if n := strings.IndexFunc(stmtTail, unicode.IsSpace); n >= 0 {
-				stmtType = stmtType + " " + strings.ToLower(stmtTail[:n])
+			if n := strings.LastIndexFunc(op.Stmt, unicode.IsSpace); n >= 0 {
+				stmtType = stmtType + " " + strings.ToLower(op.Stmt[n+1:])
 			}
 		}
 	}