// writeRows sends the rows of a Result.
960918
func (c *Conn) writeRows(result *sqltypes.Result) error {
	for _, row := range result.Rows {
		if err := c.writeRow(row); err != nil {
			return err
		}
	}
	return nil
}
853537
func (writer *Writer) Flush() error {
	if writer.Excel.writer != nil {
		defer writer.Excel.writer.Close()
		return writer.Writer.Write(writer.Excel.writer)
	}

	return writer.Writer.SaveAs(writer.Excel.filename)
}
1123300
func (cn *connection) rw() io.ReadWriter {
	return struct {
		io.Reader
		io.Writer
	}{cn.r, cn.w}
}
1209323
func (r *BenchResults) WriteOpDuration() time.Duration {
	if r.WriteOps == 0 {
		return 0
	}
	return r.WriteDuration / time.Duration(r.WriteOps)
}
413919
func writeRaw(w *textWriter, b []byte) error {
	if err := w.WriteByte('<'); err != nil {
		return err
	}
	if !w.compact {
		if err := w.WriteByte('\n'); err != nil {
			return err
		}
	}
	w.indent()
	if err := writeUnknownStruct(w, b); err != nil {
		return err
	}
	w.unindent()
	if err := w.WriteByte('>'); err != nil {
		return err
	}
	return nil
}
1185335
func (b *batch) Write() error {
	return b.db.Write(b.b, nil)
}
747911
func WriteL(w io.Writer, bs ...[]byte) (n int, err error) {
	var c int
	for i := range bs {
		if c, err = w.Write(bs[i]); err == nil {
			n += c
		} else {
			break
		}
	}

	return
}
1073912
func (w *SafeCSVWriter) Write(row []string) error {
	w.m.Lock()
	defer w.m.Unlock()
	return w.Writer.Write(row)
}
706953
func (builder *StoreBucketTypePropsCommandBuilder) WithLastWriteWins(lww bool) *StoreBucketTypePropsCommandBuilder {
	builder.props.LastWriteWins = &lww
	return builder
}
1275978
func NewWriteRowsEvent(f BinlogFormat, s *FakeBinlogStream, tableID uint64, rows Rows) BinlogEvent {
	return newRowsEvent(f, s, eWriteRowsEventV2, tableID, rows)
}
373870
func (w *WindowsWriter) Flush() error {
	_, err := w.out.Write(w.buffer)
	if err != nil {
		return err
	}
	w.buffer = []byte{}
	return nil
}
135198
func (c *Conn) writeEndResult(more bool, affectedRows, lastInsertID uint64, warnings uint16) error {
	// Send either an EOF, or an OK packet.
	// See doc.go.
	flags := c.StatusFlags
	if more {
		flags |= ServerMoreResultsExists
	}
	if c.Capabilities&CapabilityClientDeprecateEOF == 0 {
		if err := c.writeEOFPacket(flags, warnings); err != nil {
			return err
		}
	} else {
		// This will flush too.
		if err := c.writeOKPacketWithEOFHeader(affectedRows, lastInsertID, flags, warnings); err != nil {
			return err
		}
	}

	return nil
}
1081282
func (w *Writer) Close() error {
	if w.c != nil {
		return w.c.Close()
	}
	return nil
}
1335785
func (m *RWMutex) Report() {
	writers := atomic.LoadInt64(&m.writers)
	str := fmt.Sprintf(
		"writers %d (pending %d) readers %d",
		writers,
		atomic.LoadInt64(&m.pendingWriters),
		atomic.LoadInt64(&m.readers),
	)
	if writers > 0 {
		m.stateMutex.RLock()
		str += fmt.Sprintf(", stack: %s", string(m.lastLockStack))
		m.stateMutex.RUnlock()
	}
	m.println(str)
}
103108
func (w *SafeCSVWriter) Flush() {
	w.m.Lock()
	w.Writer.Flush()
	w.m.Unlock()
}
141460
func (w *VT100Writer) WriteRaw(data []byte) {
	w.buffer = append(w.buffer, data...)
	return
}
814374
func (m *multiWriter) Write(p []byte) (n int, err error) {
	// lock and make a local copy of available writers:
	getWriters := func() (writers []writerWrapper) {
		m.RLock()
		defer m.RUnlock()
		writers = make([]writerWrapper, 0, len(m.writers))
		for _, w := range m.writers {
			writers = append(writers, w)
		}

		// add the recent write chunk to the "instant replay" buffer
		// of the session, to be replayed to newly joining parties:
		m.lockedAddRecentWrite(p)
		return writers
	}

	// unlock and multiplex the write to all writers:
	for _, w := range getWriters() {
		n, err = w.Write(p)
		if err != nil {
			if w.closeOnError {
				return
			}
			continue
		}
		if n != len(p) {
			err = io.ErrShortWrite
			return
		}
	}
	return len(p), nil
}