From ae07aacd51a616581775006d05cccbdbed577349 Mon Sep 17 00:00:00 2001 From: Travis Date: Thu, 27 Aug 2020 22:49:54 -0500 Subject: [PATCH 1/2] add sql mapper routes for count(*) on joins --- sql/router.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sql/router.go b/sql/router.go index f64daa338..4c15cb975 100644 --- a/sql/router.go +++ b/sql/router.go @@ -89,6 +89,8 @@ func newRouter() *router { selectRouter.addRoute("select fld1, count(fld1) from tbl where fld2=1 group by fld1", handlerSelectGroupBy{}) selectRouter.addRoute("select count(*) from tbl1 INNER JOIN tbl2 ON tbl1._id = tbl2.bsi", handlerSelectJoin{}) + selectRouter.addRoute("select count(*) from tbl1 INNER JOIN tbl2 ON tbl1._id = tbl2.bsi where fld1=1", handlerSelectJoin{}) + selectRouter.addRoute("select count(*) from tbl1 INNER JOIN tbl2 ON tbl1._id = tbl2.bsi where fld1=1 and fld2=2", handlerSelectJoin{}) selectRouter.addRoute("select _id from tbl1 INNER JOIN tbl2 ON tbl1._id = tbl2.bsi", handlerSelectJoin{}) selectRouter.addRoute("select _id from tbl1 INNER JOIN tbl2 ON tbl1._id = tbl2.bsi where fld1=1", handlerSelectJoin{}) selectRouter.addRoute("select _id from tbl1 INNER JOIN tbl2 ON tbl1._id = tbl2.bsi where fld1=1 and fld2=2", handlerSelectJoin{}) From 57fdabfe40b639a40cb226ba83ad512464598716 Mon Sep 17 00:00:00 2001 From: Nia Weiss Date: Fri, 28 Aug 2020 13:28:50 -0400 Subject: [PATCH 2/2] write empty column headers in postgres when there is no response --- pg/protocol.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pg/protocol.go b/pg/protocol.go index f0463ecc1..8a50baf05 100644 --- a/pg/protocol.go +++ b/pg/protocol.go @@ -394,6 +394,14 @@ func (s *Server) handleStandard(ctx context.Context, proto Protocol, conn net.Co return errors.Wrap(err, "failed to send query error to client") } } else { + if !qwriter.wroteHeaders { + // The handler did not write headers. + // Write back an empty set of headers. + err = qwriter.WriteHeader() + if err != nil { + return errors.Wrap(err, "sending empty column headers") + } + } // The query completed normally. // Notify the client of completion. msg, err = encoder.CommandComplete(qwriter.tag)