good morning!!!!

Skip to content
Snippets Groups Projects
Commit 44b1f58d authored by Garet Halliday's avatar Garet Halliday
Browse files

terminate not close

parent f1fc319e
No related branches found
No related tags found
No related merge requests found
......@@ -464,6 +464,17 @@ func (c *Client) recvLoop(cancel context.CancelFunc) {
break
}
case *protocol.Close:
switch pkt.Fields.Which {
case 'S':
delete(c.statements, pkt.Fields.Name)
case 'P':
delete(c.portals, pkt.Fields.Name)
}
err = c.Send(new(protocol.CloseComplete))
if err != nil {
break
}
case *protocol.Terminate:
break
default:
c.recv <- recv
......@@ -505,8 +516,6 @@ func (c *Client) tick(ctx context.Context) (bool, error) {
return true, c.handle_query(ctx, cast)
case *protocol.FunctionCall:
return true, c.handle_function(ctx, cast)
case *protocol.Terminate:
return false, nil
default:
log.Printf("unhandled packet %#v", rsp)
}
......
......@@ -507,9 +507,10 @@ func (s *Server) destructPreparedStatement(name string) {
return
}
delete(s.boundPreparedStatments, name)
query := new(protocol.Query)
query.Fields.Query = fmt.Sprintf("DEALLOCATE \"%s\"", name)
_ = s.writePacket(query)
closeRequest := new(protocol.Close)
closeRequest.Fields.Which = 'S'
closeRequest.Fields.Name = name
_ = s.writePacket(closeRequest)
_ = s.flush()
// await server ready
for {
......@@ -749,7 +750,7 @@ func (s *Server) Close() error {
default:
s.readyForQuery = false
close(s.closed)
_ = s.writePacket(&protocol.Close{})
_ = s.writePacket(&protocol.Terminate{})
return s.conn.Close()
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment