File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -2081,6 +2081,36 @@ _mysql_ConnectionObject_use_result(
2081
2081
return result ;
2082
2082
}
2083
2083
2084
+ static const char _mysql_ConnectionObject_discard_result__doc__ [] =
2085
+ "Discard current result set.\n\n"
2086
+ "This function can be called instead of use_result() or store_result(). Non-standard." ;
2087
+
2088
+ static PyObject *
2089
+ _mysql_ConnectionObject_discard_result (
2090
+ _mysql_ConnectionObject * self ,
2091
+ PyObject * noargs )
2092
+ {
2093
+ check_connection (self );
2094
+ MYSQL * conn = & (self -> connection );
2095
+
2096
+ Py_BEGIN_ALLOW_THREADS ;
2097
+ MYSQL_RES * res = mysql_use_result (conn );
2098
+ if (res == NULL ) {
2099
+ Py_BLOCK_THREADS ;
2100
+ return _mysql_Exception (self );
2101
+ }
2102
+ MYSQL_ROW row ;
2103
+ while (NULL != (row = mysql_fetch_row (res ))) {
2104
+ // do nothing.
2105
+ }
2106
+ mysql_free_result (res );
2107
+ Py_END_ALLOW_THREADS ;
2108
+ if (mysql_errno (conn )) {
2109
+ return _mysql_Exception (self );
2110
+ }
2111
+ Py_RETURN_NONE ;
2112
+ }
2113
+
2084
2114
static void
2085
2115
_mysql_ConnectionObject_dealloc (
2086
2116
_mysql_ConnectionObject * self )
@@ -2376,6 +2406,12 @@ static PyMethodDef _mysql_ConnectionObject_methods[] = {
2376
2406
METH_NOARGS ,
2377
2407
_mysql_ConnectionObject_use_result__doc__
2378
2408
},
2409
+ {
2410
+ "discard_result" ,
2411
+ (PyCFunction )_mysql_ConnectionObject_discard_result ,
2412
+ METH_NOARGS ,
2413
+ _mysql_ConnectionObject_discard_result__doc__
2414
+ },
2379
2415
{NULL , NULL } /* sentinel */
2380
2416
};
2381
2417
You can’t perform that action at this time.
0 commit comments