@@ -706,10 +706,12 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
706706 /* create the link */
707707 pgsql = PQconnectdb (connstring );
708708 if (pgsql == NULL || PQstatus (pgsql ) == CONNECTION_BAD ) {
709- PHP_PQ_ERROR ( "Unable to connect to PostgreSQL server: %s" , pgsql )
709+ zend_string * msgbuf = _php_pgsql_trim_message ( PQerrorMessage ( pgsql ));
710710 if (pgsql ) {
711711 PQfinish (pgsql );
712712 }
713+ php_error_docref (NULL , E_WARNING , "Unable to connect to PostgreSQL server: %s" , ZSTR_VAL (msgbuf ));
714+ zend_string_release (msgbuf );
713715 goto err ;
714716 }
715717
@@ -790,19 +792,23 @@ static void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS, int persistent)
790792 if (connect_type & PGSQL_CONNECT_ASYNC ) {
791793 pgsql = PQconnectStart (connstring );
792794 if (pgsql == NULL || PQstatus (pgsql )== CONNECTION_BAD ) {
793- PHP_PQ_ERROR ( "Unable to connect to PostgreSQL server: %s" , pgsql );
795+ zend_string * msgbuf = _php_pgsql_trim_message ( PQerrorMessage ( pgsql ) );
794796 if (pgsql ) {
795797 PQfinish (pgsql );
796798 }
799+ php_error_docref (NULL , E_WARNING , "Unable to connect to PostgreSQL server: %s" , ZSTR_VAL (msgbuf ));
800+ zend_string_release (msgbuf );
797801 goto err ;
798802 }
799803 } else {
800804 pgsql = PQconnectdb (connstring );
801805 if (pgsql == NULL || PQstatus (pgsql )== CONNECTION_BAD ) {
802- PHP_PQ_ERROR ( "Unable to connect to PostgreSQL server: %s" , pgsql );
806+ zend_string * msgbuf = _php_pgsql_trim_message ( PQerrorMessage ( pgsql ) );
803807 if (pgsql ) {
804808 PQfinish (pgsql );
805809 }
810+ php_error_docref (NULL , E_WARNING , "Unable to connect to PostgreSQL server: %s" , ZSTR_VAL (msgbuf ));
811+ zend_string_release (msgbuf );
806812 goto err ;
807813 }
808814 }
0 commit comments