Ejemplo n.º 1
0
// ReadPacket reads a raw packet from the MySQL connection.
//
// A MySQL packet is "a single SQL statement sent to the MySQL server, a
// single row that is sent to the client, or a binary log event sent from a
// master replication server to a slave." -MySQL 5.1 Reference Manual
func (conn *Connection) ReadPacket() ([]byte, error) {
	length := C.vt_cli_safe_read(&conn.c)
	if length == 0 {
		return nil, conn.lastError("ReadPacket()")
	}

	return C.GoBytes(unsafe.Pointer(conn.c.mysql.net.read_pos), C.int(length)), nil
}
Ejemplo n.º 2
0
// ReadPacket reads a raw packet from the MySQL connection.
//
// A MySQL packet is "a single SQL statement sent to the MySQL server, a
// single row that is sent to the client, or a binary log event sent from a
// master replication server to a slave." -MySQL 5.1 Reference Manual
func (conn *Connection) ReadPacket() ([]byte, error) {
	length := C.vt_cli_safe_read(&conn.c)
	if length == 0 {
		return nil, fmt.Errorf("error reading packet from MySQL with cli_safe_read(): %v", conn.lastError(""))
	}

	return C.GoBytes(unsafe.Pointer(conn.c.mysql.net.read_pos), C.int(length)), nil
}