From 0e30c0ae61d79752ae36b6f4b33d76837f08abcf Mon Sep 17 00:00:00 2001 From: Jack Christensen Date: Mon, 5 Aug 2013 11:30:20 -0500 Subject: [PATCH] Fix: Prepare statement without result set --- connection.go | 1 + connection_test.go | 5 +++++ messages.go | 1 + 3 files changed, 7 insertions(+) diff --git a/connection.go b/connection.go index 0a1d04b7..e2a3ff79 100644 --- a/connection.go +++ b/connection.go @@ -454,6 +454,7 @@ func (c *Connection) Prepare(name, sql string) (err error) { ps.FieldDescriptions[i].FormatCode = 1 } } + case noData: case readyForQuery: c.rxReadyForQuery(r) c.preparedStatements[name] = &ps diff --git a/connection_test.go b/connection_test.go index 3baf5aec..38d55285 100644 --- a/connection_test.go +++ b/connection_test.go @@ -495,6 +495,11 @@ func TestPrepare(t *testing.T) { t.Errorf("Expected: %#v Received: %#v", bytea, result) } } + + mustExecute(t, conn, "create temporary table foo(id serial)") + if err = conn.Prepare("deleteFoo", "delete from foo"); err != nil { + t.Fatalf("Unable to prepare delete: %v", err) + } } func TestPrepareFailure(t *testing.T) { diff --git a/messages.go b/messages.go index a8231ddf..27d7444d 100644 --- a/messages.go +++ b/messages.go @@ -21,6 +21,7 @@ const ( parameterDescription = 't' bindComplete = '2' notificationResponse = 'A' + noData = 'n' ) type startupMessage struct {