From 0d6aa20880517e33949a4fb00a020951ecc4f91b Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 20 May 2004 15:51:25 +0000 Subject: Error handling support. Fixed possible crash when trying to fetch data from a failed query. --- ext/pdo_mysql/php_pdo_mysql_int.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'ext/pdo_mysql/php_pdo_mysql_int.h') diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index b95e9c765e..875738ccaf 100755 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -23,14 +23,21 @@ #include +typedef struct { + const char *file; + int line; + unsigned int errcode; + char *errmsg; +} pdo_mysql_error_info; + /* stuff we use in a mySQL database handle */ typedef struct { MYSQL *server; - int last_err; - unsigned int mysql_errno; - char *mysql_error; + unsigned attached:1; unsigned _reserved:31; + + pdo_mysql_error_info einfo; } pdo_mysql_db_handle; typedef struct { @@ -42,7 +49,6 @@ typedef struct { MYSQL_RES *result; MYSQL_ROW current_data; long *current_lengths; - int last_err; pdo_mysql_column *cols; } pdo_mysql_stmt; @@ -55,16 +61,8 @@ typedef struct { extern pdo_driver_t pdo_mysql_driver; -extern int _pdo_mysql_error(char *what, int mysql_errno, const char *file, int line TSRMLS_DC); -#define pdo_mysql_error(s) \ - s->mysql_errno = mysql_errno(s->server); \ - if (s->mysql_error) { \ - efree(s->mysql_error); \ - } \ - s->mysql_error = estrdup(mysql_error(s->server)); - - -extern int mysql_handle_error(pdo_dbh_t *dbh, pdo_mysql_db_handle *H, int errcode); +extern int _pdo_mysql_error(pdo_dbh_t *dbh, const char *file, int line TSRMLS_DC); +#define pdo_mysql_error(s) _pdo_mysql_error(s, __FILE__, __LINE__ TSRMLS_DC) extern struct pdo_stmt_methods mysql_stmt_methods; #endif -- cgit v1.2.1