v/vlib/mysql/utils.v

25 lines
544 B
V
Raw Normal View History

module mysql
2020-06-11 10:07:17 +02:00
// get_error_msg returns error message from MySQL instance.
fn get_error_msg(conn &C.MYSQL) string {
return unsafe { C.mysql_error(conn).vstring() }
}
2020-06-11 10:07:17 +02:00
// get_errno returns error number from MySQL instance.
fn get_errno(conn &C.MYSQL) int {
return C.mysql_errno(conn)
}
2020-06-11 10:07:17 +02:00
// resolve_nil_str returns empty string if passed value is a nil pointer.
fn resolve_nil_str(ptr byteptr) string {
2020-06-11 10:07:17 +02:00
if isnil(ptr) { return '' }
return unsafe { ptr.vstring() }
}
[inline]
fn mystring(b byteptr) string {
unsafe {
return b.vstring()
}
}