@@ -67,6 +67,7 @@ type stmt struct {
6767 preparedName string
6868 parseState parseState
6969 paramTypes []common.ParameterType
70+ lastRowDesc * msgs.BERowDescMsg
7071}
7172
7273func newStmt (connection * connection , command string ) (* stmt , error ) {
@@ -176,7 +177,7 @@ func (s *stmt) QueryContextRaw(ctx context.Context, args []driver.NamedValue) (*
176177 return s .collectResults ()
177178 }
178179
179- // We aren't a prepared statement, manually interpolate and do as a simpe query.
180+ // We aren't a prepared statement, manually interpolate and do as a simple query.
180181 cmd , err = s .interpolate (args )
181182
182183 if err != nil {
@@ -196,9 +197,12 @@ func (s *stmt) QueryContextRaw(ctx context.Context, args []driver.NamedValue) (*
196197
197198 switch msg := bMsg .(type ) {
198199 case * msgs.BEDataRowMsg :
200+ if rows == emptyRowSet {
201+ rows = newRows (s .lastRowDesc , s .conn .serverTZOffset )
202+ }
199203 rows .addRow (msg )
200204 case * msgs.BERowDescMsg :
201- rows = newRows ( msg , s . conn . serverTZOffset )
205+ s . lastRowDesc = msg
202206 case * msgs.BECmdCompleteMsg :
203207 break
204208 case * msgs.BEErrorMsg :
@@ -341,9 +345,12 @@ func (s *stmt) collectResults() (*rows, error) {
341345
342346 switch msg := bMsg .(type ) {
343347 case * msgs.BEDataRowMsg :
348+ if rows == emptyRowSet {
349+ rows = newRows (s .lastRowDesc , s .conn .serverTZOffset )
350+ }
344351 rows .addRow (msg )
345352 case * msgs.BERowDescMsg :
346- rows = newRows ( msg , s . conn . serverTZOffset )
353+ s . lastRowDesc = msg
347354 case * msgs.BEErrorMsg :
348355 return emptyRowSet , msg .ToErrorType ()
349356 case * msgs.BEEmptyQueryResponseMsg :
0 commit comments