MYSQLND_CLASS_METHODS_END;
-/* {{{ mysqlnd_upsert_status_init */
+
+/* {{{ mysqlnd_error_info_init */
enum_func_status
mysqlnd_error_info_init(MYSQLND_ERROR_INFO * const info, zend_bool persistent)
{
/* }}} */
+
+
+/* {{{ mysqlnd_connection_state::get */
+static enum mysqlnd_connection_state
+MYSQLND_METHOD(mysqlnd_connection_state, get)(const struct st_mysqlnd_connection_state * const state_struct)
+{
+ DBG_ENTER("mysqlnd_connection_state::get")
+ DBG_RETURN(state_struct->state);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_connection_state::set */
+static void
+MYSQLND_METHOD(mysqlnd_connection_state, set)(struct st_mysqlnd_connection_state * const state_struct, enum mysqlnd_connection_state state)
+{
+ DBG_ENTER("mysqlnd_connection_state::set")
+ DBG_INF_FMT("New state=%u", state);
+ state_struct->state = state;
+ DBG_VOID_RETURN;
+}
+/* }}} */
+
+
+MYSQLND_CLASS_METHODS_START(mysqlnd_connection_state)
+ MYSQLND_METHOD(mysqlnd_connection_state, get),
+ MYSQLND_METHOD(mysqlnd_connection_state, set),
+MYSQLND_CLASS_METHODS_END;
+
+
+/* {{{ mysqlnd_upsert_status_init */
+void
+mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state)
+{
+ DBG_ENTER("mysqlnd_error_info_init")
+ state->m = &MYSQLND_CLASS_METHOD_TABLE_NAME(mysqlnd_connection_state);
+ state->state = CONN_ALLOCED;
+ DBG_VOID_RETURN;
+}
+/* }}} */
+
+
/* {{{ mysqlnd_conn_data::free_options */
static void
MYSQLND_METHOD(mysqlnd_conn_data, free_options)(MYSQLND_CONN_DATA * conn)
/* }}} */
-/* {{{ mysqlnd_conn_data::get_state */
-static enum mysqlnd_connection_state
-MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, get_state)(const MYSQLND_CONN_DATA * const conn)
-{
- DBG_ENTER("mysqlnd_conn_data::get_state");
- DBG_RETURN(conn->state);
-}
-/* }}} */
-
-
-/* {{{ mysqlnd_conn_data::set_state */
-static void
-MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, set_state)(MYSQLND_CONN_DATA * const conn, enum mysqlnd_connection_state new_state)
-{
- DBG_ENTER("mysqlnd_conn_data::set_state");
- DBG_INF_FMT("New state=%u", new_state);
- conn->state = new_state;
- DBG_VOID_RETURN;
-}
-/* }}} */
-
-
/* {{{ mysqlnd_conn_data::field_count */
static unsigned int
MYSQLND_METHOD(mysqlnd_conn_data, field_count)(const MYSQLND_CONN_DATA * const conn)
MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, get_reference),
MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, free_reference),
- MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, get_state),
- MYSQLND_METHOD_PRIVATE(mysqlnd_conn_data, set_state),
-// MYSQLND_METHOD(mysqlnd_conn_data, send_command_do_request),
MYSQLND_METHOD(mysqlnd_conn_data, send_command_handle_response),
MYSQLND_METHOD(mysqlnd_conn_data, restart_psession),
MYSQLND_METHOD(mysqlnd_conn_data, end_psession),
data->persistent = persistent;
data->m = mysqlnd_conn_data_get_methods();
data->object_factory = *factory;
- CONN_SET_STATE(data, CONN_ALLOCED);
+
+ mysqlnd_connection_state_init(&data->state);
+
data->m->get_reference(data);
mysqlnd_stats_init(&data->stats, STAT_LAST, persistent);
#define SET_OOM_ERROR(info) SET_CLIENT_ERROR((info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory)
#define COPY_CLIENT_ERROR(dest, source) SET_CLIENT_ERROR((dest), (source).error_no, (source).sqlstate, (source).error)
-#define CONN_GET_STATE(c) (c)->m->get_state((c))
-#define CONN_SET_STATE(c, s) (c)->m->set_state((c), (s))
+#define CONN_GET_STATE(c) (c)->state.m->get(&(c)->state)
+#define CONN_SET_STATE(c, s) (c)->state.m->set(&(c)->state, (s))
+
+void mysqlnd_connection_state_init(struct st_mysqlnd_connection_state * const state);
/* PS stuff */
typedef void (*ps_field_fetch_func)(zval * zv, const MYSQLND_FIELD * const field, unsigned int pack_len, zend_uchar ** row);
typedef MYSQLND_CONN_DATA * (*func_mysqlnd_conn_data__get_reference)(MYSQLND_CONN_DATA * const conn);
typedef enum_func_status (*func_mysqlnd_conn_data__free_reference)(MYSQLND_CONN_DATA * const conn);
-typedef enum mysqlnd_connection_state (*func_mysqlnd_conn_data__get_state)(const MYSQLND_CONN_DATA * const conn);
-typedef void (*func_mysqlnd_conn_data__set_state)(MYSQLND_CONN_DATA * const conn, enum mysqlnd_connection_state new_state);
typedef enum_func_status (*func_mysqlnd_conn_data__send_command_do_request)(MYSQLND_CONN_DATA * const conn, const enum php_mysqlnd_server_command command, const zend_uchar * const arg, const size_t arg_len, const zend_bool silent, const zend_bool ignore_upsert_status);
typedef enum_func_status (*func_mysqlnd_conn_data__send_command_handle_response)(MYSQLND_CONN_DATA * const conn, const enum mysqlnd_packet_type ok_packet, const zend_bool silent, const enum php_mysqlnd_server_command command, const zend_bool ignore_upsert_status);
func_mysqlnd_conn_data__get_reference get_reference;
func_mysqlnd_conn_data__free_reference free_reference;
- func_mysqlnd_conn_data__get_state get_state;
- func_mysqlnd_conn_data__set_state set_state;
-// func_mysqlnd_conn_data__send_command_do_request send_command_do_request;
func_mysqlnd_conn_data__send_command_handle_response send_command_handle_response;
func_mysqlnd_conn_data__restart_psession restart_psession;
typedef struct st_mysqlnd_protocol_command * (*func_mysqlnd__command_factory)(enum php_mysqlnd_server_command command, ...);
+
+struct st_mysqlnd_connection_state;
+typedef enum mysqlnd_connection_state (*func_mysqlnd_connection_state__get)(const struct st_mysqlnd_connection_state * const state_struct);
+typedef void (*func_mysqlnd_connection_state__set)(struct st_mysqlnd_connection_state * const state_struct, enum mysqlnd_connection_state state);
+
+
+MYSQLND_CLASS_METHODS_TYPE(mysqlnd_connection_state)
+{
+ func_mysqlnd_connection_state__get get;
+ func_mysqlnd_connection_state__set set;
+};
+
+struct st_mysqlnd_connection_state
+{
+ enum mysqlnd_connection_state state;
+
+ MYSQLND_CLASS_METHODS_TYPE(mysqlnd_connection_state) *m;
+};
+
struct st_mysqlnd_connection_data
{
/* Operation related */
MYSQLND_ERROR_INFO * error_info;
MYSQLND_ERROR_INFO error_info_impl;
- /*
- To prevent queries during unbuffered fetches. Also to
- mark the connection as destroyed for garbage collection.
- */
- enum mysqlnd_connection_state state;
+ struct st_mysqlnd_connection_state state;
enum_mysqlnd_query_type last_query_type;
/* Temporary storage between query and (use|store)_result() call */
MYSQLND_RES *current_result;