10 #include <libex/str.h>
11 #include <libex/list.h>
21 myconn_t
*maria_connect (const char *host
, const char *dbname
, const char *user
, const char *pass
);
22 myconn_t
*maria_connect_str (const char *conn_info
);
23 void maria_disconnect (myconn_t
*conn
);
37 unsigned long *lengths
;
38 unsigned long *param_lengths
;
40 void maria_res_close (myres_t
*res
);
61 void maria_get_tiny (myres_t
*res
, int col
, myfld_t
*fld
);
62 void maria_get_smallint (myres_t
*res
, int col
, myfld_t
*fld
);
63 void maria_get_int (myres_t
*res
, int col
, myfld_t
*fld
);
64 void maria_get_bigint (myres_t
*res
, int col
, myfld_t
*fld
);
65 void maria_get_float (myres_t
*res
, int col
, myfld_t
*fld
);
66 void maria_get_double (myres_t
*res
, int col
, myfld_t
*fld
);
67 void maria_get_varchar (myres_t
*res
, int col
, myfld_t
*fld
);
69 #define MARIA_DEF_NULL { .is_null = 1 }
70 #define MARIA_DEF_TINY(V) { .is_null = 0, .type = MYSQL_TYPE_TINY, .data.i1 = V }
71 #define MARIA_DEF_SMALLINT(V) { .is_null = 0, .type = MYSQL_TYPE_SHORT, .data.i2 = V }
72 #define MARIA_DEF_INT(V) { .is_null = 0, .type = MYSQL_TYPE_LONG, .data.i4 = V }
73 #define MARIA_DEF_BIGINT(V) { .is_null = 0, .type = MYSQL_TYPE_LONGLONG, .data.i8 = V }
74 #define MARIA_DEF_FLOAT(V) { .is_null = 0, .type = MYSQL_TYPE_TINY, .data.f4 = V }
75 #define MARIA_DEF_DOUBLE(V) { .is_null = 0, .type = MYSQL_TYPE_DOUBLE, .data.f8 = V }
76 #define MARIA_DEF_VARCHAR(V,L) { .is_null = 0, .type = MYSQL_TYPE_VAR_STRING, .data.s.ptr = V, .data.s.len = L }
78 myres_t
*maria_prepare (myconn_t
*conn
, const char *sql
, size_t sql_len
);
79 myres_t
*maria_exec (myconn_t
*conn
, const char *sql
, size_t sql_len
, myfld_t
*arg
, ...);
80 int maria_pexec (myres_t
*res
, myfld_t
*arg
, ...);
81 int maria_exec_sql (myconn_t
*conn
, const char *sql
, size_t sql_len
);
82 int maria_fetch (myres_t
*res
);
83 static inline int maria_start (myconn_t
*conn
) { return maria_exec_sql(conn
, CONST_STR_LEN("start transaction")); }
84 static inline int maria_commit (myconn_t
*conn
) { return maria_exec_sql(conn
, CONST_STR_LEN("commit")); }
85 static inline int maria_rollback (myconn_t
*conn
) { return maria_exec_sql(conn
, CONST_STR_LEN("rollback")); }
87 #endif // __MYSQLW_H__