diff --git a/pkg/pgsql/server/query_machine.go b/pkg/pgsql/server/query_machine.go index ea6238f14e..df8088dbe5 100644 --- a/pkg/pgsql/server/query_machine.go +++ b/pkg/pgsql/server/query_machine.go @@ -68,6 +68,7 @@ func (s *session) QueryMachine() error { if err != nil { waitForSync = extQueryMode s.HandleError(err) + continue } if _, err = s.writeMessage(bm.ReadyForQuery()); err != nil { @@ -209,7 +210,7 @@ func (s *session) QueryMachine() error { continue } - if _, err = s.writeMessage(bm.BindComplete()); err != nil { + if _, err := s.writeMessage(bm.BindComplete()); err != nil { waitForSync = extQueryMode continue } @@ -241,6 +242,7 @@ func (s *session) QueryMachine() error { if err != nil { waitForSync = extQueryMode s.HandleError(err) + continue } case fm.FlushMsg: // there is no buffer to be flushed diff --git a/pkg/pgsql/server/query_machine_test.go b/pkg/pgsql/server/query_machine_test.go index 7d6d78925c..15585063c8 100644 --- a/pkg/pgsql/server/query_machine_test.go +++ b/pkg/pgsql/server/query_machine_test.go @@ -321,7 +321,7 @@ func TestSession_QueriesMachine(t *testing.T) { }, out: nil, portals: map[string]*portal{ - "port": &portal{ + "port": { Statement: &statement{ SQLStatement: "test", }, diff --git a/pkg/pgsql/server/session.go b/pkg/pgsql/server/session.go index 37df42b662..42ee94954d 100644 --- a/pkg/pgsql/server/session.go +++ b/pkg/pgsql/server/session.go @@ -27,6 +27,7 @@ import ( "github.com/codenotary/immudb/pkg/client" "github.com/codenotary/immudb/pkg/database" "github.com/codenotary/immudb/pkg/pgsql/errors" + bm "github.com/codenotary/immudb/pkg/pgsql/server/bmessages" fm "github.com/codenotary/immudb/pkg/pgsql/server/fmessages" "github.com/codenotary/immudb/pkg/pgsql/server/pgmeta" ) @@ -84,6 +85,11 @@ func (s *session) HandleError(e error) { if err != nil { s.log.Errorf("unable to write error on wire: %w", err) } + + _, err = s.writeMessage(bm.ReadyForQuery()) + if err != nil { + s.log.Errorf("unable to write error on wire: %w", err) + } } func (s *session) nextMessage() (interface{}, bool, error) {