diff options
author | Andrey Hristov <andrey@php.net> | 2011-08-04 09:51:26 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2011-08-04 09:51:26 +0000 |
commit | 11f198b203a715ff4495b452e2ec10bc6f60baad (patch) | |
tree | 889f10e5b9ef36ae7095063428319327d5e16274 /ext/mysqlnd/mysqlnd_priv.h | |
parent | 463de70efd83274ba8df51a4b75a21c8e6382baa (diff) | |
download | php-git-11f198b203a715ff4495b452e2ec10bc6f60baad.tar.gz |
Add mysqli_error_list() that returns an array with errors. Typically only
one and just one for libmysql. mysqlnd can return generate more than one error
during its work and with mysqli_error() only the last error is being reported.
In the array returned by mysqli_error_list() / $mysqli->error_list, all errors will be found.
The list is reset when the next command is executed
Diffstat (limited to 'ext/mysqlnd/mysqlnd_priv.h')
-rw-r--r-- | ext/mysqlnd/mysqlnd_priv.h | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h index 49ec127800..5bd688a285 100644 --- a/ext/mysqlnd/mysqlnd_priv.h +++ b/ext/mysqlnd/mysqlnd_priv.h @@ -134,15 +134,41 @@ (error_info).error_no = 0; \ (error_info).error[0] = '\0'; \ strlcpy((error_info).sqlstate, "00000", sizeof((error_info).sqlstate)); \ + if ((error_info).error_list) { \ + zend_llist_clean((error_info).error_list); \ + } \ } + #define SET_CLIENT_ERROR(error_info, a, b, c) \ - { \ +{ \ + if (0 == (a)) { \ + SET_EMPTY_ERROR((error_info)); \ + } else { \ (error_info).error_no = (a); \ strlcpy((error_info).sqlstate, (b), sizeof((error_info).sqlstate)); \ strlcpy((error_info).error, (c), sizeof((error_info).error)); \ + if ((error_info).error_list) {\ + MYSQLND_ERROR_LIST_ELEMENT error_for_the_list = {0}; \ + \ + error_for_the_list.error_no = (a); \ + strlcpy(error_for_the_list.sqlstate, (b), sizeof(error_for_the_list.sqlstate)); \ + error_for_the_list.error = mnd_pestrdup((c), TRUE); \ + if (error_for_the_list.error) { \ + DBG_INF_FMT("adding error [%s] to the list", error_for_the_list.error); \ + zend_llist_add_element((error_info).error_list, &error_for_the_list); \ + } \ + } \ + } \ +} + + +#define COPY_CLIENT_ERROR(error_info_to, error_info_from) \ + { \ + SET_CLIENT_ERROR((error_info_to), (error_info_from).error_no, (error_info_from).sqlstate, (error_info_from).error); \ } + #define SET_OOM_ERROR(error_info) SET_CLIENT_ERROR((error_info), CR_OUT_OF_MEMORY, UNKNOWN_SQLSTATE, mysqlnd_out_of_memory) |