diff --git a/protos/pgsql/pgsql.go b/protos/pgsql/pgsql.go index d07e30b76a46..05f7b32484ae 100644 --- a/protos/pgsql/pgsql.go +++ b/protos/pgsql/pgsql.go @@ -430,7 +430,7 @@ func (pgsql *Pgsql) pgsqlMessageParser(s *PgsqlStream) (bool, bool) { m.end = s.parseOffset m.Query = string(s.data[m.start+5 : m.end-1]) //without string termination m.toExport = true - logp.Debug("pgsqldetailed", "Simple Query", "%s", m.Query) + logp.Debug("pgsqldetailed", "Simple Query: %s", m.Query) return true, true } else { // wait for more @@ -542,6 +542,11 @@ func (pgsql *Pgsql) pgsqlMessageParser(s *PgsqlStream) (bool, bool) { if len(s.data[s.parseOffset:]) >= length+1 { s.parseOffset += 1 //type s.parseOffset += length + m.end = s.parseOffset + + // ok and complete, but ignore + m.toExport = false + return true, true } else { // wait for more logp.Debug("pgsqldetailed", "Wait for more data 6") @@ -675,6 +680,7 @@ func (pgsql *Pgsql) Parse(pkt *protos.Packet, tcptuple *common.TcpTuple, } ok, complete := pgsql.pgsqlMessageParser(priv.Data[dir]) + //logp.Debug("pgsqldetailed", "MessageParser returned ok=%v complete=%v", ok, complete) if !ok { // drop this tcp stream. Will retry parsing with the next // segment in it diff --git a/tests/pcaps/pgsql_rt.pcap b/tests/pcaps/pgsql_rt.pcap new file mode 100644 index 000000000000..764f399252c9 Binary files /dev/null and b/tests/pcaps/pgsql_rt.pcap differ diff --git a/tests/test_0009_pgsql.py b/tests/test_0009_pgsql.py index 7aeb65db29f5..9bbb6e0a1ef8 100644 --- a/tests/test_0009_pgsql.py +++ b/tests/test_0009_pgsql.py @@ -46,3 +46,19 @@ def test_insert_error(self): assert o["status"] == "Error" assert o["pgsql.error_code"] == "23505" assert o["pgsql.iserror"] is True + + def test_login_rt(self): + """ + Response time for a query happing shortly after a command type we don't + understand shouldn't have it's rt affected. Regression test for # + """ + self.render_config_template( + pgsql_ports=[5432] + ) + self.run_packetbeat(pcap="pgsql_rt.pcap") + + objs = self.read_output() + assert len(objs) == 1 + o = objs[0] + assert o["method"] == "SELECT" + assert o["responsetime"] == 38