Skip to content

Commit

Permalink
chore(pkg/pgsql): minor protocol changes
Browse files Browse the repository at this point in the history
Signed-off-by: Jeronimo Irazabal <[email protected]>
  • Loading branch information
jeroiraz committed Oct 27, 2023
1 parent 91a30ec commit 2b7347b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/pgsql/server/query_machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/pgsql/server/query_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func TestSession_QueriesMachine(t *testing.T) {
},
out: nil,
portals: map[string]*portal{
"port": &portal{
"port": {
Statement: &statement{
SQLStatement: "test",
},
Expand Down
6 changes: 6 additions & 0 deletions pkg/pgsql/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2b7347b

Please sign in to comment.