Skip to content

Commit

Permalink
Fix validating the Describe step in PG extended query protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
exAspArk committed Jan 30, 2025
1 parent 426fe3c commit d7907ee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

const VERSION = "0.30.0"
const VERSION = "0.30.1"

func main() {
config := LoadConfig()
Expand Down
2 changes: 1 addition & 1 deletion src/query_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ func (queryHandler *QueryHandler) HandleDescribeQuery(message *pgproto3.Describe
return []pgproto3.Message{&pgproto3.NoData{}}, preparedStatement, nil
}

if len(preparedStatement.ParameterOIDs) != len(preparedStatement.Variables) { // Bind step didn't happen before
if len(preparedStatement.ParameterOIDs) > 0 && len(preparedStatement.ParameterOIDs) != len(preparedStatement.Variables) { // Parse passed the parameters, but Bind didn't happen after
return []pgproto3.Message{&pgproto3.NoData{}}, preparedStatement, nil
}

Expand Down
2 changes: 1 addition & 1 deletion src/query_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ func TestHandleDescribeQuery(t *testing.T) {
t.Run("Handles DESCRIBE extended query step", func(t *testing.T) {
queryHandler := initQueryHandler()
query := "SELECT usename, passwd FROM pg_shadow WHERE usename=$1"
parseMessage := &pgproto3.Parse{Query: query, ParameterOIDs: []uint32{pgtype.TextOID}}
parseMessage := &pgproto3.Parse{Query: query}
_, preparedStatement, _ := queryHandler.HandleParseQuery(parseMessage)
bindMessage := &pgproto3.Bind{Parameters: [][]byte{[]byte("bemidb")}}
_, preparedStatement, _ = queryHandler.HandleBindQuery(bindMessage, preparedStatement)
Expand Down

0 comments on commit d7907ee

Please sign in to comment.