示例#1
0
func appendResult(qr, innerqr *sqltypes.Result) {
	if innerqr.RowsAffected == 0 && len(innerqr.Fields) == 0 {
		return
	}
	if qr.Fields == nil {
		qr.Fields = innerqr.Fields
	}
	qr.RowsAffected += innerqr.RowsAffected
	if innerqr.InsertID != 0 {
		qr.InsertID = innerqr.InsertID
	}
	qr.Rows = append(qr.Rows, innerqr.Rows...)
}
示例#2
0
func appendResult(qr, innerqr *sqltypes.Result) {
	if innerqr.RowsAffected == 0 && len(innerqr.Fields) == 0 {
		return
	}
	if qr.Fields == nil {
		qr.Fields = innerqr.Fields
	}
	qr.RowsAffected += innerqr.RowsAffected
	if innerqr.InsertID != 0 {
		qr.InsertID = innerqr.InsertID
	}
	if len(qr.Rows) == 0 {
		// we haven't gotten any result yet, just save the new extras.
		qr.Extras = innerqr.Extras
	} else {
		// Merge the EventTokens / Fresher flags within Extras.
		if innerqr.Extras == nil {
			// We didn't get any from innerq. Have to clear any
			// we'd have gotten already.
			if qr.Extras != nil {
				qr.Extras.EventToken = nil
				qr.Extras.Fresher = false
			}
		} else {
			// We may have gotten an EventToken from
			// innerqr.  If we also got one earlier, merge
			// it. If we didn't get one earlier, we
			// discard the new one.
			if qr.Extras != nil {
				// Note if any of the two is nil, we get nil.
				qr.Extras.EventToken = eventtoken.Minimum(qr.Extras.EventToken, innerqr.Extras.EventToken)

				qr.Extras.Fresher = qr.Extras.Fresher && innerqr.Extras.Fresher
			}
		}
	}
	qr.Rows = append(qr.Rows, innerqr.Rows...)
}