]> granicus.if.org Git - php/commitdiff
php_error -> php_error_docref
authorYasuo Ohgaki <yohgaki@php.net>
Wed, 4 Sep 2002 22:25:13 +0000 (22:25 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Wed, 4 Sep 2002 22:25:13 +0000 (22:25 +0000)
ext/pgsql/pgsql.c

index bd35d2412c506f05c87e57e6f8c0ec2531f35b37..2c2eec3a1b7fb15dfd22c8090468b916c293c095 100644 (file)
@@ -71,7 +71,7 @@
 #define PQ_SETNONBLOCKING(pg_link, flag) 0
 #endif
 
-#define CHECK_DEFAULT_LINK(x) if (x == -1) { php_error(E_WARNING, "%s(): No PostgreSQL link opened yet", get_active_function_name(TSRMLS_C)); }
+#define CHECK_DEFAULT_LINK(x) if ((x) == -1) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "No PostgreSQL link opened yet"); }
 
 /* {{{ pgsql_functions[]
  */
@@ -301,7 +301,7 @@ static int _rollback_transactions(zend_rsrc_list_entry *rsrc TSRMLS_DC)
        link = (PGconn *) rsrc->ptr;
 
        if (PQ_SETNONBLOCKING(link, 0)) {
-               php_error(E_NOTICE,"PostgreSQL: Cannot set connection to blocking mode");
+               php_error_docref("ref.pgsql" TSRMLS_CC, E_NOTICE, "Cannot set connection to blocking mode");
                return -1;
        }
        
@@ -527,13 +527,13 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        list_entry new_le;
                        
                        if (PGG(max_links)!=-1 && PGG(num_links)>=PGG(max_links)) {
-                               php_error(E_WARNING,"%s(): Cannot create new link. Too many open links (%d)",
-                                                 get_active_function_name(TSRMLS_C), PGG(num_links));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING,
+                                                                "Cannot create new link. Too many open links (%d)", PGG(num_links));
                                goto err;
                        }
                        if (PGG(max_persistent)!=-1 && PGG(num_persistent)>=PGG(max_persistent)) {
-                               php_error(E_WARNING,"%s(): Cannot create new link. Too many open persistent links (%d)",
-                                                 get_active_function_name(TSRMLS_C), PGG(num_persistent));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING,
+                                                                "Cannot create new link. Too many open persistent links (%d)", PGG(num_persistent));
                                goto err;
                        }
 
@@ -544,8 +544,8 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                                pgsql=PQsetdb(host,port,options,tty,dbname);
                        }
                        if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
-                               php_error(E_WARNING,"%s(): Unable to connect to PostgreSQL server: %s",
-                                                 get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING,
+                                                                "Unable to connect to PostgreSQL server: %s", PQerrorMessage(pgsql));
                                if (pgsql) {
                                        PQfinish(pgsql);
                                }
@@ -584,8 +584,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                                        PQreset(le->ptr);
                                }
                                if (le->ptr==NULL || PQstatus(le->ptr)==CONNECTION_BAD) {
-                                       php_error(E_WARNING,"%s(): PostgreSQL link lost, unable to reconnect",
-                                                         get_active_function_name(TSRMLS_C));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING,"PostgreSQL link lost, unable to reconnect");
                                        zend_hash_del(&EG(persistent_list),str.c,str.len+1);
                                        goto err;
                                }
@@ -621,8 +620,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        }
                }
                if (PGG(max_links)!=-1 && PGG(num_links)>=PGG(max_links)) {
-                       php_error(E_WARNING,"%s(): Cannot create new link. Too many open links (%d)",
-                                         get_active_function_name(TSRMLS_C), PGG(num_links));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot create new link. Too many open links (%d)", PGG(num_links));
                        goto err;
                }
                if (connstring) {
@@ -631,8 +629,7 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        pgsql = PQsetdb(host,port,options,tty,dbname);
                }
                if (pgsql==NULL || PQstatus(pgsql)==CONNECTION_BAD) {
-                       php_error(E_WARNING,"%s(): Unable to connect to PostgreSQL server: %s",
-                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to connect to PostgreSQL server: %s", PQerrorMessage(pgsql));
                        goto err;
                }
 
@@ -876,8 +873,7 @@ PHP_FUNCTION(pg_query)
 
        convert_to_string_ex(query);
        if (PQ_SETNONBLOCKING(pgsql, 0)) {
-               php_error(E_NOTICE,"%s(): Cannot set connection to blocking mode",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Cannot set connection to blocking mode");
                RETURN_FALSE;
        }
        while ((pgsql_result = PQgetResult(pgsql))) {
@@ -885,8 +881,7 @@ PHP_FUNCTION(pg_query)
                leftover = 1;
        }
        if (leftover) {
-               php_error(E_NOTICE,"%s(): Found results on this connection. Use pg_get_result() to get results",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Found results on this connection. Use pg_get_result() to get results");
        }
        pgsql_result = PQexec(pgsql, Z_STRVAL_PP(query));
        
@@ -901,8 +896,7 @@ PHP_FUNCTION(pg_query)
                case PGRES_BAD_RESPONSE:
                case PGRES_NONFATAL_ERROR:
                case PGRES_FATAL_ERROR:
-                       php_error(E_WARNING, "%s(): Query failed:  %s",
-                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed:  %s", PQerrorMessage(pgsql));
                        RETURN_FALSE;
                        break;
                case PGRES_COMMAND_OK: /* successful command that did not return rows */
@@ -952,8 +946,7 @@ static void php_pgsql_get_result_info(INTERNAL_FUNCTION_PARAMETERS, int entry_ty
 #if HAVE_PQCMDTUPLES
                        Z_LVAL_P(return_value) = atoi(PQcmdTuples(pgsql_result));
 #else
-                       php_error(E_WARNING,"%(): Not supportted under this build",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Not supportted under this build");
                        Z_LVAL_P(return_value) = 0;
 #endif
                        break;
@@ -1090,8 +1083,7 @@ static void php_pgsql_get_field_info(INTERNAL_FUNCTION_PARAMETERS, int entry_typ
        convert_to_long_ex(field);
        
        if (Z_LVAL_PP(field) < 0 || Z_LVAL_PP(field) >= PQnfields(pgsql_result)) {
-               php_error(E_WARNING,"%s(): Bad field offset specified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad field offset specified");
                RETURN_FALSE;
        }
        
@@ -1191,8 +1183,7 @@ PHP_FUNCTION(pg_fetch_result)
                convert_to_long_ex(row);
                pgsql_row = Z_LVAL_PP(row);
                if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) {
-                       php_error(E_WARNING,"%s(): Unable to jump to row %d on PostgreSQL result index %d",
-                                         get_active_function_name(TSRMLS_C), Z_LVAL_PP(row), Z_LVAL_PP(result));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %d on PostgreSQL result index %d", Z_LVAL_PP(row), Z_LVAL_PP(result));
                        RETURN_FALSE;
                }
        }
@@ -1206,8 +1197,7 @@ PHP_FUNCTION(pg_fetch_result)
                        break;
        }
        if (field_offset<0 || field_offset>=PQnfields(pgsql_result)) {
-               php_error(E_WARNING,"%s(): Bad column offset specified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified");
                RETURN_FALSE;
        }
        
@@ -1256,8 +1246,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
        }
        
        if (!(result_type & PGSQL_BOTH)) {
-               php_error(E_WARNING, "%s(): Invalid result type",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid result type");
                RETURN_FALSE;
        }
        
@@ -1277,8 +1266,7 @@ static void php_pgsql_fetch_hash(INTERNAL_FUNCTION_PARAMETERS, int result_type)
                        pgsql_row = Z_LVAL_PP(row);
                        pg_result->row = pgsql_row;
                        if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) {
-                               php_error(E_WARNING, "%s(): Unable to jump to row %d on PostgreSQL result index %d",
-                                                 get_active_function_name(TSRMLS_C), Z_LVAL_PP(row), Z_LVAL_PP(result));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %d on PostgreSQL result index %d", Z_LVAL_PP(row), Z_LVAL_PP(result));
                                RETURN_FALSE;
                        }
                } else {
@@ -1412,8 +1400,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
                convert_to_long_ex(row);
                pgsql_row = Z_LVAL_PP(row);
                if (pgsql_row < 0 || pgsql_row >= PQntuples(pgsql_result)) {
-                       php_error(E_WARNING,"%s(): Unable to jump to row %d on PostgreSQL result index %d",
-                                         get_active_function_name(TSRMLS_C), Z_LVAL_PP(row), Z_LVAL_PP(result));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to jump to row %d on PostgreSQL result index %d", Z_LVAL_PP(row), Z_LVAL_PP(result));
                        RETURN_FALSE;
                }
        }
@@ -1429,8 +1416,7 @@ static void php_pgsql_data_info(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
                        break;
        }
        if (field_offset < 0 || field_offset >= PQnfields(pgsql_result)) {
-               php_error(E_WARNING, "%s(): Bad column offset specified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Bad column offset specified");
                RETURN_FALSE;
        }
        
@@ -1626,7 +1612,7 @@ PHP_FUNCTION(pg_lo_create)
        
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink);
        
-       /* XXX: Archive modes not supported until I get some more data. Don't think anybody's
+       /* NOTE: Archive modes not supported until I get some more data. Don't think anybody's
           using it anyway. I believe it's also somehow related to the 'time travel' feature of
           PostgreSQL, that's on the list of features to be removed... Create modes not supported.
           What's the use of an object that can be only written to, but not read from, and vice
@@ -1635,8 +1621,7 @@ PHP_FUNCTION(pg_lo_create)
        */
 
        if ((pgsql_oid = lo_creat(pgsql, INV_READ|INV_WRITE)) == InvalidOid) {
-               php_error(E_WARNING, "%s(): Unable to create PostgreSQL large object",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create PostgreSQL large object");
                RETURN_FALSE;
        }
        PGSQL_RETURN_OID(pgsql_oid);    
@@ -1662,16 +1647,14 @@ PHP_FUNCTION(pg_lo_unlink)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
        }
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                 "rl", &pgsql_link, &oid_long) == SUCCESS) {
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
@@ -1681,8 +1664,7 @@ PHP_FUNCTION(pg_lo_unlink)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
                id = PGG(default_link);
@@ -1691,8 +1673,7 @@ PHP_FUNCTION(pg_lo_unlink)
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                 "l", &oid_long) == SUCCESS) {
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
@@ -1700,16 +1681,14 @@ PHP_FUNCTION(pg_lo_unlink)
                CHECK_DEFAULT_LINK(id);
        }
        else {
-               php_error(E_WARNING, "%s(): Requires 1 or 2 arguments",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 1 or 2 arguments");
                RETURN_FALSE;
        }
        
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (lo_unlink(pgsql, oid) == -1) {
-               php_error(E_WARNING, "%s(): Unable to delete PostgreSQL large object %u",
-                                 get_active_function_name(TSRMLS_C), oid);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to delete PostgreSQL large object %u", oid);
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -1737,16 +1716,14 @@ PHP_FUNCTION(pg_lo_open)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
        }
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                 "rls", &pgsql_link, &oid_long, &mode_string, &mode_strlen) == SUCCESS) {
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
@@ -1756,8 +1733,7 @@ PHP_FUNCTION(pg_lo_open)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
                id = PGG(default_link);
@@ -1766,8 +1742,7 @@ PHP_FUNCTION(pg_lo_open)
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                 "ls", &oid_long, &mode_string, &mode_strlen) == SUCCESS) {
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
@@ -1775,8 +1750,7 @@ PHP_FUNCTION(pg_lo_open)
                CHECK_DEFAULT_LINK(id);
        }
        else {
-               php_error(E_WARNING, "%s(): Requires 1 or 2 arguments",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 1 or 2 arguments");
                RETURN_FALSE;
        }
        
@@ -1807,20 +1781,17 @@ PHP_FUNCTION(pg_lo_open)
                if (create) {
                        if ((oid = lo_creat(pgsql, INV_READ|INV_WRITE)) == 0) {
                                efree(pgsql_lofp);
-                               php_error(E_WARNING, "%s(): Unable to create PostgreSQL large object",
-                                                 get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to create PostgreSQL large object");
                                RETURN_FALSE;
                        } else {
                                if ((pgsql_lofd = lo_open(pgsql, oid, pgsql_mode)) == -1) {
                                        if (lo_unlink(pgsql, oid) == -1) {
                                                efree(pgsql_lofp);
-                                               php_error(E_WARNING, "%s(): Something's really messed up!!! Your database is badly corrupted in a way NOT related to PHP",
-                                                                 get_active_function_name(TSRMLS_C));
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Something's really messed up!!! Your database is badly corrupted in a way NOT related to PHP");
                                                RETURN_FALSE;
                                        }
                                        efree(pgsql_lofp);
-                                       php_error(E_WARNING, "%s(): Unable to open PostgreSQL large object",
-                                                         get_active_function_name(TSRMLS_C));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open PostgreSQL large object");
                                        RETURN_FALSE;
                                } else {
                                        pgsql_lofp->conn = pgsql;
@@ -1831,8 +1802,7 @@ PHP_FUNCTION(pg_lo_open)
                        }
                } else {
                        efree(pgsql_lofp);
-                       php_error(E_WARNING,"%s(): Unable to open PostgreSQL large object",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to open PostgreSQL large object");
                        RETURN_FALSE;
                }
        } else {
@@ -1864,8 +1834,7 @@ PHP_FUNCTION(pg_lo_close)
        ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp);
        
        if (lo_close((PGconn *)pgsql->conn, pgsql->lofd) < 0) {
-               php_error(E_WARNING, "%s(): Unable to close PostgreSQL large object descriptor %d",
-                                 get_active_function_name(TSRMLS_C), pgsql->lofd);
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to close PostgreSQL large object descriptor %d", pgsql->lofd);
                RETVAL_FALSE;
        } else {
                RETVAL_TRUE;
@@ -1930,13 +1899,11 @@ PHP_FUNCTION(pg_lo_write)
        if (argc > 2) {
                convert_to_long_ex(z_len);
                if (Z_LVAL_PP(z_len) > Z_STRLEN_PP(str)) {
-                       php_error(E_WARNING, "%s(): Cannot write more than buffer size %d. Tried to wtite %d",
-                                         get_active_function_name(TSRMLS_C), Z_LVAL_PP(str), Z_LVAL_PP(z_len));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot write more than buffer size %d. Tried to wtite %d", Z_LVAL_PP(str), Z_LVAL_PP(z_len));
                        RETURN_FALSE;
                }
                if (Z_LVAL_PP(z_len) < 0) {
-                       php_error(E_WARNING, "%s(): Buffer size must be larger than 0. %d specified for buffer size",
-                                         get_active_function_name(TSRMLS_C), Z_LVAL_PP(str), Z_LVAL_PP(z_len));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Buffer size must be larger than 0. %d specified for buffer size", Z_LVAL_PP(str), Z_LVAL_PP(z_len));
                        RETURN_FALSE;
                }
                len = Z_LVAL_PP(z_len);
@@ -2009,7 +1976,7 @@ PHP_FUNCTION(pg_lo_import)
        }
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                          "sr", &file_in, &name_len, &pgsql_link ) == SUCCESS) {
-               php_error(E_NOTICE, "%s(): Old API is used.", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Old API is used.");
        }
        else {
                WRONG_PARAM_COUNT;
@@ -2051,8 +2018,7 @@ PHP_FUNCTION(pg_lo_export)
        if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                 "rls", &pgsql_link, &oid_long, &file_out, &name_len) == SUCCESS) {
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
@@ -2062,16 +2028,14 @@ PHP_FUNCTION(pg_lo_export)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
        }
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                          "ls",  &oid_long, &file_out, &name_len) == SUCCESS) {
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
@@ -2083,8 +2047,7 @@ PHP_FUNCTION(pg_lo_export)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
                id = PGG(default_link);
@@ -2095,24 +2058,21 @@ PHP_FUNCTION(pg_lo_export)
                oid = (Oid)strtoul(oid_string, &end_ptr, 10);
                if ((oid_string+oid_strlen) != end_ptr) {
                        /* wrong integer format */
-                       php_error(E_NOTICE, "%s(): Wrong OID value passed",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Wrong OID value passed");
                        RETURN_FALSE;
                }
        }
        else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, argc TSRMLS_CC,
                                                                          "lsr", &oid_long, &file_out, &name_len, &pgsql_link) == SUCCESS) {
-               php_error(E_NOTICE, " %s(): Old API is used", get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, " %s(): Old API is used");
                if (oid_long <= InvalidOid) {
-                       php_error(E_NOTICE, "%s(): Invalid OID is specified",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid OID is specified");
                        RETURN_FALSE;
                }
                oid = (Oid)oid_long;
        }
        else {
-               php_error(E_WARNING, "%s(): Requires 2 or 3 arguments",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Requires 2 or 3 arguments");
                RETURN_FALSE;
        }
        
@@ -2146,8 +2106,7 @@ PHP_FUNCTION(pg_lo_seek)
                return;
        }
        if (whence != SEEK_SET && whence != SEEK_CUR && whence != SEEK_END) {
-               php_error(E_WARNING, " %s(): Invalid whence parameter",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid whence parameter");
                return;
        }
 
@@ -2289,8 +2248,7 @@ PHP_FUNCTION(pg_end_copy)
        result = PQendcopy(pgsql);
 
        if (result!=0) {
-               php_error(E_WARNING, "%s(): Query failed: %s",
-                                 get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -2331,8 +2289,7 @@ PHP_FUNCTION(pg_put_line)
        result = PQputline(pgsql, Z_STRVAL_PP(query));
 
        if (result==EOF) {
-               php_error(E_WARNING, "%s(): Query failed: %s",
-                                 get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                RETURN_FALSE;
        }
        RETURN_TRUE;
@@ -2400,8 +2357,7 @@ PHP_FUNCTION(pg_copy_to)
                                while (!copydone)
                                {
                                        if ((ret = PQgetline(pgsql, copybuf, COPYBUFSIZ))) {
-                                               php_error(E_WARNING, "%s(): Query failed: %s",
-                                                                 get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                                                RETURN_FALSE;
                                        }
                        
@@ -2435,8 +2391,7 @@ PHP_FUNCTION(pg_copy_to)
                                        }
                                }
                                if (PQendcopy(pgsql)) {
-                                       php_error(E_WARNING, "%s(): Query failed: %s",
-                                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                                        RETURN_FALSE;
                                }
                                while ((pgsql_result = PQgetResult(pgsql))) {
@@ -2449,8 +2404,7 @@ PHP_FUNCTION(pg_copy_to)
                        break;
                default:
                        PQclear(pgsql_result);
-                       php_error(E_WARNING, "%s(): Query failed: %s",
-                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                        RETURN_FALSE;
                        break;
        }
@@ -2517,21 +2471,18 @@ PHP_FUNCTION(pg_copy_from)
                                        if(*(query+Z_STRLEN_PP(tmp)-1) != '\n') strcat(query, "\n");
                                        if (PQputline(pgsql, query)) {
                                                efree(query);
-                                               php_error(E_WARNING, "%s(): Query failed: %s",
-                                                                 get_active_function_name, PQerrorMessage(pgsql));
+                                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                                                RETURN_FALSE;
                                        }
                                        efree(query);
                                        zend_hash_move_forward_ex(Z_ARRVAL_P(pg_rows), &pos);
                                }
                                if (PQputline(pgsql, "\\.\n")) {
-                                       php_error(E_WARNING, "%s(): Query failed: %s",
-                                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                                        RETURN_FALSE;
                                }
                                if (PQendcopy(pgsql)) {
-                                       php_error(E_WARNING, "%s(): Query failed: %s",
-                                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                                        RETURN_FALSE;
                                }
                                while ((pgsql_result = PQgetResult(pgsql))) {
@@ -2545,8 +2496,7 @@ PHP_FUNCTION(pg_copy_from)
                        break;
                default:
                        PQclear(pgsql_result);
-                       php_error(E_WARNING, "%s(): Query failed: %s",
-                                         get_active_function_name(TSRMLS_C), PQerrorMessage(pgsql));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Query failed: %s", PQerrorMessage(pgsql));
                        RETURN_FALSE;
                        break;
        }
@@ -2669,8 +2619,7 @@ static int php_pgsql_flush_query(PGconn *pgsql TSRMLS_DC)
        int leftover = 0;
        
        if (PQsetnonblocking(pgsql, 1)) {
-               php_error(E_NOTICE,"%s(): Cannot set connection to nonblocking mode",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Cannot set connection to nonblocking mode");
                return -1;
        }
        while ((res = PQgetResult(pgsql))) {
@@ -2699,8 +2648,7 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (PQ_SETNONBLOCKING(pgsql, 1)) {
-               php_error(E_NOTICE,"%s(): Cannot set connection to nonblocking mode",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Cannot set connection to nonblocking mode");
                RETURN_FALSE;
        }
        switch(entry_type) {
@@ -2717,13 +2665,11 @@ static void php_pgsql_do_async(INTERNAL_FUNCTION_PARAMETERS, int entry_type)
                        }
                        break;
                default:
-                       php_error(E_ERROR,"%s(): PostgreSQL module error. Report this error",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_ERROR,"PostgreSQL module error. Report this error");
                        break;
        }
        if (PQ_SETNONBLOCKING(pgsql, 0)) {
-               php_error(E_NOTICE,"%s(): Cannot set connection to blocking mode",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Cannot set connection to blocking mode");
        }
        convert_to_boolean_ex(&return_value);
 }
@@ -2765,8 +2711,7 @@ PHP_FUNCTION(pg_send_query)
        ZEND_FETCH_RESOURCE2(pgsql, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (PQ_SETNONBLOCKING(pgsql, 1)) {
-               php_error(E_NOTICE,"%s(): Cannot set connection to nonblocking mode",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Cannot set connection to nonblocking mode");
                RETURN_FALSE;
        }
        while ((res = PQgetResult(pgsql))) {
@@ -2774,15 +2719,13 @@ PHP_FUNCTION(pg_send_query)
                leftover = 1;
        }
        if (leftover) {
-               php_error(E_NOTICE,"%s(): There are results on this connection. Call pg_get_result() until it returns FALSE",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"There are results on this connection. Call pg_get_result() until it returns FALSE");
        }
        if (!PQsendQuery(pgsql, query)) {
                RETURN_FALSE;
        }
        if (PQ_SETNONBLOCKING(pgsql, 0)) {
-               php_error(E_NOTICE,"%s(): Cannot set connection to blocking mode",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Cannot set connection to blocking mode");
        }
        RETURN_TRUE;
 }
@@ -2845,8 +2788,7 @@ PHP_FUNCTION(pg_result_status)
                RETURN_STRING(PQcmdStatus(pgsql_result), 1);
        }
        else {
-               php_error(E_WARNING, "%s(): Expects optional 2nd parameter to be PGSQL_STATUS_LONG or PGSQL_STATUS_STRING",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Expects optional 2nd parameter to be PGSQL_STATUS_LONG or PGSQL_STATUS_STRING");
                RETURN_FALSE;
        }
 }
@@ -2880,8 +2822,7 @@ PHPAPI int php_pgsql_metadata(PGconn *pg_link, const char *table_name, zval *met
        
        pg_result = PQexec(pg_link, querystr.c);
        if (PQresultStatus(pg_result) != PGRES_TUPLES_OK || (num_rows = PQntuples(pg_result)) == 0) {
-               php_error(E_NOTICE, "%s(): Failed to query metadata for '%s' table %s",
-                                 get_active_function_name(TSRMLS_C), table_name, querystr.c);
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to query metadata for '%s' table %s", table_name, querystr.c);
                smart_str_free(&querystr);
                PQclear(pg_result);
                return FAILURE;
@@ -3046,29 +2987,25 @@ static int php_pgsql_convert_match(const char *str, const char *regex , int icas
        
        regerr = regcomp(&re, regex, regopt);
        if (regerr) {
-               php_error(E_WARNING, "%s(): Cannot compile regex",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot compile regex");
                regfree(&re);
                return FAILURE;
        }
        subs = (regmatch_t *)ecalloc(sizeof(regmatch_t), re.re_nsub+1);
        if (!subs) {
-               php_error(E_WARNING, "%s(): Cannot allocate memory",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot allocate memory");
                regfree(&re);
                return FAILURE;
        }
        regerr = regexec(&re, str, re.re_nsub+1, subs, 0);
        if (regerr == REG_NOMATCH) {
 #ifdef PHP_DEBUG               
-               php_error(E_NOTICE, "%s(): '%s' does not match with '%s'",
-                                 get_active_function_name(TSRMLS_C), str, regex);
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "'%s' does not match with '%s'", str, regex);
 #endif
                ret = FAILURE;
        }
        else if (regerr) {
-               php_error(E_WARNING, "%s(): Cannot exec regex",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot exec regex");
                ret = FAILURE;
        }
        regfree(&re);
@@ -3113,8 +3050,7 @@ static int php_pgsql_add_quotes(zval *src, zend_bool should_free TSRMLS_DC)
                                        } \
                                        /* raise error if it's not null */ \
                                        else if (Z_BVAL_PP(not_null)) { \
-                                               php_error(E_NOTICE, "%s(): Detected NULL for 'NOT NULL' field '%s'", \
-                                                                 get_active_function_name(TSRMLS_C), field ); \
+                                               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected NULL for 'NOT NULL' field '%s'", field ); \
                                                err = 1; \
                                        } \
                                }               
@@ -3155,45 +3091,37 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                 zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos)) {
                skip_field = 0;
                if ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(values), &field, &field_len, &num_idx, 0, &pos)) == HASH_KEY_NON_EXISTANT) {
-                       php_error(E_WARNING, "%s(): Failed to get array key type",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to get array key type");
                        err = 1;
                }
                if (!err && key_type == HASH_KEY_IS_LONG) {
-                       php_error(E_WARNING, "%s(): Accepts only string key for values",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values");
                        err = 1;
                }
                if (!err && key_type == HASH_KEY_NON_EXISTANT) {
-                       php_error(E_WARNING, "%s(): Accepts only string key for values",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "Accepts only string key for values");
                        err = 1;
                }
                if (!err && zend_hash_find(Z_ARRVAL_P(meta), field, field_len, (void **)&def) == FAILURE) {
-                       php_error(E_NOTICE, "%s(): Invalid field name (%s) in values", 
-                                                 get_active_function_name(TSRMLS_C), field);
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Invalid field name (%s) in values", field);
                        err = 1;
                }
                if (!err && zend_hash_find(Z_ARRVAL_PP(def), "type", sizeof("type"), (void **)&type) == FAILURE) {
-                       php_error(E_NOTICE, "%s(): Detected broken meta data. Missing 'type'",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected broken meta data. Missing 'type'");
                        err = 1;
                }
                if (!err && zend_hash_find(Z_ARRVAL_PP(def), "not null", sizeof("not null"), (void **)&not_null) == FAILURE) {
-                       php_error(E_NOTICE, "%s(): Detected broken meta data. Missing 'not null'",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected broken meta data. Missing 'not null'");
                        err = 1;
                }
                if (!err && zend_hash_find(Z_ARRVAL_PP(def), "has default", sizeof("has default"), (void **)&has_default) == FAILURE) {
-                       php_error(E_NOTICE, "%s(): Detected broken meta data. Missing 'has default'",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected broken meta data. Missing 'has default'");
                        err = 1;
                }
                if (!err && (Z_TYPE_PP(val) == IS_ARRAY ||
                         Z_TYPE_PP(val) == IS_OBJECT ||
                         Z_TYPE_PP(val) == IS_CONSTANT_ARRAY)) {
-                       php_error(E_NOTICE, "%s(): Expects scaler values as field values",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects scaler values as field values");
                        err = 1;
                }
                if (err) {
@@ -3225,8 +3153,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                                                ZVAL_STRING(new_val, "'f'", 1);
                                                        }
                                                        else {
-                                                               php_error(E_NOTICE, "%s(): Detected invalid value (%s) for pgsql %s field (%s)",
-                                                                                 get_active_function_name(TSRMLS_C), Z_STRVAL_PP(val), Z_STRVAL_PP(type), field);
+                                                               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected invalid value (%s) for PostgreSQL %s field (%s)", Z_STRVAL_PP(val), Z_STRVAL_PP(type), field);
                                                                err = 1;
                                                        }
                                                }
@@ -3251,8 +3178,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string, null, long or boolelan value for pgsql '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string, null, long or boolelan value for PostgreSQL '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
                                        
@@ -3294,8 +3220,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string, null, long or double value for pgsql '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string, null, long or double value for pgsql '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
 
@@ -3336,8 +3261,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string, null, long or double value for pgsql '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string, null, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
 
@@ -3384,8 +3308,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string, null, long or double value for pgsql '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string, null, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
                                        
@@ -3427,8 +3350,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string, null, long or double value for '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string, null, long or double value for '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
                                
@@ -3460,8 +3382,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }                               
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string or null for '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string or null for '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
                                
@@ -3493,8 +3414,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string or null for pgsql %s field (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string or null for PostgreSQL %s field (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
                                
@@ -3525,8 +3445,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string or null for pgsql %s field (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string or null for PostgreSQL %s field (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
 
@@ -3557,8 +3476,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string or null for pgsql %s field (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string or null for PostgreSQL %s field (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
 
@@ -3590,8 +3508,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string or null for pgsql %s field (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string or null for PostgreSQL %s field (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
 #ifdef HAVE_PQESCAPE
@@ -3634,8 +3551,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string, null, long or double value for pgsql '%s' (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string, null, long or double value for PostgreSQL '%s' (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
                                
@@ -3666,8 +3582,7 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                                }
                                PGSQL_CONV_CHECK_IGNORE();
                                if (err) {
-                                       php_error(E_NOTICE, "%s(): Expects string or null for pgsql %s field (%s)",
-                                                         get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects string or null for PostgreSQL %s field (%s)", Z_STRVAL_PP(type), field);
                                }
                                break;
 
@@ -3682,15 +3597,13 @@ PHPAPI int php_pgsql_convert(PGconn *pg_link, const char *table_name, const zval
                        case PG_PATH:
                        case PG_POLYGON:
                        case PG_CIRCLE:
-                               php_error(E_NOTICE, "%s(): does not support  pgsql '%s' type (%s)",
-                                                 get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "does not support PostgreSQL '%s' type (%s)", Z_STRVAL_PP(type), field);
                                err = 1;
                                break;
                                
                        case PG_UNKNOWN:
                        default:
-                               php_error(E_NOTICE, "%s(): unknown or system data type '%s' for '%s'",
-                                                 get_active_function_name(TSRMLS_C), Z_STRVAL_PP(type), field);
+                               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "unknown or system data type '%s' for '%s'", Z_STRVAL_PP(type), field);
                                err = 1;
                                break;
                } /* switch */
@@ -3735,21 +3648,18 @@ PHP_FUNCTION(pg_convert)
                return;
        }
        if (option & ~PGSQL_CONV_OPTS) {
-               php_error(E_WARNING, "%s(): Invalid option is spedified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option is spedified");
                RETURN_FALSE;
        }
        if (!table_name_len) {
-               php_error(E_NOTICE, "%s(): Table name is invalid",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Table name is invalid");
                RETURN_FALSE;
        }
 
        ZEND_FETCH_RESOURCE2(pg_link, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (php_pgsql_flush_query(pg_link TSRMLS_CC)) {
-               php_error(E_NOTICE, "%s(): Detected unhandled result(s) in connection",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected unhandled result(s) in connection");
        }
        array_init(return_value);
        if (php_pgsql_convert(pg_link, table_name, values, return_value, option TSRMLS_CC) == FAILURE) {
@@ -3773,8 +3683,7 @@ static int do_exec(smart_str *querystr, int expect, PGconn *pg_link, ulong opt T
                if (PQresultStatus(pg_result) == expect) {
                        return 0;
                } else {
-                       php_error(E_NOTICE, "%s(): Failed to execute '%s'",
-                                 get_active_function_name(TSRMLS_C), querystr->c);
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to execute '%s'", querystr->c);
                        PQclear(pg_result);
                }
        }
@@ -3820,8 +3729,7 @@ PHPAPI int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array,
        while ((key_type = zend_hash_get_current_key_ex(Z_ARRVAL_P(var_array), &fld,
                                        &fld_len, &num_idx, 0, &pos)) != HASH_KEY_NON_EXISTANT) {
                if (key_type == HASH_KEY_IS_LONG) {
-                       php_error(E_NOTICE,"%s(): Expects associative array for values to be inserted",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Expects associative array for values to be inserted");
                        goto cleanup;
                }
                smart_str_appendl(&querystr, fld, fld_len - 1);
@@ -3849,8 +3757,7 @@ PHPAPI int php_pgsql_insert(PGconn *pg_link, const char *table, zval *var_array,
                                break;
                        default:
                                /* should not happen */
-                               php_error(E_WARNING, "%s(): Report this error to php-dev@lists.php.net. Type = %d",
-                                                 get_active_function_name(TSRMLS_C), Z_TYPE_PP(val));
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Report this error to php-dev@lists.php.net. Type = %d", Z_TYPE_PP(val));
                                goto cleanup;
                                break;
                }
@@ -3900,16 +3807,14 @@ PHP_FUNCTION(pg_insert)
                return;
        }
        if (option & ~(PGSQL_CONV_OPTS|PGSQL_DML_NO_CONV|PGSQL_DML_EXEC|PGSQL_DML_ASYNC|PGSQL_DML_STRING)) {
-               php_error(E_WARNING, "%s(): Invalid option is spedified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option is spedified");
                RETURN_FALSE;
        }
        
        ZEND_FETCH_RESOURCE2(pg_link, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (php_pgsql_flush_query(pg_link TSRMLS_CC)) {
-               php_error(E_NOTICE, "%s(): Detected unhandled result(s) in connection",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected unhandled result(s) in connection");
        }
        if (php_pgsql_insert(pg_link, table, values, option, &sql TSRMLS_CC) == FAILURE) {
                RETURN_FALSE;
@@ -3936,8 +3841,7 @@ static inline int build_assignment_string(smart_str *querystr, HashTable *ht, co
                 zend_hash_move_forward_ex(ht, &pos)) {
                 key_type = zend_hash_get_current_key_ex(ht, &fld, &fld_len, &num_idx, 0, &pos);                
                if (key_type == HASH_KEY_IS_LONG) {
-                       php_error(E_NOTICE,"%s(): Expects associative array for values to be inserted",
-                                         get_active_function_name(TSRMLS_C));
+                       php_error_docref(NULL TSRMLS_CC, E_NOTICE,"Expects associative array for values to be inserted");
                        return -1;
                }
                smart_str_appendl(querystr, fld, fld_len - 1);
@@ -3955,8 +3859,7 @@ static inline int build_assignment_string(smart_str *querystr, HashTable *ht, co
                                break;
                        default:
                                /* should not happen */
-                               php_error(E_NOTICE, "%s(): Expects scaler values other than null. Need to convert?",
-                                                 get_active_function_name(TSRMLS_C));
+                               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Expects scaler values other than null. Need to convert?");
                                return -1;
                }
                smart_str_appendl(querystr, pad, pad_len);
@@ -4053,16 +3956,14 @@ PHP_FUNCTION(pg_update)
                return;
        }
        if (option & ~(PGSQL_CONV_OPTS|PGSQL_DML_NO_CONV|PGSQL_DML_EXEC|PGSQL_DML_STRING)) {
-               php_error(E_WARNING, "%s(): Invalid option is spedified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option is spedified");
                RETURN_FALSE;
        }
        
        ZEND_FETCH_RESOURCE2(pg_link, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (php_pgsql_flush_query(pg_link TSRMLS_CC)) {
-               php_error(E_NOTICE, "%s(): Detected unhandled result(s) in connection",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected unhandled result(s) in connection");
        }
        if (php_pgsql_update(pg_link, table, values, ids, option, &sql TSRMLS_CC) == FAILURE) {
                RETURN_FALSE;
@@ -4143,16 +4044,14 @@ PHP_FUNCTION(pg_delete)
                return;
        }
        if (option & ~(PGSQL_CONV_FORCE_NULL|PGSQL_DML_NO_CONV|PGSQL_DML_EXEC|PGSQL_DML_STRING)) {
-               php_error(E_WARNING, "%s(): Invalid option is spedified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option is spedified");
                RETURN_FALSE;
        }
        
        ZEND_FETCH_RESOURCE2(pg_link, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (php_pgsql_flush_query(pg_link TSRMLS_CC)) {
-               php_error(E_NOTICE, "%s(): Detected unhandled result(s) in connection",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected unhandled result(s) in connection");
        }
        if (php_pgsql_delete(pg_link, table, ids, option, &sql TSRMLS_CC) == FAILURE) {
                RETURN_FALSE;
@@ -4248,8 +4147,7 @@ PHPAPI int php_pgsql_select(PGconn *pg_link, const char *table, zval *ids_array,
        if (PQresultStatus(pg_result) == PGRES_TUPLES_OK) {
                ret = php_pgsql_result2array(pg_result, ret_array TSRMLS_CC);
        } else {
-               php_error(E_NOTICE, "%s(): Failed to execute '%s'",
-                                 get_active_function_name(TSRMLS_C), querystr.c);
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Failed to execute '%s'", querystr.c);
                PQclear(pg_result);
        }
        
@@ -4283,16 +4181,14 @@ PHP_FUNCTION(pg_select)
                return;
        }
        if (option & ~(PGSQL_CONV_FORCE_NULL|PGSQL_DML_NO_CONV|PGSQL_DML_EXEC|PGSQL_DML_ASYNC|PGSQL_DML_STRING)) {
-               php_error(E_WARNING, "%s(): Invalid option is spedified",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Invalid option is spedified");
                RETURN_FALSE;
        }
        
        ZEND_FETCH_RESOURCE2(pg_link, PGconn *, &pgsql_link, id, "PostgreSQL link", le_link, le_plink);
 
        if (php_pgsql_flush_query(pg_link TSRMLS_CC)) {
-               php_error(E_NOTICE, "%s(): Detected unhandled result(s) in connection",
-                                 get_active_function_name(TSRMLS_C));
+               php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Detected unhandled result(s) in connection");
        }
        array_init(return_value);
        if (php_pgsql_select(pg_link, table, ids, return_value, option, &sql TSRMLS_CC) == FAILURE) {