]> granicus.if.org Git - php/commitdiff
Unify error messages
authorDerick Rethans <derick@php.net>
Wed, 26 Jun 2002 08:07:59 +0000 (08:07 +0000)
committerDerick Rethans <derick@php.net>
Wed, 26 Jun 2002 08:07:59 +0000 (08:07 +0000)
ext/mysql/php_mysql.c

index da12b4091a8be4ae8cea7d3e3acd2701f84c009b..00b8f4ac1f05fd45f03eaa01e841b3471ed8b6df 100644 (file)
@@ -221,7 +221,7 @@ ZEND_GET_MODULE(mysql)
 
 void timeout(int sig);
 
-#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING, "MySQL:  A link to the server could not be established"); RETURN_FALSE; } }
+#define CHECK_LINK(link) { if (link==-1) { php_error(E_WARNING, "%s(): A link to the server could not be established", get_active_function_name(TSRMLS_C)); RETURN_FALSE; } }
 
 /* {{{ _free_mysql_result
  * This wrapper is required since mysql_free_result() returns an integer, and
@@ -450,7 +450,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 
        if (PG(sql_safe_mode)) {
                if (ZEND_NUM_ARGS()>0) {
-                       php_error(E_NOTICE, "SQL safe mode in effect - ignoring host/user/password information");
+                       php_error(E_NOTICE, "%s(): SQL safe mode in effect - ignoring host/user/password information", get_active_function_name(TSRMLS_C));
                }
                host_and_port=passwd=NULL;
                user=php_get_current_user();
@@ -559,12 +559,12 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        list_entry new_le;
 
                        if (MySG(max_links)!=-1 && MySG(num_links)>=MySG(max_links)) {
-                               php_error(E_WARNING, "MySQL:  Too many open links (%d)", MySG(num_links));
+                               php_error(E_WARNING, "%s(): Too many open links (%d)", get_active_function_name(TSRMLS_C), MySG(num_links));
                                efree(hashed_details);
                                MYSQL_DO_CONNECT_RETURN_FALSE();
                        }
                        if (MySG(max_persistent)!=-1 && MySG(num_persistent)>=MySG(max_persistent)) {
-                               php_error(E_WARNING, "MySQL:  Too many open persistent links (%d)", MySG(num_persistent));
+                               php_error(E_WARNING, "%s(): Too many open persistent links (%d)", get_active_function_name(TSRMLS_C), MySG(num_persistent));
                                efree(hashed_details);
                                MYSQL_DO_CONNECT_RETURN_FALSE();
                        }
@@ -580,7 +580,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                                /* Populate connect error globals so that the error functions can read them */
                                if (MySG(connect_error)!=NULL) efree(MySG(connect_error));
                                MySG(connect_error)=estrdup(mysql_error(&mysql->conn));
-                               php_error(E_WARNING, "%s", MySG(connect_error));
+                               php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), MySG(connect_error));
 #if defined(HAVE_MYSQL_ERRNO)
                                MySG(connect_errno)=mysql_errno(&mysql->conn);
 #endif
@@ -617,7 +617,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
 #else
                                if (mysql_connect(le->ptr, host, user, passwd)==NULL) {
 #endif
-                                       php_error(E_WARNING, "MySQL:  Link to server lost, unable to reconnect");
+                                       php_error(E_WARNING, "%s: Link to server lost, unable to reconnect", get_active_function_name(TSRMLS_C));
                                        zend_hash_del(&EG(persistent_list), hashed_details, hashed_details_length+1);
                                        efree(hashed_details);
                                        MYSQL_DO_CONNECT_RETURN_FALSE();
@@ -657,7 +657,7 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        }
                }
                if (MySG(max_links)!=-1 && MySG(num_links)>=MySG(max_links)) {
-                       php_error(E_WARNING, "MySQL:  Too many open links (%d)", MySG(num_links));
+                       php_error(E_WARNING, "%s(): Too many open links (%d)", get_active_function_name(TSRMLS_C), MySG(num_links));
                        efree(hashed_details);
                        MYSQL_DO_CONNECT_RETURN_FALSE();
                }
@@ -673,11 +673,11 @@ static void php_mysql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        /* Populate connect error globals so that the error functions can read them */
                        if (MySG(connect_error)!=NULL) efree(MySG(connect_error));
                        MySG(connect_error)=estrdup(mysql_error(&mysql->conn));
-                       php_error(E_WARNING, "%s", MySG(connect_error));
+                       php_error(E_WARNING, "%s(): %s", get_active_function_name(TSRMLS_C), MySG(connect_error));
 #if defined(HAVE_MYSQL_ERRNO)
                        MySG(connect_errno)=mysql_errno(&mysql->conn);
 #endif
-                       php_error(E_WARNING, "MySQL Connection Failed: %s\n", mysql_error(&mysql->conn));
+                       php_error(E_WARNING, "%s(): MySQL Connection Failed: %s\n", get_active_function_name(TSRMLS_C), mysql_error(&mysql->conn));
                        efree(hashed_details);
                        efree(mysql);
                        MYSQL_DO_CONNECT_RETURN_FALSE();
@@ -1133,7 +1133,7 @@ static void php_mysql_do_query_general(zval **query, zval **mysql_link, int link
                mysql_result = (MYSQL_RES *) zend_list_find(mysql->active_result_id, &type);
                if (mysql_result && type==le_result) {
                        if (!mysql_eof(mysql_result)) {
-                               php_error(E_NOTICE, "Called %s() without first fetching all rows from a previous unbuffered query",
+                               php_error(E_NOTICE, "%s(): Function called without first fetching all rows from a previous unbuffered query",
                                                        get_active_function_name(TSRMLS_C));
                                while (mysql_fetch_row(mysql_result));
                        }
@@ -1160,7 +1160,7 @@ static void php_mysql_do_query_general(zval **query, zval **mysql_link, int link
        }
        if (!mysql_result) {
                if (PHP_MYSQL_VALID_RESULT(&mysql->conn)) { /* query should have returned rows */
-                       php_error(E_WARNING, "MySQL:  Unable to save result set");
+                       php_error(E_WARNING, "%s(): Unable to save result set", get_active_function_name(TSRMLS_C));
                        RETURN_FALSE;
                } else {
                        RETURN_TRUE;
@@ -1281,7 +1281,7 @@ PHP_FUNCTION(mysql_list_dbs)
        ZEND_FETCH_RESOURCE2(mysql, php_mysql_conn *, mysql_link, id, "MySQL-Link", le_link, le_plink);
 
        if ((mysql_result=mysql_list_dbs(&mysql->conn, NULL))==NULL) {
-               php_error(E_WARNING, "Unable to save MySQL query result");
+               php_error(E_WARNING, "%s(): Unable to save MySQL query result", get_active_function_name(TSRMLS_C));
                RETURN_FALSE;
        }
        ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
@@ -1324,7 +1324,7 @@ PHP_FUNCTION(mysql_list_tables)
                RETURN_FALSE;
        }
        if ((mysql_result=mysql_list_tables(&mysql->conn, NULL))==NULL) {
-               php_error(E_WARNING, "Unable to save MySQL query result");
+               php_error(E_WARNING, "%s(): Unable to save MySQL query result", get_active_function_name(TSRMLS_C));
                RETURN_FALSE;
        }
        ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
@@ -1368,7 +1368,7 @@ PHP_FUNCTION(mysql_list_fields)
        }
        convert_to_string_ex(table);
        if ((mysql_result=mysql_list_fields(&mysql->conn, Z_STRVAL_PP(table), NULL))==NULL) {
-               php_error(E_WARNING, "Unable to save MySQL query result");
+               php_error(E_WARNING, "%s(): Unable to save MySQL query result", get_active_function_name(TSRMLS_C));
                RETURN_FALSE;
        }
        ZEND_REGISTER_RESOURCE(return_value, mysql_result, le_result);
@@ -1397,7 +1397,7 @@ PHP_FUNCTION(mysql_list_processes)
 
        mysql_result = mysql_list_processes(&mysql->conn);
        if (mysql_result == NULL) {
-               php_error(E_WARNING, "Unable to save MySQL query result");
+               php_error(E_WARNING, "%s(): Unable to save MySQL query result", get_active_function_name(TSRMLS_C));
                RETURN_FALSE;
        }
 
@@ -1628,7 +1628,7 @@ PHP_FUNCTION(mysql_result)
                
        convert_to_long_ex(row);
        if (Z_LVAL_PP(row)<0 || Z_LVAL_PP(row)>=(int)mysql_num_rows(mysql_result)) {
-               php_error(E_WARNING, "Unable to jump to row %d on MySQL result index %d", Z_LVAL_PP(row), Z_LVAL_PP(result));
+               php_error(E_WARNING, "%s(): Unable to jump to row %d on MySQL result index %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(row), Z_LVAL_PP(result));
                RETURN_FALSE;
        }
        mysql_data_seek(mysql_result, Z_LVAL_PP(row));
@@ -1660,7 +1660,7 @@ PHP_FUNCTION(mysql_result)
                                                i++;
                                        }
                                        if (!tmp_field) { /* no match found */
-                                               php_error(E_WARNING, "%s%s%s not found in MySQL result index %d",
+                                               php_error(E_WARNING, "%s(): %s%s%s not found in MySQL result index %d", get_active_function_name(TSRMLS_C),
                                                                        (table_name?table_name:""), (table_name?".":""), field_name, Z_LVAL_PP(result));
                                                efree(field_name);
                                                if (table_name) {
@@ -1678,7 +1678,7 @@ PHP_FUNCTION(mysql_result)
                                convert_to_long_ex(field);
                                field_offset = Z_LVAL_PP(field);
                                if (field_offset<0 || field_offset>=(int)mysql_num_fields(mysql_result)) {
-                                       php_error(E_WARNING, "Bad column offset specified");
+                                       php_error(E_WARNING, "%s(): Bad column offset specified", get_active_function_name(TSRMLS_C));
                                        RETURN_FALSE;
                                }
                                break;
@@ -1880,7 +1880,7 @@ PHP_FUNCTION(mysql_data_seek)
 
        convert_to_long_ex(offset);
        if (Z_LVAL_PP(offset)<0 || Z_LVAL_PP(offset)>=(int)mysql_num_rows(mysql_result)) {
-               php_error(E_WARNING, "Offset %d is invalid for MySQL result index %d (or the query data is unbuffered)", Z_LVAL_PP(offset), Z_LVAL_PP(result));
+               php_error(E_WARNING, "%s(): Offset %d is invalid for MySQL result index %d (or the query data is unbuffered)", get_active_function_name(TSRMLS_C), Z_LVAL_PP(offset), Z_LVAL_PP(result));
                RETURN_FALSE;
        }
        mysql_data_seek(mysql_result, Z_LVAL_PP(offset));
@@ -2003,7 +2003,7 @@ PHP_FUNCTION(mysql_fetch_field)
 
        if (field) {
                if (Z_LVAL_PP(field)<0 || Z_LVAL_PP(field)>=(int)mysql_num_fields(mysql_result)) {
-                       php_error(E_WARNING, "MySQL:  Bad field offset");
+                       php_error(E_WARNING, "%s(): Bad field offset", get_active_function_name(TSRMLS_C));
                        RETURN_FALSE;
                }
                mysql_field_seek(mysql_result, Z_LVAL_PP(field));
@@ -2047,7 +2047,7 @@ PHP_FUNCTION(mysql_field_seek)
 
        convert_to_long_ex(offset);
        if (Z_LVAL_PP(offset)<0 || Z_LVAL_PP(offset)>=(int)mysql_num_fields(mysql_result)) {
-               php_error(E_WARNING, "Field %d is invalid for MySQL result index %d", Z_LVAL_PP(offset), Z_LVAL_PP(result));
+               php_error(E_WARNING, "%s(): Field %d is invalid for MySQL result index %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(offset), Z_LVAL_PP(result));
                RETURN_FALSE;
        }
        mysql_field_seek(mysql_result, Z_LVAL_PP(offset));
@@ -2080,7 +2080,7 @@ static void php_mysql_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
        
        convert_to_long_ex(field);
        if (Z_LVAL_PP(field)<0 || Z_LVAL_PP(field)>=(int)mysql_num_fields(mysql_result)) {
-               php_error(E_WARNING, "Field %d is invalid for MySQL result index %d", Z_LVAL_PP(field), Z_LVAL_PP(result));
+               php_error(E_WARNING, "%s(): Field %d is invalid for MySQL result index %d", get_active_function_name(TSRMLS_C), Z_LVAL_PP(field), Z_LVAL_PP(result));
                RETURN_FALSE;
        }
        mysql_field_seek(mysql_result, Z_LVAL_PP(field));