func (conn *csvConn) Close() error {
	if conn.refs > 1 {
		conn.refs--
		return nil
	}
	var err error
	defer conn.f.Close()

	// FIXME(sbinet) write-back to file if needed.
	// err = conn.exportCSV()

	err = conn.conn.Close()
	if err != nil {
		return err
	}

	err = conn.f.Close()
	if err != nil {
		return err
	}

	conn.drv.mu.Lock()
	if conn.refs == 1 {
		delete(conn.drv.dbs, conn.f.Name())
	}
	conn.refs = 0
	conn.drv.mu.Unlock()

	return err
}
// Close invalidates and potentially stops any current
// prepared statements and transactions, marking this
// connection as no longer in use.
//
// Because the sql package maintains a free pool of
// connections and only calls Close when there's a surplus of
// idle connections, it shouldn't be necessary for drivers to
// do their own connection caching.
Close invalidates and potentially stops any current
prepared statements and transactions, marking this
connection as no longer in use.

Because the sql package maintains a free pool of
connections and only calls Close when there's a surplus of
idle connections, it shouldn't be necessary for drivers to
do their own connection caching.
// Close invalidates and potentially stops any current // prepared statements and transactions marking this // connection as no longer in use . // // Because the sql package maintains a free pool of // connections and only calls Close when there ' s a surplus of // idle connections it shouldn ' t be necessary for drivers to // do their own connection caching .
func (conn *csvConn) Close() error {
	if conn.refs > 1 {
		conn.refs--
		return nil
	}
	var err error
	defer conn.f.Close()
	err = conn.conn.Close()
	if err != nil {
		return err
	}
	err = conn.f.Close()
	if err != nil {
		return err
	}
	conn.drv.mu.Lock()
	if conn.refs == 1 {
		delete(conn.drv.dbs, conn.f.Name())
	}
	conn.refs = 0
	conn.drv.mu.Unlock()
	return err
}
func ( conn * csvConn ) Close ( ) error { if conn . refs > 1 { conn . refs -- return nil } var err error defer conn . f . Close ( ) err = conn . conn . Close ( ) if err != nil { return err } err = conn . f . Close ( ) if err != nil { return err } conn . drv . mu . Lock ( ) if conn . refs == 1 { delete ( conn . drv . dbs , conn . f . Name ( ) ) } conn . refs = 0 conn . drv . mu . Unlock ( ) return err }
Close invalidates and potentially stops any current
prepared statements and transactions, marking this
connection as no longer in use.
Close invalidates and potentially stops any current prepared statements and transactions marking this connection as no longer in use .
// FIXME(sbinet) write-back to file if needed. // err = conn.exportCSV()