Skip to content

Commit 1cc7d5e

Browse files
authored
Merge pull request #2216 from dolthub/fulghum/row-description-fix
Bug fix: don't send RowDescription message with each spooled batch of rows
2 parents 69d8a95 + c51326a commit 1cc7d5e

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

server/connection_handler.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,10 @@ func (h *ConnectionHandler) query(query ConvertedQuery) error {
996996
func (h *ConnectionHandler) spoolRowsCallback(query ConvertedQuery, rows *int32, isExecute bool) func(ctx *sql.Context, res *Result) error {
997997
// IsIUD returns whether the query is either an INSERT, UPDATE, or DELETE query.
998998
isIUD := query.StatementTag == "INSERT" || query.StatementTag == "UPDATE" || query.StatementTag == "DELETE"
999+
1000+
// The RowDescription message should only be sent once, before any DataRow messages,
1001+
// otherwise some clients will not properly handle results.
1002+
hasSentRowDescription := false
9991003
return func(ctx *sql.Context, res *Result) error {
10001004
sess := dsess.DSessFromSess(ctx.Session)
10011005
for _, notice := range sess.Notices() {
@@ -1012,7 +1016,8 @@ func (h *ConnectionHandler) spoolRowsCallback(query ConvertedQuery, rows *int32,
10121016

10131017
if returnsRow(query) {
10141018
// EXECUTE does not send RowDescription; instead it should be sent from DESCRIBE prior to it
1015-
if !isExecute {
1019+
if !isExecute && !hasSentRowDescription {
1020+
hasSentRowDescription = true
10161021
if err := h.send(&pgproto3.RowDescription{
10171022
Fields: res.Fields,
10181023
}); err != nil {

0 commit comments

Comments
 (0)