[libgda] postgres: adding error suppervision
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] postgres: adding error suppervision
- Date: Sun, 17 Feb 2019 22:47:08 +0000 (UTC)
commit b915953d6a2aa9b0a6e9bdffe6e5f7066b93036b
Author: Daniel Espinosa Ortiz <esodan gmail com>
Date: Sun Feb 17 15:48:40 2019 -0600
postgres: adding error suppervision
libgda-ui/data-entries/gdaui-entry-shell.c | 2 +-
libgda/gda-data-select.c | 3 +++
providers/postgres/gda-postgres-recordset.c | 5 +++++
.../reuseable/postgres/gda-postgres-reuseable.c | 20 +++++++++++++++-----
4 files changed, 24 insertions(+), 6 deletions(-)
---
diff --git a/libgda-ui/data-entries/gdaui-entry-shell.c b/libgda-ui/data-entries/gdaui-entry-shell.c
index 0efdc0300..704323ff3 100644
--- a/libgda-ui/data-entries/gdaui-entry-shell.c
+++ b/libgda-ui/data-entries/gdaui-entry-shell.c
@@ -96,7 +96,7 @@ typedef struct {
GtkWidget *stack;
GtkWidget *button; /* "..." button */
GtkWidget *label;
- GdaDataHandler *data_handler; /* FIXME: to remove if unused elsewhere */
+ GdaDataHandler *data_handler; /* FIXME: to remove if unused elsewhere */
gboolean show_actions;
gboolean is_cell_renderer;
gboolean editable;
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index 2c0122f52..84408124c 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -1914,6 +1914,9 @@ static void dump_d (GdaDataSelect *model)
static const GValue *
gda_data_select_get_value_at (GdaDataModel *model, gint col, gint row, GError **error)
{
+ g_return_val_if_fail (model != NULL, NULL);
+ g_return_val_if_fail (GDA_IS_DATA_SELECT (model), NULL);
+
GdaRow *prow;
gint int_row;
GdaDataSelectPrivate *priv = gda_data_select_get_instance_private (GDA_DATA_SELECT (model));
diff --git a/providers/postgres/gda-postgres-recordset.c b/providers/postgres/gda-postgres-recordset.c
index 6d6c63116..9030f49bb 100644
--- a/providers/postgres/gda-postgres-recordset.c
+++ b/providers/postgres/gda-postgres-recordset.c
@@ -440,6 +440,9 @@ gda_postgres_recordset_fetch_nb_rows (GdaDataSelect *model)
static gboolean
gda_postgres_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
{
+ g_return_val_if_fail (model != NULL, FALSE);
+ g_return_val_if_fail (GDA_IS_DATA_SELECT (model), FALSE);
+
GdaPostgresRecordset *imodel = (GdaPostgresRecordset *) model;
if (!imodel->priv->pg_res) {
@@ -819,6 +822,8 @@ set_prow_with_pg_res (GdaPostgresRecordset *imodel, GdaRow *prow, gint pg_res_ro
static GdaRow *
new_row_from_pg_res (GdaPostgresRecordset *imodel, gint pg_res_rownum, GError **error)
{
+ g_return_val_if_fail (imodel != NULL, NULL);
+ g_return_val_if_fail (GDA_IS_DATA_SELECT (imodel), NULL);
GdaRow *prow;
prow = gda_row_new (_gda_data_select_get_prep_stmt ((GdaDataSelect*) imodel)->ncols);
diff --git a/providers/reuseable/postgres/gda-postgres-reuseable.c
b/providers/reuseable/postgres/gda-postgres-reuseable.c
index c6c1e5c51..e0e358d43 100644
--- a/providers/reuseable/postgres/gda-postgres-reuseable.c
+++ b/providers/reuseable/postgres/gda-postgres-reuseable.c
@@ -185,11 +185,14 @@ _gda_postgres_compute_version (GdaConnection *cnc, GdaPostgresReuseable *rdata,
return FALSE;
const GValue *cvalue;
- cvalue = gda_data_model_get_value_at (model, 0, 0, NULL);
+ GError *lerror = NULL;
+ cvalue = gda_data_model_get_value_at (model, 0, 0, &lerror);
if (!cvalue) {
g_set_error (error, GDA_SERVER_PROVIDER_ERROR,
- GDA_SERVER_PROVIDER_INTERNAL_ERROR, "%s",
- _("Can't get version data from server"));
+ GDA_SERVER_PROVIDER_INTERNAL_ERROR,
+ _("Can't get version data from server: %s"),
+ lerror && lerror->message ? lerror->message : _("No detail"));
+ g_clear_error (&lerror);
g_object_unref (model);
return FALSE;
}
@@ -305,8 +308,15 @@ _gda_postgres_compute_types (GdaConnection *cnc, GdaPostgresReuseable *rdata)
gchar *avoid_types = NULL;
GString *string;
- if (rdata->version_float == 0)
- _gda_postgres_compute_version (cnc, rdata, NULL);
+ if (rdata->version_float == 0) {
+ GError *lerror = NULL;
+ _gda_postgres_compute_version (cnc, rdata, &lerror);
+ if (lerror != NULL) {
+ g_warning (_("Internal Error: Can't calculate PostgreSQL version: %s"),
+ lerror && lerror->message ? lerror->message : _("No detail"));
+ return;
+ }
+ }
if (rdata->version_float < 7.3) {
gchar *query;
avoid_types = "'SET', 'cid', 'oid', 'int2vector', 'oidvector', 'regproc', 'smgr', 'tid',
'unknown', 'xid'";
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]