Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: payload issue for data row packet in postgres #1163

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions pkg/proxy/integrations/postgresParser/postgres_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewPostgresParser(logger *zap.Logger, h *hooks.Hook) *PostgresParser {
}
}

func(p *PostgresParser) OutgoingType(buffer []byte) bool {
func (p *PostgresParser) OutgoingType(buffer []byte) bool {
const ProtocolVersion = 0x00030000 // Protocol version 3.0

if len(buffer) < 8 {
Expand All @@ -58,7 +58,7 @@ func(p *PostgresParser) OutgoingType(buffer []byte) bool {
return version == ProtocolVersion
}

func(p *PostgresParser) ProcessOutgoing(requestBuffer []byte, clientConn, destConn net.Conn, ctx context.Context) {
func (p *PostgresParser) ProcessOutgoing(requestBuffer []byte, clientConn, destConn net.Conn, ctx context.Context) {
switch models.GetMode() {
case models.MODE_RECORD:
encodePostgresOutgoing(requestBuffer, clientConn, destConn, p.hooks, p.logger, ctx)
Expand Down Expand Up @@ -400,7 +400,7 @@ func encodePostgresOutgoing(requestBuffer []byte, clientConn, destConn net.Conn,
}

after_encoded, _ := PostgresDecoderFrontend(*pg_mock)
if len(after_encoded) != len(buffer) && pg_mock.PacketTypes[0] != "R"{
if (len(after_encoded) != len(buffer) && pg_mock.PacketTypes[0] != "R") || len(pg_mock.DataRows) > 0 {
logger.Debug("the length of the encoded buffer is not equal to the length of the original buffer", zap.Any("after_encoded", len(after_encoded)), zap.Any("buffer", len(buffer)))
pg_mock.Payload = bufStr
}
Expand Down