Skip to content

Commit

Permalink
feat(usql): allow usql to connect using pg protocol (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoyException authored Nov 20, 2024
1 parent 63c7da3 commit 2ae5055
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pgserver/connection_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,16 @@ func (h *ConnectionHandler) handleMessage(msg pgproto3.Message) (stop, endOfMess
// expected as part of this query, in which case the server will send a READY FOR QUERY message back to the client so
// that it can send its next query.
func (h *ConnectionHandler) handleQuery(message *pgproto3.Query) (endOfMessages bool, err error) {
// usql use ";" to test if the connection is alive. If we don't handle it, this will return an error. So we need to
// manually handle it here.
if message.String == ";" {
err := h.send(makeCommandComplete("", 0))
if err != nil {
return true, err
}
return true, nil
}

handled, err := h.handledPSQLCommands(message.String)
if handled || err != nil {
return true, err
Expand Down

0 comments on commit 2ae5055

Please sign in to comment.