diff --git a/conn.go b/conn.go index 0b262a69..33eef2f1 100644 --- a/conn.go +++ b/conn.go @@ -83,12 +83,8 @@ type CommandTag string // RowsAffected returns the number of rows affected. If the CommandTag was not // for a row affecting command (such as "CREATE TABLE") then it returns 0 func (ct CommandTag) RowsAffected() int64 { - words := strings.SplitN(string(ct), " ", 2) - if len(words) != 2 { - return 0 - } - - n, _ := strconv.ParseInt(words[1], 10, 64) + words := strings.Split(string(ct), " ") + n, _ := strconv.ParseInt(words[len(words)-1], 10, 64) return n } diff --git a/conn_test.go b/conn_test.go index 4eed28b1..d5bd350d 100644 --- a/conn_test.go +++ b/conn_test.go @@ -860,6 +860,7 @@ func TestCommandTag(t *testing.T) { commandTag pgx.CommandTag rowsAffected int64 }{ + {commandTag: "INSERT 0 5", rowsAffected: 5}, {commandTag: "UPDATE 0", rowsAffected: 0}, {commandTag: "UPDATE 1", rowsAffected: 1}, {commandTag: "DELETE 0", rowsAffected: 0},