Author: ahristov
Date: 2008-04-10 16:35:58 +0200 (Thu, 10 Apr 2008)
New Revision: 1414
Modified:
trunk/mysqlnd/mysqlnd.h
trunk/mysqlnd/mysqlnd_ps.c
trunk/mysqlnd/mysqlnd_structs.h
Log:
Give the client code the possibility the free itself the
data, if needed
Modified: trunk/mysqlnd/mysqlnd.h
===================================================================
--- trunk/mysqlnd/mysqlnd.h 2008-04-10 12:42:13 UTC (rev 1413)
+++ trunk/mysqlnd/mysqlnd.h 2008-04-10 14:35:58 UTC (rev 1414)
@@ -222,7 +222,10 @@
/*****************************************************************************************************/
+PHPAPI void mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind);
+PHPAPI void mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind);
+
PHPAPI const char * mysqlnd_field_type_name(enum mysqlnd_field_types field_type);
/* LOAD DATA LOCAL */
@@ -269,7 +272,9 @@
#define mysqlnd_stmt_send_long_data(s,p,d,l) (s)->m->send_long_data((s), (p), (d),
(l) TSRMLS_CC)
#define mysqlnd_stmt_bind_param(stmt,bind) (stmt)->m->bind_param((stmt), (bind)
TSRMLS_CC)
#define mysqlnd_stmt_refresh_bind_param(s) (s)->m->refresh_bind_param((s)
TSRMLS_CC)
+#define mysqlnd_stmt_set_param_bind_dtor(s,d) (s)->m->set_param_bind_dtor((s), (d)
TSRMLS_CC)
#define mysqlnd_stmt_bind_result(stmt,bind) (stmt)->m->bind_result((stmt), (bind)
TSRMLS_CC)
+#define mysqlnd_stmt_set_result_bind_dtor(s,d) (s)->m->set_result_bind_dtor((s),
(d) TSRMLS_CC)
#define mysqlnd_stmt_param_metadata(stmt) (stmt)->m->get_parameter_metadata((stmt))
#define mysqlnd_stmt_result_metadata(stmt) (stmt)->m->get_result_metadata((stmt)
TSRMLS_CC)
Modified: trunk/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/mysqlnd/mysqlnd_ps.c 2008-04-10 12:42:13 UTC (rev 1413)
+++ trunk/mysqlnd/mysqlnd_ps.c 2008-04-10 14:35:58 UTC (rev 1414)
@@ -1180,7 +1180,7 @@
/* }}} */
-/* {{{ _mysqlnd_stmt_bind_param */
+/* {{{ mysqlnd_stmt::bind_param */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, bind_param)(MYSQLND_STMT * const stmt,
MYSQLND_PARAM_BIND * const param_bind TSRMLS_DC)
@@ -1193,6 +1193,9 @@
if (stmt->state < MYSQLND_STMT_PREPARED) {
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
DBG_ERR("not prepared");
+ if (param_bind && stmt->param_bind_dtor) {
+ stmt->param_bind_dtor(param_bind);
+ }
DBG_RETURN(FAIL);
}
@@ -1222,7 +1225,9 @@
stmt->param_bind[i].zv = NULL;
}
}
- mnd_efree(stmt->param_bind);
+ if (stmt->param_bind != param_bind && stmt->param_bind_dtor) {
+ stmt->param_bind_dtor(stmt->param_bind);
+ }
}
stmt->param_bind = param_bind;
@@ -1246,7 +1251,7 @@
/* }}} */
-/* {{{ _mysqlnd_stmt_refresh_bind_param */
+/* {{{ mysqlnd_stmt::refresh_bind_param */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, refresh_bind_param)(MYSQLND_STMT * const stmt TSRMLS_DC)
{
@@ -1271,6 +1276,19 @@
/* }}} */
+/* {{{ mysqlnd_stmt::set_bind_param_dtor */
+static void
+MYSQLND_METHOD(mysqlnd_stmt, set_param_bind_dtor)(MYSQLND_STMT * const stmt,
+ void (*param_bind_dtor)(MYSQLND_PARAM_BIND *dtor) TSRMLS_DC)
+{
+ DBG_ENTER("mysqlnd_stmt::set_bind_param_dtor");
+ DBG_INF_FMT("stmt=%p", param_bind_dtor);
+ stmt->param_bind_dtor = param_bind_dtor;
+ DBG_VOID_RETURN;
+}
+/* }}} */
+
+
/* {{{ mysqlnd_stmt::bind_result */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, bind_result)(MYSQLND_STMT * const stmt,
@@ -1286,8 +1304,8 @@
if (stmt->state < MYSQLND_STMT_PREPARED) {
SET_STMT_ERROR(stmt, CR_NO_PREPARE_STMT, UNKNOWN_SQLSTATE, mysqlnd_stmt_not_prepared);
- if (result_bind) {
- mnd_efree(result_bind);
+ if (result_bind && stmt->result_bind_dtor) {
+ stmt->result_bind_dtor(result_bind);
}
DBG_ERR("not prepared");
DBG_RETURN(FAIL);
@@ -1312,8 +1330,8 @@
*/
stmt->result_bind[i].bound = TRUE;
}
- } else if (result_bind) {
- mnd_efree(result_bind);
+ } else if (result_bind && stmt->result_bind_dtor) {
+ stmt->result_bind_dtor(result_bind);
}
DBG_INF("PASS");
DBG_RETURN(PASS);
@@ -1321,6 +1339,19 @@
/* }}} */
+/* {{{ mysqlnd_stmt::set_bind_result_dtor */
+static void
+MYSQLND_METHOD(mysqlnd_stmt, set_result_bind_dtor)(MYSQLND_STMT * const stmt,
+ void (*result_bind_dtor)(MYSQLND_RESULT_BIND *dtor) TSRMLS_DC)
+{
+ DBG_ENTER("mysqlnd_stmt::set_bind_param_dtor");
+ DBG_INF_FMT("stmt=%p", result_bind_dtor);
+ stmt->result_bind_dtor = result_bind_dtor;
+ DBG_VOID_RETURN;
+}
+/* }}} */
+
+
/* {{{ mysqlnd_stmt::insert_id */
static uint64
MYSQLND_METHOD(mysqlnd_stmt, insert_id)(const MYSQLND_STMT * const stmt)
@@ -1510,7 +1541,7 @@
/* }}} */
-/* {{{ _mysqlnd_stmt_attr_get */
+/* {{{ mysqlnd_stmt::attr_get */
static enum_func_status
MYSQLND_METHOD(mysqlnd_stmt, attr_get)(MYSQLND_STMT * const stmt,
enum mysqlnd_stmt_attr attr_type,
@@ -1626,7 +1657,9 @@
}
}
}
- mnd_efree(stmt->result_bind);
+ if (stmt->result_bind_dtor) {
+ stmt->result_bind_dtor(stmt->result_bind);
+ }
stmt->result_bind = NULL;
DBG_VOID_RETURN;
@@ -1656,8 +1689,9 @@
zval_ptr_dtor(&stmt->param_bind[i].zv);
}
}
-
- mnd_efree(stmt->param_bind);
+ if (stmt->param_bind_dtor) {
+ stmt->param_bind_dtor(stmt->param_bind);
+ }
stmt->param_bind = NULL;
}
@@ -1794,7 +1828,9 @@
MYSQLND_METHOD(mysqlnd_stmt, bind_param),
MYSQLND_METHOD(mysqlnd_stmt, refresh_bind_param),
+ MYSQLND_METHOD(mysqlnd_stmt, set_param_bind_dtor),
MYSQLND_METHOD(mysqlnd_stmt, bind_result),
+ MYSQLND_METHOD(mysqlnd_stmt, set_result_bind_dtor),
MYSQLND_METHOD(mysqlnd_stmt, send_long_data),
MYSQLND_METHOD(mysqlnd_stmt, param_metadata),
MYSQLND_METHOD(mysqlnd_stmt, result_metadata),
@@ -1837,10 +1873,32 @@
*/
stmt->conn = conn->m->get_reference(conn);
+ stmt->m->set_param_bind_dtor(stmt, mysqlnd_efree_param_bind_dtor TSRMLS_CC);
+ stmt->m->set_result_bind_dtor(stmt, mysqlnd_efree_result_bind_dtor TSRMLS_CC);
+
DBG_RETURN(stmt);
}
/* }}} */
+
+/* {{{ mysqlnd_efree_param_bind_dtor */
+PHPAPI void
+mysqlnd_efree_param_bind_dtor(MYSQLND_PARAM_BIND * param_bind)
+{
+ efree(param_bind);
+}
+/* }}} */
+
+
+/* {{{ mysqlnd_efree_result_bind_dtor */
+PHPAPI void
+mysqlnd_efree_result_bind_dtor(MYSQLND_RESULT_BIND * result_bind)
+{
+ efree(result_bind);
+}
+/* }}} */
+
+
/*
* Local variables:
* tab-width: 4
Modified: trunk/mysqlnd/mysqlnd_structs.h
===================================================================
--- trunk/mysqlnd/mysqlnd_structs.h 2008-04-10 12:42:13 UTC (rev 1413)
+++ trunk/mysqlnd/mysqlnd_structs.h 2008-04-10 14:35:58 UTC (rev 1414)
@@ -356,7 +356,9 @@
enum_func_status (*bind_param)(MYSQLND_STMT * const stmt, MYSQLND_PARAM_BIND * const
param_bind TSRMLS_DC);
enum_func_status (*refresh_bind_param)(MYSQLND_STMT * const stmt TSRMLS_DC);
+ void (*set_param_bind_dtor)(MYSQLND_STMT * const stmt, void
(*param_bind_dtor)(MYSQLND_PARAM_BIND *) TSRMLS_DC);
enum_func_status (*bind_result)(MYSQLND_STMT * const stmt, MYSQLND_RESULT_BIND * const
result_bind TSRMLS_DC);
+ void (*set_result_bind_dtor)(MYSQLND_STMT * const stmt, void
(*result_bind_dtor)(MYSQLND_RESULT_BIND *) TSRMLS_DC);
enum_func_status (*send_long_data)(MYSQLND_STMT * const stmt, unsigned int param_num,
const char * const data, unsigned long length TSRMLS_DC);
MYSQLND_RES * (*get_parameter_metadata)(MYSQLND_STMT * const stmt);
@@ -619,6 +621,9 @@
MYSQLND_CMD_BUFFER cmd_buffer;
unsigned int execute_count;/* count how many times the stmt was executed */
+ void (*param_bind_dtor)(MYSQLND_PARAM_BIND *);
+ void (*result_bind_dtor)(MYSQLND_RESULT_BIND *);
+
struct st_mysqlnd_stmt_methods *m;
};
| Thread |
|---|
| • PHP mysqlnd svn commit: r1414 - trunk/mysqlnd | ahristov | 10 Apr |