Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,43 @@
}
}

type doneConfig struct {
status uint16
errors []Error
}

type DoneOption func(*doneConfig)

func WithFinal() DoneOption {
return func(dc *doneConfig) {
dc.status = dc.status | doneFinal
}
}

func WithErrors(errs ...Error) DoneOption {
return func(dc *doneConfig) {
if len(errs) > 0 {
dc.status = dc.status | doneSrvError
dc.errors = errs
}
}
}

// SendDone sends the response for a query and optionally marks
// it as final, prompting the client to close the connection.
func (ss *ServerSession) SendDone(opts ...DoneOption) {
dc := &doneConfig{
status: uint16(0),
errors: []Error{},
}
for _, opt := range opts {
opt(dc)
}
if _, err := ss.tdsSession.buf.Write(writeDone(doneStruct{Status: dc.status, errors: dc.errors})); err != nil {
Copy link

Copilot AI May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doneStruct passed to writeDone includes the 'errors' field, but the writeDone function does not process or include error details in the written output. Consider updating writeDone to serialize and communicate error information if it is intended to be signaled to the client.

Copilot uses AI. Check for mistakes.
ss.logger.Error("failed to write doneStruct with error to mssql client", zap.Error(err))
}
}

func (s *Server) handshake(r *tdsBuffer) (map[uint8][]byte, login, error) {
var login login

Expand Down Expand Up @@ -1283,7 +1320,7 @@
var err error

for _, e := range d.errors {
err = errors.Join(err, e)

Check failure on line 1323 in proxy.go

View workflow job for this annotation

GitHub Actions / build (1.19, 2019-latest)

undefined: errors.Join

Check failure on line 1323 in proxy.go

View workflow job for this annotation

GitHub Actions / build (1.19, 2022-latest)

undefined: errors.Join
}

return err
Expand Down
Loading