EV-MariaDB
view release on metacpan or search on metacpan
typedef ev_mariadb_t* EV__MariaDB;
typedef struct ev_loop* EV__Loop;
#define EV_MARIADB_MAGIC 0xDEADBEEF
#define EV_MARIADB_FREED 0xFEEDFACE
enum ev_mariadb_state {
STATE_IDLE,
STATE_CONNECTING,
STATE_SEND,
STATE_READ_RESULT,
STATE_STORE_RESULT,
STATE_NEXT_RESULT,
STATE_PING,
STATE_CHANGE_USER,
STATE_SELECT_DB,
STATE_RESET_CONNECTION,
STATE_SET_CHARSET,
STATE_COMMIT,
STATE_ROLLBACK,
STATE_AUTOCOMMIT,
STATE_STMT_PREPARE, /* boundary: states >= here block query queueing */
STATE_STMT_EXECUTE,
STATE_STMT_STORE,
STATE_STMT_CLOSE,
STATE_STMT_RESET,
STATE_STMT_SEND_LONG_DATA,
STATE_REAL_QUERY,
STATE_STREAM_FETCH,
STATE_CLOSE,
};
struct ev_mariadb_s {
unsigned int magic;
struct ev_loop *loop;
MYSQL *conn;
ev_io rio, wio;
ev_timer timer;
int reading, writing, timing;
int fd;
enum ev_mariadb_state state;
char *host, *user, *password, *database, *unix_socket;
unsigned int port;
ngx_queue_t cb_queue; /* callbacks for sent queries (awaiting results) */
ngx_queue_t send_queue; /* queries waiting to be sent */
int pending_count; /* total: send_queue + cb_queue */
int send_count; /* queries sent, results not yet read */
int draining; /* draining multi-result extras */
/* current operation context */
int op_ret;
MYSQL_RES *op_result;
MYSQL_STMT *op_stmt;
ev_mariadb_stmt_t *op_stmt_ctx; /* per-stmt wrapper for bind_params cleanup */
ev_mariadb_stmt_t *stmt_list; /* all allocated stmt wrappers */
MYSQL *op_conn_ret;
my_bool op_bool_ret;
MYSQL_ROW op_row; /* for streaming fetch_row result */
SV *stream_cb; /* streaming per-row callback */
char *op_data_ptr; /* copied data buffer for send_long_data */
SV *on_connect;
SV *on_error;
int callback_depth;
pid_t connect_pid; /* PID at connect time, for fork detection */
/* connection options (applied before mysql_real_connect_start) */
unsigned int connect_timeout;
unsigned int read_timeout;
unsigned int write_timeout;
int compress;
int multi_statements;
int found_rows;
char *charset;
char *init_command;
char *ssl_key;
char *ssl_cert;
char *ssl_ca;
char *ssl_capath;
char *ssl_cipher;
int ssl_verify_server_cert;
int utf8; /* auto-flag result strings as UTF-8 */
unsigned long client_flags;
};
struct ev_mariadb_cb_s {
SV *cb;
ngx_queue_t queue;
};
struct ev_mariadb_send_s {
char *sql;
unsigned long sql_len;
SV *cb;
ngx_queue_t queue;
};
struct ev_mariadb_stmt_s {
MYSQL_STMT *stmt;
MYSQL_BIND *bind_params;
int bind_param_count;
int closed; /* invalidated by cleanup_connection */
ev_mariadb_stmt_t *next; /* linked list of all stmts on this connection */
};
#define MAX_PIPELINE_DEPTH 64
#define MAX_FREELIST_DEPTH 64
#define COPY_ERROR(buf, src) do { \
strncpy((buf), (src), sizeof(buf) - 1); \
(buf)[sizeof(buf) - 1] = '\0'; \
} while (0)
#define SET_STR_OPTION(field) do { \
if (self->field) Safefree(self->field); \
self->field = SvOK(value) ? safe_strdup(SvPV_nolen(value)) : NULL; \
} while (0)
( run in 0.912 second using v1.01-cache-2.11-cpan-39bf76dae61 )