[gnome-db] gda_postgres_make_error function with sqlstate support



Hi,

This is a version of libgda/providers/postgres/utils.c
gda_postgres_make_error function with sqlstate support:

GdaError *
gda_postgres_make_error (PGconn *pconn, PGresult *pg_res)
{
        GdaError *error;
        gchar *sqlstate;

        error = gda_error_new ();
        if (pconn != NULL) {
                gchar *message;

                if (pg_res != NULL) {
                        message = PQresultErrorMessage (pg_res);
                        sqlstate = PQresultErrorField (pg_res,
PG_DIAG_SQLSTATE);
                } else {
                        message = PQerrorMessage (pconn);
                        sqlstate = _("Not available");
                }

                gda_error_set_description (error, message);
                gda_error_set_sqlstate (error, sqlstate);
        } else {
                gda_error_set_description (error, _("NO DESCRIPTION"));
                gda_error_set_sqlstate (error, _("Not available"));
        }

        gda_error_set_number (error, -1);
        gda_error_set_source (error, "gda-postgres");

        return error;
}

Can we replace the current gda_postgres_make_error with this more
useful function?.

Thanks

-- 
Juan Manuel Mouriz
Buenos Aires
Argentina



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]