[libgda] Misc provider corrections related to iterators



commit 517d954cf944081d928074230dac0cf3608ea2f8
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun Sep 18 19:04:08 2011 +0200

    Misc provider corrections related to iterators

 providers/firebird/gda-firebird-recordset.c        |    8 +++---
 providers/jdbc/gda-jdbc-recordset.c                |   18 +++++++++++-
 providers/oracle/gda-oracle-recordset.c            |   13 +++++++++
 .../skel-implementation/capi/gda-capi-recordset.c  |   29 +++++++++-----------
 providers/web/gda-web-recordset.c                  |    2 +-
 5 files changed, 47 insertions(+), 23 deletions(-)
---
diff --git a/providers/firebird/gda-firebird-recordset.c b/providers/firebird/gda-firebird-recordset.c
index 9ccce03..1f1d29a 100644
--- a/providers/firebird/gda-firebird-recordset.c
+++ b/providers/firebird/gda-firebird-recordset.c
@@ -243,7 +243,7 @@ gda_firebird_recordset_fetch_nb_rows (GdaDataSelect *model)
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -288,7 +288,7 @@ gda_firebird_recordset_store_all (GdaDataSelect *model, GError **error)
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -311,7 +311,7 @@ gda_firebird_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, gint row
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -335,7 +335,7 @@ gda_firebird_recordset_fetch_prev (GdaDataSelect *model, GdaRow **prow, gint row
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
diff --git a/providers/jdbc/gda-jdbc-recordset.c b/providers/jdbc/gda-jdbc-recordset.c
index ceb7760..70df56e 100644
--- a/providers/jdbc/gda-jdbc-recordset.c
+++ b/providers/jdbc/gda-jdbc-recordset.c
@@ -508,7 +508,7 @@ gda_jdbc_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint rownu
  * if set, is discarded.
  */
 static gboolean 
-gda_jdbc_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, G_GNUC_UNUSED gint rownum, GError **error)
+gda_jdbc_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
 {
 	GdaJdbcRecordset *imodel = (GdaJdbcRecordset*) model;
 	JNIEnv *jenv = NULL;
@@ -518,9 +518,23 @@ gda_jdbc_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, G_GNUC_UNUSE
 	if (!jenv)
 		return FALSE;
 
-	if (imodel->priv->tmp_row)
+	if (imodel->priv->tmp_row) {
                 g_object_unref (imodel->priv->tmp_row);
+		imodel->priv->tmp_row = NULL;
+	}
+	if (imodel->priv->next_row_num != rownum) {
+		GError *lerror = NULL;
+		*prow = NULL;
+		g_set_error (&lerror, GDA_DATA_MODEL_ERROR,
+			     GDA_DATA_MODEL_ROW_NOT_FOUND_ERROR,
+			     "%s", _("Can't set iterator on requested row"));
+		gda_data_select_add_exception (GDA_DATA_SELECT (model), lerror);
+		if (error)
+			g_propagate_error (error, g_error_copy (lerror));
+		_gda_jdbc_release_jenv (jni_detach);
 
+		return TRUE;
+	}
         *prow = fetch_next_jdbc_row (imodel, jenv, FALSE, error);
         imodel->priv->tmp_row = *prow;
 
diff --git a/providers/oracle/gda-oracle-recordset.c b/providers/oracle/gda-oracle-recordset.c
index 54f2a8c..c61b32c 100644
--- a/providers/oracle/gda-oracle-recordset.c
+++ b/providers/oracle/gda-oracle-recordset.c
@@ -622,6 +622,19 @@ gda_oracle_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint row
 static gboolean 
 gda_oracle_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow, gint rownum, GError **error)
 {
+	GdaOracleRecordset *imodel = (GdaOracleRecordset*) model;
+
+	if (imodel->priv->next_row_num != rownum) {
+		GError *lerror = NULL;
+		*prow = NULL;
+		g_set_error (&lerror, GDA_DATA_MODEL_ERROR,
+			     GDA_DATA_MODEL_ROW_NOT_FOUND_ERROR,
+			     "%s", _("Can't set iterator on requested row"));
+		gda_data_select_add_exception (GDA_DATA_SELECT (model), lerror);
+		if (error)
+			g_propagate_error (error, g_error_copy (lerror));
+		return TRUE;
+	}
 	*prow = fetch_next_oracle_row ((GdaOracleRecordset*) model, TRUE, error);
 	return TRUE;
 }
diff --git a/providers/skel-implementation/capi/gda-capi-recordset.c b/providers/skel-implementation/capi/gda-capi-recordset.c
index 5079737..389a9df 100644
--- a/providers/skel-implementation/capi/gda-capi-recordset.c
+++ b/providers/skel-implementation/capi/gda-capi-recordset.c
@@ -249,7 +249,7 @@ gda_capi_recordset_fetch_nb_rows (GdaDataSelect *model)
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -258,14 +258,11 @@ gda_capi_recordset_fetch_nb_rows (GdaDataSelect *model)
  * - this method is only called when data model is used in random access mode
  */
 static gboolean 
-gda_capi_recordset_fetch_random (GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow, G_GNUC_UNUSED gint rownum,
-				 G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_random (GdaDataSelect *model, GdaRow **prow, gint rownum,
+				 GError **error)
 {
-	GdaCapiRecordset *imodel;
-
-	imodel = GDA_CAPI_RECORDSET (model);
+	/*GdaCapiRecordset *imodel = GDA_CAPI_RECORDSET (model);*/
 
-	g_warning("imodel not used: %p", imodel); /* Avoids a compiler warning. */
 	TO_IMPLEMENT;
 
 	return TRUE;
@@ -298,7 +295,7 @@ gda_capi_recordset_store_all (GdaDataSelect *model, GError **error)
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -307,8 +304,8 @@ gda_capi_recordset_store_all (GdaDataSelect *model, GError **error)
  * - this method is only called when data model is used in cursor access mode
  */
 static gboolean 
-gda_capi_recordset_fetch_next (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow,
-			       G_GNUC_UNUSED gint rownum, G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_next (GdaDataSelect *model, GdaRow **prow,
+			       gint rownum, GError **error)
 {
 	/* GdaCapiRecordset *imodel = (GdaCapiRecordset*) model; */
 
@@ -322,7 +319,7 @@ gda_capi_recordset_fetch_next (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -332,8 +329,8 @@ gda_capi_recordset_fetch_next (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
  * - this method is only called when data model is used in cursor access mode
  */
 static gboolean 
-gda_capi_recordset_fetch_prev (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow,
-			       G_GNUC_UNUSED gint rownum, G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_prev (GdaDataSelect *model, GdaRow **prow,
+			       gint rownum, GError **error)
 {
 	/* GdaCapiRecordset *imodel = (GdaCapiRecordset*) model; */
 
@@ -347,7 +344,7 @@ gda_capi_recordset_fetch_prev (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
  *
  * NOTES:
  * - @prow will NOT be NULL, but *prow WILL be NULL.
- * - a new #GdaRow object has to be created.
+ * - a new #GdaRow object has to be created, corresponding to the @rownum row
  * - memory management for that new GdaRow object is left to the implementation, which
  *   can use gda_data_select_take_row() to "give" the GdaRow to @model (in this case
  *   this method won't be called anymore for the same @rownum), or may decide to
@@ -357,8 +354,8 @@ gda_capi_recordset_fetch_prev (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED
  * - this method is only called when data model is used in cursor access mode
  */
 static gboolean 
-gda_capi_recordset_fetch_at (G_GNUC_UNUSED GdaDataSelect *model, G_GNUC_UNUSED GdaRow **prow,
-			     G_GNUC_UNUSED gint rownum, G_GNUC_UNUSED GError **error)
+gda_capi_recordset_fetch_at (GdaDataSelect *model, GdaRow **prow,
+			     gint rownum, GError **error)
 {
 	/* GdaCapiRecordset *imodel = (GdaCapiRecordset*) model; */
 	
diff --git a/providers/web/gda-web-recordset.c b/providers/web/gda-web-recordset.c
index 4e39508..357a563 100644
--- a/providers/web/gda-web-recordset.c
+++ b/providers/web/gda-web-recordset.c
@@ -338,7 +338,7 @@ gda_web_recordset_fetch_nb_rows (GdaDataSelect *model)
  * Create a new filled #GdaRow object for the row at position @rownum, and put it into *prow.
  *
  * WARNING: @prow will NOT be NULL, but *prow may or may not be NULL:
- *  -  If *prow is NULL then a new #GdaRow object has to be created, 
+ *  -  If *prow is NULL then a new #GdaRow object has to be created, corresponding to the @rownum row 
  *  -  and otherwise *prow contains a #GdaRow object which has already been created 
  *     (through a call to this very function), and in this case it should not be modified
  *     but the function may return FALSE if an error occurred.



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